/* ==========================================================================
   Puzword v1.0.0 - Stylesheet & Animation Tokens
   Implements ANIM-2026-001 (GPU-only animations, 60fps, anti-kaku easing)
   ========================================================================== */

:root, [data-theme="cream"] {
  /* Easing Tokens */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-std: ease-in-out;

  /* Durations */
  --dur-micro: 100ms;
  --dur-pill: 220ms;
  --dur-shake: 260ms;
  --dur-overlay: 400ms;
  --dur-star: 350ms;

  /* Cozy Cream (Warm Papercraft) Palette */
  --color-bg-gradient: linear-gradient(180deg, #FBF8F3 0%, #F5EFEB 100%);
  --color-surface: #FFFFFF;
  --color-surface-translucent: rgba(255, 255, 255, 0.94);
  --color-board-bg: #EFE8DF;
  --color-tile-bg: #FFFDF9;
  --color-tile-text: #2C2420;
  --color-primary: #EA580C;
  --color-primary-dark: #C2410C;
  --color-primary-light: #FFEDD5;
  --color-gold: #F59E0B;
  --color-gold-light: #FEF3C7;
  --color-text-main: #2C2420;
  --color-text-muted: #786C65;
  --color-border: #E5DDD3;
  --color-border-light: #F0EAE1;

  /* Grid Tokens */
  --grid-size: min(92vw, 480px);
  --grid-rows: 9;
  --grid-cols: 9;

  /* Shadows */
  --shadow-sm: 0 1px 3px 0 rgba(44, 36, 32, 0.06);
  --shadow-card: 0 6px 12px -2px rgba(44, 36, 32, 0.08), 0 3px 6px -3px rgba(44, 36, 32, 0.06);
  --shadow-overlay: 0 20px 25px -5px rgba(44, 36, 32, 0.18), 0 8px 10px -6px rgba(44, 36, 32, 0.1);
}

[data-theme="dark"] {
  --color-bg-gradient: linear-gradient(180deg, #13131A 0%, #1A1A24 100%);
  --color-surface: #1E1E2A;
  --color-surface-translucent: rgba(30, 30, 42, 0.94);
  --color-board-bg: #181822;
  --color-tile-bg: #272738;
  --color-tile-text: #F8FAFC;
  --color-primary: #F43F5E;
  --color-primary-dark: #E11D48;
  --color-primary-light: #4C1D24;
  --color-gold: #FBBF24;
  --color-gold-light: #422006;
  --color-text-main: #F1F5F9;
  --color-text-muted: #94A3B8;
  --color-border: #333348;
  --color-border-light: #2C2C3D;
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.25);
  --shadow-card: 0 6px 12px -2px rgba(0, 0, 0, 0.35);
  --shadow-overlay: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

[data-theme="mint"] {
  --color-bg-gradient: linear-gradient(180deg, #F0FDF4 0%, #DCFCE7 100%);
  --color-surface: #FFFFFF;
  --color-surface-translucent: rgba(255, 255, 255, 0.94);
  --color-board-bg: #E1F3E7;
  --color-tile-bg: #F9FFF9;
  --color-tile-text: #14532D;
  --color-primary: #16A34A;
  --color-primary-dark: #15803D;
  --color-primary-light: #DCFCE7;
  --color-gold: #EAB308;
  --color-gold-light: #FEF9C3;
  --color-text-main: #0F291E;
  --color-text-muted: #4B6358;
  --color-border: #BBF7D0;
  --color-border-light: #E2F9E9;
  --shadow-sm: 0 1px 3px 0 rgba(20, 83, 45, 0.06);
  --shadow-card: 0 6px 12px -2px rgba(20, 83, 45, 0.08);
  --shadow-overlay: 0 20px 25px -5px rgba(20, 83, 45, 0.16);
}

[data-theme="obsidian-amber"] {
  --color-bg-gradient: linear-gradient(180deg, #111116 0%, #18171E 100%);
  --color-surface: #1E1D26;
  --color-surface-translucent: rgba(30, 29, 38, 0.94);
  --color-board-bg: #15141A;
  --color-tile-bg: #262432;
  --color-tile-text: #FDE68A;
  --color-primary: #F59E0B;
  --color-primary-dark: #D97706;
  --color-primary-light: #451A03;
  --color-gold: #FBBF24;
  --color-gold-light: #78350F;
  --color-text-main: #FEF3C7;
  --color-text-muted: #A39B8E;
  --color-border: #3D3528;
  --color-border-light: #2A251D;
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.35);
  --shadow-card: 0 6px 12px -2px rgba(0, 0, 0, 0.45);
  --shadow-overlay: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
}

[data-theme="midnight-neon"] {
  --color-bg-gradient: linear-gradient(180deg, #090D16 0%, #0D1322 100%);
  --color-surface: #111827;
  --color-surface-translucent: rgba(17, 24, 39, 0.94);
  --color-board-bg: #0C101B;
  --color-tile-bg: #1A2338;
  --color-tile-text: #38BDF8;
  --color-primary: #06B6D4;
  --color-primary-dark: #0891B2;
  --color-primary-light: #164E63;
  --color-gold: #A855F7;
  --color-gold-light: #3B0764;
  --color-text-main: #F0F9FF;
  --color-text-muted: #94A3B8;
  --color-border: #1E293B;
  --color-border-light: #151D2E;
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4);
  --shadow-card: 0 6px 12px -2px rgba(6, 182, 212, 0.15), 0 3px 6px -3px rgba(0, 0, 0, 0.4);
  --shadow-overlay: 0 20px 25px -5px rgba(0, 0, 0, 0.7);
}

[data-theme="sunset-rose"] {
  --color-bg-gradient: linear-gradient(180deg, #FFF1F2 0%, #FFE4E6 100%);
  --color-surface: #FFFFFF;
  --color-surface-translucent: rgba(255, 255, 255, 0.94);
  --color-board-bg: #FCE7F3;
  --color-tile-bg: #FFF5F7;
  --color-tile-text: #881337;
  --color-primary: #E11D48;
  --color-primary-dark: #BE123C;
  --color-primary-light: #FFE4E6;
  --color-gold: #F59E0B;
  --color-gold-light: #FEF3C7;
  --color-text-main: #4C0519;
  --color-text-muted: #9F1239;
  --color-border: #FECDD3;
  --color-border-light: #FFE4E6;
  --shadow-sm: 0 1px 3px 0 rgba(225, 29, 72, 0.08);
  --shadow-card: 0 6px 12px -2px rgba(225, 29, 72, 0.1);
  --shadow-overlay: 0 20px 25px -5px rgba(225, 29, 72, 0.2);
}

/* Base Reset & Typography */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--color-bg-gradient);
  color: var(--color-text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  user-select: none;
  -webkit-user-select: none;
  overflow-x: hidden;
}

#app {
  width: 100%;
  max-width: 520px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 12px 14px 24px;
}

/* ==========================================================================
   Shared Buttons & Controls (Minimum 44x44px Tap Target)
   ========================================================================== */

button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--dur-micro) var(--ease-out), opacity var(--dur-micro) var(--ease-out);
}

