/* ============================================
   えぽっけプロト - Design Polished v2
   ============================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

/* ==============================
   PASSWORD GATE
   ============================== */
#pw-gate {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #FFF4EC 0%, #FDE8E6 50%, #FDDDD8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  font-family: 'Zen Maru Gothic', 'Hiragino Kaku Gothic ProN', sans-serif;
}
/* Floating dots background */
#pw-gate::before, #pw-gate::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  opacity: 0.15;
}
#pw-gate::before {
  width: 120px; height: 120px;
  background: #E8736C;
  top: 12%; left: -20px;
  animation: pw-float 6s ease-in-out infinite;
}
#pw-gate::after {
  width: 80px; height: 80px;
  background: #F4ADA8;
  bottom: 15%; right: -10px;
  animation: pw-float 8s 2s ease-in-out infinite;
}
@keyframes pw-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}

.pw-card {
  background: #fff;
  border-radius: 28px;
  padding: 36px 32px 30px;
  width: 88%;
  max-width: 320px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(74,55,40,0.12);
  position: relative;
  animation: pw-card-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pw-card-in {
  0% { opacity: 0; transform: scale(0.88) translateY(20px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Mini Epokke on gate */
.pw-epokke-mini {
  margin: 0 auto 14px;
  width: 56px; height: 56px;
  animation: epokke-peek 3s ease-in-out infinite;
}
@keyframes epokke-peek {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.pw-epokke-body {
  width: 48px; height: 44px;
  background: linear-gradient(180deg, #E8736C, #C95A54);
  border-radius: 12px;
  margin: 0 auto;
  position: relative;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.15), inset 0 -2px 0 #B04A44, 0 4px 12px rgba(232,115,108,0.25);
}
.pw-epokke-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 12px;
  background: linear-gradient(180deg, #C95A54, #B04A44);
  border-radius: 12px 12px 0 0;
}
.pw-epokke-face {
  position: absolute;
  bottom: 5px; left: 50%;
  transform: translateX(-50%);
  width: 34px;
}
.pw-eye {
  position: absolute;
  width: 8px; height: 8px;
  background: #fff;
  border-radius: 50%;
  top: 0;
}
.pw-eye.left { left: 3px; }
.pw-eye.right { right: 3px; }
.pw-pupil {
  width: 4px; height: 4px;
  background: #4A3728;
  border-radius: 50%;
  position: absolute;
  top: 2px; left: 2px;
}
.pw-pupil::after {
  content: '';
  position: absolute;
  top: 0.5px; left: 1px;
  width: 1.5px; height: 1.5px;
  background: rgba(255,255,255,0.7);
  border-radius: 50%;
}
.pw-mouth {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  width: 8px; height: 4px;
  border-bottom: 2px solid #fff;
  border-radius: 0 0 6px 6px;
}

.pw-title {
  font-size: 20px;
  font-weight: 700;
  color: #4A3728;
  margin-bottom: 4px;
  letter-spacing: 1px;
}
.pw-label {
  font-size: 13px;
  font-weight: 500;
  color: #B8A08A;
  margin-bottom: 18px;
}
.pw-input {
  width: 100%;
  padding: 13px 18px;
  border: 2px solid rgba(0,0,0,0.06);
  border-radius: 16px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  color: #4A3728;
  background: #FFF8F0;
  transition: border-color 0.2s, box-shadow 0.2s;
  text-align: center;
  letter-spacing: 2px;
}
.pw-input:focus {
  border-color: #F4ADA8;
  box-shadow: 0 0 0 3px rgba(232,115,108,0.08);
}
.pw-btn {
  width: 100%;
  margin-top: 12px;
  padding: 14px 0;
  background: linear-gradient(135deg, #E8736C, #C95A54);
  color: #fff;
  border: none;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(232,115,108,0.3), inset 0 1px 0 rgba(255,255,255,0.2);
  transition: transform 0.15s;
  letter-spacing: 1px;
}
.pw-btn:active { transform: scale(0.96); }
.pw-error {
  margin-top: 10px;
  font-size: 12px;
  color: #C95A54;
  font-weight: 600;
  min-height: 18px;
}
.pw-hint {
  margin-top: 6px;
  font-size: 11px;
  color: #C8B8A8;
  font-weight: 400;
}

:root {
  --coral: #E8736C;
  --coral-light: #F4ADA8;
  --coral-pale: #FDE8E6;
  --coral-dark: #C95A54;
  --coral-deep: #B04A44;
  --cream: #FFF8F0;
  --cream-warm: #FFF4E8;
  --wall: #FDEEE0;
  --wall-light: #FFF4EC;
  --wall-shadow: #F0D4BA;
  --floor: #E8CDB5;
  --floor-dark: #D4B89E;
  --floor-light: #F0DAC6;
  --wood: #B8885A;
  --wood-dark: #A07848;
  --wood-light: #C8986A;
  --text: #4A3728;
  --text-sub: #8B7360;
  --text-light: #B8A08A;
  --white: #FFFFFF;
  --shadow-xs: 0 1px 2px rgba(74,55,40,0.06);
  --shadow-sm: 0 2px 6px rgba(74,55,40,0.08);
  --shadow-md: 0 4px 14px rgba(74,55,40,0.10);
  --shadow-lg: 0 8px 28px rgba(74,55,40,0.14);
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  height: 100%;
  font-family: 'Zen Maru Gothic', 'Hiragino Kaku Gothic ProN', sans-serif;
  background: linear-gradient(135deg, #F0E6DA 0%, #E8DDD0 100%);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--cream);
  box-shadow: 0 0 60px rgba(0,0,0,0.10);
}

/* ==============================
   ROOM AREA
   ============================== */
.room-area {
  flex-shrink: 0;
  height: 48%;
  position: relative;
  transition: height 0.5s var(--ease-smooth);
  overflow: hidden;
}
.room-area.chat-active { height: 28%; }

.room-bg {
  width: 100%; height: 100%;
  position: relative;
  /* Warm gradient wall with a subtle wood floor */
  background:
    linear-gradient(180deg,
      var(--wall-light) 0%,
      var(--wall) 48%,
      var(--wall) 58%,
      var(--floor-light) 58.5%,
      var(--floor) 70%,
      var(--floor-dark) 100%
    );
  overflow: hidden;
}

/* Wall texture & wainscoting */
.room-wall-line {
  position: absolute;
  top: 55.5%;
  left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, transparent 3%, var(--wall-shadow) 15%, var(--wood-light) 50%, var(--wall-shadow) 85%, transparent 97%);
  box-shadow: 0 1px 0 rgba(255,255,255,0.3);
}

.room-floor-line {
  position: absolute;
  top: 58%;
  left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 5%, var(--floor-dark) 50%, transparent 95%);
  opacity: 0.5;
}

/* Floor wood grain effect */
.room-bg::after {
  content: '';
  position: absolute;
  top: 60%; left: 0; right: 0; bottom: 0;
  background:
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 40px,
      rgba(160,120,72,0.04) 40px,
      rgba(160,120,72,0.04) 41px
    );
  pointer-events: none;
}

/* --- Window --- */
.room-window {
  position: absolute;
  top: 6%;
  left: 50%;
  transform: translateX(-50%);
  width: 78px;
  height: 66px;
}

.window-frame {
  width: 100%; height: 100%;
  border: 5px solid var(--wood);
  border-radius: 6px 6px 3px 3px;
  position: relative;
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.25),
    var(--shadow-md),
    0 1px 0 var(--wood-dark);
}

.window-glass {
  width: 100%; height: 100%;
  background: linear-gradient(180deg, #A8D0F0 0%, #C4E0FF 40%, #D8ECFF 70%, #EEF6FF 100%);
  position: relative;
  overflow: hidden;
}

/* Sun glow */
.window-glass::before {
  content: '';
  position: absolute;
  top: -6px; right: -4px;
  width: 24px; height: 24px;
  background: radial-gradient(circle, rgba(255,240,180,0.5) 0%, transparent 70%);
  border-radius: 50%;
}

.window-cloud {
  position: absolute;
  width: 22px; height: 9px;
  background: rgba(255,255,255,0.75);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.window-cloud.c1 { top: 14px; left: 6px; animation: cloud-drift 14s linear infinite; }
.window-cloud.c2 { top: 28px; left: 42px; width: 17px; height: 7px; animation: cloud-drift 18s 5s linear infinite; }

@keyframes cloud-drift {
  0% { transform: translateX(0); opacity: 0.8; }
  80% { opacity: 0.8; }
  100% { transform: translateX(75px); opacity: 0; }
}

.window-cross-h, .window-cross-v {
  position: absolute;
  background: var(--wood);
}
.window-cross-h {
  top: 50%; left: 0; right: 0;
  height: 4px;
  transform: translateY(-50%);
  box-shadow: 0 1px 0 rgba(0,0,0,0.06);
}
.window-cross-v {
  left: 50%; top: 0; bottom: 0;
  width: 4px;
  transform: translateX(-50%);
  box-shadow: 1px 0 0 rgba(0,0,0,0.06);
}

/* Curtains (reward) */
.window-curtain {
  position: absolute;
  top: -3px;
  width: 20px;
  height: 72px;
  opacity: 0;
  transition: all 0.8s var(--ease-bounce);
}
.window-curtain.left {
  left: -16px;
  background: linear-gradient(180deg, #E8A87C 0%, #D4886B 40%, #C87A60 100%);
  border-radius: 3px 0 6px 6px;
  transform: scaleY(0);
  transform-origin: top;
  box-shadow: 2px 0 4px rgba(0,0,0,0.06);
}
.window-curtain.right {
  right: -16px;
  background: linear-gradient(180deg, #E8A87C 0%, #D4886B 40%, #C87A60 100%);
  border-radius: 0 3px 6px 6px;
  transform: scaleY(0);
  transform-origin: top;
  box-shadow: -2px 0 4px rgba(0,0,0,0.06);
}
/* Curtain folds */
.window-curtain.left::after,
.window-curtain.right::after {
  content: '';
  position: absolute;
  top: 10px; bottom: 10px;
  width: 3px;
  background: rgba(0,0,0,0.06);
  border-radius: 2px;
}
.window-curtain.left::after { right: 5px; }
.window-curtain.right::after { left: 5px; }
.window-curtain.visible { opacity: 1; transform: scaleY(1); }

/* --- Bookshelf --- */
.bookshelf {
  position: absolute;
  top: 10%;
  left: 5%;
  width: 84px;
  height: 60px;
}

.shelf-top-board, .shelf-mid-board, .shelf-bottom-board {
  position: absolute;
  left: -2px; right: -2px;
  height: 5px;
  background: linear-gradient(180deg, var(--wood-light) 0%, var(--wood) 60%, var(--wood-dark) 100%);
  border-radius: 1px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.shelf-top-board { top: 0; }
.shelf-mid-board { top: 50%; }
.shelf-bottom-board { bottom: 0; box-shadow: 0 3px 6px rgba(0,0,0,0.1); }

.shelf-side {
  position: absolute;
  top: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(90deg, var(--wood-dark), var(--wood));
  border-radius: 1px;
}
.shelf-side.left { left: 0; }
.shelf-side.right { right: 0; }

.shelf-books {
  position: absolute;
  bottom: 6px;
  left: 6px; right: 6px;
  height: 22px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
}

.shelf-book {
  width: 13px;
  border-radius: 2px 2px 0 0;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.6s var(--ease-bounce);
  box-shadow: 1px 0 0 rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.15);
}
.shelf-book.visible { opacity: 1; transform: translateY(0); }

.book-spine {
  display: block;
  font-size: 5px;
  color: rgba(255,255,255,0.6);
  text-align: center;
  padding-top: 4px;
  writing-mode: vertical-rl;
  line-height: 13px;
}

/* --- Rewards (CSS-drawn) --- */
.room-reward {
  position: absolute;
  opacity: 0;
  transform: scale(0.3);
  transition: all 0.8s var(--ease-bounce);
  pointer-events: none;
}
.room-reward.visible { opacity: 1; transform: scale(1); }

/* Rug */
.reward-rug {
  bottom: 14%;
  left: 50%;
  transform: translateX(-50%) scale(0.3);
}
.reward-rug.visible { transform: translateX(-50%) scale(1); }
.rug-body {
  width: 110px; height: 22px;
  background: linear-gradient(135deg, #D4886B, #C87A60);
  border-radius: 50%;
  position: relative;
  box-shadow: 0 3px 8px rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.15);
}
.rug-pattern {
  position: absolute;
  top: 5px; left: 14px; right: 14px; bottom: 5px;
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: 50%;
}
/* Inner pattern */
.rug-body::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 12px; height: 6px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
}

/* Clock */
.reward-clock { top: 8%; right: 22%; }
.clock-body {
  width: 32px; height: 32px;
  background: var(--white);
  border-radius: 50%;
  border: 3.5px solid var(--wood);
  box-shadow: var(--shadow-md), inset 0 1px 3px rgba(0,0,0,0.04);
  position: relative;
}
/* Clock top hook */
.clock-body::before {
  content: '';
  position: absolute;
  top: -6px; left: 50%;
  transform: translateX(-50%);
  width: 8px; height: 5px;
  border: 2px solid var(--wood);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
}
.clock-face { width: 100%; height: 100%; position: relative; }
/* Hour marks */
.clock-face::before {
  content: '';
  position: absolute;
  top: 3px; left: 50%;
  width: 1.5px; height: 3px;
  background: var(--text-light);
  transform: translateX(-50%);
}
.clock-face::after {
  content: '';
  position: absolute;
  bottom: 3px; left: 50%;
  width: 1.5px; height: 3px;
  background: var(--text-light);
  transform: translateX(-50%);
}
.clock-hand {
  position: absolute;
  bottom: 50%;
  left: 50%;
  background: var(--text);
  transform-origin: bottom center;
  border-radius: 1px;
}
.clock-hand.hour { width: 2px; height: 8px; transform: translateX(-50%) rotate(45deg); }
.clock-hand.minute { width: 1.5px; height: 10px; transform: translateX(-50%) rotate(170deg); animation: clock-tick 60s linear infinite; }
.clock-center-dot {
  position: absolute;
  top: 50%; left: 50%;
  width: 4px; height: 4px;
  background: var(--coral);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px rgba(232,115,108,0.3);
}
@keyframes clock-tick { to { transform: translateX(-50%) rotate(530deg); } }

/* Lamp */
.reward-lamp { bottom: 38%; left: 8%; }
.lamp-shade {
  width: 28px; height: 16px;
  background: linear-gradient(180deg, #F5E0A8 0%, #F0D898 50%, #E8C880 100%);
  clip-path: polygon(12% 0%, 88% 0%, 100% 100%, 0% 100%);
  position: relative;
  box-shadow: 0 2px 4px rgba(0,0,0,0.06);
}
/* Shade line */
.lamp-shade::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: rgba(200,160,80,0.3);
}
.lamp-pole { width: 3px; height: 18px; background: linear-gradient(90deg, var(--wood-dark), var(--wood-light), var(--wood-dark)); margin: 0 auto; }
.lamp-base {
  width: 18px; height: 5px;
  background: linear-gradient(180deg, var(--wood-light), var(--wood-dark));
  border-radius: 2px;
  margin: 0 auto;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.lamp-glow {
  position: absolute;
  top: 16px; left: 50%; transform: translateX(-50%);
  width: 36px; height: 36px;
  background: radial-gradient(circle, rgba(255,220,140,0.35) 0%, rgba(255,220,140,0.1) 40%, transparent 70%);
  border-radius: 50%;
  animation: lamp-flicker 4s ease-in-out infinite;
}
@keyframes lamp-flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

/* Picture */
.reward-picture { top: 12%; left: 34%; }
.picture-frame {
  width: 30px; height: 24px;
  border: 3.5px solid var(--wood);
  border-radius: 2px;
  background: var(--white);
  box-shadow: var(--shadow-sm), 0 1px 0 var(--wood-dark);
  padding: 2px;
}
.picture-inner {
  width: 100%; height: 100%;
  background:
    linear-gradient(135deg, #A8D0F0 30%, #8DC67E 60%, #7BAE6B 100%);
  border-radius: 1px;
  position: relative;
  overflow: hidden;
}
/* Mountain/hill in picture */
.picture-inner::before {
  content: '';
  position: absolute;
  bottom: 0; left: -2px; right: -2px;
  height: 60%;
  background: linear-gradient(180deg, #8DC67E, #6BAE5B);
  border-radius: 50% 50% 0 0;
}
/* Sun in picture */
.picture-inner::after {
  content: '';
  position: absolute;
  top: 2px; right: 2px;
  width: 5px; height: 5px;
  background: #F0D898;
  border-radius: 50%;
}

/* --- Plant --- */
.plant-container {
  position: absolute;
  bottom: 34%;
  right: 7%;
  width: 48px;
  height: 64px;
}

.plant-pot {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}
.plant-pot-rim {
  width: 34px; height: 6px;
  background: linear-gradient(180deg, #D08060, #C87A5A);
  border-radius: 3px 3px 0 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15);
}
.plant-pot-body {
  width: 30px; height: 20px;
  background: linear-gradient(180deg, #C87A5A, #B06A4A);
  clip-path: polygon(6% 0%, 94% 0%, 82% 100%, 18% 100%);
  margin: 0 auto;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
/* Pot decorative line */
.plant-pot-body::after {
  content: '';
  display: block;
  margin: 5px auto 0;
  width: 14px; height: 2px;
  background: rgba(255,255,255,0.12);
  border-radius: 1px;
}

.plant {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
}

.plant-stem {
  width: 3px; height: 14px;
  background: linear-gradient(180deg, #5EA04E, #6BAE5B, #7EC66E);
  border-radius: 2px;
  margin: 0 auto;
  transition: height 0.8s ease;
}

.plant-leaf {
  position: absolute;
  width: 12px; height: 8px;
  background: linear-gradient(135deg, #6EC05E, #7EC66E);
  border-radius: 50% 50% 50% 0;
  opacity: 0;
  transition: all 0.8s var(--ease-bounce);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.plant-leaf.visible { opacity: 1; }
.plant-leaf-1 { top: 2px; left: 3px; transform: rotate(-30deg); }
.plant-leaf-2 { top: -6px; right: 3px; left: auto; transform: rotate(30deg) scaleX(-1); }
.plant-leaf-3 { top: -14px; left: 0; transform: rotate(-20deg); }
.plant-leaf-4 { top: -20px; right: 0; left: auto; transform: rotate(25deg) scaleX(-1); }
.plant-leaf-5 { top: -26px; left: 3px; transform: rotate(-10deg); width: 10px; height: 7px; }

.plant.level-0 .plant-stem { height: 10px; }
.plant.level-1 .plant-stem { height: 20px; }
.plant.level-2 .plant-stem { height: 28px; }
.plant.level-3 .plant-stem { height: 36px; }
.plant.level-4 .plant-stem { height: 44px; }
.plant.level-5 .plant-stem { height: 48px; }

/* --- Epokke Character --- */
.epokke-home {
  position: absolute;
  bottom: 12%;
  left: 50%;
  transform: translateX(-50%);
}

.epokke-shadow {
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 58px; height: 12px;
  background: radial-gradient(ellipse, rgba(74,55,40,0.12) 0%, transparent 70%);
  border-radius: 50%;
  animation: epokke-shadow 3s ease-in-out infinite;
}
@keyframes epokke-shadow {
  0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.12; }
  50% { transform: translateX(-50%) scale(0.92); opacity: 0.08; }
}

.epokke-character {
  position: relative;
  width: 78px; height: 100px;
  animation: epokke-idle 3s ease-in-out infinite;
}

@keyframes epokke-idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.epokke-body {
  width: 60px; height: 56px;
  background: linear-gradient(180deg, var(--coral) 0%, var(--coral-dark) 100%);
  border-radius: 14px;
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  overflow: hidden;
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.15),
    inset 0 -3px 0 var(--coral-deep),
    var(--shadow-md);
}

.epokke-card-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 15px;
  background: linear-gradient(180deg, var(--coral-dark) 0%, var(--coral-deep) 100%);
  border-radius: 14px 14px 0 0;
}
/* Card stripe accent */
.epokke-card-top::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 10%, rgba(255,255,255,0.12) 50%, transparent 90%);
}

.epokke-chip-row {
  position: absolute;
  top: 17px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
}
.epokke-chip-row span {
  width: 5px; height: 4px;
  background: rgba(255,255,255,0.6);
  border-radius: 1px;
  display: block;
  box-shadow: 0 0 0 0.5px rgba(255,255,255,0.3);
}

.epokke-face {
  position: absolute;
  bottom: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
}

.epokke-eye {
  position: absolute;
  width: 10px; height: 10px;
  background: var(--white);
  border-radius: 50%;
  top: 0;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
}
.epokke-eye.left { left: 4px; }
.epokke-eye.right { right: 4px; }

.epokke-pupil {
  width: 5px; height: 5px;
  background: var(--text);
  border-radius: 50%;
  position: absolute;
  top: 3px; left: 3px;
  transition: transform 0.3s ease;
}
/* Pupil highlight */
.epokke-pupil::after {
  content: '';
  position: absolute;
  top: 0.5px; left: 1px;
  width: 2px; height: 2px;
  background: rgba(255,255,255,0.7);
  border-radius: 50%;
}

/* Blush cheeks */
.epokke-face::before,
.epokke-face::after {
  content: '';
  position: absolute;
  top: 8px;
  width: 7px; height: 4px;
  background: rgba(255,180,160,0.45);
  border-radius: 50%;
}
.epokke-face::before { left: -1px; }
.epokke-face::after { right: -1px; }

.epokke-mouth {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px; height: 5px;
  border-bottom: 2.5px solid var(--white);
  border-radius: 0 0 8px 8px;
  transition: all 0.3s ease;
}

.epokke-arm {
  position: absolute;
  width: 10px; height: 18px;
  background: linear-gradient(180deg, var(--coral), var(--coral-dark));
  border-radius: 6px;
  top: 42px;
  box-shadow: inset 0 -1px 0 var(--coral-deep);
}
.epokke-arm.left { left: 2px; transform: rotate(12deg); }
.epokke-arm.right { right: 2px; transform: rotate(-12deg); }

.epokke-leg {
  position: absolute;
  width: 12px; height: 14px;
  background: linear-gradient(180deg, var(--coral), var(--coral-dark));
  border-radius: 6px;
  bottom: 0;
  box-shadow: inset 0 -1px 0 var(--coral-deep);
}
.epokke-leg.left { left: 18px; }
.epokke-leg.right { right: 18px; }

/* Happy animation */
.epokke-character.happy { animation: epokke-happy 0.7s ease-in-out; }
@keyframes epokke-happy {
  0%, 100% { transform: translateY(0) rotate(0); }
  20% { transform: translateY(-12px) rotate(-5deg); }
  40% { transform: translateY(-16px) rotate(0); }
  60% { transform: translateY(-12px) rotate(5deg); }
  80% { transform: translateY(-6px) rotate(-2deg); }
}
/* Smile when happy */
.epokke-character.happy .epokke-mouth {
  width: 14px; height: 7px;
}

/* Talking animation */
.epokke-character.talking .epokke-arm.right {
  animation: arm-wave 0.7s ease-in-out infinite;
}
@keyframes arm-wave {
  0%, 100% { transform: rotate(-12deg); }
  50% { transform: rotate(-32deg) translateY(-2px); }
}
/* Blink animation */
.epokke-character .epokke-eye {
  animation: epokke-blink 4s ease-in-out infinite;
}
.epokke-character .epokke-eye.right {
  animation-delay: 0.1s;
}
@keyframes epokke-blink {
  0%, 94%, 100% { transform: scaleY(1); }
  96% { transform: scaleY(0.1); }
}

/* Reset */
.reset-btn {
  position: absolute;
  top: 8px; right: 8px;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.65);
  color: var(--text-light);
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  -webkit-tap-highlight-color: transparent;
  transition: all 0.2s;
  box-shadow: var(--shadow-xs);
}
.reset-btn:active { background: rgba(255,255,255,0.95); transform: scale(0.92); }

/* ==============================
   BOTTOM AREA
   ============================== */
.bottom-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--cream);
  position: relative;
}
/* Subtle top border */
.bottom-area::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 10%, rgba(0,0,0,0.04) 50%, transparent 90%);
}

/* Idle */
.idle-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 22px 24px;
  gap: 16px;
  flex: 1;
  justify-content: center;
}
.idle-panel.hidden { display: none; }

.speech-bubble {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 16px 24px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  box-shadow: var(--shadow-md);
  text-align: center;
  line-height: 1.75;
  position: relative;
  max-width: 280px;
  white-space: pre-line;
  animation: bubble-pop 0.4s var(--ease-bounce);
}
@keyframes bubble-pop {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.speech-bubble::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 16px; height: 16px;
  background: var(--white);
  border-radius: 3px;
  box-shadow: -2px -2px 4px rgba(74,55,40,0.04);
}

.today-suggest {
  display: flex;
  align-items: center;
  gap: 8px;
}

.suggest-badge {
  font-size: 10px;
  font-weight: 700;
  background: var(--coral-pale);
  color: var(--coral-dark);
  padding: 4px 10px;
  border-radius: 8px;
  letter-spacing: 0.5px;
}

.suggest-text {
  font-size: 13px;
  color: var(--text-sub);
  font-weight: 500;
}

.talk-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 280px;
  padding: 16px 0;
  background: linear-gradient(135deg, var(--coral) 0%, var(--coral-dark) 100%);
  color: var(--white);
  border: none;
  border-radius: 28px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow:
    0 4px 16px rgba(232, 115, 108, 0.35),
    inset 0 1px 0 rgba(255,255,255,0.2);
  transition: all 0.15s ease;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
}
/* Button shine */
.talk-btn::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 50%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
  animation: btn-shine 3s ease-in-out infinite;
}
@keyframes btn-shine {
  0%, 70%, 100% { left: -100%; }
  85% { left: 150%; }
}
.talk-btn:active { transform: scale(0.96); box-shadow: 0 2px 8px rgba(232,115,108,0.3); }

/* Idle buttons container */
.idle-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 280px;
  align-items: center;
}

