:root {
  --bg:          #070b17;
  --surface:     #0c1020;
  --surface2:    #101628;
  --surface3:    #141d30;
  --b0:          #0f1523;
  --b1:          #182135;
  --b2:          #1e2a42;
  --b3:          #283650;

  --accent:      #0df5d0;
  --accent-d:    rgba(13,245,208,.06);
  --accent-l:    rgba(13,245,208,.14);
  --accent-m:    rgba(13,245,208,.28);

  --indigo:      #5b6af2;
  --indigo-d:    rgba(91,106,242,.1);

  --err:         #f2305a;
  --err-d:       rgba(242,48,90,.1);

  --warn:        #f2a30d;
  --hint-c:      #c27ef5;
  --hint-d:      rgba(194,126,245,.12);

  --text:        #dce8f5;
  --text-m:      #4a607a;
  --text-d:      #28384e;

  --given:       #7a9fc0;
  --user-c:      #0df5d0;
  --user-z:      #e8f5ff;

  --cell:        min(56px, calc((100vw - 32px) / 9));

  --r:           4px;
  --rl:          8px;
  --tr:          .14s ease;

  --f-logo: 'Orbitron', monospace;
  --f-num:  'Share Tech Mono', monospace;
  --f-ui:   'Rajdhani', sans-serif;

  --safe-t: env(safe-area-inset-top,    0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left,   0px);
  --safe-r: env(safe-area-inset-right,  0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--f-ui);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  padding-left:  var(--safe-l);
  padding-right: var(--safe-r);
}
button { cursor: pointer; font-family: inherit; }
input  { font-family: inherit; }

.ambient-bg {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none; overflow: hidden;
}
.ambient-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(13,245,208,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(13,245,208,.025) 1px, transparent 1px);
  background-size: 44px 44px;
}
.ambient-glow {
  position: absolute; border-radius: 50%;
  filter: blur(130px); opacity: .1;
}
.ambient-glow.g1 { width:700px; height:700px; background:var(--accent);  top:-250px; left:-150px; }
.ambient-glow.g2 { width:600px; height:600px; background:var(--indigo); bottom:-200px; right:-100px; }
.scanline {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px,
    rgba(0,0,0,.08) 2px, rgba(0,0,0,.08) 4px
  );
  pointer-events: none;
}

.screen {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center;
  overflow-y: auto; overflow-x: hidden;
  opacity: 0; pointer-events: none;
  transform: translateY(10px);
  transition: opacity .28s ease, transform .28s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--b2) transparent;
}
.screen.active {
  opacity: 1; pointer-events: all; transform: translateY(0);
}
.screen::-webkit-scrollbar { width: 4px; }
.screen::-webkit-scrollbar-thumb { background: var(--b2); border-radius: 2px; }
.hidden { display: none !important; }

.overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4,7,16,.88);
  backdrop-filter: blur(10px);
  transition: opacity .25s ease;
  padding: 16px;
}
.overlay.hidden { opacity: 0; pointer-events: none; }

.ov-panel {
  background: var(--surface2);
  border: 1px solid var(--b3);
  border-radius: var(--rl);
  padding: 40px 48px;
  text-align: center;
  max-width: 400px; width: 100%;
  position: relative;
}
.ov-symbol { font-size: 44px; color: var(--accent); margin-bottom: 12px; }
.go-symbol { color: var(--err); }
.ov-title {
  font-family: var(--f-logo); font-size: 26px;
  letter-spacing: 4px; margin-bottom: 8px;
}
.ov-sub { color: var(--text-m); font-size: 15px; margin-bottom: 24px; }
.ov-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }

.complete-panel { overflow: hidden; }
.victory-rings {
  position: relative; width: 90px; height: 90px;
  margin: 0 auto 20px;
  display: flex; align-items: center; justify-content: center;
}
.vring {
  position: absolute; border-radius: 50%;
  border: 2px solid var(--accent);
  animation: ring-expand .6s ease-out forwards;
  opacity: 0;
}
.vring.r1 { width: 50px; height: 50px; animation-delay: .1s; }
.vring.r2 { width: 70px; height: 70px; animation-delay: .25s; }
.vring.r3 { width: 90px; height: 90px; animation-delay: .4s; }
@keyframes ring-expand {
  from { transform: scale(.4); opacity: .8; }
  to   { transform: scale(1);  opacity: 0; }
}
.vcheck {
  font-family: var(--f-logo); font-size: 32px;
  color: var(--accent); position: relative; z-index: 1;
  animation: pop-in .4s cubic-bezier(.34,1.56,.64,1) .5s both;
}
@keyframes pop-in {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.complete-stats {
  display: grid; grid-template-columns: repeat(3,1fr);
  gap: 12px; margin: 16px 0 0;
  background: var(--b0); border-radius: var(--r);
  padding: 16px 12px; border: 1px solid var(--b1);
}
.cs-item { text-align: center; }
.cs-val {
  font-family: var(--f-logo); font-size: 22px;
  color: var(--accent); display: block;
}
.cs-lbl { font-size: 10px; color: var(--text-m); letter-spacing: 1px; }

.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; padding: 16px 28px;
  background: var(--accent); color: var(--bg);
  border: none; border-radius: var(--r);
  font-family: var(--f-logo); font-size: 14px; font-weight: 700;
  letter-spacing: 2px; transition: all var(--tr);
  position: relative; overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn-primary::after {
  content: ''; position: absolute; inset: 0;
  background: white; opacity: 0; transition: opacity var(--tr);
}
.btn-primary:hover::after { opacity: .1; }
.btn-primary:active { transform: scale(.98); }
.btn-primary.btn-xl { padding: 18px 32px; font-size: 16px; }
.btn-icon { font-size: 20px; }
.btn-text-wrap { display: flex; flex-direction: column; align-items: flex-start; }
.btn-text { line-height: 1; }
.btn-sub {
  font-family: var(--f-num); font-size: 11px;
  opacity: .65; font-weight: 400; letter-spacing: 0; margin-top: 2px;
}

.btn-secondary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 13px 20px;
  background: transparent; color: var(--text);
  border: 1px solid var(--b3); border-radius: var(--r);
  font-family: var(--f-logo); font-size: 12px; letter-spacing: 1.5px;
  transition: all var(--tr);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-d); }

.btn-ghost {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 12px 20px;
  background: transparent; color: var(--text-m);
  border: none; border-radius: var(--r);
  font-family: var(--f-logo); font-size: 12px; letter-spacing: 1.5px;
  transition: color var(--tr);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn-ghost:hover { color: var(--text); }

.btn-back {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none;
  color: var(--text-m); font-family: var(--f-logo);
  font-size: 11px; letter-spacing: 1px;
  transition: color var(--tr); padding: 8px 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 44px;
}
.btn-back:hover { color: var(--accent); }

.btn-icon-round {
  background: none; border: 1px solid var(--b2);
  color: var(--text-m); width: 40px; height: 40px;
  border-radius: var(--r); font-size: 14px;
  transition: all var(--tr);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn-icon-round:hover { border-color: var(--accent); color: var(--accent); }

.screen-header {
  width: 100%; max-width: 860px;
  padding: 28px 24px 0;
  display: flex; flex-direction: column; gap: 12px;
  flex-shrink: 0;
}
.screen-title {
  font-family: var(--f-logo); font-size: 18px;
  letter-spacing: 4px; color: var(--text);
}

#screen-home { justify-content: center; }

.home-content {
  display: flex; flex-direction: column; align-items: center;
  gap: 44px; padding: 48px 24px;
  max-width: 460px; width: 100%;
}

.logo-area { text-align: center; }
.logo-eyebrow {
  font-family: var(--f-num); font-size: 11px;
  color: var(--text-d); letter-spacing: 3px; margin-bottom: 16px;
}
.logo-title {
  font-family: var(--f-logo);
  font-size: clamp(52px, 15vw, 72px);
  font-weight: 900; letter-spacing: 14px; color: var(--text); line-height: 1;
  text-shadow: 0 0 60px rgba(13,245,208,.15);
}
.logo-accent { color: var(--accent); }
.logo-underline {
  width: 60px; height: 2px; margin: 18px auto 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.home-actions { display: flex; flex-direction: column; gap: 12px; width: 100%; }

.btn-trio { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.btn-tile {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 16px 8px;
  background: var(--surface2); border: 1px solid var(--b2);
  border-radius: var(--r); transition: all var(--tr);
  position: relative; overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 80px;
}
.btn-tile::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--accent); transform: scaleX(0);
  transform-origin: left; transition: transform .3s ease;
}
.btn-tile:hover { border-color: var(--b3); background: var(--surface3); }
.btn-tile:hover::before { transform: scaleX(1); }
.btn-tile-icon  { font-size: 22px; color: var(--accent); }
.btn-tile-label { font-family: var(--f-logo); font-size: 10px; letter-spacing: 1.5px; color: var(--text); }
.btn-tile-sub   { font-family: var(--f-num); font-size: 10px; color: var(--text-m); }

.home-strip {
  display: flex; gap: 32px; width: 100%; justify-content: center;
  border-top: 1px solid var(--b1); padding-top: 20px;
}
.hstrip-item { text-align: center; }
.hstrip-val {
  font-family: var(--f-logo); font-size: 26px;
  color: var(--accent); display: block;
}
.hstrip-lbl { font-size: 11px; color: var(--text-m); letter-spacing: 1px; margin-top: 2px; }

.mode-bar {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 16px 24px 0;
  width: 100%; max-width: 860px; flex-shrink: 0;
}
.mode-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  background: transparent; border: 1px solid var(--b1);
  color: var(--text-m); border-radius: var(--r);
  font-family: var(--f-logo); font-size: 11px; letter-spacing: 1px;
  transition: all var(--tr);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 40px;
}
.mode-chip:hover { border-color: var(--b3); color: var(--text); }
.mode-chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-d); }