button:active {
  transform: scale(0.95); /* B5 feedback */
}

.btn {
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  gap: 8px;
}

.btn-primary {
  background: var(--color-primary);
  color: #FFFFFF;
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.3);
}

.btn-primary:active {
  background: var(--color-primary-dark);
}

.btn-secondary {
  background: #F1F5F9;
  color: var(--color-text-main);
  border: 1px solid var(--color-border);
}

.btn-outline {
  border: 1.5px solid var(--color-border);
  color: var(--color-text-muted);
}

/* Header & Stat Pills */
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.95rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  min-height: 44px;
}

/* ==========================================================================
   Level Map View
   ========================================================================== */

.map-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 8px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.map-logo {
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #0284C7 0%, #6366F1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.map-meta-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-lang-toggle {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  gap: 6px;
}

/* Stage Navigation Tabs */
.stage-nav {
  width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 2px 0;
}

.stage-nav::-webkit-scrollbar {
  display: none;
}

.stage-tabs-list {
  display: flex;
  gap: 8px;
  min-width: max-content;
}

.stage-tab-btn {
  padding: 8px 16px;
  border-radius: 12px;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border-light);
  color: var(--color-text-muted);
  font-size: 0.95rem;
  font-weight: 700;
  min-height: 44px;
  box-shadow: var(--shadow-sm);
}

.stage-tab-btn.active {
  background: var(--color-primary);
  color: #FFFFFF;
  border-color: var(--color-primary);
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.25);
}