/* Free chat button */
.chat-free-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 13px 0;
  background: var(--white);
  color: var(--coral);
  border: 2px solid var(--coral-light);
  border-radius: 28px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.3px;
}
.chat-free-btn:active {
  background: var(--coral-pale);
  transform: scale(0.96);
}

/* ==============================
   CHAT PANEL
   ============================== */
.chat-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--cream);
  animation: slide-up 0.4s var(--ease-smooth);
}
@keyframes slide-up {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-panel.active { display: flex; }

.chat-handle {
  display: flex;
  justify-content: center;
  padding: 10px 0 6px;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.chat-handle-bar {
  width: 36px; height: 4px;
  background: rgba(0,0,0,0.08);
  border-radius: 2px;
  transition: background 0.2s;
}
.chat-handle:active .chat-handle-bar { background: rgba(0,0,0,0.16); }

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

.msg {
  max-width: 82%;
  padding: 11px 15px;
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-line;
  opacity: 0;
  transform: translateY(10px);
  animation: msg-appear 0.35s ease forwards;
  font-weight: 400;
  word-break: break-word;
}
@keyframes msg-appear { to { opacity: 1; transform: translateY(0); } }

.msg.epokke {
  background: var(--white);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-sm);
  position: relative;
}
/* Epokke message avatar dot */
.msg.epokke::before {
  content: '';
  position: absolute;
  top: 10px; left: -8px;
  width: 5px; height: 5px;
  background: var(--coral);
  border-radius: 50%;
}

.msg.user {
  background: linear-gradient(135deg, var(--coral), var(--coral-dark));
  color: var(--white);
  align-self: flex-end;
  border-bottom-right-radius: 6px;
  box-shadow: 0 2px 10px rgba(232,115,108,0.22);
}

.msg.system {
  align-self: center;
  background: var(--coral-pale);
  color: var(--text-sub);
  font-size: 12px;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  text-align: center;
  font-weight: 500;
  max-width: 90%;
  box-shadow: var(--shadow-xs);
}
.msg.system a {
  color: var(--coral-dark);
  text-decoration: none;
  font-weight: 700;
  border-bottom: 1.5px solid var(--coral-light);
  word-break: break-all;
  transition: border-color 0.2s;
}

/* Typing */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 12px 16px;
  align-self: flex-start;
  background: var(--white);
  border-radius: var(--radius-md);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-sm);
}