.diff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px,1fr));
  gap: 14px; padding: 20px 24px 40px;
  width: 100%; max-width: 860px;
}
.diff-card {
  background: var(--surface2); border: 1px solid var(--b1);
  border-radius: var(--rl); padding: 22px 18px;
  cursor: pointer; transition: all .2s ease;
  position: relative; overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.diff-card::after {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: var(--acc-color, var(--accent));
  transform: scaleX(0); transform-origin: left;
  transition: transform .3s ease;
}
.diff-card:hover {
  border-color: var(--b3); background: var(--surface3);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
.diff-card:hover::after { transform: scaleX(1); }

.dc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.dc-name { font-family: var(--f-logo); font-size: 13px; letter-spacing: 2px; color: var(--text); }
.dc-badge {
  font-family: var(--f-num); font-size: 10px;
  padding: 3px 7px; border-radius: 2px;
  background: var(--accent-d); color: var(--accent);
  border: 1px solid var(--accent-m);
}
.dc-clues  { font-size: 12px; color: var(--text-m); margin-bottom: 12px; }
.dc-row    { display: flex; gap: 16px; margin-bottom: 12px; }
.dc-stat   { font-family: var(--f-num); font-size: 11px; color: var(--text-d); }
.dc-stat .v { color: var(--accent); }
.dc-bar    { height: 3px; background: var(--b1); border-radius: 2px; overflow: hidden; }
.dc-fill   { height: 100%; background: var(--acc-color, var(--accent)); border-radius: 2px; }

.level-progress-line {
  font-family: var(--f-num); font-size: 12px; color: var(--text-m);
}
.levels-wrap { padding: 20px 24px 40px; width: 100%; max-width: 860px; }
.levels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px,1fr));
  gap: 8px;
}
.lvl-btn {
  aspect-ratio: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--surface2); border: 1px solid var(--b1);
  border-radius: var(--r); font-family: var(--f-logo); font-size: 12px;
  color: var(--text-m); transition: all var(--tr); position: relative;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 44px;
}
.lvl-btn:hover  { border-color: var(--accent); color: var(--accent); background: var(--accent-d); }
.lvl-btn.done   { border-color: var(--accent); color: var(--accent); background: var(--accent-d); }
.lvl-btn.done::after {
  content: '✓'; position: absolute; top: 2px; right: 4px;
  font-size: 8px; opacity: .7;
}
.lvl-btn.best { background: var(--accent-l); }
.lvl-btn .lvl-time {
  font-family: var(--f-num); font-size: 8px;
  color: var(--text-m); margin-top: 2px; display: none;
}
.lvl-btn.done .lvl-time { display: block; }