.stage-tab-btn.stage-locked {
  opacity: 0.6;
  background: #F8FAFC;
}

/* Stage Levels Grid */
.stage-levels-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stage-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 2px;
}

.stage-title {
  font-size: 1.25rem;
  font-weight: 800;
}

.stage-progress-badge {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-primary);
  background: var(--color-primary-light);
  padding: 4px 10px;
  border-radius: 12px;
}

.levels-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.level-card-btn {
  width: 100%;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border-light);
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-card);
  text-align: left;
  min-height: 58px;
  animation: levelEntrance 240ms var(--ease-out) both;
}

.level-card-btn.level-current {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15), var(--shadow-card);
}

.level-card-btn.level-locked {
  opacity: 0.65;
  background: #F8FAFC;
  cursor: not-allowed;
}

.level-num {
  font-size: 1.1rem;
  font-weight: 800;
  min-width: 32px;
}

.level-theme-name {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text-main);
  padding: 0 12px;
}

.level-card-stars {
  font-size: 1.15rem;
  letter-spacing: 2px;
  color: #CBD5E1;
}

.level-card-stars .star-filled {
  color: var(--color-gold);
}

/* ==========================================================================
   Play Screen View
   ========================================================================== */

.play-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.play-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-icon-back,
.btn-map-back {
  font-size: 1.4rem;
  font-weight: 800;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  color: var(--color-text-main);
  min-height: 40px;
  min-width: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.play-title-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.play-level-title {
  font-size: 1.15rem;
  font-weight: 800;
}

.solved-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.play-stats-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-hint {
  background: var(--color-gold-light);
  border: 1px solid #FDE68A;
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 0.9rem;
  font-weight: 800;
  color: #92400E;
  box-shadow: var(--shadow-sm);
  gap: 4px;
}

/* Theme & Word List Card */
.theme-card {
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.theme-title {
  font-size: 1.05rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--color-primary-dark);
}

.word-chips-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  width: 100%;
}

.word-chip {
  padding: 5px 10px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  background: #F1F5F9;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border-light);
  letter-spacing: 0.4px;
  transition: transform 180ms var(--ease-back), background-color 180ms var(--ease-out);
}

.word-chip.chip-found {
  transform: scale(1.05); /* A4 pop */
  text-decoration: line-through;
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Puzzle Grid & Pill Overlay
   ========================================================================== */

.grid-card {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px 0;
}

.board-wrapper {
  position: relative;
  width: var(--grid-size);
  height: var(--grid-size);
  touch-action: none; /* Essential: prevents browser scroll steal */
}

.canvas-highlighter {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
}

.grid-board {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: repeat(var(--grid-rows), 1fr);
  grid-template-columns: repeat(var(--grid-cols), 1fr);
  background: var(--color-board-bg);
  border: 3px solid var(--color-border);
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  padding: 8px;
  gap: 3px;
  z-index: 2;
}

.grid-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1rem, 4.5vw, 1.4rem);
  font-weight: 800;
  color: var(--color-tile-text);
  background: var(--color-tile-bg);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: transform var(--dur-micro) var(--ease-out);
  cursor: pointer;
  position: relative;
  z-index: 3;
}

/* Active Drag Cell Highlight - scale gently without jarring box background */
.grid-cell.cell-selecting {
  transform: scale(1.08);
}

/* Pills Layer & Pill Geometry */
.pills-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.word-pill {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 9999px;
  border: 1.5px solid;
  pointer-events: none;
  opacity: 0.88;
  transform-origin: center center;
}

.word-pill.pill-animating {
  animation: pillScaleIn var(--dur-pill) var(--ease-back) forwards;
}

@keyframes pillScaleIn {
  from {
    opacity: 0;
    transform: scale(0.7);
  }
  to {
    opacity: 0.88;
    transform: scale(1);
  }
}

/* Wrong Word Shake Animation (A3) */
.grid-cell.cell-shake {
  animation: cellShake var(--dur-shake) var(--ease-std);
}

@keyframes cellShake {
  0% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
  100% { transform: translateX(0); }
}

/* Hint Pulse Ring (A5) */
.grid-cell.cell-hint-pulse {
  animation: hintPulse 2.5s var(--ease-out);
}

