:root {
  --line-thin: #c7c7c7;
  --line-box: #4a4a4a;
  --line-outer: #1a1a1a;
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-muted: #fafafa;
  --surface-hover: #f0f0f0;
  --chip-bg: #e4e4e8;
  --chip-invert: #111111;
  --chip-invert-hover: #222222;
  --thumb-bg: #ffffff;
  --cell-bg: #ffffff;
  --number-bg: #eeeeee;
  --text: #222222;
  --text-strong: #111111;
  --text-secondary: #333333;
  --text-muted: #555555;
  --text-soft: #666666;
  --text-faint: #888888;
  --text-dim: #999999;
  --text-on-invert: #ffffff;
  --text-on-invert-muted: rgba(255, 255, 255, 0.72);
  --given-color: #333333;
  --user-color: #1a5fb4;
  --note-color: #888888;
  --selected-bg: #dbe9ff;
  --peer-bg: #eef3fb;
  --same-value-bg: #cfe3ff;
  --correct-color: #1a7a1a;
  --incorrect-color: #b02a2a;
  --accent: #1a5fb4;
  --heart: #e03131;
  --overlay-scrim: rgba(247, 246, 242, 0.88);
  --overlay-scrim-soft: rgba(247, 246, 242, 0.45);
  --overlay-scrim-strong: rgba(247, 246, 242, 0.92);
  --modal-scrim: rgba(0, 0, 0, 0.5);
  --tip-bg: #111111;
  --tip-fg: #ffffff;
  --shadow-thumb: 0 1px 3px rgba(0, 0, 0, 0.15);
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-menu: 0 6px 20px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
  --shadow-heavy: 0 12px 40px rgba(0, 0, 0, 0.25);
  --lb-me-bg: #f5f8ff;
  --lb-row-border: #eeeeee;
  --focus-border: #111111;
  --segment-inactive: #666666;
  --pause-card-bg: #111111;
  --pause-btn-bg: #ffffff;
  --pause-btn-fg: #111111;
  --pause-btn-hover: #f0f0f0;
  --theme-color: #f7f6f2;
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23666' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
}

[data-theme="dark"] {
  --line-thin: #3f3e3a;
  --line-box: #9a9890;
  --line-outer: #e8e4dc;
  --bg: #1c1b19;
  --surface: #2a2926;
  --surface-muted: #242320;
  --surface-hover: #353430;
  --chip-bg: #353430;
  --chip-invert: #e8e4dc;
  --chip-invert-hover: #d4d0c8;
  --thumb-bg: #2a2926;
  --cell-bg: #262522;
  --number-bg: #32302c;
  --text: #e8e4dc;
  --text-strong: #f2efe8;
  --text-secondary: #d8d4cc;
  --text-muted: #b0aca4;
  --text-soft: #9a968e;
  --text-faint: #7a7770;
  --text-dim: #6a6760;
  --text-on-invert: #1c1b19;
  --text-on-invert-muted: rgba(28, 27, 25, 0.72);
  --given-color: #e8e4dc;
  --user-color: #7eb0e8;
  --note-color: #8a8780;
  --selected-bg: #2a3d55;
  --peer-bg: #252e3a;
  --same-value-bg: #314a66;
  --correct-color: #6bb86b;
  --incorrect-color: #e07070;
  --accent: #7eb0e8;
  --heart: #e05555;
  --overlay-scrim: rgba(28, 27, 25, 0.88);
  --overlay-scrim-soft: rgba(28, 27, 25, 0.55);
  --overlay-scrim-strong: rgba(28, 27, 25, 0.92);
  --modal-scrim: rgba(0, 0, 0, 0.65);
  --tip-bg: #e8e4dc;
  --tip-fg: #1c1b19;
  --shadow-thumb: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-menu: 0 6px 20px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.45);
  --shadow-heavy: 0 12px 40px rgba(0, 0, 0, 0.55);
  --lb-me-bg: #2a3545;
  --lb-row-border: #3a3834;
  --focus-border: #e8e4dc;
  --segment-inactive: #9a968e;
  --pause-card-bg: #2a2926;
  --pause-btn-bg: #e8e4dc;
  --pause-btn-fg: #1c1b19;
  --pause-btn-hover: #d4d0c8;
  --theme-color: #1c1b19;
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23aaa' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color-scheme: light;
}
[data-theme="dark"] {
  color-scheme: dark;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  margin: 0;
  padding: 64px 12px 60px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text);
  touch-action: manipulation;
  overscroll-behavior: none;
}
button, a, .chip-control, .numpad, .controls {
  touch-action: manipulation;
}
.hidden { display: none !important; }
.chip-control {
  position: relative;
  display: flex;
  align-items: stretch;
  height: 100%;
  background: var(--chip-bg);
  border-radius: 7px;
  padding: 2px;
  box-sizing: border-box;
}
.chip-control--invert {
  background: var(--chip-invert);
}
.segmented-control {
  width: max-content;
  max-width: calc(100vw - 120px);
}
.segmented-thumb {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 0;
  width: 0;
  background: var(--thumb-bg);
  border-radius: 5px;
  box-shadow: var(--shadow-thumb);
  transform: translateX(0);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}