.game-header {
  display: flex; align-items: center; gap: 10px;
  width: 100%; max-width: 900px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--b1);
  flex-shrink: 0;
}
.btn-back-game {
  background: none; border: none;
  color: var(--text-m); font-family: var(--f-logo);
  font-size: 18px; padding: 4px 8px 4px 0;
  transition: color var(--tr); flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-width: 36px; min-height: 44px;
  display: flex; align-items: center;
}
.btn-back-game:hover { color: var(--accent); }

.game-tags { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; align-items: center; }
.tag {
  font-family: var(--f-logo); font-size: 10px;
  letter-spacing: 1px; padding: 4px 8px;
  border-radius: 2px; border: 1px solid; white-space: nowrap;
}
.tag-diff  { border-color: var(--b2); color: var(--text-m); }
.tag-mode  { border-color: var(--accent-m); color: var(--accent); background: var(--accent-d); }
.tag-level { border-color: var(--b1); color: var(--text-d); }

.game-timer-wrap { margin-left: auto; }
.game-timer {
  font-family: var(--f-num); font-size: 22px;
  color: var(--text); letter-spacing: 3px;
  min-width: 72px; text-align: right;
  transition: color .3s ease;
}
.game-timer.warn     { color: var(--warn); }
.game-timer.critical { color: var(--err); animation: pulse-text .5s ease infinite alternate; }
@keyframes pulse-text { to { opacity: .5; } }

.game-status {
  display: flex; gap: 0; align-items: center;
  width: 100%; max-width: 900px;
  padding: 10px 18px; border-bottom: 1px solid var(--b0);
  flex-shrink: 0;
}
.status-group { display: flex; align-items: center; gap: 10px; padding-right: 24px; }
.status-group.fill { flex: 1; }
.status-lbl {
  font-family: var(--f-logo); font-size: 9px;
  letter-spacing: 1.5px; color: var(--text-m);
}

.pips { display: flex; gap: 5px; }
.pip {
  width: 9px; height: 9px; border-radius: 50%;
  border: 1.5px solid var(--b3); transition: all .3s ease;
}
.pip.lit { background: var(--err); border-color: var(--err); box-shadow: 0 0 8px var(--err); }

.hints-val { font-family: var(--f-logo); font-size: 15px; color: var(--hint-c); }

.prog-bar {
  flex: 1; height: 4px; background: var(--b1);
  border-radius: 2px; overflow: hidden; position: relative; max-width: 120px;
}
.prog-fill  { height: 100%; background: var(--accent); border-radius: 2px; transition: width .6s ease; width: 0%; }
.prog-text  { font-family: var(--f-num); font-size: 10px; color: var(--text-m); margin-left: 8px; }

.game-body {
  display: flex; gap: 28px; padding: 18px;
  align-items: flex-start; justify-content: center;
  width: 100%; max-width: 900px;
  flex: 1; min-height: 0;
}

.board-frame { position: relative; flex-shrink: 0; }
.frame-corner {
  position: absolute; width: 14px; height: 14px;
  border-color: var(--accent); border-style: solid; opacity: .5; z-index: 2;
}
.frame-corner.tl { top: -7px; left: -7px;   border-width: 2px 0 0 2px; }
.frame-corner.tr { top: -7px; right: -7px;   border-width: 2px 2px 0 0; }
.frame-corner.bl { bottom: -7px; left: -7px; border-width: 0 0 2px 2px; }
.frame-corner.br { bottom: -7px; right: -7px;border-width: 0 2px 2px 0; }

.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, var(--cell));
  grid-template-rows: repeat(9, var(--cell));
  border: 2px solid var(--b3);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--b0);
}
.sudoku-cell {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--f-num);
  font-size: max(16px, calc(var(--cell) * .42));
  border-right: 1px solid var(--b1);
  border-bottom: 1px solid var(--b1);
  background: var(--surface);
  cursor: pointer; user-select: none;
  position: relative; transition: background .1s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.sudoku-cell[data-col="8"] { border-right: none; }
.sudoku-cell[data-row="8"] { border-bottom: none; }
.sudoku-cell.box-right  { border-right:  2px solid var(--b3); }
.sudoku-cell.box-bottom { border-bottom: 2px solid var(--b3); }