@keyframes hintPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
    transform: scale(1);
  }
  25% {
    box-shadow: 0 0 0 12px rgba(245, 158, 11, 0);
    transform: scale(1.15);
  }
  50% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
    transform: scale(1);
  }
  75% {
    box-shadow: 0 0 0 12px rgba(245, 158, 11, 0);
    transform: scale(1.15);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
    transform: scale(1);
  }
}

/* Lock Wiggle (B3) */
.lock-wiggle {
  animation: lockWiggle 300ms var(--ease-std);
}

@keyframes lockWiggle {
  0% { transform: rotate(0deg); }
  25% { transform: rotate(-10deg); }
  50% { transform: rotate(10deg); }
  75% { transform: rotate(-6deg); }
  100% { transform: rotate(0deg); }
}

@keyframes levelEntrance {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   Complete Overlay Modal (A7, A8)
   ========================================================================== */

.overlay-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  opacity: 0;
  transition: opacity 200ms var(--ease-out);
}

.overlay-backdrop.overlay-visible {
  opacity: 1;
}

.complete-card {
  width: 100%;
  max-width: 380px;
  background: var(--color-surface);
  border-radius: 24px;
  padding: 28px 24px;
  box-shadow: var(--shadow-overlay);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  transform: translateY(20px) scale(0.94);
  transition: transform var(--dur-overlay) var(--ease-back);
}

.overlay-visible .complete-card {
  transform: translateY(0) scale(1);
}

.complete-title {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--color-primary-dark);
}

.complete-subtitle {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text-muted);
}

.stars-container {
  display: flex;
  gap: 8px;
  font-size: 2.8rem;
  color: #E2E8F0;
  margin: 4px 0;
}

.star-item.star-earned {
  color: var(--color-gold);
  animation: starPop var(--dur-star) var(--ease-back) both;
}