.segmented-control button {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  border: none;
  background: transparent;
  padding: 0 8px;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.62rem;
  font-weight: 500;
  line-height: 1;
  color: var(--segment-inactive);
  white-space: nowrap;
  transition: color 0.2s ease;
}
.segmented-control button.active {
  color: var(--text-strong);
  font-weight: 600;
}

.puzzle-meta {
  width: min(100%, calc(9 * 46px + 6px));
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 8px;
  min-height: 1.1em;
}
.puzzle-kind {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-soft);
}
.puzzle-streak-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.puzzle-streak {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: right;
  white-space: nowrap;
}
.puzzle-lives-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.puzzle-lives {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  line-height: 1;
  color: var(--heart);
  border: none;
  background: transparent;
  padding: 2px;
  margin: 0;
  border-radius: 4px;
  cursor: help;
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}
.puzzle-lives:focus-visible {
  outline: 2px solid var(--heart);
  outline-offset: 2px;
}
.puzzle-lives i {
  font-size: 0.78rem;
  line-height: 1;
}
.puzzle-lives .life-gone {
  color: var(--heart);
  opacity: 0.9;
}
.puzzle-lives-tip {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  width: max-content;
  max-width: min(240px, calc(100vw - 32px));
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--tip-bg);
  color: var(--tip-fg);
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  box-shadow: var(--shadow-heavy);
  pointer-events: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.puzzle-lives-tip::before {
  content: "";
  position: absolute;
  top: -5px;
  right: 10px;
  width: 10px;
  height: 10px;
  background: var(--tip-bg);
  transform: rotate(45deg);
}
.puzzle-lives-wrap:hover .puzzle-lives-tip,
.puzzle-lives-wrap:focus-within .puzzle-lives-tip,
.puzzle-lives-wrap.is-open .puzzle-lives-tip {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.board {
  display: grid;
  grid-template-columns: repeat(9, minmax(34px, 46px));
  grid-template-rows: repeat(9, minmax(34px, 46px));
  border: 3px solid var(--line-outer);
  touch-action: manipulation;
  user-select: none;
}
.cell {
  position: relative;
  background: var(--cell-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  cursor: pointer;
}
.cell.given, .cell.user-value { background: var(--number-bg); }
.cell.given { color: var(--given-color); font-weight: 700; }
.cell.user-value { color: var(--user-color); font-weight: 600; }

.cell.grid-right { border-right: 1px solid var(--line-thin); }
.cell.grid-bottom { border-bottom: 1px solid var(--line-thin); }
.cell.border-right { border-right: 2px solid var(--line-box); }
.cell.border-bottom { border-bottom: 2px solid var(--line-box); }

.cell.exploding {
  transition: transform 0.9s cubic-bezier(0.55, 0.06, 0.68, 0.19), opacity 0.9s ease;
  transform: translate(var(--ex, 0px), var(--ey, 0px)) rotate(var(--er, 0deg));
  opacity: 0;
  pointer-events: none;
}

.confetti {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 300;
}
.confetti-piece {
  position: absolute;
  bottom: 12%;
  width: 8px;
  height: 14px;
  border-radius: 1px;
  background: var(--c, #e63946);
  /* Cheap single soft glow — no bokeh discs, no pulse (FPS) */
  box-shadow: 0 0 6px color-mix(in srgb, var(--c, #e63946) 55%, transparent);
  opacity: 0;
  will-change: transform, opacity;
  animation: confetti-side-arc var(--dur, 3s) forwards;
  animation-delay: var(--delay, 0ms);
}
.confetti-piece.from-left {
  left: -4px;
  --launch-x: var(--spread, 90vw);
}
.confetti-piece.from-right {
  right: -4px;
  --launch-x: calc(-1 * var(--spread, 90vw));
}
/*
  Side cannons: start → cross mid (apex) → fall across opposite half.
  Apex uses ~0.62 of launch-x so streams overlap over the board.
*/
@keyframes confetti-side-arc {
  0% {
    transform: translate(0, 0) rotate(0deg);
    opacity: 0;
    animation-timing-function: cubic-bezier(0.15, 0.75, 0.25, 1);
  }
  3% {
    opacity: 1;
  }
  38% {
    transform: translate(calc(var(--launch-x) * 0.62), var(--peak, -50vh))
      rotate(calc(var(--spin, 360deg) * 0.45));
    opacity: 1;
    animation-timing-function: cubic-bezier(0.35, 0, 0.65, 0.25);
  }
  100% {
    transform: translate(var(--launch-x), var(--fall, 90vh))
      rotate(var(--spin, 360deg));
    opacity: 0;
  }
}

.local-debug {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 250;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: min(220px, calc(100vw - 32px));
  padding: 10px;
  border: 1px solid var(--line-thin);
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
}
.local-debug-title {
  margin: 0;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.local-debug-btns {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.local-debug button {
  border: 1px solid var(--line-thin);
  background: var(--surface-muted);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.local-debug button:hover { background: var(--surface-hover); }
.local-debug button.is-active {
  background: var(--chip-invert);
  border-color: var(--chip-invert);
  color: var(--text-on-invert);
}

.cell.peer { background: var(--peer-bg); }
.cell.selected { background: var(--selected-bg); }
.cell.same-value { background: var(--same-value-bg); }

.cell.incorrect::after,
.cell.conflict::after {
  content: "";
  position: absolute;
  inset: 3px;
  background: linear-gradient(
    to top right,
    transparent calc(50% - 1.5px),
    var(--incorrect-color) calc(50% - 1.5px),
    var(--incorrect-color) calc(50% + 1.5px),
    transparent calc(50% + 1.5px)
  );
  pointer-events: none;
}

.notes-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  pointer-events: none;
}
.notes-grid span {
  font-size: 0.55rem;
  color: var(--note-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
}

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 20px;
  width: 100%;
  max-width: 420px;
}

.numpad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: 100%;
  border: 1px solid var(--line-thin);
  border-radius: 6px;
  overflow: hidden;
}
.numpad button {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 1rem;
  border: none;
  border-right: 1px solid var(--line-thin);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.numpad button:last-child { border-right: none; }
.numpad button:hover { background: var(--surface-hover); }
.numpad button.dimmed { opacity: 0.3; }

.action-row {
  display: flex;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line-thin);
  border-radius: 10px;
  padding: 4px;
  box-shadow: var(--shadow-soft);
}
.action-row button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 48px;
  height: 42px;
  border: none;
  background: transparent;
  border-radius: 7px;
  cursor: pointer;
  font-size: 1.05rem;
  color: var(--text-secondary);
}
.action-row button .btn-label {
  font-size: 0.5rem;
  line-height: 1;
  font-weight: 500;
  white-space: nowrap;
}
.action-row button:hover { background: var(--surface-hover); }
.action-row button.toggle-active { background: var(--accent); color: #fff; }
.action-row button:disabled { opacity: 0.5; cursor: default; background: transparent; }
.spin { display: inline-block; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#status {
  min-height: 24px;
  font-weight: 600;
  text-align: center;
}
#status.ok { color: var(--correct-color); }
#status.bad { color: var(--incorrect-color); }
#status.info { color: var(--text-muted); }

.auth-bar {
  margin-top: 14px;
  text-align: center;
  min-height: 1.2em;
}
.auth-login-link {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-faint);
  text-decoration: underline;
  text-underline-offset: 4px;
}
.auth-login-link:hover { color: var(--text-muted); }
.auth-signed-in {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.72rem;
  color: var(--text-soft);
}
.auth-username {
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 4px;
}
.auth-username:hover { color: var(--text); }

.auth-page,
.about-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.auth-card,
.about-card {
  width: 100%;
  max-width: 340px;
  text-align: center;
}
.about-card {
  max-width: 420px;
}
.about-brand {
  margin: 0 0 8px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.about-card h1 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}
.about-lead {
  margin: 0 0 16px;
  font-size: 0.95rem;
  color: var(--text-soft);
  line-height: 1.45;
}
.about-body {
  margin: 0 0 24px;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.55;
}
.about-cta {
  margin: 0;
}
.auth-kicker {
  margin: 0 0 8px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.auth-card h1 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}
.auth-lead {
  margin: 0 0 20px;
  font-size: 0.9rem;
  color: var(--text-soft);
  line-height: 1.4;
}
.auth-error {
  margin: 0 0 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--incorrect-color);
}
.auth-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  text-align: left;
}
.auth-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}
.auth-input {
  font: inherit;
  font-size: 1rem;
  padding: 10px 12px;
  border: 1px solid var(--line-thin);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
.auth-hint {
  margin: 0 0 8px;
  font-size: 0.7rem;
  color: var(--text-faint);
}
.auth-submit {
  margin-top: 4px;
  border: none;
  border-radius: 8px;
  background: var(--chip-invert);
  color: var(--text-on-invert);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 11px 16px;
  cursor: pointer;
}
.auth-submit:hover { background: var(--chip-invert-hover); }
.auth-foot { margin: 18px 0 0; }

.timer {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.timer i { font-size: 0.85rem; color: var(--accent); }

.top-left-bar {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 50;
  height: 30px;
  display: flex;
  align-items: center;
}

.top-right-bar {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 50;
  height: 28px;
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.top-menu {
  position: relative;
  height: 100%;
}
.top-menu-btn {
  position: relative;
  z-index: 1;
  border: none;
  background: transparent;
  padding: 0 10px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-family: inherit;
  font-size: 0.62rem;
  font-weight: 600;
  line-height: 1;
  color: var(--text-on-invert);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.top-menu-btn i {
  font-size: 0.7rem;
  line-height: 1;
  color: inherit;
}
.chip-control--invert:hover { background: var(--chip-invert-hover); }
.top-menu-btn[aria-expanded="true"] { background: rgba(255, 255, 255, 0.12); }
[data-theme="dark"] .top-menu-btn[aria-expanded="true"] { background: rgba(28, 27, 25, 0.12); }
.top-menu-dropdown {
  position: absolute;
  top: 38px;
  right: 0;
  min-width: 170px;
  background: var(--surface);
  border: 1px solid var(--line-thin);
  border-radius: 10px;
  box-shadow: var(--shadow-menu);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.top-menu-dropdown.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.top-menu-dropdown button,
.top-menu-dropdown .top-menu-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: left;
  text-decoration: none;
  box-sizing: border-box;
}
.top-menu-dropdown button:hover,
.top-menu-dropdown .top-menu-link:hover { background: var(--surface-hover); }
.top-menu-dropdown button i,
.top-menu-dropdown .top-menu-link i { font-size: 1rem; color: var(--accent); }
.top-menu-lang {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px 8px;
  margin-top: 4px;
  border-top: 1px solid var(--line-thin);
}
.top-menu-lang + .top-menu-lang {
  margin-top: 0;
  border-top: none;
  padding-top: 0;
}
.top-menu-lang-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: 0.03em;
}
.lang-select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-thin);
  border-radius: 6px;
  background: var(--surface-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.lang-select:focus {
  outline: none;
  border-color: var(--focus-border);
  background-color: var(--surface);
}

.pause-overlay {
  position: fixed;
  inset: 0;
  z-index: 160;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--overlay-scrim-soft);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.pause-card {
  max-width: 280px;
  width: 100%;
  text-align: center;
  background: var(--pause-card-bg);
  color: var(--text-on-invert);
  border-radius: 14px;
  padding: 22px 20px 18px;
  box-shadow: var(--shadow-heavy);
}
[data-theme="dark"] .pause-card {
  color: var(--text);
  border: 1px solid var(--line-thin);
}
.pause-title {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 700;
}
.pause-copy {
  margin: 0 0 16px;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text-on-invert-muted);
}
[data-theme="dark"] .pause-copy {
  color: var(--text-muted);
}
.pause-continue {
  border: none;
  border-radius: 8px;
  background: var(--pause-btn-bg);
  color: var(--pause-btn-fg);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 18px;
  min-width: 140px;
  cursor: pointer;
}

.lb-overlay {
  position: fixed;
  inset: 0;
  z-index: 190;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  background: var(--overlay-scrim);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.lb-panel {
  width: min(100%, 420px);
  margin: 12px auto 40px;
  background: var(--surface);
  border: 1px solid var(--line-thin);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 16px 16px 18px;
  color: var(--text);
}
.lb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.lb-head h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}
.lb-close {
  border: none;
  background: var(--surface-hover);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
}
.lb-close:hover { background: var(--chip-bg); }
.lb-tabs,
.lb-level-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.lb-tab,
.lb-level-tab {
  border: 1px solid var(--line-thin);
  background: var(--surface-muted);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}
.lb-tab.active,
.lb-level-tab.active {
  background: var(--chip-invert);
  border-color: var(--chip-invert);
  color: var(--text-on-invert);
}
.lb-note {
  margin: 0 0 10px;
  font-size: 0.72rem;
  color: var(--text-faint);
  line-height: 1.35;
}
.lb-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 10px;
  flex-wrap: wrap;
}
.lb-nav-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.lb-nav-btn,
.lb-more-btn {
  border: 1px solid var(--line-thin);
  background: var(--surface-muted);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}
.lb-nav-btn:hover,
.lb-more-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.lb-nav-btn.active {
  background: var(--chip-invert);
  border-color: var(--chip-invert);
  color: var(--text-on-invert);
}
.lb-range {
  margin: 0;
  font-size: 0.7rem;
  color: var(--text-faint);
  white-space: nowrap;
}
.lb-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.lb-table th,
.lb-table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--lb-row-border);
  vertical-align: top;
}
.lb-table th {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.lb-table .lb-user {
  font-weight: 600;
  color: var(--text-strong);
}
.lb-table .lb-rank {
  display: inline-block;
  min-width: 2.1em;
  margin-right: 4px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text-faint);
}
.lb-table tr.lb-me td {
  background: var(--lb-me-bg);
  font-weight: 700;
}
.lb-table tr.lb-me .lb-user {
  color: var(--accent);
}
.lb-table tr.lb-me .lb-rank {
  color: var(--accent);
}
.lb-you {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  vertical-align: middle;
  background: var(--accent);
  color: var(--text-on-invert);
}
[data-theme="dark"] .lb-you {
  color: var(--bg);
}
.lb-empty {
  margin: 16px 0 4px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-faint);
}
.lb-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}
.lb-more-btn {
  min-width: 140px;
}