.sudoku-cell.related  { background: var(--b0); }
.sudoku-cell.same-num { background: rgba(13,245,208,.07); }
.sudoku-cell.selected {
  background: var(--accent-l) !important;
  outline: 2px solid var(--accent);
  outline-offset: -2px; z-index: 2;
}
.sudoku-cell.flash-cell { animation: cell-flash .35s ease; }
@keyframes cell-flash {
  0%   { background: var(--accent-m); }
  100% { background: var(--surface); }
}
.sudoku-cell.shake { animation: cell-shake .3s ease; }
@keyframes cell-shake {
  0%,100% { transform: translateX(0); }
  25%     { transform: translateX(-3px); }
  75%     { transform: translateX(3px); }
}

.cell-given { color: var(--given); font-weight: 400; }
.cell-user  { color: var(--user-c); }
.cell-error { color: var(--err) !important; }
.cell-hint  { color: var(--hint-c); }

body.zen-mode .cell-user  { color: var(--user-z); }
body.zen-mode .cell-error { color: var(--user-z) !important; }

.notes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%; height: 100%;
  padding: max(1px, calc(var(--cell) * .04));
}
.note-cell {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--f-num);
  font-size: max(7px, calc(var(--cell) * .21));
  color: var(--text-m); line-height: 1;
}
.note-cell.set { color: var(--accent); opacity: .7; }
.game-panel {
  display: flex; flex-direction: column; gap: 14px;
  flex-shrink: 0; width: 200px;
}

.numpad {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.num-btn {
  aspect-ratio: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--surface2); border: 1px solid var(--b2);
  border-radius: var(--r);
  font-family: var(--f-num);
  font-size: max(20px, calc(var(--cell) * .36));
  color: var(--text); transition: all var(--tr);
  position: relative;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.num-btn:hover   { border-color: var(--accent); color: var(--accent); background: var(--accent-d); }
.num-btn:active  { transform: scale(.94); }
.num-btn.complete { opacity: .3; pointer-events: none; }
.num-btn .num-count {
  font-size: 9px; color: var(--text-m); margin-top: 1px;
  font-family: var(--f-logo); letter-spacing: 0;
  position: absolute; bottom: 4px; right: 5px;
}

.action-strip {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.action-btn {
  display: flex; flex-direction: column; align-items: center;
  gap: 3px; padding: 10px 4px;
  background: var(--surface2); border: 1px solid var(--b2);
  border-radius: var(--r); transition: all var(--tr);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 52px;
}
.action-btn:hover       { border-color: var(--accent); background: var(--accent-d); }
.action-btn.active-mode { border-color: var(--accent); color: var(--accent); background: var(--accent-l); }
.action-icon { font-size: 16px; color: inherit; }
.action-lbl  { font-family: var(--f-logo); font-size: 8px; letter-spacing: 1px; color: var(--text-m); }
.action-btn:hover .action-lbl       { color: var(--accent); }
.action-btn.active-mode .action-lbl { color: var(--accent); }

.number-counts { display: flex; gap: 4px; flex-wrap: wrap; }
.nc-item {
  display: flex; align-items: center; gap: 3px;
  font-family: var(--f-num); font-size: 11px;
  color: var(--text-d); padding: 2px 4px;
  background: var(--b0); border-radius: 2px;
}
.nc-item .nc-num { color: var(--accent); font-size: 13px; }
.nc-item.all-placed { opacity: .3; }

.stats-body {
  width: 100%; max-width: 860px;
  padding: 20px 24px 40px;
  display: flex; flex-direction: column; gap: 24px;
}
.stats-overview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px,1fr));
  gap: 12px;
}
.stat-tile {
  background: var(--surface2); border: 1px solid var(--b1);
  border-radius: var(--r); padding: 16px 12px; text-align: center;
}
.stat-tile-val {
  font-family: var(--f-logo); font-size: 30px;
  color: var(--accent); display: block; line-height: 1;
}
.stat-tile-lbl { font-size: 11px; color: var(--text-m); letter-spacing: 1px; margin-top: 6px; }

