:root {
  --cream: #F9F4E8;
  --cream-dark: #F0E9D6;
  --pink: #F5D0C5;
  --pink-dark: #E8B8A8;
  --mint: #B8E0D2;
  --lavender: #D4C5E2;
  --honey: #E8C07D;
  --terracotta: #E07856;
  --terracotta-dark: #C8633F;
  --plum: #4A3B52;
  --plum-light: #6B5570;
  --shadow: 0 8px 24px rgba(74, 59, 82, 0.08);
  --shadow-hover: 0 12px 32px rgba(74, 59, 82, 0.15);
  --radius: 20px;
  --radius-sm: 12px;
  --radius-lg: 28px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Inter', 'Segoe UI', -apple-system, system-ui, sans-serif;
  color: var(--plum);
  background: var(--cream);
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}
button, input { font-family: inherit; color: inherit; }

h1, h2, h3 {
  font-family: 'Playfair Display', 'Georgia', serif;
  font-weight: 700;
  color: var(--plum);
}

.screen { position: fixed; inset: 0; display: none; overflow: hidden; background: var(--cream); }
.screen.active { display: flex; flex-direction: column; }

#splash {
  background: radial-gradient(ellipse at center, #FDF8ED 0%, var(--cream) 50%, #F0E2D4 100%);
  align-items: center;
  justify-content: center;
}
.splash-inner { text-align: center; animation: fadeIn 0.8s ease; padding: 20px; }
.splash-piece {
  width: 120px; height: 120px; margin-bottom: 24px;
  fill: var(--terracotta);
  filter: drop-shadow(0 8px 20px rgba(224, 120, 86, 0.3));
  animation: float 3s ease-in-out infinite;
}
.splash-title { font-size: clamp(32px, 8vw, 52px); letter-spacing: 0.5px; margin-bottom: 8px; }
.splash-tagline { font-size: clamp(14px, 3vw, 18px); color: var(--plum-light); margin-bottom: 40px; font-style: italic; }
.progress-wrap { width: min(320px, 70vw); margin: 0 auto; }
.progress-bar { height: 8px; background: rgba(74, 59, 82, 0.1); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--terracotta), var(--honey)); border-radius: 999px; transition: width 0.3s ease; }
.progress-text { font-size: 13px; color: var(--plum-light); margin-top: 10px; }

.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: var(--cream);
  border-bottom: 1px solid rgba(74, 59, 82, 0.06);
  flex-shrink: 0;
}
.top-bar-title { font-family: 'Playfair Display', serif; font-weight: 700; font-size: 18px; }
.top-bar-right { display: flex; gap: 10px; align-items: center; }
.logo-small { display: flex; align-items: center; gap: 10px; font-family: 'Playfair Display', serif; font-weight: 700; font-size: 18px; }
.logo-small svg { width: 28px; height: 28px; fill: var(--terracotta); }

.stat-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--cream-dark);
  padding: 7px 14px;
  border-radius: 999px;
  font-weight: 600; font-size: 14px;
}
.stat-icon { font-size: 14px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--cream-dark);
  border: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform 0.15s, background 0.15s;
  color: var(--plum);
}
.icon-btn svg { fill: currentColor; }
.icon-btn:hover, .icon-btn:active { background: var(--pink); transform: scale(1.05); }

.btn {
  border: none; cursor: pointer;
  padding: 14px 28px;
  border-radius: 999px;
  font-size: 16px; font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--terracotta), var(--terracotta-dark));
  color: white;
  box-shadow: 0 6px 18px rgba(224, 120, 86, 0.35);
}
.btn-primary:hover, .btn-primary:active { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(224, 120, 86, 0.45); }
.btn-ghost { background: transparent; color: var(--plum); padding: 12px 24px; }
.btn-ghost:hover { background: var(--cream-dark); }

.menu-content { flex: 1; overflow-y: auto; padding: 20px; }
.menu-content::-webkit-scrollbar { width: 8px; }
.menu-content::-webkit-scrollbar-thumb { background: var(--cream-dark); border-radius: 999px; }

.hero-daily {
  position: relative;
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, #FFF4EA 0%, var(--pink) 100%);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 28px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.hero-daily-text { z-index: 1; max-width: 70%; }
.daily-badge {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--terracotta);
  background: rgba(255,255,255,0.7); padding: 4px 12px; border-radius: 999px;
  margin-bottom: 10px;
}
.hero-daily-title { font-size: clamp(20px, 4vw, 28px); margin-bottom: 6px; }
.hero-daily-sub { color: var(--plum-light); font-size: 14px; margin-bottom: 16px; }
.hero-daily-art { position: absolute; right: -20px; top: 10px; bottom: 10px; width: 160px; pointer-events: none; }
.daily-piece { position: absolute; width: 60px; height: 60px; background: rgba(255,255,255,0.5); border-radius: 14px; backdrop-filter: blur(4px); animation: float 4s ease-in-out infinite; }
.daily-piece-1 { top: 10px; right: 40px; }
.daily-piece-2 { top: 60px; right: 0; animation-delay: 0.6s; background: rgba(184, 224, 210, 0.7); }
.daily-piece-3 { top: 110px; right: 60px; animation-delay: 1.2s; background: rgba(212, 197, 226, 0.7); }

.section-title { font-size: 22px; margin: 14px 6px 14px; }
.section-title.center { text-align: center; }