.typing-dot {
  width: 7px; height: 7px;
  background: var(--coral-light);
  border-radius: 50%;
  animation: typing-bounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Choices */
.chat-choices {
  padding: 6px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex-shrink: 0;
}

.choice-btn {
  width: 100%;
  padding: 12px 18px;
  background: var(--white);
  border: 2px solid var(--coral-light);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  color: var(--coral);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  transform: translateY(8px);
  animation: choice-appear 0.3s ease forwards;
  letter-spacing: 0.3px;
  position: relative;
  overflow: hidden;
}
.choice-btn:nth-child(2) { animation-delay: 0.08s; }
.choice-btn:nth-child(3) { animation-delay: 0.16s; }
@keyframes choice-appear { to { opacity: 1; transform: translateY(0); } }

.choice-btn:active {
  background: var(--coral);
  color: var(--white);
  border-color: var(--coral);
  transform: scale(0.97);
}

/* Input */
.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 10px 16px 16px;
  flex-shrink: 0;
  animation: slide-up 0.3s ease;
}

#chat-input {
  flex: 1;
  padding: 12px 18px;
  border: 2px solid rgba(0,0,0,0.06);
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.2s, box-shadow 0.2s;
  font-weight: 400;
}
#chat-input:focus {
  border-color: var(--coral-light);
  box-shadow: 0 0 0 3px rgba(232,115,108,0.08);
}
#chat-input::placeholder { color: var(--text-light); }

