/* ========================================
   NUMBER KNOTS PWA — Responsive Stylesheet
   Mobile-first, scales to desktop.
   Dark teal / greenish-blue cosmic theme, sharing the
   structure of the SET game's system.
   ======================================== */

:root {
  --bg-deep:      #05171d;
  --bg-card:      #0a2731;
  --bg-surface:   #0e3340;
  --bg-elevated:  #12404f;

  --red:    #f43f5e;
  --green:  #22c55e;
  --teal:   #14b8a6;

  /* Semantic accent names kept from the shared system; values are now the
     greenish-blue family (teal → cyan → sky) rather than violet/pink. */
  --accent-violet: #14b8a6;   /* teal  */
  --accent-pink:   #22d3ee;   /* cyan  */
  --accent-orange: #38bdf8;   /* sky   */
  --accent-cyan:   #22d3ee;

  --text-primary:   #e8fbf6;
  --text-secondary: #86b8b3;
  --text-muted:     #4a7d78;

  --border:        rgba(20,184,166,0.22);
  --border-bright: rgba(34,211,238,0.5);

  --radius-card: 16px;
  --radius-btn:  10px;

  --font-display: 'Space Grotesk', sans-serif;
  --font-mono:    'Space Mono', monospace;

  --shadow-glow: 0 0 20px rgba(34,211,238,0.4);

  /* Safe-area insets behind variables so they can be reasoned about in one
     place — and simulated in tests, since env() always reports 0 off-device. */
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);

  /* Fluid spacing scale */
  --sp-xs:  clamp(4px,  1vw,  6px);
  --sp-sm:  clamp(8px,  2vw,  12px);
  --sp-md:  clamp(12px, 2.5vw,18px);
  --sp-lg:  clamp(16px, 3vw,  24px);
  --sp-xl:  clamp(20px, 4vw,  32px);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-display);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  cursor: auto;
}

body * { cursor: auto !important; }

/* The blanket `body *` rule forces the arrow cursor onto everything, so
   anything interactive has to opt back in — links included. */
button,
button *,
a[href],
a[href] * { cursor: pointer !important; }

.hidden { display: none !important; }

/* ════════════════════════════════════════
   SPLASH SCREEN
   ════════════════════════════════════════ */