.stats-section-title {
  font-family: var(--f-logo); font-size: 12px; letter-spacing: 2px;
  color: var(--text-m); border-bottom: 1px solid var(--b1);
  padding-bottom: 10px; margin-bottom: 12px;
}
.diff-stats-table { display: flex; flex-direction: column; gap: 10px; }
.dst-row {
  display: grid;
  grid-template-columns: 110px 50px 60px 1fr 80px;
  gap: 10px; align-items: center;
  background: var(--surface2); border: 1px solid var(--b1);
  border-radius: var(--r); padding: 12px 14px;
}
.dst-name  { font-family: var(--f-logo); font-size: 11px; letter-spacing: 1px; }
.dst-val   { font-family: var(--f-num); font-size: 13px; color: var(--accent); }
.dst-label { font-size: 10px; color: var(--text-m); }
.dst-bar-wrap { background: var(--b1); border-radius: 2px; height: 4px; overflow: hidden; }
.dst-bar-fill { height: 100%; background: var(--accent); border-radius: 2px; }
.dst-time  { font-family: var(--f-num); font-size: 11px; color: var(--text-m); text-align: right; }

.daily-calendar { display: flex; gap: 6px; flex-wrap: wrap; }
.cal-day {
  width: 32px; height: 32px; border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--f-logo); font-size: 10px;
  background: var(--surface2); border: 1px solid var(--b1);
  color: var(--text-m);
}
.cal-day.solved { background: var(--accent-d); border-color: var(--accent); color: var(--accent); }
.cal-day.today  { outline: 2px solid var(--accent); outline-offset: 1px; }

@keyframes fade-up {
  from { opacity:0; transform:translateY(10px); }
  to   { opacity:1; transform:translateY(0); }
}
.anim-fade-up { animation: fade-up .3s ease both; }

@keyframes slide-in-right {
  from { opacity:0; transform:translateX(20px); }
  to   { opacity:1; transform:translateX(0); }
}

@keyframes num-place {
  0%   { transform: scale(1.5); opacity:0; }
  60%  { transform: scale(.9); }
  100% { transform: scale(1); opacity:1; }
}
.num-place { animation: num-place .25s cubic-bezier(.34,1.56,.64,1); }

.flash-row, .flash-col, .flash-box {
  animation: region-flash .4s ease;
}
@keyframes region-flash {
  0%,100% { background: var(--surface); }
  40%     { background: rgba(13,245,208,.06); }
}

.board-solved .sudoku-cell {
  animation: solved-wave .8s ease calc(var(--delay, 0) * .03s) both;
}
@keyframes solved-wave {
  0%   { background: var(--surface); }
  50%  { background: var(--accent-l); }
  100% { background: var(--surface); }
}

@media (max-width: 860px) {
  .diff-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
  .dst-row {
    grid-template-columns: 90px 40px 50px 1fr 70px;
    padding: 10px 12px;
  }
}

