:root {
  color-scheme: light;
  --ink: #19202a;
  --muted: #667085;
  --line: #d7dde8;
  --paper: #f6f7f1;
  --surface: #ffffff;
  --cell: #fffdf5;
  --block: #202531;
  --teal: #137c74;
  --teal-dark: #0c5d57;
  --amber: #d99922;
  --rose: #c84f62;
  --blue: #3169a8;
  --shadow: 0 18px 42px rgba(31, 41, 55, 0.14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(19, 124, 116, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(19, 124, 116, 0.08) 1px, transparent 1px),
    var(--paper);
  background-size: 34px 34px;
  color: var(--ink);
}

body.intro-open {
  background:
    radial-gradient(circle at top left, rgba(49, 105, 168, 0.16), transparent 32%),
    radial-gradient(circle at top right, rgba(217, 153, 34, 0.18), transparent 26%),
    linear-gradient(180deg, #151a22 0%, #1d2430 42%, #242c39 100%);
}

body.game-page .intro-screen {
  display: none;
}

body.dashboard-page .game-shell {
  display: none;
}

button {
  font: inherit;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

#gameShell[hidden] {
  display: none;
}

.game-over-overlay[hidden] {
  display: none !important;
}

.intro-screen {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(49, 105, 168, 0.18), transparent 32%),
    radial-gradient(circle at top right, rgba(217, 153, 34, 0.14), transparent 26%),
    linear-gradient(180deg, #151a22 0%, #1d2430 42%, #242c39 100%);
  color: #f5f7fb;
}

.intro-screen::before,
.intro-screen::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.intro-screen::before {
  width: 460px;
  height: 460px;
  top: -120px;
  right: -120px;
  background: radial-gradient(circle, rgba(49, 105, 168, 0.22), transparent 70%);
}

.intro-screen::after {
  width: 340px;
  height: 340px;
  left: -110px;
  bottom: -110px;
  background: radial-gradient(circle, rgba(19, 124, 116, 0.24), transparent 70%);
}

.intro-screen.exit {
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 360ms ease, transform 360ms ease;
}

.music-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 10px 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(12, 16, 24, 0.72);
  color: #f7fbff;
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 30px rgba(5, 10, 18, 0.25);
}

.music-toggle:hover {
  transform: translateY(-1px);
}

.music-toggle.is-active {
  background: rgba(19, 124, 116, 0.9);
  border-color: rgba(142, 246, 232, 0.4);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 10px 0 8px;
}

.music-icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.theme-icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

#themeToggleLabel,
#musicToggleLabel {
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.intro-stream {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.stream-item {
  position: absolute;
  top: 110%;
  left: var(--x);
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--bg, rgba(255, 255, 255, 0.07));
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--fg, rgba(255, 255, 255, 0.76));
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: var(--size, 0.95rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
  mix-blend-mode: screen;
  opacity: var(--alpha, 0.7);
  transform: translate3d(0, 0, 0);
  animation: streamRise var(--duration, 18s) linear infinite;
  animation-delay: var(--delay, 0s);
}

.intro-orbit {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.orbit-tile {
  position: absolute;
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.82);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 1.35rem;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  animation: floatTile 10s ease-in-out infinite;
}

.orbit-tile.t1 { top: 9%; left: 8%; animation-delay: 0s; }
.orbit-tile.t2 { top: 14%; right: 10%; animation-delay: -1.5s; }
.orbit-tile.t3 { top: 25%; left: 20%; animation-delay: -3s; }
.orbit-tile.t4 { top: 18%; right: 26%; animation-delay: -4.5s; }
.orbit-tile.t5 { bottom: 22%; left: 7%; animation-delay: -2s; }
.orbit-tile.t6 { bottom: 28%; right: 14%; animation-delay: -5s; }
.orbit-tile.t7 { bottom: 14%; left: 28%; animation-delay: -3.5s; }
.orbit-tile.t8 { bottom: 10%; right: 29%; animation-delay: -6s; }

.intro-shell {
  position: relative;
  z-index: 1;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px 22px 36px;
  display: grid;
  gap: 22px;
}

.intro-hero,
.intro-visual,
.rules-panel {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(12, 16, 24, 0.35);
  box-shadow: 0 24px 70px rgba(5, 10, 18, 0.28);
  backdrop-filter: blur(10px);
}

.intro-hero {
  display: grid;
  gap: 18px;
  padding: 28px;
}

.intro-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-mark,
.topbar-mark {
  display: block;
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  object-fit: contain;
}

.brand-photo {
  padding: 0;
  border-radius: 50%;
  background: #ffffff;
  overflow: hidden;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}

.intro-screen .eyebrow,
.intro-screen h1,
.intro-screen .panel-heading span,
.intro-screen .intro-copy,
.intro-screen .intro-note,
.intro-screen .rule-item p {
  color: inherit;
}

.intro-screen .eyebrow {
  color: rgba(142, 246, 232, 0.9);
}

.intro-screen h1 {
  color: #f7fbff;
}

.intro-copy {
  max-width: 62ch;
  color: rgba(245, 247, 251, 0.82);
  font-size: 1.02rem;
  line-height: 1.65;
}

.intro-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.intro-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #f7fbff;
}