.lang-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--overlay-scrim-strong);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.lang-picker {
  max-width: 300px;
  width: 100%;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line-thin);
  border-radius: 16px;
  padding: 24px 20px 20px;
  box-shadow: var(--shadow-lg);
}
.lang-picker-brand {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.lang-picker h1 {
  margin: 0 0 6px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-strong);
}
.lang-picker-lead {
  margin: 0 0 18px;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--text-soft);
}
.lang-suggested-btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 10px;
  background: var(--chip-invert);
  color: var(--text-on-invert);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 14px 16px;
  cursor: pointer;
}
.lang-suggested-btn:hover { background: var(--chip-invert-hover); }
.lang-picker-or {
  margin: 16px 0 10px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.lang-picker-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: min(40vh, 280px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  text-align: left;
}
.lang-picker-list button {
  display: block;
  width: 100%;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
}
.lang-picker-list button:hover { background: var(--surface-hover); }
.pause-continue:hover { background: var(--pause-btn-hover); }

.rotate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 200;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 24px;
}
.rotate-overlay i { font-size: 3rem; color: var(--accent); }
.rotate-overlay p { font-size: 1rem; color: var(--text-secondary); max-width: 280px; margin: 0; }

@media screen and (max-height: 500px) and (orientation: landscape) {
  .rotate-overlay { display: flex; }
}