.categories-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; padding-bottom: 80px; }
.category-card {
  background: white;
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer; border: none; text-align: left;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex; flex-direction: column; gap: 10px;
}
.category-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.category-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  background: var(--cream-dark) center/cover;
  position: relative; overflow: hidden;
}
.category-thumb::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 60%, rgba(0,0,0,0.25));
}
.category-name { font-family: 'Playfair Display', serif; font-weight: 700; font-size: 16px; }
.category-count { font-size: 12px; color: var(--plum-light); }

.diff-content { flex: 1; overflow-y: auto; padding: 20px; text-align: center; }
.diff-preview {
  width: min(280px, 70vw);
  aspect-ratio: 4/3;
  margin: 0 auto 24px;
  border-radius: var(--radius);
  background: var(--cream-dark) center/cover;
  box-shadow: var(--shadow);
}
.diff-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; max-width: 560px; margin: 0 auto 24px; }
.diff-card {
  background: white; border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 18px 12px; cursor: pointer; text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.15s, border-color 0.15s;
}
.diff-card:hover { transform: translateY(-3px); border-color: var(--terracotta); }
.diff-icon { font-size: 28px; margin-bottom: 6px; }
.diff-name { font-family: 'Playfair Display', serif; font-weight: 700; font-size: 17px; }
.diff-desc { font-size: 12px; color: var(--plum-light); margin-top: 2px; }

.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 420px; margin: 14px auto;
  background: white; padding: 14px 20px; border-radius: var(--radius);
  box-shadow: var(--shadow); cursor: pointer;
}
.toggle-row input[type="checkbox"] { display: none; }
.toggle-slider {
  width: 44px; height: 24px; background: var(--cream-dark); border-radius: 999px;
  position: relative; transition: background 0.2s;
}
.toggle-slider::before {
  content: ''; position: absolute; left: 2px; top: 2px;
  width: 20px; height: 20px; background: white; border-radius: 50%;
  transition: transform 0.2s; box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.toggle-row input:checked ~ .toggle-slider { background: var(--terracotta); }
.toggle-row input:checked ~ .toggle-slider::before { transform: translateX(20px); }

.lang-row { display: flex; align-items: center; justify-content: space-between; max-width: 420px; margin: 14px auto; background: white; padding: 14px 20px; border-radius: var(--radius); box-shadow: var(--shadow); }
.lang-btns { display: flex; gap: 8px; }
.lang-btn { padding: 6px 14px; border-radius: 999px; border: none; background: var(--cream-dark); cursor: pointer; font-weight: 600; }
.lang-btn.active { background: var(--terracotta); color: white; }

.game-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: rgba(249, 244, 232, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(74, 59, 82, 0.06);
  flex-shrink: 0; z-index: 5;
}
.game-stats { display: flex; gap: 10px; }
.canvas-wrap {
  flex: 1; position: relative;
  background: var(--cream-dark);
  background-image: url('../assets/bg/board.svg');
  background-size: cover; background-position: center;
  overflow: hidden;
}
#board { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#board.dragging { cursor: grabbing; }

.game-footer { padding: 10px 16px 14px; flex-shrink: 0; background: var(--cream); }
.hint-banner {
  width: 100%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--honey), var(--terracotta));
  color: white;
  border-radius: var(--radius);
  padding: 12px 18px;
  display: flex; align-items: center; gap: 14px;
  text-align: left;
  box-shadow: 0 4px 14px rgba(224, 120, 86, 0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}
.hint-banner:hover, .hint-banner:active { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(224, 120, 86, 0.4); }
.hint-icon { font-size: 26px; flex-shrink: 0; }
.hint-text-wrap { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.hint-text { font-weight: 700; font-size: 15px; }
.hint-sub { font-size: 12px; opacity: 0.92; }
.hint-arrow { font-size: 28px; opacity: 0.8; }

.modal {
  position: fixed; inset: 0;
  background: rgba(74, 59, 82, 0.55);
  backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal.active { display: flex; animation: fadeIn 0.2s ease; }
.modal-box {
  background: var(--cream);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 420px; width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  animation: scaleIn 0.25s ease;
}
.modal-box h2 { margin-bottom: 18px; font-size: 26px; }
.modal-box .btn { width: 100%; margin-bottom: 10px; }
.modal-box .btn:last-child { margin-bottom: 0; }

.preview-box { padding: 16px; }
.preview-box img { width: 100%; border-radius: var(--radius); margin-bottom: 14px; }

.win-box .win-sparkle { font-size: 60px; margin-bottom: 8px; animation: pop 0.5s ease; }
.win-stats { font-size: 15px; color: var(--plum-light); margin-bottom: 18px; }
.win-stats b { color: var(--plum); font-weight: 700; }

.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(100px);
  background: var(--plum); color: white;
  padding: 12px 22px; border-radius: 999px;
  font-size: 14px; font-weight: 500;
  opacity: 0; transition: transform 0.3s, opacity 0.3s;
  z-index: 200; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes pop { 0% { transform: scale(0); } 60% { transform: scale(1.3); } 100% { transform: scale(1); } }

@media (max-width: 640px) {
  .top-bar, .game-bar { padding: 10px 14px; }
  .menu-content { padding: 14px; }
  .hero-daily { padding: 20px; }
  .hero-daily-art { width: 120px; }
  .categories-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .hero-daily { padding: 18px 24px; }
  .diff-preview { width: 200px; }
}