@media (max-width: 680px) {
  :root {
    --cell: min(48px, calc((100vw - 32px) / 9));
  }

  .home-content {
    gap: 28px;
    padding: 32px 20px calc(28px + var(--safe-b));
  }
  .logo-title {
    font-size: clamp(44px, 13vw, 64px);
    letter-spacing: 10px;
  }
  .logo-eyebrow { font-size: 10px; }
  .btn-trio { gap: 8px; }
  .btn-tile { padding: 14px 6px; gap: 3px; }
  .btn-tile-icon { font-size: 20px; }
  .home-strip { gap: 20px; }
  .hstrip-val { font-size: 22px; }

  .screen-header { padding: 20px 16px 0; }
  .mode-bar { padding: 14px 16px 0; gap: 6px; }
  .mode-chip { padding: 7px 12px; font-size: 10px; }
  .diff-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px; padding: 16px 16px 32px;
  }
  .diff-card { padding: 16px 14px; }
  .dc-name { font-size: 12px; }

  .levels-wrap { padding: 14px 16px 32px; }
  .levels-grid {
    grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
    gap: 7px;
  }
  .lvl-btn { font-size: 11px; }

  .game-header { padding: 10px 12px; gap: 8px; }
  .game-timer  { font-size: 18px; letter-spacing: 2px; min-width: 60px; }
  .tag { font-size: 9px; padding: 3px 6px; }

  .game-status { padding: 7px 12px; }
  .status-group { gap: 7px; padding-right: 14px; }
  .pip { width: 8px; height: 8px; }

  .game-body {
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 12px 12px calc(12px + var(--safe-b));
    overflow-y: auto;
  }

  .game-panel {
    width: 100%;
    max-width: calc(var(--cell) * 9 + 4px);
    gap: 10px;
  }

  .numpad { gap: 7px; }
  .num-btn {
    min-height: 52px;
    font-size: clamp(22px, 6vw, 32px);
  }
  .num-btn .num-count { font-size: 8px; bottom: 3px; right: 4px; }

  .action-strip { gap: 7px; }
  .action-btn   { padding: 12px 4px; min-height: 52px; }
  .action-icon  { font-size: 18px; }
  .action-lbl   { font-size: 8px; }

  .number-counts { gap: 3px; }
  .nc-item { font-size: 10px; }

  .stats-body { padding: 16px 16px 32px; gap: 18px; }
  .stats-overview { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
  .stat-tile-val { font-size: 24px; }

  .dst-row {
    grid-template-columns: 80px 36px 1fr 64px;
    gap: 8px; padding: 10px;
  }
  .dst-bar-wrap { display: none; }   
  .dst-label    { display: none; }
  .ov-panel { padding: 28px 20px calc(20px + var(--safe-b)); }
  .ov-title { font-size: 22px; letter-spacing: 3px; }
  .ov-symbol { font-size: 36px; }
  .cs-val { font-size: 18px; }
  .complete-stats { gap: 8px; padding: 12px 8px; }
}

@media (max-width: 400px) {
  :root {
    --cell: calc((100vw - 28px) / 9);
  }

  .home-content { padding: 24px 14px calc(24px + var(--safe-b)); gap: 22px; }
  .logo-title { font-size: clamp(38px, 12vw, 52px); letter-spacing: 8px; }
  .logo-eyebrow { display: none; }

  .btn-trio {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
  }
  .btn-tile { padding: 12px 4px; min-height: 72px; }
  .btn-tile-sub { display: none; }

  .diff-grid {
    grid-template-columns: 1fr;
    gap: 8px; padding: 12px 14px 28px;
  }

  .levels-grid {
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 5px;
  }
  .lvl-btn { font-size: 10px; min-height: 40px; }

  .game-header { padding: 8px 10px; gap: 6px; }
  .game-timer  { font-size: 16px; }
  .tag-level   { display: none; }

  .game-status { padding: 6px 10px; }
  .status-group { padding-right: 10px; }
  .hints-val   { font-size: 13px; }

  .action-lbl { display: none; }
  .action-btn { padding: 14px 0; min-height: 48px; }
  .action-icon { font-size: 20px; }

  .ov-panel { padding: 24px 16px calc(16px + var(--safe-b)); }
  .complete-stats { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .cs-val { font-size: 16px; }
  .cs-lbl { font-size: 9px; }

  .dst-row {
    grid-template-columns: 70px 36px 1fr;
    gap: 6px;
  }
  .dst-time { display: none; }
}

@media (max-width: 340px) {
  :root { --cell: calc((100vw - 20px) / 9); }

  .home-content { padding: 18px 10px calc(18px + var(--safe-b)); }
  .btn-tile-label { font-size: 9px; letter-spacing: 0; }
  .game-body { padding: 8px 8px calc(8px + var(--safe-b)); gap: 10px; }
  .num-btn { min-height: 44px; }
}

@media (max-height: 500px) and (orientation: landscape) {
  :root {
    --cell: min(40px, calc((100vh - 100px) / 9));
  }

  .home-content {
    flex-direction: row; flex-wrap: wrap; justify-content: center;
    gap: 16px; padding: 16px 24px calc(12px + var(--safe-b));
    max-width: 700px;
  }
  .logo-area   { flex: 0 0 auto; }
  .home-actions{ flex: 1 1 220px; max-width: 280px; gap: 8px; }
  .home-strip  { display: none; }
  .logo-title  { font-size: clamp(36px, 8vw, 52px); letter-spacing: 8px; }
  .logo-eyebrow{ display: none; }
  .btn-tile    { padding: 10px 6px; min-height: 64px; }

  .mode-bar  { padding: 10px 20px 0; }
  .diff-grid { grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); padding: 12px 20px 20px; }

  .game-body {
    flex-direction: row;
    align-items: flex-start;
    padding: 8px 16px calc(8px + var(--safe-b));
    gap: 16px;
    overflow-y: auto;
  }
  .game-panel {
    width: 180px; max-width: none;
    gap: 8px;
  }
  .numpad { gap: 5px; }
  .num-btn { min-height: 36px; font-size: 18px; }
  .action-btn { min-height: 38px; padding: 8px 2px; }

  .game-header { padding: 8px 14px; }
  .game-status { padding: 5px 14px; }
  .game-timer  { font-size: 16px; }

  .ov-panel { padding: 20px 24px; max-height: 96vh; overflow-y: auto; }
  .victory-rings { width: 70px; height: 70px; }
  .vring.r1 { width: 40px; height: 40px; }
  .vring.r2 { width: 55px; height: 55px; }
  .vring.r3 { width: 70px; height: 70px; }
  .vcheck   { font-size: 26px; }
}