.intro-screen .ghost-btn {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #f7fbff;
}

.intro-visual {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 18px;
  padding: 18px;
}

.intro-board-preview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
  padding: 10px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    rgba(255, 255, 255, 0.02);
  background-size: 28px 28px;
}

.intro-board-preview span {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background:
    linear-gradient(180deg, #fffef9 0%, #f5efdf 100%);
  color: #0b5f58;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 1.22rem;
  font-weight: 950;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.72);
  box-shadow:
    inset 0 0 0 1px rgba(25, 32, 42, 0.14),
    0 8px 18px rgba(0, 0, 0, 0.12);
  animation: tilePulse 4.8s ease-in-out infinite;
}

.intro-board-preview span:nth-child(2n) {
  animation-delay: -1s;
}

.intro-board-preview span:nth-child(3n) {
  animation-delay: -2s;
}

.intro-code {
  display: grid;
  align-content: center;
  gap: 12px;
  padding: 18px;
  border-radius: 8px;
  background: #111722;
  color: #d9e2f1;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.code-line {
  line-height: 1.6;
}

.code-key {
  color: #8ee8db;
}

.code-value {
  color: #f4c46a;
}

.code-good {
  color: #9bf0c7;
}

.code-bad {
  color: #ff9bad;
}

.rules-panel {
  padding-bottom: 8px;
}