#chat-send-btn {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--coral), var(--coral-dark));
  color: var(--white);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(232,115,108,0.3);
  flex-shrink: 0;
  transition: transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
#chat-send-btn:active { transform: scale(0.9); }

/* ==============================
   GROWTH OVERLAY
   ============================== */
.growth-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(74,55,40,0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.growth-overlay.active { display: flex; }

.growth-content {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 40px 30px 30px;
  text-align: center;
  max-width: 300px;
  width: 88%;
  transform: scale(0.8);
  opacity: 0;
  animation: growth-pop 0.5s var(--ease-bounce) forwards;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: visible;
}
@keyframes growth-pop {
  to { transform: scale(1); opacity: 1; }
}

.growth-sparkles { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
.sparkle {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 50%;
  animation: sparkle-burst 1.2s ease-out forwards;
}
.sparkle.s1 { top: 8%; left: 12%; background: var(--coral-light); animation-delay: 0.1s; }
.sparkle.s2 { top: 6%; right: 10%; background: #E8D06C; animation-delay: 0.25s; }
.sparkle.s3 { bottom: 22%; left: 8%; background: #7CE88A; animation-delay: 0.35s; }
.sparkle.s4 { bottom: 18%; right: 12%; background: var(--coral-light); animation-delay: 0.2s; }
@keyframes sparkle-burst {
  0% { transform: scale(0) rotate(0); opacity: 0; }
  40% { transform: scale(1.8) rotate(90deg); opacity: 1; }
  100% { transform: scale(0) rotate(180deg); opacity: 0; }
}

.growth-icon { font-size: 48px; margin-bottom: 14px; }
.growth-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.75;
  margin-bottom: 22px;
  white-space: pre-line;
}

.growth-ok-btn {
  background: linear-gradient(135deg, var(--coral), var(--coral-dark));
  color: var(--white);
  border: none;
  border-radius: 24px;
  padding: 13px 40px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  box-shadow:
    0 4px 14px rgba(232, 115, 108, 0.35),
    inset 0 1px 0 rgba(255,255,255,0.2);
  letter-spacing: 0.5px;
  transition: transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.growth-ok-btn:active { transform: scale(0.95); }

/* Confetti */
.confetti {
  position: fixed;
  top: -12px;
  border-radius: 3px;
  z-index: 101;
  animation: confetti-fall 2.5s ease-in forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0) scale(1); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg) scale(0.5); opacity: 0; }
}

/* ==============================
   ROOM TABS
   ============================== */
.room-tabs {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  gap: 0;
  padding: 6px 12px 0;
  background: rgba(255,244,236,0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.room-tab {
  flex: 1;
  padding: 8px 0 6px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.3px;
}
.room-tab.active {
  color: var(--coral);
}
.room-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 20%; right: 20%;
  height: 2.5px;
  background: var(--coral);
  border-radius: 2px;
}

/* ==============================
   GALLERY VIEW
   ============================== */
.gallery-view {
  width: 100%; height: 100%;
  position: absolute;
  top: 0; left: 0;
  background: linear-gradient(180deg, var(--cream-warm) 0%, var(--cream) 100%);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 44px 16px 16px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding-bottom: 8px;
}

.gallery-card {
  background: var(--white);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: transform 0.2s var(--ease-bounce);
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  animation: gallery-card-in 0.4s var(--ease-bounce) forwards;
}
.gallery-card:active { transform: scale(0.96); }

@keyframes gallery-card-in {
  from { opacity: 0; transform: scale(0.85) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.gallery-card-img {
  aspect-ratio: 3 / 4;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-card-img img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
/* Placeholder fallback when image fails */
.gallery-card-img.placeholder::after {
  content: '🃏';
  font-size: 42px;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

.gallery-card-label {
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  letter-spacing: 0.3px;
}

.gallery-empty {
  text-align: center;
  color: var(--text-light);
  font-size: 14px;
  font-weight: 500;
  padding: 40px 0;
}

/* ==============================
   CARD DETAIL OVERLAY
   ============================== */
.card-detail-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(74,55,40,0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.card-detail-overlay.active { display: flex; }

.card-detail-content {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  max-width: 300px;
  width: 85%;
  transform: scale(0.8);
  opacity: 0;
  animation: growth-pop 0.5s var(--ease-bounce) forwards;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.card-detail-close {
  position: absolute;
  top: 8px; right: 12px;
  width: 32px; height: 32px;
  border: none;
  background: none;
  font-size: 24px;
  color: var(--text-light);
  cursor: pointer;
  line-height: 32px;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s;
}
.card-detail-close:active { color: var(--text); }

.card-detail-image {
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 14px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-detail-image img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.card-detail-image.placeholder::after {
  content: '🃏';
  font-size: 64px;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.2));
}

.card-detail-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}

.card-detail-desc {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sub);
  line-height: 1.6;
}

/* ==============================
   UTILITY
   ============================== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .chat-input-area, .chat-choices, .idle-panel {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
}

.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--coral-light);
  border-radius: 2px;
}
.chat-messages::-webkit-scrollbar-track { background: transparent; }

button, .choice-btn, .talk-btn {
  user-select: none;
  -webkit-user-select: none;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
