/* ======================================================================
   SudokuWeb — theme tokens, lifted from ividi.dev's dark/amber palette
   ====================================================================== */

:root {
  --bg: #141716;
  --bg-panel: #191d1b;
  --bg-panel-2: #202622;
  --border: rgba(225, 235, 222, 0.14);
  --border-strong: rgba(225, 235, 222, 0.38);
  --text: #f0f1e9;
  --text-dim: #b4bcb3;
  --text-faint: #8d998f;
  --accent: #e8b86d;
  --accent-light: #f5ce90;
  --accent-dark: #c99548;
  --accent-glow: rgba(232, 184, 109, 0.12);
  --danger: #ff8c87;
  --ok: #22c55e;

  --given-digit: #f0f1e9;
  --user-digit: #f5ce90;
  --selected-cell-bg: #55472f;
  --peer-highlight-bg: #28332b;
  --same-number-bg: #414332;
  --conflict-bg: #492e2b;
  --conflict-text: #ff8c87;
  --note-text: #b4bcb3;

  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --radius: 10px;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
button { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }

#app { position: relative; width: 100%; height: 100%; }

.bg-glow {
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(600px 400px at 15% 10%, rgba(232, 184, 109, 0.06), transparent 60%),
    radial-gradient(500px 500px at 85% 90%, rgba(232, 184, 109, 0.025), transparent 60%);
}

.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ======================================================================
   Splash
   ====================================================================== */

.splash-screen {
  justify-content: center;
  background: var(--bg);
}
.splash-screen.leaving { animation: splashOut .6s var(--ease) forwards; }
@keyframes splashOut { to { opacity: 0; transform: scale(1.03); } }

.splash-grid {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
}
.splash-grid-frame {
  width: min(58vw, 340px); aspect-ratio: 1;
  border: 3px solid var(--accent);
  border-radius: 14px;
  opacity: 0;
  background-image:
    linear-gradient(to right, transparent calc(33.33% - 1px), rgba(249,156,0,.4) calc(33.33% - 1px), rgba(249,156,0,.4) calc(33.33% + 1px), transparent calc(33.33% + 1px)),
    linear-gradient(to right, transparent calc(66.66% - 1px), rgba(249,156,0,.4) calc(66.66% - 1px), rgba(249,156,0,.4) calc(66.66% + 1px), transparent calc(66.66% + 1px)),
    linear-gradient(to bottom, transparent calc(33.33% - 1px), rgba(249,156,0,.4) calc(33.33% - 1px), rgba(249,156,0,.4) calc(33.33% + 1px), transparent calc(33.33% + 1px)),
    linear-gradient(to bottom, transparent calc(66.66% - 1px), rgba(249,156,0,.4) calc(66.66% - 1px), rgba(249,156,0,.4) calc(66.66% + 1px), transparent calc(66.66% + 1px));
  animation: gridIn 1.1s var(--ease) forwards, gridGlow 2.4s ease-in-out .9s infinite;
}
@keyframes gridIn { from { opacity: 0; transform: scale(.7) rotate(-4deg); } to { opacity: .5; transform: scale(1) rotate(0); } }
@keyframes gridGlow {
  0%, 100% { box-shadow: 0 0 0 rgba(249,156,0,0); }
  50% { box-shadow: 0 0 60px rgba(249,156,0,.25); }
}

.splash-content {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  animation: contentIn 1s var(--ease) both; animation-delay: .4s;
  opacity: 0;
}
@keyframes contentIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

.brand-logo {
  font-family: var(--font-body);
  font-weight: 900;
  font-size: clamp(2.6rem, 8vw, 4.6rem);
  letter-spacing: -.02em;
  margin: 0;
  line-height: 1;
}
.brand-sudoku { color: var(--text); }
.brand-web { color: var(--accent); }

.splash-tagline {
  font-family: var(--font-mono);
  color: var(--text-dim);
  margin: .9rem 0 0;
  font-size: clamp(.85rem, 2vw, 1rem);
  max-width: 24rem;
}

.splash-credit {
  margin-top: 3rem;
  opacity: 0;
  animation: contentIn .9s var(--ease) both; animation-delay: 1.4s;
}
.credit-line {
  font-family: var(--font-mono);
  color: var(--text-faint);
  font-size: .8rem;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.credit-name {
  font-family: var(--font-mono);
  color: var(--text);
  font-weight: 700;
  font-size: 1rem;
  margin: .3rem 0 .6rem;
}
.credit-links {
  font-family: var(--font-mono);
  font-size: .82rem;
  color: var(--text-dim);
}
.credit-links .dot { margin: 0 .5em; color: var(--text-faint); }

.splash-skip {
  position: absolute; bottom: 2.4rem; left: 50%; transform: translateX(-50%);
  background: none; border: 1px solid var(--border); color: var(--text-faint);
  font-family: var(--font-mono); font-size: .75rem; letter-spacing: .06em;
  padding: .5rem 1rem; border-radius: 999px; cursor: pointer;
  opacity: 0; animation: contentIn .8s var(--ease) both; animation-delay: 2.2s;
  transition: color .2s, border-color .2s;
}
.splash-skip:hover { color: var(--text); border-color: var(--border-strong); }

/* ======================================================================
   Menu
   ====================================================================== */

.menu-screen {
  justify-content: safe center;
  overflow-y: auto;

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

.lang-toggle {
  position: absolute; top: 1.4rem; right: 1.4rem; z-index: 5;
  display: flex; align-items: center;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px; cursor: pointer;
  font-family: var(--font-mono); font-size: .78rem; font-weight: 700;
}
.lang-opt { position: relative; z-index: 1; padding: .4rem .75rem; color: var(--text-faint); transition: color .25s; }
.lang-opt.active { color: #141716; }
.lang-pill {
  position: absolute; top: 3px; left: 3px; height: calc(100% - 6px); width: calc(50% - 3px);
  background: var(--accent); border-radius: 999px;
  transition: transform .28s var(--ease);
}
.lang-toggle[data-lang="en"] .lang-pill { transform: translateX(100%); }

.menu-content {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  margin: 3.5rem 0 4rem;
  flex-shrink: 0;
}
.eyebrow {
  font-family: var(--font-mono); color: var(--accent);
  letter-spacing: .18em; font-size: .72rem; margin: 0 0 .6rem;
}
.brand-logo--menu { font-size: clamp(2.4rem, 7vw, 3.6rem); }
.menu-subtitle {
  font-family: var(--font-mono); color: var(--text-dim);
  margin: .7rem 0 0; font-size: .92rem; max-width: 26rem;
}

.difficulty-picker { margin-top: 1.6rem; display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.difficulty-label {
  font-family: var(--font-mono); color: var(--text-faint);
  letter-spacing: .1em; font-size: .68rem; text-transform: uppercase; margin: 0;
}
.difficulty-options {
  display: flex; background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px; gap: 2px;
}
.difficulty-option {
  font-family: var(--font-mono); font-size: .78rem; font-weight: 700;
  color: var(--text-faint); background: transparent; border: none; cursor: pointer;
  padding: .45rem 1rem; border-radius: 999px; transition: background .2s, color .2s;
}
.difficulty-option:hover { color: var(--text); }
.difficulty-option.active { background: var(--accent); color: #14100a; }

.menu-buttons { display: flex; flex-direction: column; gap: .8rem; margin-top: 1.6rem; width: min(320px, 80vw); }

.btn {
  font-family: var(--font-body); font-weight: 600; font-size: .96rem;
  padding: .85rem 1.6rem; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent; letter-spacing: .02em;
  display: flex; align-items: center; justify-content: center; text-decoration: none;
  transition: transform .15s var(--ease), box-shadow .15s var(--ease), background .2s, border-color .2s;
}
.btn:active { transform: scale(.97); }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #14100a; box-shadow: 0 8px 24px var(--accent-glow); }
.btn-primary:hover { background: var(--accent-light); box-shadow: 0 10px 30px var(--accent-glow); }
.btn-secondary { background: var(--bg-panel-2); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); }

.app-footer, .menu-screen .app-footer {
  position: absolute; bottom: 1.6rem; left: 0; right: 0; text-align: center;
  font-family: var(--font-mono); font-size: .74rem; color: var(--text-faint);
}
.app-footer a { color: var(--text-dim); }
.app-footer a:hover { color: var(--accent); }
.dot { margin: 0 .5em; opacity: .5; }

/* ======================================================================
   How to play
   ====================================================================== */

.htp-screen { align-items: stretch; }
.sub-header {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.1rem 1.2rem; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.sub-header h2 { margin: 0; font-size: 1.1rem; font-family: var(--font-mono); }
.sub-header-spacer { width: 40px; }

.htp-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  padding: 1.4rem 1.4rem 3rem; max-width: 640px; margin: 0 auto; width: 100%;
}
.htp-intro { color: var(--text-dim); line-height: 1.6; }
.htp-section { margin-top: 2rem; }
.htp-section h3 { font-family: var(--font-mono); color: var(--accent); font-size: .95rem; margin-bottom: .6rem; }
.htp-section p { color: var(--text-dim); line-height: 1.6; margin: 0; }

.htp-diagram { display: flex; justify-content: center; margin-top: 1.2rem; }
.mini-grid { width: 130px; aspect-ratio: 1; position: relative; }
.mini-grid-frame {
  width: 100%; height: 100%;
  border: 2px solid var(--accent); border-radius: 8px;
  background-image:
    linear-gradient(to right, transparent calc(33.33% - 1px), var(--border-strong) calc(33.33% - 1px), var(--border-strong) calc(33.33% + 1px), transparent calc(33.33% + 1px)),
    linear-gradient(to right, transparent calc(66.66% - 1px), var(--border-strong) calc(66.66% - 1px), var(--border-strong) calc(66.66% + 1px), transparent calc(66.66% + 1px)),
    linear-gradient(to bottom, transparent calc(33.33% - 1px), var(--border-strong) calc(33.33% - 1px), var(--border-strong) calc(33.33% + 1px), transparent calc(33.33% + 1px)),
    linear-gradient(to bottom, transparent calc(66.66% - 1px), var(--border-strong) calc(66.66% - 1px), var(--border-strong) calc(66.66% + 1px), transparent calc(66.66% + 1px));
}

.htp-tools { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .7rem; }
.htp-tools li { color: var(--text-dim); line-height: 1.5; font-size: .92rem; }
.htp-tools strong { color: var(--accent); font-family: var(--font-mono); }

.htp-close { margin-top: 2.4rem; width: 100%; }

/* ======================================================================
   Game screen
   ====================================================================== */

.game-screen { overflow-y: auto; }

.game-header {
  width: 100%; flex-shrink: 0;
  display: flex; align-items: center; gap: .8rem;
  padding: .7rem 1rem; border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  flex-wrap: wrap;
}
.icon-btn {
  display: flex; align-items: center; gap: .35rem;
  background: var(--bg-panel-2); border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 8px; padding: .5rem .6rem;
  cursor: pointer; position: relative;
  transition: color .15s, border-color .15s, background .15s, transform .1s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn:active { transform: scale(.94); }
.icon-btn:disabled { opacity: .35; cursor: default; pointer-events: none; }

.game-stats { display: flex; gap: 1.2rem; margin: 0 auto; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; align-items: center; font-family: var(--font-mono); line-height: 1.2; }
.stat-label { font-size: .62rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; }
.stat-value { font-size: 1rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.stat-value.pop { animation: statPop .3s var(--ease); }
@keyframes statPop { 0% { transform: scale(1); } 45% { transform: scale(1.2); } 100% { transform: scale(1); } }

.game-actions { display: flex; gap: .5rem; margin-left: auto; }

.board-wrap {
  flex: 0 0 auto; width: 100%; position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 1.2rem 1rem .8rem;
}