@media (min-width: 481px) and (max-width: 860px) {
  :root { --cell: min(52px, calc((100vw - 48px) / 9)); }

  .home-content  { max-width: 520px; gap: 36px; padding: 40px 28px; }
  .game-body     { gap: 20px; padding: 16px 20px; }
  .game-panel    { width: 180px; }
  .diff-grid     { grid-template-columns: repeat(3, 1fr); }
  .levels-grid   { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); }
  .stats-overview{ grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}

@media (min-width: 861px) and (max-width: 1100px) {
  :root { --cell: min(54px, calc((100vw - 480px) / 9)); }

  .game-body  { gap: 32px; }
  .game-panel { width: 210px; }
  .diff-grid  { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1101px) {
  :root { --cell: min(58px, calc((90vh - 180px) / 9)); }

  .game-body  { gap: 40px; padding: 24px; }
  .game-panel { width: 220px; }
  .diff-grid  { grid-template-columns: repeat(4, 1fr); }
  .stats-overview { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

@media (hover: none) and (pointer: coarse) {
  .btn-primary:hover::after { opacity: 0; }
  .btn-secondary:hover { border-color: var(--b3); color: var(--text); background: transparent; }
  .btn-ghost:hover     { color: var(--text-m); }
  .btn-back:hover      { color: var(--text-m); }
  .btn-tile:hover      { border-color: var(--b2); background: var(--surface2); }
  .btn-tile:hover::before { transform: scaleX(0); }
  .diff-card:hover     { transform: none; box-shadow: none; }
  .lvl-btn:hover       { border-color: var(--b1); color: var(--text-m); background: var(--surface2); }
  .num-btn:hover       { border-color: var(--b2); color: var(--text); background: var(--surface2); }
  .action-btn:hover    { border-color: var(--b2); background: var(--surface2); }
  .action-btn:hover .action-lbl { color: var(--text-m); }
  .mode-chip:hover     { border-color: var(--b1); color: var(--text-m); }
  .btn-icon-round:hover{ border-color: var(--b2); color: var(--text-m); }

  .btn-primary:active { transform: scale(.97); }
  .num-btn:active     { transform: scale(.92); background: var(--accent-d); border-color: var(--accent); color: var(--accent); }
  .action-btn:active  { background: var(--accent-d); border-color: var(--accent); }
  .lvl-btn:active     { background: var(--accent-d); border-color: var(--accent); }
  .diff-card:active   { transform: scale(.98); }
  .btn-tile:active    { background: var(--surface3); }
}

#screen-home    { padding-bottom: var(--safe-b); }
#screen-game    { padding-bottom: 0; } 
#screen-stats   { padding-bottom: var(--safe-b); }
#screen-difficulty { padding-bottom: var(--safe-b); }
#screen-levels  { padding-bottom: var(--safe-b); }

@media print {
  .ambient-bg, .scanline, .ambient-glow, .game-panel,
  .action-strip, .numpad, .number-counts, .overlay { display: none !important; }
  body { background: white; color: black; }
  .sudoku-board { border-color: black; }
  .sudoku-cell  { border-color: #ccc !important; color: black; }
  .cell-given   { color: #333; }
}