@keyframes starPop {
  0% {
    opacity: 0;
    transform: scale(0) rotate(-15deg);
  }
  70% {
    transform: scale(1.25) rotate(5deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

.final-trophy {
  font-size: 4rem;
  margin-bottom: -6px;
}

.reward-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-gold-light);
  border: 1.5px solid #FDE68A;
  border-radius: 9999px;
  padding: 8px 18px;
  font-size: 1.15rem;
  font-weight: 800;
  color: #92400E;
}

.btn-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.btn-group .btn {
  width: 100%;
  min-height: 48px;
}

/* ==========================================================================
   Toast Notification (B6)
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
  width: 90%;
  max-width: 400px;
}

.toast-item {
  background: rgba(15, 23, 42, 0.92);
  color: #FFFFFF;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-overlay);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
  text-align: center;
}

.toast-item.toast-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-item.toast-warning {
  background: rgba(180, 83, 9, 0.95);
}

.toast-item.toast-error {
  background: rgba(185, 28, 28, 0.95);
}

/* ==========================================================================
   Accessibility & Prefers Reduced Motion
   ========================================================================== */

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

/* ==========================================================================
   Animated Brand Splash Screen
   ========================================================================== */

.splash-screen {
  position: fixed;
  inset: 0;
  background: var(--color-bg-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 380ms var(--ease-out);
  cursor: pointer;
}

.splash-screen.is-exiting {
  opacity: 0;
  pointer-events: none;
}

.splash-brand-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.splash-letters {
  display: flex;
  gap: 8px;
}

.splash-tile {
  width: 44px;
  height: 52px;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.65rem;
  font-weight: 900;
  color: var(--color-primary);
  box-shadow: 0 8px 16px -3px rgba(44, 36, 32, 0.12);
  animation: splashTileDrop 600ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes splashTileDrop {
  0% {
    transform: translateY(-80px) scale(0.5);
    opacity: 0;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.splash-subtitle {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.splash-progress-track {
  width: 150px;
  height: 5px;
  background: var(--color-border-light);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}

.splash-progress-bar {
  width: 100%;
  height: 100%;
  background: var(--color-primary);
  animation: splashProgress 1400ms ease-in-out infinite;
}

@keyframes splashProgress {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Header Control Buttons */
.btn-control-icon {
  font-size: 1.15rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  color: var(--color-text-main);
  padding: 6px;
  min-height: 40px;
  min-width: 40px;
}

/* ==========================================================================
   Home / Intro Welcome Screen (v1.1.0)
   ========================================================================== */

.home-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(12px, 2.5vh, 20px) 16px clamp(16px, 3.5vh, 28px);
  gap: 16px;
  animation: homeFadeIn 0.25s ease-out;
  width: 100%;
  box-sizing: border-box;
}

.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.home-controls-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.home-hero-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 18px;
  margin: auto 0;
  width: 100%;
  max-width: 480px;
}

/* Brand Letter Tiles "P U Z W O R D" */
.home-brand-tiles {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 1.8vw, 8px);
  width: 100%;
}

.home-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(38px, 9vw, 50px);
  height: clamp(46px, 10.5vw, 58px);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: 12px;
  font-family: inherit;
  font-size: clamp(1.3rem, 3.8vw, 1.7rem);
  font-weight: 900;
  color: var(--color-primary-dark);
  box-shadow: 0 4px 0 var(--color-border), 0 8px 16px rgba(0, 0, 0, 0.08);
  user-select: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  animation: homeTilePop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.home-tile:active {
  transform: translateY(3px) scale(0.96);
  box-shadow: 0 1px 0 var(--color-border);
}

.home-tile.tile-bounced {
  animation: tileBounce 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes tileBounce {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-8px) scale(1.18) rotate(-4deg); }
  70% { transform: translateY(2px) scale(0.97) rotate(2deg); }
  100% { transform: translateY(0) scale(1) rotate(0deg); }
}

.home-tile:nth-child(1) { animation-delay: 0.03s; }
.home-tile:nth-child(2) { animation-delay: 0.06s; }
.home-tile:nth-child(3) { animation-delay: 0.09s; }
.home-tile:nth-child(4) { animation-delay: 0.12s; }
.home-tile:nth-child(5) { animation-delay: 0.15s; }
.home-tile:nth-child(6) { animation-delay: 0.18s; }
.home-tile:nth-child(7) { animation-delay: 0.21s; }

@keyframes homeTilePop {
  0% {
    transform: translateY(14px) scale(0.9);
    opacity: 0.6;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.home-slogan {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text-sub);
  margin: 0;
}

.home-progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-main);
  box-shadow: var(--shadow-sm);
}

/* Primary Play CTA */
.home-cta-section {
  width: 100%;
  max-width: 380px;
}

.btn-home-play {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 16px 28px;
  font-size: 1.25rem;
  font-weight: 800;
  color: #FFFFFF;
  background: linear-gradient(135deg, #10B981 0%, #059669 100%);
  border: none;
  border-radius: 18px;
  box-shadow: 0 6px 0 #047857, 0 12px 24px rgba(16, 185, 129, 0.35);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn-home-play:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #047857, 0 4px 10px rgba(16, 185, 129, 0.25);
}

.btn-home-play-icon {
  font-size: 1.35rem;
}

/* Secondary Actions */
.home-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 380px;
}

.btn-home-action {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  background: var(--color-surface);
  border: 2px solid var(--color-border-light);
  border-radius: 14px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text-main);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
}

.btn-home-action:active {
  transform: scale(0.97);
  background: var(--color-bg);
}

/* Tutorial / How to Play Modal Overlay */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: homeFadeIn 0.25s ease-out;
}

.tutorial-overlay.is-closing {
  animation: homeFadeOut 0.2s ease-in forwards;
}

.tutorial-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 400px;
  padding: 28px 24px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  animation: homeScaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tutorial-title {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--color-text-main);
  text-align: center;
  margin: 0;
}

.tutorial-steps {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tutorial-step-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: var(--color-bg);
  border-radius: 14px;
}

.tutorial-step-icon {
  font-size: 1.5rem;
  line-height: 1.2;
}

.tutorial-step-text {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--color-text-main);
  margin: 0;
}

.tutorial-close-btn {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 14px;
}