.rules-panel .panel-heading {
  padding-bottom: 18px;
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.rules-panel h2,
.rules-panel .panel-heading span {
  color: #f7fbff;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 18px 18px;
}

.rule-item {
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.rule-item span {
  display: inline-flex;
  margin-bottom: 12px;
  color: rgba(142, 246, 232, 0.9);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.rule-item p {
  color: rgba(245, 247, 251, 0.82);
  line-height: 1.6;
}

.intro-note {
  padding: 0 18px 14px;
  color: rgba(255, 255, 255, 0.72);
  font-weight: 700;
}

.difficulty-modal {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(10, 14, 21, 0.72);
  backdrop-filter: blur(8px);
}

.difficulty-modal-card {
  width: min(860px, 100%);
  padding: 26px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background:
    radial-gradient(circle at top right, rgba(49, 105, 168, 0.18), transparent 22%),
    radial-gradient(circle at bottom left, rgba(19, 124, 116, 0.14), transparent 24%),
    rgba(16, 20, 29, 0.98);
  color: #f7fbff;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.35);
}

.modal-eyebrow {
  margin-bottom: 8px;
  color: rgba(142, 246, 232, 0.92);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.difficulty-modal-card h2 {
  margin-bottom: 10px;
  font-size: clamp(1.6rem, 3.8vw, 2.4rem);
}

.modal-disclaimer {
  margin-bottom: 18px;
  color: rgba(245, 247, 251, 0.78);
  line-height: 1.6;
}

.difficulty-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.difficulty-choice {
  display: grid;
  gap: 6px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: #f7fbff;
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.difficulty-choice strong {
  font-size: 1.1rem;
}

.difficulty-choice span {
  color: #8ee8db;
  font-weight: 800;
}

.difficulty-choice small {
  color: rgba(245, 247, 251, 0.72);
  line-height: 1.45;
}

.difficulty-choice.active {
  border-color: rgba(142, 246, 232, 0.5);
  background: rgba(19, 124, 116, 0.16);
  box-shadow: 0 0 0 3px rgba(19, 124, 116, 0.14);
}

.difficulty-choice:hover {
  transform: translateY(-1px);
}

.easy-layout-picker {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.easy-layout-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.easy-layout-header p {
  color: rgba(245, 247, 251, 0.72);
  line-height: 1.45;
}

.easy-layout-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.easy-layout-option {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: #f7fbff;
  font-weight: 850;
}

.easy-layout-option.active {
  border-color: rgba(142, 246, 232, 0.5);
  background: rgba(19, 124, 116, 0.16);
  box-shadow: 0 0 0 3px rgba(19, 124, 116, 0.14);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.difficulty-summary {
  display: grid;
  gap: 2px;
  min-height: 42px;
  align-content: center;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  min-width: 128px;
}

.difficulty-summary strong {
  color: var(--ink);
}

.countdown-overlay {
  position: fixed;
  inset: 0;
  z-index: 58;
  display: grid;
  place-items: center;
  background: rgba(10, 14, 21, 0.75);
  backdrop-filter: blur(6px);
}

.countdown-stage {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 28px 36px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(12, 16, 24, 0.92);
  color: #f7fbff;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.35);
}

.countdown-eyebrow {
  color: rgba(142, 246, 232, 0.9);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.countdown-number {
  font-size: clamp(4rem, 18vw, 7rem);
  font-weight: 900;
  line-height: 0.9;
  color: #8ee8db;
  text-shadow: 0 0 28px rgba(142, 232, 219, 0.15);
}

.countdown-message {
  color: rgba(245, 247, 251, 0.8);
  line-height: 1.5;
}

.difficulty-btn,
.primary-btn,
.ghost-btn,
.number-item,
.cell {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.game-shell {
  background: transparent;
}

.auth-shell {
  width: min(1120px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 20px 40px;
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(620px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.auth-brand h1 {
  margin: 0;
  font-size: clamp(1.9rem, 4vw, 3rem);
}

.auth-copy {
  margin-top: 14px;
  color: var(--muted);
  line-height: 1.65;
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.auth-field {
  display: grid;
  gap: 8px;
}

.auth-field .status-label {
  font-size: 0.74rem;
}

.auth-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.auth-note {
  color: var(--muted);
  line-height: 1.55;
}

.auth-error {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(200, 79, 98, 0.24);
  border-radius: 8px;
  background: rgba(200, 79, 98, 0.08);
  color: #9a2439;
}

.auth-error ul {
  margin: 0;
  padding-left: 18px;
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 22px;
}

.auth-links a {
  color: var(--teal-dark);
  font-weight: 800;
}

.profile-shell {
  padding: 24px;
  display: grid;
  gap: 22px;
}

.profile-heading {
  margin-bottom: 0;
}

.profile-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.profile-name {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1.05;
}

body[data-theme="dark"] .profile-name {
  color: #f7fbff;
}

.profile-hero {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(19, 124, 116, 0.06), rgba(49, 105, 168, 0.03));
}

body[data-theme="dark"] .profile-hero {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border-radius: 24px;
  background: linear-gradient(180deg, #137c74 0%, #0c5d57 100%);
  color: #f7fbff;
  font-size: 2rem;
  font-weight: 950;
  box-shadow: 0 16px 30px rgba(19, 124, 116, 0.22);
}

.profile-summary {
  display: grid;
  gap: 16px;
}

.profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.profile-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(19, 124, 116, 0.14);
  border-radius: 999px;
  background: rgba(19, 124, 116, 0.08);
  color: var(--teal-dark);
  font-size: 0.9rem;
  font-weight: 750;
}

body[data-theme="dark"] .profile-chip {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #eafcf8;
}

.profile-about {
  display: grid;
  gap: 10px;
}

.profile-about h2 {
  font-size: 1.3rem;
}

.profile-about p {
  color: var(--muted);
  line-height: 1.6;
}

.profile-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.profile-details div {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

body[data-theme="dark"] .profile-details div {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
}

.profile-details dt {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.profile-details dd {
  margin: 0;
  color: var(--ink);
  font-weight: 850;
}

body[data-theme="dark"] .profile-details dd {
  color: #f7fbff;
}

.profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.profile-stats-grid .statusbar {
  min-height: 84px;
}

.profile-run-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.profile-run-group {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
}

body[data-theme="dark"] .profile-run-group {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.profile-run-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.profile-run-heading h2 {
  margin-top: 4px;
  font-size: 1.1rem;
}

.profile-run-heading > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.profile-run-list {
  display: grid;
  gap: 10px;
}

.profile-run-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 82px;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
}

body[data-theme="dark"] .profile-run-row {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(10, 14, 21, 0.92);
}

.profile-run-rank {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(19, 124, 116, 0.12);
  color: var(--teal-dark);
  font-weight: 900;
}

.profile-run-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.profile-run-main strong {
  color: var(--ink);
  font-size: 1rem;
}

.profile-run-main span {
  color: var(--muted);
  font-size: 0.82rem;
}

.profile-run-meta {
  display: grid;
  justify-items: end;
  gap: 4px;
}

.profile-run-meta strong {
  color: var(--ink);
}

.profile-run-empty {
  color: var(--muted);
  font-size: 0.9rem;
}

.leaderboard-row {
  align-items: center;
}

.leaderboard-rank {
  display: flex;
  align-items: center;
  gap: 10px;
}

.leaderboard-rank-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(19, 124, 116, 0.12);
  color: var(--teal-dark);
  font-weight: 900;
}

.leaderboard-rank-icon {
  color: var(--amber);
  font-size: 1.2rem;
  font-weight: 900;
}

.profile-textarea {
  min-height: 112px;
  resize: vertical;
}

.dashboard-shell {
  position: relative;
  z-index: 1;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px 22px 36px;
  display: grid;
  gap: 22px;
}

.dashboard-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.intro-shell-dashboard {
  width: 100%;
  padding: 0;
}

.user-menu {
  position: relative;
}

.user-menu summary {
  list-style: none;
}

.user-menu summary::-webkit-details-marker {
  display: none;
}

.user-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 6px 12px 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(12, 16, 24, 0.58);
  color: #f7fbff;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

body:not(.intro-open) .user-menu-trigger {
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  border-color: var(--line);
}

body[data-theme="dark"]:not(.intro-open) .user-menu-trigger {
  background: rgba(17, 23, 34, 0.96);
  color: #f7fbff;
  border-color: rgba(255, 255, 255, 0.08);
}

.user-menu-avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(142, 246, 232, 0.16);
  color: #8ee8db;
  font-size: 0.78rem;
  font-weight: 900;
}

.user-menu-name {
  font-size: 0.8rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  color: inherit;
}

.user-menu-caret {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 10;
  display: grid;
  min-width: 220px;
  padding: 8px;
  gap: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(16, 20, 29, 0.98);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.28);
}

.user-menu-panel a,
.user-menu-panel button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: flex-start;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #f7fbff;
  text-align: left;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}

.user-menu-panel a:hover,
.user-menu-panel button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.user-menu:not([open]) .user-menu-panel {
  display: none;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-mark {
  width: 52px;
  height: 52px;
}

.game-over-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(168, 14, 28, 0.96);
  backdrop-filter: blur(2px);
}

.game-over-card {
  width: min(92vw, 420px);
  padding: 28px 24px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff7f7;
  text-align: center;
  box-shadow: 0 22px 60px rgba(66, 0, 8, 0.35);
  animation: gameOverPop 380ms ease-out;
}

.game-over-eyebrow {
  margin-bottom: 10px;
  color: rgba(255, 238, 238, 0.8);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.game-over-card h2 {
  margin-bottom: 8px;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
}

.game-over-card p:last-child {
  color: rgba(255, 240, 240, 0.82);
  line-height: 1.55;
}

.win-effects-layer {
  position: fixed;
  inset: 0;
  z-index: 62;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -12vh;
  left: var(--left, 50vw);
  width: var(--size, 8px);
  height: calc(var(--size, 8px) * 1.35);
  border-radius: var(--shape, 1px);
  background: hsl(var(--hue, 180) 88% 62%);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.18);
  transform: translate3d(0, 0, 0) rotate(0deg);
  animation: confettiFall var(--duration, 3200ms) linear forwards;
  animation-delay: var(--delay, 0ms);
}

.firework-burst {
  position: absolute;
  left: var(--left, 50%);
  top: var(--top, 50%);
  width: 12px;
  height: 12px;
  margin-left: -6px;
  margin-top: -6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  box-shadow:
    0 0 0 0 rgba(255, 255, 255, 0.58),
    0 0 22px rgba(255, 255, 255, 0.22);
  animation: fireworkBurst 900ms ease-out forwards;
}

@keyframes streamRise {
  0% {
    transform: translate3d(0, 0, 0);
  }
  100% {
    transform: translate3d(calc(var(--drift, 0px)), -240vh, 0);
  }
}

@keyframes gameOverPop {
  0% {
    transform: scale(0.92);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes confettiFall {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  100% {
    transform: translate3d(var(--drift, 0px), 116vh, 0) rotate(var(--spin, 360deg));
    opacity: 1;
  }
}

@keyframes fireworkBurst {
  0% {
    transform: scale(0.2);
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  100% {
    transform: scale(18);
    opacity: 0;
  }
}

.app {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.topbar,
.statusbar,
.game-layout {
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.5rem);
  line-height: 0.95;
}

h2 {
  font-size: 1rem;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.game-menu {
  position: relative;
}

.game-menu summary {
  list-style: none;
}

.game-menu summary::-webkit-details-marker {
  display: none;
}

.game-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-weight: 850;
}

.game-menu-bars {
  display: grid;
  gap: 3px;
}

.game-menu-bars span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.game-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 20;
  display: grid;
  min-width: 240px;
  padding: 8px;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 20px 48px rgba(31, 41, 55, 0.16);
}

.game-menu-item {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: flex-start;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.game-menu-item:hover {
  background: rgba(19, 124, 116, 0.08);
}

.game-menu .theme-toggle,
.game-menu .music-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
}

.game-menu .theme-toggle:hover,
.game-menu .music-toggle:hover {
  background: rgba(19, 124, 116, 0.08);
  transform: none;
}

body[data-theme="dark"] .game-menu-trigger,
body[data-theme="dark"] .game-menu-panel {
  background: rgba(17, 23, 34, 0.96);
  color: #f7fbff;
  border-color: rgba(255, 255, 255, 0.08);
}

body[data-theme="dark"] .game-menu-item,
body[data-theme="dark"] .game-menu .theme-toggle,
body[data-theme="dark"] .game-menu .music-toggle {
  color: #f7fbff;
}

body[data-theme="dark"] .game-menu-item:hover,
body[data-theme="dark"] .game-menu .theme-toggle:hover,
body[data-theme="dark"] .game-menu .music-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
}

.difficulty {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(76px, 1fr));
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(31, 41, 55, 0.07);
}

.difficulty-btn {
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.difficulty-btn.active {
  background: var(--ink);
  color: #ffffff;
}

.primary-btn {
  padding: 0 18px;
  background: var(--teal);
  color: #ffffff;
  font-weight: 850;
  box-shadow: 0 10px 24px rgba(19, 124, 116, 0.22);
}

.primary-btn:hover,
.ghost-btn:hover,
.number-item:not(:disabled):hover,
.cell.playable:hover {
  transform: translateY(-1px);
}

.ghost-btn {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  font-weight: 800;
}

.statusbar {
  display: grid;
  grid-template-columns: minmax(110px, max-content) minmax(110px, max-content) minmax(120px, max-content) 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.statusbar > div,
.statusbar > p {
  min-height: 54px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 22px rgba(31, 41, 55, 0.06);
}

.statusbar > div {
  display: grid;
  align-content: center;
  gap: 2px;
}

.status-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.statusbar strong {
  font-size: 1.05rem;
}

#messageText {
  display: flex;
  align-items: center;
  color: var(--muted);
  font-weight: 700;
}

#messageText.good {
  color: var(--teal-dark);
}

#messageText.bad {
  color: var(--rose);
}

.feedback-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 30;
  min-width: min(92vw, 380px);
  max-width: calc(100vw - 24px);
  padding: 14px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 42px rgba(31, 41, 55, 0.18);
  color: var(--ink);
  font-weight: 800;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease, border-color 180ms ease, color 180ms ease, background 180ms ease;
}

.feedback-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.feedback-toast.bad {
  border-color: rgba(200, 79, 98, 0.36);
  background: #fff4f6;
  color: var(--rose);
}

.feedback-toast.good {
  border-color: rgba(17, 107, 94, 0.28);
  background: #ecfaf3;
  color: var(--teal-dark);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(250px, 330px) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.number-panel,
.board-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.number-panel {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow: auto;
}

.board-panel {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 210px);
  height: 100%;
}

.board-panel.error-shake {
  animation: shake 240ms ease;
  box-shadow: 0 0 0 2px rgba(200, 79, 98, 0.18), var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px;
  border-bottom: 1px solid var(--line);
}

.panel-heading span {
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 750;
}

.board-heading {
  align-items: flex-start;
}

.board-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 300px);
  align-items: stretch;
  flex: 1;
  min-height: 0;
  height: 100%;
}

@media (max-width: 1160px) {
  .board-workspace {
    grid-template-columns: 1fr;
  }

  .board-side {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

.number-bank {
  display: grid;
  gap: 14px;
  padding: 15px;
}

.entry-card {
  display: grid;
  gap: 10px;
  padding: 15px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(19, 124, 116, 0.05), rgba(19, 124, 116, 0));
}

.entry-card-board {
  padding: 0;
  border-bottom: 0;
  background: none;
}

.entry-card label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.entry-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.entry-input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.entry-input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(19, 124, 116, 0.14);
}

.entry-input.error {
  border-color: var(--rose);
  background: #ffe8eb;
  box-shadow: 0 0 0 3px rgba(200, 79, 98, 0.12);
}

.entry-input:disabled {
  background: #f2f4f7;
  color: #98a2b3;
}

.entry-card p {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.number-group {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(19, 124, 116, 0.02);
  transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.number-group.is-active {
  background: rgba(19, 124, 116, 0.07);
  box-shadow: inset 0 0 0 1px rgba(19, 124, 116, 0.12);
}

.group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
  text-transform: uppercase;
}

.number-group.is-active .group-title {
  color: var(--teal-dark);
}

.number-group.is-active .group-title span:last-child {
  color: var(--teal-dark);
}

.number-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 8px;
}

.number-item {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 1rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  cursor: default;
}

.number-item.selected {
  border-color: var(--amber);
  background: #fff2d3;
  box-shadow: 0 0 0 3px rgba(217, 153, 34, 0.18);
}

.number-item.used,
.number-item.seeded {
  color: #116b5e;
  background: #dff3ea;
  border-color: #a7d8c0;
  text-decoration: line-through;
}

.number-item.seeded::after {
  content: "seed";
  position: absolute;
  top: -7px;
  right: 8px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--blue);
  color: #ffffff;
  font-family: inherit;
  font-size: 0.58rem;
  letter-spacing: 0;
}

.board-wrap {
  width: 100%;
  padding: 16px;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.board-side {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 16px;
  border-left: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(19, 124, 116, 0.04), rgba(19, 124, 116, 0)),
    rgba(255, 255, 255, 0.65);
  min-height: 100%;
  height: 100%;
}

.dashboard-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(7, 10, 16, 0.52);
  backdrop-filter: blur(5px);
}

.dashboard-confirm-card {
  width: min(100%, 440px);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.28);
}

body[data-theme="dark"] .dashboard-confirm-card {
  background: rgba(17, 23, 34, 0.98);
}

.dashboard-confirm-card h2 {
  font-size: 1.45rem;
}

.dashboard-confirm-card p {
  color: var(--muted);
  line-height: 1.55;
}

.dashboard-confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.board-side .entry-row {
  gap: 8px;
}

.board-side .entry-input {
  min-height: 44px;
}

.board-side .ghost-btn {
  white-space: nowrap;
}

.board-side-actions {
  display: grid;
  gap: 10px;
  align-content: start;
}

.board-side-actions .ghost-btn {
  width: 100%;
}

.board-side-note {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.board {
  --grid-size: 15;
  display: grid;
  grid-template-columns: repeat(var(--grid-size), var(--cell-size, 34px));
  grid-auto-rows: var(--cell-size, 34px);
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  border: 2px solid var(--block);
  background: var(--block);
  gap: var(--grid-gap, 2px);
  touch-action: manipulation;
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-height: 0;
  border-radius: 0;
  border: 0;
  background: var(--block);
  color: transparent;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(0.92rem, 2.4vw, 1.45rem);
  font-weight: 900;
  line-height: 1;
}

.cell.playable {
  background: var(--cell);
  color: transparent;
  box-shadow: inset 0 0 0 1px rgba(25, 32, 42, 0.16);
}

.cell.filled {
  background: #e0f3e8;
  color: var(--teal-dark);
}

.cell.draft-filled {
  background: #fff0bf;
  color: #553700;
}

.cell.draft-preview {
  animation: draftBlink 1s ease-in-out infinite;
}

.cell.draft-match {
  background: #e0f3e8;
  color: var(--teal-dark);
}

.cell.draft-mismatch {
  background: #ffdce3;
  color: #9d1231;
  box-shadow: inset 0 0 0 2px rgba(200, 79, 98, 0.32);
}

.cell.fixed {
  background: #d4efe2;
  color: var(--teal-dark);
}

.cell.in-selected-slot {
  background: #ffe7aa;
  box-shadow: inset 0 0 0 2px rgba(217, 153, 34, 0.42);
}

.cell.in-selected-slot.filled {
  color: #442d03;
}

.cell.conflict-flash {
  animation: shake 240ms ease;
  background: #ffd7df;
  color: #8d1129;
}

.result-dialog {
  width: min(420px, calc(100% - 32px));
  border: 0;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.3);
}

.result-dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.result-dialog h2 {
  margin-bottom: 8px;
  font-size: 1.45rem;
}

.result-dialog p {
  margin-bottom: 18px;
  color: var(--muted);
  line-height: 1.5;
}

body[data-theme="dark"] {
  color-scheme: dark;
  --ink: #ecf1f7;
  --muted: #a8b3c5;
  --line: #364152;
  --paper: #121722;
  --surface: #1a2130;
  --cell: #f3efe2;
  --block: #0f1520;
  --teal: #20a39a;
  --teal-dark: #91f2e6;
  --amber: #e3b24a;
  --rose: #ef7a8d;
  --blue: #7aa3df;
  --shadow: 0 20px 46px rgba(0, 0, 0, 0.34);
  background:
    linear-gradient(90deg, rgba(94, 170, 224, 0.07) 1px, transparent 1px),
    linear-gradient(0deg, rgba(94, 170, 224, 0.07) 1px, transparent 1px),
    var(--paper);
}

body[data-theme="dark"] .app,
body[data-theme="dark"] .number-panel,
body[data-theme="dark"] .board-panel,
body[data-theme="dark"] .statusbar > div,
body[data-theme="dark"] .statusbar > p,
body[data-theme="dark"] .ghost-btn,
body[data-theme="dark"] .primary-btn,
body[data-theme="dark"] .difficulty-summary,
body[data-theme="dark"] .entry-input,
body[data-theme="dark"] .number-group,
body[data-theme="dark"] .number-item,
body[data-theme="dark"] .board-side,
body[data-theme="dark"] .result-dialog,
body[data-theme="dark"] .game-over-card,
body[data-theme="dark"] .countdown-stage {
  color: var(--ink);
}

body[data-theme="dark"] .intro-screen {
  background:
    radial-gradient(circle at top left, rgba(94, 170, 224, 0.22), transparent 32%),
    radial-gradient(circle at top right, rgba(227, 178, 74, 0.18), transparent 26%),
    linear-gradient(180deg, #0d1118 0%, #111825 42%, #151c28 100%);
}

body[data-theme="dark"] .topbar,
body[data-theme="dark"] .statusbar > div,
body[data-theme="dark"] .statusbar > p,
body[data-theme="dark"] .number-panel,
body[data-theme="dark"] .board-panel,
body[data-theme="dark"] .difficulty-summary,
body[data-theme="dark"] .entry-input,
body[data-theme="dark"] .number-group,
body[data-theme="dark"] .number-item,
body[data-theme="dark"] .board-side,
body[data-theme="dark"] .result-dialog {
  background: rgba(17, 23, 34, 0.94);
  border-color: var(--line);
}

body[data-theme="dark"] .topbar {
  background: transparent;
}

body[data-theme="dark"] .ghost-btn {
  background: rgba(24, 31, 44, 0.96);
}

body[data-theme="dark"] .ghost-btn:hover {
  background: rgba(31, 39, 54, 0.98);
}

body[data-theme="dark"] .difficulty-btn.active,
body[data-theme="dark"] .primary-btn,
body[data-theme="dark"] .music-toggle.is-active,
body[data-theme="dark"] .theme-toggle.is-active {
  box-shadow: 0 12px 26px rgba(32, 163, 154, 0.22);
}

body[data-theme="dark"] .difficulty-btn.active {
  background: #eaf6ff;
  color: #101722;
}

body[data-theme="dark"] .entry-card {
  background: linear-gradient(180deg, rgba(32, 163, 154, 0.1), rgba(32, 163, 154, 0));
}

body[data-theme="dark"] .entry-input {
  background: rgba(10, 14, 21, 0.96);
}

body[data-theme="dark"] .entry-input:disabled {
  background: rgba(17, 23, 34, 0.92);
  color: #738299;
}

body[data-theme="dark"] .number-panel,
body[data-theme="dark"] .board-panel,
body[data-theme="dark"] .result-dialog,
body[data-theme="dark"] .game-over-card,
body[data-theme="dark"] .countdown-stage {
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.38);
}

body[data-theme="dark"] .statusbar > div,
body[data-theme="dark"] .statusbar > p {
  background: rgba(19, 26, 39, 0.95);
}

body[data-theme="dark"] .number-group {
  background: rgba(18, 28, 40, 0.95);
}

body[data-theme="dark"] .number-group.is-active {
  background: rgba(32, 163, 154, 0.14);
  box-shadow: inset 0 0 0 1px rgba(145, 242, 230, 0.12);
}

body[data-theme="dark"] .number-item {
  background: rgba(11, 15, 22, 0.94);
}

body[data-theme="dark"] .number-item.used,
body[data-theme="dark"] .number-item.seeded {
  background: rgba(18, 50, 44, 0.94);
  border-color: rgba(145, 242, 230, 0.25);
}

body[data-theme="dark"] .board-side {
  background:
    linear-gradient(180deg, rgba(32, 163, 154, 0.08), rgba(32, 163, 154, 0)),
    rgba(14, 19, 28, 0.96);
}

body[data-theme="dark"] .cell.playable {
  background: #f1ecdf;
}

body[data-theme="dark"] .cell.filled,
body[data-theme="dark"] .cell.fixed,
body[data-theme="dark"] .cell.in-selected-slot {
  color: #0f4f49;
}

body[data-theme="dark"] .cell.in-selected-slot {
  background: #f7d77e;
  color: #4d3100;
  box-shadow:
    inset 0 0 0 2px rgba(125, 83, 0, 0.62),
    0 0 0 1px rgba(0, 0, 0, 0.34);
}

body[data-theme="dark"] .cell.in-selected-slot.filled {
  color: #3a2500;
}

body[data-theme="dark"] .cell.draft-filled {
  background: #ffe08c;
  color: #493000;
}

body[data-theme="dark"] .cell.draft-mismatch {
  background: rgba(255, 193, 204, 0.92);
  color: #8d1129;
}

body[data-theme="dark"] .feedback-toast {
  background: rgba(14, 19, 28, 0.98);
  color: var(--ink);
}

body[data-theme="dark"] .feedback-toast.good {
  background: rgba(18, 42, 36, 0.98);
}

body[data-theme="dark"] .feedback-toast.bad {
  background: rgba(58, 15, 24, 0.98);
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  40% {
    transform: translateX(-4px);
  }
  70% {
    transform: translateX(4px);
  }
}

@keyframes draftBlink {
  0%,
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
  50% {
    transform: scale(0.985);
    filter: brightness(1.07);
  }
}

@keyframes floatTile {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(0, -14px, 0);
  }
}

@keyframes tilePulse {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

@media (max-width: 920px) {
  .intro-shell {
    padding: 18px 14px 24px;
  }

  .intro-visual {
    grid-template-columns: 1fr;
  }

  .rules-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .profile-shell {
    padding: 18px;
  }

  .profile-hero {
    grid-template-columns: 1fr;
  }

  .profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 20px;
  }

  .profile-details,
  .profile-stats-grid {
    grid-template-columns: 1fr;
  }

  .profile-run-grid {
    grid-template-columns: 1fr;
  }

  .leaderboard-row {
    grid-template-columns: 64px 1fr 110px 82px !important;
  }

  .difficulty-choices {
    grid-template-columns: 1fr;
  }

  .modal-actions {
    flex-direction: column;
  }

  .modal-actions .primary-btn,
  .modal-actions .ghost-btn {
    width: 100%;
  }

  .app {
    padding: 14px;
  }

  .topbar,
  .statusbar {
    align-items: stretch;
  }

  .topbar {
    flex-direction: column;
  }

  .top-actions,
  .difficulty-summary {
    width: 100%;
  }

  .top-actions {
    justify-content: space-between;
    gap: 8px;
  }

  .game-menu {
    margin-left: auto;
  }

  .statusbar {
    grid-template-columns: repeat(3, 1fr);
  }

  #messageText {
    grid-column: 1 / -1;
  }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .number-panel {
    position: static;
    max-height: none;
  }

  .number-list {
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  }

  .board-panel {
    min-height: auto;
  }

  .game-menu-panel {
    min-width: min(92vw, 260px);
  }
}

@media (max-width: 560px) {
  .intro-brand {
    align-items: flex-start;
  }

  .brand-mark,
  .topbar-mark {
    width: 54px;
    height: 54px;
  }

  .music-toggle {
    min-height: 38px;
    padding: 0 9px 0 7px;
  }

  .game-menu-trigger {
    min-height: 46px;
    padding: 0 12px;
  }

  .difficulty-modal {
    padding: 14px;
  }

  .difficulty-modal-card {
    padding: 20px;
  }

  .auth-shell {
    padding: 18px 14px 28px;
  }

  .auth-card {
    padding: 20px;
  }

  .auth-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .profile-actions {
    width: 100%;
  }

  .profile-actions .ghost-btn,
  .profile-actions .user-menu {
    width: 100%;
  }

  .leaderboard-row {
    grid-template-columns: 56px 1fr 84px 72px !important;
    gap: 8px;
  }

  .user-menu-trigger {
    max-width: 100%;
  }

  .user-menu-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .rules-grid {
    grid-template-columns: 1fr;
  }

  .statusbar {
    grid-template-columns: 1fr 1fr;
  }

  .leaderboard-row .statusbar,
  .leaderboard-row .leaderboard-rank {
    grid-column: auto;
  }

  .statusbar > div:last-of-type,
  #messageText {
    grid-column: 1 / -1;
  }

  .board-wrap {
    padding: 10px;
  }

  .board-side {
    padding: 12px;
  }

  .board {
    grid-template-columns: repeat(var(--grid-size), var(--cell-size, 30px));
    grid-auto-rows: var(--cell-size, 30px);
  }

  .cell {
    font-size: clamp(0.78rem, calc(var(--cell-size, 30px) * 0.55), 1.05rem);
  }
}
