/* style.css — all styling */
:root {
  --bg: #0e0f15;
  --bg2: #161823;
  --panel: rgba(22, 24, 35, 0.78);
  --panel-solid: #1a1c28;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8e9f0;
  --muted: #9aa0b4;
  --accent: #e8b87a;
  --accent-soft: rgba(232, 184, 122, 0.18);
  --cell-bg: rgba(255, 255, 255, 0.04);
  --cell-bg-hover: rgba(255, 255, 255, 0.09);
  --found: rgba(120, 220, 150, 0.32);
  --selecting: rgba(232, 184, 122, 0.35);
  --radius: 14px;
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #f3f1ea;
  --bg2: #e7e3d8;
  --panel: rgba(255, 255, 255, 0.85);
  --panel-solid: #ffffff;
  --border: rgba(0, 0, 0, 0.1);
  --text: #1c1d24;
  --muted: #5a5f70;
  --cell-bg: rgba(0, 0, 0, 0.04);
  --cell-bg-hover: rgba(0, 0, 0, 0.08);
  --found: rgba(60, 170, 90, 0.28);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.4;
  overflow-x: hidden;
}
.app { max-width: 1080px; margin: 0 auto; padding: 18px; min-height: 100%; display: flex; flex-direction: column; gap: 14px; }

/* Top bar */
.topbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #b8784a);
  display: grid; place-items: center; color: #1a0d05; font-size: 22px; font-weight: 800;
  box-shadow: 0 6px 18px var(--accent-soft);
}
.brand-text h1 { font-size: 18px; margin: 0; letter-spacing: .3px; }
.brand-text .tag { margin: 0; font-size: 12px; color: var(--muted); }
.progress { flex: 1; min-width: 120px; height: 8px; background: var(--cell-bg); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #88d878); border-radius: 99px; transition: width .4s cubic-bezier(.2,.7,.2,1); }
.count { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--muted); font-size: 13px; }

/* Puzzle nav */
.puzzle-nav { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.nav-btn {
  flex: 0 0 auto; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--border);
  background: var(--cell-bg); color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .2s ease; white-space: nowrap;
}
.nav-btn:hover { color: var(--text); background: var(--cell-bg-hover); }
.nav-btn.active { background: var(--accent); color: #1a0d05; border-color: transparent; box-shadow: 0 4px 14px var(--accent-soft); }

/* Stage */
.stage {
  position: relative; display: grid; grid-template-columns: 1fr 240px; gap: 16px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 20px;
  padding: 16px; backdrop-filter: blur(8px); flex: 1; min-height: 0;
}
.scene { position: absolute; inset: 0; border-radius: 20px; overflow: hidden; opacity: .55; z-index: 0; }
.scene svg { width: 100%; height: 100%; display: block; }
.panel, .side { position: relative; z-index: 1; }
.puzzle-head { margin-bottom: 12px; }
.puzzle-head h2 { margin: 0; font-size: 22px; color: var(--accent); }
.puzzle-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

/* Grid */
.grid-wrap { display: flex; justify-content: center; }
.grid {
  display: grid; gap: 3px; width: 100%; max-width: 540px;
  background: rgba(0, 0, 0, 0.25); padding: 8px; border-radius: 12px;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
html[data-theme="light"] .grid { background: rgba(0,0,0,0.06); }
.cell {
  aspect-ratio: 1; display: grid; place-items: center;
  background: var(--cell-bg); border-radius: 6px;
  font-size: clamp(11px, 2.6vw, 17px); font-weight: 700; letter-spacing: .3px;
  color: var(--text); cursor: pointer; transition: background .12s ease, transform .12s ease, color .12s ease;
  border: 1px solid transparent;
}
.cell:hover { background: var(--cell-bg-hover); }
.cell.selecting { background: var(--selecting); color: #fff; transform: scale(1.04); }
html[data-theme="light"] .cell.selecting { color: #1a0d05; }
.cell.found { background: var(--found); color: #b8f0c8; }
html[data-theme="light"] .cell.found { color: #1c6a3a; }
.cell.hint { animation: hintPulse 1.6s ease; }
@keyframes hintPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent); }
  50% { box-shadow: 0 0 0 6px var(--accent-soft); background: var(--accent-soft); transform: scale(1.1); }
}

/* Side */
.side { display: flex; flex-direction: column; }
.side h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.wordlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow-y: auto; }
.word {
  font-size: 13px; font-weight: 600; padding: 7px 10px; border-radius: 8px;
  background: var(--cell-bg); color: var(--text); letter-spacing: .4px;
  transition: all .25s ease;
}
.word.found { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--muted); background: var(--found); }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.actions button {
  padding: 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--cell-bg); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .18s ease;
}
.actions button:hover { background: var(--cell-bg-hover); border-color: var(--accent); color: var(--accent); }
.actions button:active { transform: translateY(1px); }
#fullscreenBtn { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.instructions { margin: 14px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--panel-solid); color: var(--text); padding: 11px 18px; border-radius: 99px;
  border: 1px solid var(--border); box-shadow: 0 12px 32px rgba(0,0,0,.4);
  font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .3s ease; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Responsive */
@media (max-width: 760px) {
  .stage { grid-template-columns: 1fr; padding: 12px; }
  .side { order: 2; }
  .wordlist { max-height: 200px; flex-direction: row; flex-wrap: wrap; }
  .word { font-size: 12px; padding: 6px 9px; }
  .actions { flex-direction: row; flex-wrap: wrap; }
  .actions button { flex: 1; min-width: 90px; }
}
@media (max-width: 420px) {
  .brand-text h1 { font-size: 16px; }
  .puzzle-head h2 { font-size: 19px; }
  .progress { order: 3; flex-basis: 100%; }
}