.post-solve-wrapper {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(28px, 12vh, 96px);
  padding: 12px 0;
  overflow: auto;
}

.post-solve {
  text-align: center;
  max-width: min(34rem, 92vw);
  padding: 0 16px;
  box-sizing: border-box;
}
.result-title {
  margin: 0;
  font-size: clamp(1.25rem, 4.5vw, 1.6rem);
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  text-wrap: balance;
}
.result-praise {
  margin: 10px 0 0;
  font-size: clamp(0.95rem, 3.4vw, 1.1rem);
  font-weight: 500;
  line-height: 1.45;
  color: var(--text-secondary);
  text-wrap: pretty;
}
.result-praise.hidden { display: none; }
.result-meta {
  margin: 10px 0 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.bottom-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.text-link {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 5px;
}
.text-link-primary {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
}
.text-link-secondary {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-faint);
}
.admire-board {
  margin-top: 20px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--surface);
  border-radius: 10px;
  padding: 28px 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-heavy);
  color: var(--text);
}
.modal-box h2 { margin: 0 0 10px; font-size: 1.2rem; }
.modal-box p { margin: 0 0 20px; color: var(--text-muted); }
.modal-box button,
.modal-btn {
  padding: 10px 20px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 0.95rem;
  font: inherit;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 0;
}
.modal-btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--line-thin);
}
.modal-btn-secondary:hover {
  background: var(--surface-hover);
}
.modal-btn-danger {
  background: var(--incorrect-color);
  border-color: var(--incorrect-color);
  color: #fff;
}
.modal-btn-danger:hover {
  filter: brightness(0.95);
}

.profile-card {
  max-width: 420px;
  text-align: center;
}
.profile-stats {
  margin: 0 0 24px;
  text-align: left;
}
.profile-dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  margin: 0 0 20px;
}
.profile-dl div {
  margin: 0;
}
.profile-dl dt {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.profile-dl dd {
  margin: 2px 0 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}
.profile-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.profile-table th,
.profile-table td {
  padding: 8px 6px;
  text-align: right;
  border-bottom: 1px solid var(--line-thin);
  color: var(--text-soft);
}
.profile-table th {
  font-weight: 600;
  color: var(--text-faint);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.profile-table th:first-child,
.profile-table td:first-child {
  text-align: left;
  color: var(--text-secondary);
  font-weight: 600;
}
.profile-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.profile-delete-btn {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.78rem;
  color: var(--incorrect-color);
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
  opacity: 0.85;
}
.profile-delete-btn:hover { opacity: 1; }