.splash {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(ellipse at 50% 10%, #0b4650 0%, #05171d 65%);
  display: flex; align-items: flex-start; justify-content: center;
  padding: max(var(--sp-lg), var(--sat)) max(var(--sp-lg), var(--sar)) var(--sp-lg) max(var(--sp-lg), var(--sal));
  /* Auto margins on the child centre when it fits and let it scroll when it
     doesn't — align-items:center would clip the TOP in landscape. */
  overflow-y: auto;
}
.splash-inner {
  display: flex; flex-direction: column;
  align-items: center;
  gap: clamp(12px, 2.5vw, 20px);
  width: 100%;
  max-width: 420px;
  text-align: center;
  margin: auto 0;
  padding-bottom: max(32px, var(--sab));
}

/* The wordmark IS the goal itself: the number 24, a digit per tile. */
.splash-title {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(8px, 2vw, 12px);
}
/* One tile holding "24" — the two digits stay teal/cyan but read as a single
   logo, mirroring the app icon. */
.logo-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: clamp(2px, 0.6vw, 5px);
  padding: clamp(10px, 3vw, 18px) clamp(20px, 6vw, 34px);
  border-radius: 22px;
  background: linear-gradient(135deg, #0f3d40, #0a2731);
  border: 2px solid #22d3ee;
  box-shadow: 0 0 26px rgba(34,211,238,0.28);
  font-family: var(--font-mono);
  font-size: clamp(2.6rem, 12vw, 4.2rem);
  font-weight: 700;
  line-height: 1;
  animation: tilePop 0.6s ease backwards;
}
.logo-2 { color: #7fecd8; }
.logo-4 { color: #a5f3fc; }
@keyframes tilePop {
  from { transform: scale(0.5) rotate(-10deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}

.splash-name {
  font-size: clamp(1.5rem, 6vw, 2.1rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, #2dd4bf, #22d3ee);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.splash-sub {
  font-size: clamp(0.72rem, 2.5vw, 0.9rem);
  color: var(--text-secondary);
  letter-spacing: 0.08em; text-transform: uppercase;
}

/* ── Difficulty selector (segmented pill) ── */
.level-select {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(34,211,238,0.06);
  border: 1px solid var(--border);
  animation: tilePop 0.5s ease backwards;
  animation-delay: 0.15s;
}
.level-opt {
  border: none;
  background: none;
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: clamp(0.72rem, 2vw, 0.85rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 8px clamp(14px, 4vw, 20px);
  border-radius: 999px;
  cursor: pointer;
  min-height: 38px;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}
.level-opt.is-active {
  background: linear-gradient(135deg, #0d9488, #06b6d4);
  color: #fff;
  box-shadow: 0 2px 14px rgba(34,211,238,0.32);
}
@media (hover: hover) {
  .level-opt:not(.is-active):hover { color: var(--text-primary); }
}

/* ── Personal best ── */
.best-strip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 15px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.10);
  border: 1px solid rgba(251, 191, 36, 0.32);
  font-size: clamp(0.72rem, 2.1vw, 0.84rem);
  color: var(--text-secondary);
  animation: tilePop 0.5s ease backwards;
  animation-delay: 0.3s;
}
.best-badge { font-size: 1.1rem; line-height: 1; }
.best-line strong { color: #fbbf24; font-weight: 700; }

.go-best { font-size: clamp(0.78rem, 2.2vw, 0.9rem); color: var(--text-secondary); }
.go-best.is-new { color: #fbbf24; font-weight: 700; animation: bounce 0.7s ease; }

.splash-inner .btn-primary { max-width: 320px; }
.splash-inner .btn-ghost   { max-width: 320px; }

/* ── Secondary actions: icon buttons in one row (splash + game over) ── */
.icon-action-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  justify-items: center;
  gap: clamp(8px, 2.5vw, 14px);
  width: 100%;
  max-width: 300px;
  margin-inline: auto;
}
.icon-action {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0;
  background: none;
  border: none;
  font-family: var(--font-display);
}
.icon-action-glyph {
  width: clamp(46px, 13vw, 56px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 14px;
  border: 2px solid var(--border-bright);
  background: rgba(34, 211, 238, 0.07);
  color: var(--text-primary);
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.icon-action-glyph svg { width: 38%; height: auto; display: block; }
@media (hover: hover) {
  .icon-action:hover .icon-action-glyph {
    border-color: var(--accent-cyan);
    background: rgba(34, 211, 238, 0.16);
    transform: translateY(-2px);
  }
}
.icon-action:active .icon-action-glyph { transform: scale(0.96); }
.icon-action-label {
  font-size: clamp(0.58rem, 1.8vw, 0.66rem);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.install-steps {
  color: var(--text-secondary);
  font-size: clamp(0.8rem, 2.2vw, 0.92rem);
  line-height: 1.5;
  margin-bottom: 18px;
}

.splash-footer {
  margin-top: clamp(4px, 1.5vw, 10px);
  font-family: var(--font-mono);
  font-size: clamp(0.62rem, 1.8vw, 0.72rem);
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

/* ════════════════════════════════════════
   BUTTONS — fluid, touch-safe
   ════════════════════════════════════════ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: clamp(12px,2.5vw,16px) clamp(20px,4vw,28px);
  background: linear-gradient(135deg, #0d9488, #06b6d4);
  border: none; border-radius: var(--radius-btn);
  color: #fff; font-family: var(--font-display);
  font-size: clamp(0.9rem, 2.5vw, 1.05rem); font-weight: 600;
  cursor: pointer; letter-spacing: 0.04em;
  line-height: 1.1;
  transition: box-shadow 0.15s;
  box-shadow: 0 4px 20px rgba(20,184,166,0.4);
  transform: translateY(0);
  min-height: 44px;
}
.btn-primary:hover  { box-shadow: 0 6px 28px rgba(34,211,238,0.55); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  width: 100%;
  padding: clamp(10px,2vw,14px) clamp(20px,4vw,28px);
  background: transparent; border: 2px solid var(--border-bright);
  border-radius: var(--radius-btn);
  color: var(--text-secondary); font-family: var(--font-display);
  font-size: clamp(0.85rem, 2.3vw, 1rem); font-weight: 500;
  cursor: pointer; transition: all 0.15s;
  min-height: 44px;
}
.btn-ghost:hover { border-color: var(--accent-cyan); color: var(--text-primary); }

.btn-outline {
  padding: clamp(8px,1.5vw,11px) clamp(14px,3vw,22px);
  background: transparent;
  border: 1.5px solid var(--border-bright);
  border-radius: var(--radius-btn);
  color: var(--text-secondary); font-family: var(--font-display);
  font-size: clamp(0.78rem, 2vw, 0.88rem); font-weight: 500;
  cursor: pointer; transition: all 0.2s;
  min-height: 40px; white-space: nowrap;
}
.btn-outline:hover { border-color: var(--accent-cyan); color: var(--text-primary); background: rgba(34,211,238,0.1); }
.btn-outline:disabled { opacity: 0.35; cursor: not-allowed; }

.full-w { width: 100%; margin-top: 8px; }

/* ════════════════════════════════════════
   MODAL
   ════════════════════════════════════════ */
.modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: clamp(12px, 3vw, 24px);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 180ms ease, transform 180ms ease;
}
.modal:not(.hidden) { opacity: 1; transform: translateY(0); }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(10px);
}
.modal-box {
  position: relative; z-index: 1;
  background: linear-gradient(180deg, rgba(10,39,49,0.98), rgba(6,25,32,0.98));
  border: 1px solid rgba(34,211,238,0.24);
  border-radius: 24px;
  padding: clamp(20px, 4vw, 32px) clamp(18px, 4vw, 28px);
  width: 100%; max-width: 500px;
  max-height: 92vh; max-height: 92dvh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.35);
  transform: translateY(10px);
  opacity: 0;
  transition: transform 180ms ease, opacity 180ms ease;
}
.modal:not(.hidden) .modal-box { transform: translateY(0); opacity: 1; }
.modal-sm { max-width: 360px; text-align: center; }
.modal-sm .btn-primary { margin-bottom: 14px; }
.modal-sm .btn-ghost,
.modal-sm .btn-outline { width: 100%; }
.modal-sm .btn-outline { margin-bottom: 10px; }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  background: none; border: none;
  color: var(--text-secondary); font-size: 1rem;
  cursor: pointer; padding: 6px 10px;
  border-radius: 8px; transition: color 0.15s;
  min-width: 36px; min-height: 36px;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { color: var(--text-primary); background: rgba(255,255,255,0.06); }

.modal-box h2 {
  font-size: clamp(1.3rem, 4vw, 1.7rem); font-weight: 700;
  margin-bottom: clamp(14px, 3vw, 22px); padding-right: 32px;
  background: linear-gradient(135deg, #2dd4bf, #22d3ee);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.modal-sm h2 { margin-bottom: 14px; padding-right: 0; }

/* How to Play: centre the title (header) and the closing button/app-switcher
   (footer). The ✕ is absolutely positioned, so a centred title clears it. */
#howToModal .modal-box h2 { text-align: center; padding-right: 0; }
#howToModal .modal-box > .btn-primary,
#howToModal .modal-box > app-switcher { text-align: center; }

/* Rules */
.rules-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: clamp(8px, 2vw, 14px); margin-bottom: clamp(14px, 3vw, 22px);
}
.rule-block {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: clamp(10px, 2.5vw, 16px);
}
.rule-icon { font-size: clamp(1.3rem, 4vw, 1.7rem); margin-bottom: 6px; }
.rule-block h3 { font-size: clamp(0.75rem,2vw,0.88rem); font-weight:600; margin-bottom:4px; color:var(--accent-cyan); }
.rule-block p  { font-size: clamp(0.7rem, 1.8vw, 0.8rem); color: var(--text-secondary); line-height: 1.5; }
.rule-block strong { color: var(--text-primary); }

.example-set {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 12px; padding: clamp(12px,3vw,18px);
  margin-bottom: clamp(14px,3vw,20px); text-align: center;
}
.example-set h3 { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 12px; }
.example-row {
  display: flex; gap: clamp(6px,2vw,10px);
  justify-content: center; align-items: center; flex-wrap: wrap;
  margin-bottom: 8px;
}
.example-tile {
  width: clamp(38px, 11vw, 48px); aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: var(--bg-card); border: 1px solid var(--border-bright);
  font-family: var(--font-mono); font-weight: 700;
  font-size: clamp(1rem, 3.4vw, 1.3rem); color: var(--text-primary);
}
.example-op {
  font-family: var(--font-mono); font-size: clamp(1.1rem, 3.6vw, 1.4rem);
  color: var(--accent-cyan); font-weight: 700;
}
.example-tile.is-target { border-color: var(--green); color: var(--green); }
.example-note { font-size: 0.78rem; color: var(--green); }

/* ════════════════════════════════════════
   GAME SCREEN — flex column, full height
   ════════════════════════════════════════ */
.game-screen {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  overflow: hidden;
  margin: 0 auto;
  max-width: 620px;
}

/* ── Header ── */
.game-header {
  flex-shrink: 0;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: clamp(44px, 6.2vh, 56px);
  align-items: center;
  gap: 8px;
  padding: calc(6px + var(--sat)) max(10px, var(--sar)) 6px max(10px, var(--sal));
  background: rgba(5,23,29,0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  box-sizing: border-box;
}
.header-item {
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  box-sizing: border-box;
}
.header-menu { grid-column: 1; justify-self: stretch; align-self: stretch; }
.header-menu .icon-btn {
  width: 100%; height: 100%; max-width: 100%; min-width: 0;
  padding: 0; border-radius: 12px;
}
.header-title { grid-column: 2; justify-self: stretch; align-self: stretch; }
.header-stats { grid-column: 3; justify-self: stretch; }

.icon-btn {
  flex-shrink: 0;
  background: none; border: none;
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 1.8rem;
  width: 64px; height: 64px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.icon-btn:hover { border-color: rgba(34,211,238,0.55); color: var(--text-primary); }

.game-title-sm {
  width: auto;
  display: inline-flex;
  justify-content: center; align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  font-family: var(--font-mono);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1;
  color: var(--text-primary);
  margin: 0 auto;
}

.header-stats { display: flex; justify-content: center; align-items: center; }
.stat-stack {
  position: relative;
  width: 110px;
  min-height: 52px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.stat-stack .stat-pill {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  opacity: 0;
  animation: loopFade 6s ease-in-out infinite;
  padding: 1px 5px;
}
.stat-stack .stat-pill:first-child { z-index: 2; animation-delay: 0s; }
.stat-stack .stat-pill:last-child  { z-index: 1; animation-delay: 3s; }
@keyframes loopFade {
  0%, 45% { opacity: 1; }
  50%, 95% { opacity: 0; }
  100% { opacity: 1; }
}
.stat-pill {
  display: flex; flex-direction: column; align-items: center;
  border-radius: 12px;
  min-width: 38px; min-height: 32px;
}
.stat-label { font-size: clamp(0.55rem, 1.4vw, 0.65rem); color: var(--text-muted); letter-spacing: 0.04em; text-transform: uppercase; }
.stat-val   { font-family: var(--font-mono); font-size: clamp(0.9rem, 2.2vw, 1.05rem); font-weight: 700; color: var(--text-primary); }
.timer-pill .stat-val { color: var(--accent-cyan); }

/* ── Toast ── */
.toast {
  position: fixed;
  top: clamp(70px, 12vh, 90px);
  left: 50%; transform: translateX(-50%);
  z-index: 300;
  padding: clamp(8px,1.5vw,11px) clamp(16px,4vw,24px);
  border-radius: 40px;
  font-size: clamp(0.8rem, 2.2vw, 0.92rem); font-weight: 600;
  white-space: nowrap; pointer-events: none;
  animation: toastIn 0.25s ease;
}
@keyframes toastIn {
  from { transform: translateX(-50%) translateY(-10px); opacity:0; }
  to   { transform: translateX(-50%) translateY(0); opacity:1; }
}
.toast-success { background: rgba(34,197,94,0.2);  border:1px solid #22c55e; color:#4ade80; }
.toast-error   { background: rgba(244,63,94,0.2);   border:1px solid #f43f5e; color:#fb7185; }
.toast-info    { background: rgba(34,211,238,0.18); border:1px solid #22d3ee; color:#a5f3fc; }

/* ════════════════════════════════════════
   NUMBER BOARD — the heart of the game
   ════════════════════════════════════════ */
.board-wrapper {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 3.2vh, 30px);
  padding: clamp(12px, 3vw, 24px) clamp(12px, 4vw, 24px);
  padding-left: max(clamp(12px,4vw,24px), var(--sal));
  padding-right: max(clamp(12px,4vw,24px), var(--sar));
}

/* Target + progress */
.nk-target {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-align: center;
}
.nk-target-label { font-size: clamp(0.62rem, 1.8vw, 0.74rem); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.14em; }
.nk-target-val {
  font-family: var(--font-mono); font-weight: 700;
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  background: linear-gradient(135deg, #2dd4bf, #22d3ee);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}
.nk-expr {
  font-family: var(--font-mono);
  font-size: clamp(0.9rem, 3vw, 1.15rem);
  color: var(--text-secondary);
  min-height: 1.4em;
  letter-spacing: 0.02em;
}
.nk-expr .op { color: var(--accent-cyan); }

/* Number tiles */
.nk-nums {
  display: flex; flex-wrap: wrap;
  justify-content: center; align-content: center;
  gap: clamp(10px, 3vw, 18px);
  width: 100%;
  max-width: 340px;
}
.nk-num {
  width: clamp(84px, 25vw, 122px);
  aspect-ratio: 1 / 1;
  background: var(--bg-card);
  border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-card);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 700;
  color: var(--text-primary);
  position: relative; overflow: hidden;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s, background 0.15s;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
  animation: tileDeal 0.28s ease backwards;
}
.nk-num::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(255,255,255,0.05), transparent 70%);
  pointer-events: none;
}
@keyframes tileDeal {
  from { transform: scale(0.7) rotate(-5deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}
@media (hover: hover) {
  .nk-num:hover {
    transform: translateY(-3px);
    border-color: var(--border-bright);
    box-shadow: 0 6px 20px rgba(0,0,0,0.5);
  }
}
.nk-num:active { transform: scale(0.97); }

/* Inset ring so the top row isn't clipped by the scroll container. */
.nk-num.selected {
  border-color: var(--accent-cyan);
  box-shadow: inset 0 0 0 3px rgba(34,211,238,0.75), var(--shadow-glow);
  transform: translateY(-4px) scale(1.03);
  background: rgba(34,211,238,0.12);
}
.nk-num.merged {
  animation: mergePop 0.4s ease;
  border-color: var(--accent-cyan);
}
@keyframes mergePop {
  0%   { transform: scale(0.4); opacity: 0; }
  60%  { transform: scale(1.12); }
  100% { transform: scale(1); opacity: 1; }
}
.nk-num.hint-highlight {
  border-color: #fbbf24 !important;
  box-shadow: inset 0 0 0 3px rgba(251,191,36,0.75) !important;
  animation: hintPulse 1.2s ease infinite;
}
@keyframes hintPulse {
  0%,100% { box-shadow: inset 0 0 0 3px rgba(251,191,36,0.75); }
  50%     { box-shadow: inset 0 0 0 7px rgba(251,191,36,0.35); }
}
.nk-num.solved-flash {
  border-color: var(--green) !important;
  box-shadow: inset 0 0 0 3px rgba(34,197,94,0.8), 0 0 30px rgba(34,197,94,0.35) !important;
  color: var(--green);
  animation: solvedFlash 0.6s ease;
}
@keyframes solvedFlash {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* Operators */
.nk-ops {
  display: flex;
  gap: clamp(8px, 2.6vw, 14px);
  justify-content: center;
}
.nk-op {
  width: clamp(52px, 15vw, 62px);
  aspect-ratio: 1;
  border-radius: 14px;
  border: 2px solid var(--border-bright);
  background: rgba(34, 211, 238, 0.07);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: clamp(1.4rem, 5.5vw, 1.8rem);
  font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, background 0.15s, transform 0.15s, color 0.15s;
}
@media (hover: hover) {
  .nk-op:hover { border-color: var(--accent-cyan); background: rgba(34,211,238,0.16); transform: translateY(-2px); }
}
.nk-op:active { transform: scale(0.94); }
.nk-op.active {
  border-color: var(--accent-cyan);
  background: linear-gradient(135deg, rgba(34,211,238,0.38), rgba(20,184,166,0.28));
  color: #fff;
  box-shadow: 0 0 18px rgba(34,211,238,0.45);
}

/* Action buttons */
.nk-actions {
  display: flex;
  gap: clamp(8px, 2.5vw, 12px);
  justify-content: center;
}

/* ── Footer ── */
.game-footer {
  flex-shrink: 0;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 8px;
  padding: 6px max(10px, var(--sar)) max(6px, var(--sab)) max(10px, var(--sal));
  background: rgba(5,23,29,0.96);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(10px);
  box-sizing: border-box;
}
.footer-item { display: flex; justify-content: center; align-items: center; min-width: 0; }
.info-item { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.info-label { font-size: clamp(0.55rem,1.4vw,0.65rem); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.info-val   { font-family: var(--font-mono); font-size: clamp(0.9rem,2.2vw,1.05rem); font-weight: 700; color: var(--accent-cyan); }
.hint-btn {
  background: rgba(234,179,8,0.12); border: 1px solid rgba(234,179,8,0.3);
  border-radius: 8px; color: #fbbf24;
  font-family: var(--font-display);
  font-size: clamp(0.72rem, 1.8vw, 0.82rem);
  padding: clamp(4px,0.7vw,6px) clamp(8px,1.5vw,10px);
  cursor: pointer; transition: all 0.15s; font-weight: 500;
  min-height: 32px; white-space: nowrap;
}
.hint-btn:hover    { background: rgba(234,179,8,0.2); }
.hint-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ════════════════════════════════════════
   GAME OVER
   ════════════════════════════════════════ */
.game-over {
  position: fixed; inset: 0; z-index: 150;
  background: radial-gradient(ellipse at 50% 0%, #0b4650 0%, #05171d 70%);
  display: flex; align-items: flex-start; justify-content: center;
  padding: max(var(--sp-lg), var(--sat)) max(var(--sp-lg), var(--sar)) var(--sp-lg) max(var(--sp-lg), var(--sal));
  overflow-y: auto;
}
.go-inner {
  display: flex; flex-direction: column;
  align-items: center; text-align: center;
  gap: clamp(12px, 2.5vw, 20px);
  max-width: 400px; width: 100%;
  margin: auto 0;
  padding-bottom: max(24px, var(--sab));
}
.go-emoji { font-size: clamp(2.8rem,8vw,4rem); animation: bounce 0.8s ease; }
@keyframes bounce {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}
.go-title {
  font-size: clamp(1.7rem, 6vw, 2.4rem); font-weight: 700;
  background: linear-gradient(135deg, #2dd4bf, #22d3ee, #38bdf8);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.go-stats { display: flex; gap: clamp(16px, 5vw, 32px); margin: 4px 0; }
.go-stat  { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.go-stat-val {
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 5vw, 2rem); font-weight: 700;
  color: var(--text-primary);
}
.go-stat-label { font-size: clamp(0.62rem, 1.6vw, 0.74rem); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.go-rating {
  background: var(--bg-elevated); border: 1px solid var(--border-bright);
  border-radius: 12px; padding: clamp(10px,2vw,14px) clamp(16px,3vw,22px);
  font-size: clamp(0.82rem,2.2vw,0.94rem); color: var(--text-secondary);
  font-style: italic; max-width: 300px;
}
.go-inner .btn-primary { margin-top: 4px; }

/* ════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════ */
@media (max-width: 479px) {
  .board-wrapper { gap: clamp(12px, 2.4vh, 20px); }
}

@media (orientation: landscape) and (max-height: 640px) {
  .game-screen { height: 100vh; height: 100dvh; }
  .board-wrapper {
    flex-direction: row;
    flex-wrap: wrap;
    gap: clamp(10px, 3vw, 22px);
  }
  .nk-nums { max-width: 300px; }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .mini-tile, .nk-num, .go-emoji { animation: none; }
  .nk-num.hint-highlight { animation: none; }
}

/* ════════════════════════════════════════
   SCROLLBAR — hidden everywhere
   Content still scrolls (touch, wheel, keys); the bar is simply never painted.
   ════════════════════════════════════════ */
* { scrollbar-width: none; -ms-overflow-style: none; }
::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* System font stack — matches SET; no webfont dependency, works offline. */
:root {
  --font-display: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Menlo', 'Monaco', 'Courier New', monospace;
}