@keyframes homeFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes homeFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes homeScaleUp {
  0% {
    opacity: 0;
    transform: scale(0.9) translateY(12px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ==========================================================================
   Tablet & Multi-Device Responsive Architecture
   ========================================================================== */

@media (min-width: 600px) {
  :root {
    --grid-size: min(85vw, 540px);
  }
  #app {
    max-width: 620px;
  }
}

/* Tablet Landscape Split-View (PRD 3.1) */
@media (min-width: 768px) and (orientation: landscape) {
  #app {
    max-width: 1020px;
    padding: 16px 32px;
  }

  .play-view {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    grid-template-rows: auto 1fr;
    gap: 24px;
    align-items: center;
  }

  .play-header {
    grid-column: 1 / -1;
  }

  .grid-card {
    grid-column: 1;
    grid-row: 2;
  }

  .theme-card {
    grid-column: 2;
    grid-row: 2;
    height: 100%;
    justify-content: center;
  }

  .home-view {
    max-width: 540px;
    margin: 0 auto;
    padding: 24px 0;
  }
}

/* ==========================================================================
   Phase 1 & 2: Floating Preview, Milestones, Daily & Retention Components
   ========================================================================== */

/* Floating Live Word Preview Bubble */
.word-preview-bubble {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  margin: 0 auto 12px;
  padding: 6px 18px;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: 9999px;
  box-shadow: var(--shadow-card);
  opacity: 0;
  transform: translateY(8px) scale(0.92);
  transition: opacity 160ms var(--ease-out), transform 180ms var(--ease-back), border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
  pointer-events: none;
  z-index: 15;
  width: fit-content;
  max-width: 90%;
}

.word-preview-bubble.active {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.word-preview-bubble.match-target {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  box-shadow: 0 4px 16px rgba(234, 88, 12, 0.28);
}

.word-preview-bubble.match-bonus {
  border-color: #8B5CF6;
  background: #F5F3FF;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.28);
}

.word-preview-text {
  font-family: inherit;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--color-text-main);
  text-transform: uppercase;
  text-align: center;
}

.word-preview-bubble.match-target .word-preview-text {
  color: var(--color-primary-dark);
}

.word-preview-bubble.match-bonus .word-preview-text {
  color: #6D28D9;
}

/* Stage Milestone Celebration Banner in Complete Overlay */
.stage-milestone-banner {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.16) 0%, rgba(217, 119, 6, 0.24) 100%);
  border: 2px solid var(--color-gold);
  border-radius: 16px;
  padding: 14px 16px;
  margin: 12px 0 16px;
  text-align: center;
  animation: homeScaleUp 320ms var(--ease-back) both;
}

.stage-milestone-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--color-gold);
  margin-bottom: 4px;
}

.stage-milestone-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-text-main);
  margin-bottom: 4px;
}

.stage-milestone-desc {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.btn-share {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  color: var(--color-text-main);
}

.btn-share:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* Daily Challenge Widget on Home View */
.daily-challenge-card {
  width: 100%;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: transform 180ms var(--ease-out), border-color 180ms ease;
  cursor: pointer;
}

.daily-challenge-card:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
}

.daily-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.daily-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.daily-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 9999px;
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.daily-streak-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 9999px;
  background: var(--color-gold-light);
  color: var(--color-gold);
}

.daily-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text-main);
}

.daily-subtitle {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.daily-action-btn {
  flex-shrink: 0;
  padding: 8px 14px;
  font-size: 0.875rem;
  font-weight: 700;
  border-radius: 12px;
  background: var(--color-primary);
  color: #FFFFFF;
}

.daily-action-btn.completed {
  background: var(--color-border);
  color: var(--color-text-muted);
}

/* Modals (Vault & Achievements) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms var(--ease-out);
}

.modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 460px;
  max-height: 85vh;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  box-shadow: var(--shadow-overlay);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: homeScaleUp 250ms var(--ease-back) both;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--color-border);
}

.modal-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-text-main);
}

.modal-subtitle {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.modal-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-border-light);
  color: var(--color-text-muted);
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Vault Chips & Empty State */
.vault-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.vault-chip {
  padding: 6px 12px;
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-weight: 700;
  font-size: 0.875rem;
  border-radius: 8px;
  letter-spacing: 0.5px;
}

.vault-empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Achievement Item */
.achievement-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--color-board-bg);
  border: 1px solid var(--color-border);
  border-radius: 14px;
}

.achievement-icon {
  font-size: 1.75rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  border-radius: 12px;
  flex-shrink: 0;
}

.achievement-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.achievement-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text-main);
}

.achievement-desc {
  font-size: 0.775rem;
  color: var(--color-text-muted);
}

.achievement-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}

.achievement-progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
  transition: width 200ms ease;
}

.achievement-action {
  flex-shrink: 0;
}

.btn-claim {
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 10px;
  background: var(--color-gold);
  color: #FFFFFF;
}

.btn-claimed {
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 10px;
  background: var(--color-border);
  color: var(--color-text-muted);
  cursor: default;
}

