@import url("https://fonts.googleapis.com/css2?family=Lexend:wght@100..900&display=swap");

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

a:focus,
input:focus,
button:focus,
:focus-visible {
  outline: none;
  box-shadow: none;
}

/* ── CUSTOM SCROLLBAR ── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(3, 64, 63, 0.35);
  border-radius: 99px;
  transition: background .2s;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(3, 64, 63, 0.6);
}

[data-scheme="dark"] ::-webkit-scrollbar-thumb {
  background: rgba(142, 196, 74, 0.35);
}

[data-scheme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(142, 196, 74, 0.65);
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(3, 64, 63, 0.35) transparent;
}

[data-scheme="dark"] * {
  scrollbar-color: rgba(142, 196, 74, 0.35) transparent;
}

:root {
  --game1-background: #c9e78a;
  --game1-logo: #03403f;
  --game2-background: #ffb2b2;
  --white-color: #ffffff;
  --black-color: #000000;
  --radius-pill: 60px;
  --transition-fast: 0.2s ease;
  --transition-med: 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-strong: 0 16px 56px rgba(0, 0, 0, 0.22);

  --bg: var(--game1-background);
  --accent: var(--game2-background);
  --logo: var(--game1-logo);
  --ink: rgba(0, 0, 0, 0.82);
  --ink2: rgba(0, 0, 0, 0.5);
  --card: rgba(255, 255, 255, 0.72);
  --card-border: rgba(255, 255, 255, 0.9);
  --x-col: #e85d6a;
  --o-col: #3daa60;
  --font: 'Lexend', sans-serif;
}

html,
body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.18) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.12) 0%, transparent 50%);
  opacity: 0.8;
}

header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  z-index: 99;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px 16px;
  pointer-events: none;
  gap: 10px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  pointer-events: all;
  overflow: hidden;
}

.btn-back {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font);
  font-weight: 700;
  font-size: clamp(12px, 1.5vw, 17px);
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.95);
  background: rgba(0, 0, 0, 0.22);
  border: 2px solid rgba(255, 255, 255, 0.6);
  padding: 10px 24px;
  border-radius: var(--radius-pill);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-back:hover {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 1);
}

/* ── GAME BADGE — fully responsive, never truncated ── */
.game-badge {
  font-family: var(--font);
  font-weight: 800;
  font-size: clamp(12px, 1.4vw, 17px);
  letter-spacing: clamp(0.5px, 0.15vw, 2px);
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.95);
  background: rgba(0, 0, 0, 0.22);
  border: 2px solid rgba(255, 255, 255, 0.5);
  padding: 10px clamp(12px, 1.4vw, 18px);
  border-radius: var(--radius-pill);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── LOGO  ── */
.header-logo-img {
  height: 47px;
  width: auto;
  display: block;
  flex-shrink: 0;
  pointer-events: none;
  user-select: none;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 100px 1.5rem 2.5rem;
}

.shell {
  width: 100%;
  max-width: 1200px;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 1.5rem;
  align-items: stretch;
}

@media(max-width:1024px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .app {
    padding: 90px 1.2rem 1.5rem;
  }
}

.card {
  background: rgba(255, 255, 255, 0.52);
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 32px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-soft);
  padding: 2rem 2.2rem;
}

.board-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
}

.status-bar {
  font-family: var(--font);
  font-weight: 800;
  font-size: clamp(.78rem, 3.5vw, 1.2rem);
  letter-spacing: .3px;
  color: #fff;
  background: rgba(0, 0, 0, 0.30);
  border: 2px solid rgba(255, 255, 255, 0.6);
  padding: 12px 26px;
  border-radius: var(--radius-pill);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  width: 100%;
  text-align: center;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background .3s, border-color .3s;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-bar.sx {
  background: rgba(200, 50, 65, 0.85);
  border-color: rgba(255, 160, 170, 0.7);
}

.status-bar.so {
  background: rgba(30, 135, 70, 0.82);
  border-color: rgba(140, 220, 170, 0.7);
}

.status-bar.sw {
  background: rgba(155, 105, 0, 0.90);
  border-color: rgba(255, 220, 80, 0.8);
  animation: sbounce .4s cubic-bezier(.34, 1.56, .64, 1);
}

.status-bar.sd {
  background: rgba(0, 0, 0, 0.50);
  border-color: rgba(255, 255, 255, 0.35);
}

@keyframes sbounce {
  from {
    transform: scale(.92);
    opacity: .6;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ── Status symbol sizing ── */
.status-sym {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  vertical-align: middle;
  user-select: none;
  -webkit-user-select: none;
}

.status-sym svg {
  display: block;
}

#board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
}

.cell {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.45);
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  font-weight: 900;
  font-size: clamp(2rem, 5vw, 3rem);
  user-select: none;
  transition: transform .12s, box-shadow .12s, background .18s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.cell:hover:not(.taken):not(.paused-cell) {
  background: rgba(255, 255, 255, 0.68);
  transform: scale(1.02);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
}

.cell:active:not(.taken):not(.paused-cell) {
  transform: scale(0.97);
}

.cell.taken {
  cursor: default;
}

/* ── PAUSED STATE  ── */
.cell.paused-cell {
  cursor: not-allowed;
  opacity: 0.6;
}

.cell-sym {
  display: inline-block;
  animation: sympop .28s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes sympop {
  from {
    transform: scale(0)rotate(-20deg);
    opacity: 0;
  }

  to {
    transform: scale(1)rotate(0);
    opacity: 1;
  }
}

.cell.cx-cell {
  background: rgba(232, 93, 106, 0.22);
  border-color: rgba(232, 93, 106, 0.6);
}

.cell.cx-cell .cell-sym {
  color: var(--x-col);
}

.cell.co-cell {
  background: rgba(61, 170, 96, 0.18);
  border-color: rgba(61, 170, 96, 0.55);
}

.cell.co-cell .cell-sym {
  color: var(--o-col);
}

.cell.winner {
  animation: wbounce .45s cubic-bezier(.34, 1.56, .64, 1) forwards, wglow .7s .45s ease infinite alternate;
}

@keyframes wbounce {
  from {
    transform: scale(.85);
  }

  to {
    transform: scale(1);
  }
}

@keyframes wglow {
  from {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  }

  to {
    box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.75), 0 8px 32px rgba(0, 0, 0, 0.2);
  }
}

.sidebar-card {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.sec-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1rem 0;
}

.sec-block:not(:last-child) {
  border-bottom: 1.5px solid rgba(255, 255, 255, 0.5);
}

.sec-lbl {
  font-size: 1rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: rgba(0, 0, 0, 0.4);
  margin-bottom: .65rem;
}

.score-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  text-align: center;
}

.score-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.score-lbl {
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: rgba(0, 0, 0, 0.5);
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-num {
  font-size: 3.2rem;
  font-weight: 900;
  line-height: 1;
  transition: transform .2s;
  color: var(--logo);
}

.score-num.bump {
  animation: sbump .35s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes sbump {
  from {
    transform: scale(1.55);
  }

  to {
    transform: scale(1);
  }
}

.snx {
  color: var(--x-col);
}

.sno {
  color: var(--o-col);
}

.draw-num {
  font-size: 3.2rem;
  font-weight: 900;
  line-height: 1;
  color: rgba(0, 0, 0, 0.3);
}

.name-rows {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}

.name-badge {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 900;
  flex-shrink: 0;
  backdrop-filter: blur(4px);
}

.nbx {
  background: rgba(232, 93, 106, 0.25);
  color: var(--x-col);
}

.nbo {
  background: rgba(61, 170, 96, 0.22);
  color: var(--o-col);
}

/* ── NAME ROW  ── */
.name-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.name-input {
  flex: 1;
  min-width: 0;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  font-family: var(--font);
  font-size: .9rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.45);
  color: var(--ink);
  outline: none;
  backdrop-filter: blur(6px);
  transition: border-color .2s, background .2s;
  pointer-events: none;
  cursor: default;
  opacity: 0.85;
}

.name-input.editing {
  pointer-events: all;
  cursor: text;
  opacity: 1;
  border-color: rgba(255, 255, 255, 1);
  background: rgba(255, 255, 255, 0.65);
}

.name-input:focus {
  border-color: rgba(255, 255, 255, 1);
  background: rgba(255, 255, 255, 0.65);
}

.btn-edit {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(6px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, border-color .2s, transform .15s;
  color: rgba(0, 0, 0, 0.55);
}

.btn-edit:hover {
  background: rgba(255, 255, 255, 0.5);
  border-color: #fff;
  transform: scale(1.1);
}

.btn-edit:active {
  transform: scale(0.93);
}

.btn-edit.active {
  background: rgba(61, 170, 96, 0.35);
  border-color: rgba(61, 170, 96, 0.9);
  color: #1a6e38;
}

.btn-edit svg {
  width: 15px;
  height: 15px;
  display: block;
}

[data-scheme="dark"] .btn-edit {
  color: rgba(255, 255, 255, 0.65);
  background: rgba(255, 255, 255, 0.08);
}

[data-scheme="dark"] .btn-edit.active {
  background: rgba(142, 196, 74, 0.28);
  border-color: rgba(142, 196, 74, 0.8);
  color: #8ec44a;
}

[data-scheme="dark"] .name-input.editing {
  background: rgba(0, 0, 0, 0.4);
}

/* ── HOW TO PLAY button ── */
.btn-help {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 47px;
  height: 47px;
  font-family: var(--font);
  font-weight: 900;
  font-size: 1.5rem;
  color: rgba(255, 255, 255, 0.95);
  background: rgba(0, 0, 0, 0.22);
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  pointer-events: all;
  transition: background .2s, border-color .2s, transform .15s;
  text-decoration: none;
  text-transform: uppercase;
  flex-shrink: 0;
}

.btn-help:hover {
  background: rgba(255, 255, 255, 0.28);
  border-color: #fff;
  transform: scale(1.08);
}

.btn-help:active {
  transform: scale(0.95);
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: rgba(255, 255, 255, 0.88);
  border: 2px solid rgba(255, 255, 255, 1);
  border-radius: 28px;
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.28);
  padding: 2rem 2.2rem 1.8rem;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.92) translateY(16px);
  transition: transform .28s cubic-bezier(.34, 1.56, .64, 1);
  position: relative;
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

[data-scheme="dark"] .modal {
  background: rgba(26, 40, 16, 0.97);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.4rem;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: .5px;
  color: var(--logo);
}

[data-scheme="dark"] .modal-title {
  color: #8ec44a;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.18);
  background: rgba(0, 0, 0, 0.08);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(0, 0, 0, 0.55);
  transition: background .2s, transform .15s;
}

.modal-close:hover {
  background: rgba(232, 93, 106, 0.2);
  transform: scale(1.1);
}

[data-scheme="dark"] .modal-close {
  border-color: rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.08);
}

.modal-steps {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-step {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.step-num {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.07);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid rgba(0, 0, 0, 0.08);
}

[data-scheme="dark"] .step-num {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.12);
}

.step-body {
  flex: 1;
}

.step-title {
  font-weight: 800;
  font-size: .95rem;
  margin-bottom: .2rem;
  color: var(--ink);
}

.step-desc {
  font-size: .82rem;
  font-weight: 500;
  color: var(--ink2);
  line-height: 1.5;
}

[data-scheme="dark"] .step-desc {
  color: rgba(255, 255, 255, 0.55);
}

.modal-divider {
  height: 1.5px;
  background: rgba(0, 0, 0, 0.1);
  margin: 1.2rem 0;
  border: none;
}

[data-scheme="dark"] .modal-divider {
  background: rgba(255, 255, 255, 0.12);
}

.modal-tip {
  font-size: .8rem;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.45);
  text-align: center;
  line-height: 1.5;
}

[data-scheme="dark"] .modal-tip {
  color: rgba(255, 255, 255, 0.38);
}

.timer-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.countdown-ring {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ring-bg {
  fill: none;
  stroke: rgba(0, 0, 0, 0.1);
  stroke-width: 4;
}

.ring-fill {
  fill: none;
  stroke: var(--logo);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 125.6;
  stroke-dashoffset: 0;
  transform: rotate(-90deg);
  transform-origin: center;
  transition: stroke .4s, stroke-dashoffset .9s linear;
}

.ring-fill.urgent {
  stroke: #e85d6a;
}

#timer-disp {
  position: absolute;
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--logo);
  line-height: 1;
}

#timer-disp.urgent {
  color: #e85d6a;
}

.timer-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.timer-detail {
  font-size: .72rem;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.4);
  letter-spacing: .5px;
}

.theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.theme-lbl {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: rgba(0, 0, 0, 0.4);
}

.theme-sel {
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-pill);
  padding: 7px 36px 7px 16px;
  font-family: var(--font);
  font-size: .85rem;
  font-weight: 700;
  background-color: rgba(255, 255, 255, 0.45);
  color: var(--ink);
  cursor: pointer;
  outline: none;
  backdrop-filter: blur(6px);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: calc(100% - 14px) center;
  background-size: 10px;
}

.action-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .55rem;
}

.btn {
  font-family: var(--font);
  font-weight: 700;
  font-size: clamp(12px, 1.3vw, 15px);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 13px 18px;
  border-radius: var(--radius-pill);
  border: 2px solid rgba(255, 255, 255, 0.75);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
  color: #fff;
}

.btn:hover {
  transform: scale(1.05) translateY(-1px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.20);
  border-color: rgba(255, 255, 255, 1);
}

.btn:active {
  transform: scale(0.97);
}

.bl {
  background: rgba(0, 0, 0, 0.22);
}

.br {
  background: rgba(232, 93, 106, 0.48);
}

.bw {
  background: rgba(255, 255, 255, 0.30);
  color: rgba(0, 0, 0, 0.72);
  border-color: rgba(255, 255, 255, 0.75);
}

.bc {
  background: rgba(255, 255, 255, 0.30);
  color: rgba(0, 0, 0, 0.72);
  border-color: rgba(255, 255, 255, 0.75);
}

.bsm {
  padding: 9px 16px;
  font-size: .78rem;
}

.cp {
  position: fixed;
  pointer-events: none;
  border-radius: 2px;
  z-index: 9999;
  animation: cfall linear forwards;
}

@keyframes cfall {
  0% {
    transform: translateY(-20px)rotate(0deg);
    opacity: 1;
  }

  100% {
    transform: translateY(110vh)rotate(800deg);
    opacity: 0;
  }
}

.action-btns button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* theme overrides */
[data-scheme="dark"] {
  --bg: #1a2810;
  --logo: #8ec44a;
  --ink: rgba(255, 255, 255, 0.88);
  --ink2: rgba(255, 255, 255, 0.5);
}

[data-scheme="dark"] body {
  background: #1a2810;
}

[data-scheme="dark"] .card {
  background: rgba(0, 0, 0, 0.28);
  border-color: rgba(255, 255, 255, 0.18);
}

[data-scheme="dark"] .name-input {
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
}

[data-scheme="dark"] .sec-lbl,
[data-scheme="dark"] .score-lbl,
[data-scheme="dark"] .theme-lbl {
  color: rgba(255, 255, 255, 0.45);
}

[data-scheme="dark"] #timer-disp {
  color: #8ec44a;
}

[data-scheme="dark"] .draw-num {
  color: rgba(255, 255, 255, 0.3);
}

[data-scheme="dark"] .theme-sel {
  background-color: #2a3d1a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: calc(100% - 14px) center;
  background-size: 10px;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

[data-scheme="dark"] .theme-sel option {
  background: #2a3d1a;
  color: #fff;
}

[data-scheme="dark"] .ring-bg {
  stroke: rgba(255, 255, 255, 0.15);
}

[data-scheme="dark"] .timer-detail {
  color: rgba(255, 255, 255, 0.4);
}

/* ── RESPONSIVE BREAKPOINTS ── */

/* ── 768px–1024px: iPads & tablets (portrait + landscape) ── */
@media(max-width:1024px) {
  .sidebar-card {
    height: auto;
  }

  .sec-block {
    flex: none;
  }

  header {
    padding: 18px 28px 14px;
    gap: 14px;
  }

  .btn-back {
    padding: 13px 28px;
    font-size: 16px;
    letter-spacing: 1px;
  }

  .btn-help {
    width: 52px;
    height: 52px;
    font-size: 1.5rem;
  }

  .header-logo-img {
    height: 52px;
  }

  .game-badge {
    font-size: 16px;
    padding: 13px 20px;
    letter-spacing: 1.8px;
  }

  .action-btns {
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
  }

  .btn {
    font-size: 15px;
    padding: 16px 20px;
    letter-spacing: 1.2px;
  }

  .modal-overlay {
    padding: 2rem;
  }

  .modal {
    max-width: 800px;
    width: 95%;
    padding: 4rem 4.2rem 3.8rem;
    border-radius: 40px;
  }

  .modal-header {
    margin-bottom: 2.4rem;
  }

  .modal-title {
    font-size: 2.2rem;
    letter-spacing: .5px;
  }

  .modal-close {
    width: 55px;
    height: 55px;
    font-size: 1.7rem;
    border-width: 2.5px;
  }

  .modal-steps {
    gap: 2rem;
  }

  .modal-step {
    gap: 1.6rem;
    align-items: center;
  }

  .step-num {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    font-size: 1.8rem;
    border-width: 2px;
  }

  .step-title {
    font-size: 1.3rem;
    margin-bottom: .4rem;
  }

  .step-desc {
    font-size: 1.1rem;
    line-height: 1.7;
  }

  .modal-tip {
    font-size: 1.1rem;
  }

  .modal-divider {
    margin: 2rem 0;
    height: 2px;
  }
}

@media(max-width:855px) {
  .app {
    padding: 90px 1rem 1.5rem;
  }

  .shell {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .card {
    padding: 1.4rem 1.2rem;
    border-radius: 24px;
  }

  header {
    padding: 12px 16px;
    gap: 10px;
  }

  .btn-back {
    padding: 10px 20px;
    font-size: 14px;
    letter-spacing: .8px;
  }

  .btn-help {
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
  }

  .header-logo-img {
    height: 42px;
  }

  .game-badge {
    font-size: 13px;
    padding: 10px 16px;
    letter-spacing: 1.2px;
  }

  .score-num,
  .draw-num {
    font-size: 2.2rem;
  }

  .score-lbl {
    font-size: .72rem;
  }

  .name-input {
    font-size: .82rem;
    padding: 7px 12px;
  }

  .btn-edit {
    width: 30px;
    height: 30px;
  }

  .timer-row {
    gap: .7rem;
    flex-wrap: wrap;
  }

  #btn-pause {
    margin-left: auto;
  }

  .action-btns {
    grid-template-columns: 1fr 1fr;
    gap: .6rem;
  }

  .btn {
    font-size: 13px;
    padding: 13px 16px;
    letter-spacing: 1px;
  }

  .modal-overlay {
    padding: 1.5rem;
  }

  .modal {
    max-width: 650px;
    width: 95%;
    padding: 2.8rem 3rem 2.4rem;
    border-radius: 32px;
  }

  .modal-header {
    margin-bottom: 1.8rem;
  }

  .modal-title {
    font-size: 1.8rem;
  }

  .modal-close {
    width: 46px;
    height: 46px;
    font-size: 1.4rem;
  }

  .modal-steps {
    gap: 1.4rem;
  }

  .modal-step {
    gap: 1.2rem;
    align-items: center;
  }

  .step-num {
    width: 48px;
    height: 48px;
    border-radius: 15px;
    font-size: 1.5rem;
  }

  .step-title {
    font-size: 1.08rem;
    margin-bottom: .3rem;
  }

  .step-desc {
    font-size: .95rem;
    line-height: 1.6;
  }

  .modal-tip {
    font-size: .95rem;
  }

  .modal-divider {
    margin: 1.6rem 0;
  }
}

/* ── ≤540px: large phones / small tablets ── */
@media(max-width:540px) {
  .modal-overlay {
    padding: 1rem;
  }

  .modal {
    max-width: 400px;
    width: 90%;
    padding: 1.7rem 1.9rem 1.5rem;
    border-radius: 26px;
  }

  .modal-header {
    margin-bottom: 1.2rem;
  }

  .modal-title {
    font-size: 1.1rem;
  }

  .modal-close {
    width: 35px;
    height: 35px;
    font-size: 1rem;
  }

  .modal-steps {
    gap: 1rem;
  }

  .modal-step {
    gap: 1rem;
    align-items: center;
  }

  .step-num {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    font-size: 1rem;
  }

  .step-title {
    font-size: .90rem;
    margin-bottom: .22rem;
  }

  .step-desc {
    font-size: .82rem;
    line-height: 1.3;
  }

  .modal-tip {
    font-size: .80rem;
  }

  .modal-divider {
    margin: 1rem 0;
  }
}

@media(max-width:480px) {
  .app {
    padding: 72px .75rem 1.2rem;
  }

  .card {
    padding: 1.1rem 1rem;
    border-radius: 20px;
  }

  header {
    padding: 8px 12px;
    gap: 6px;
  }

  .btn-back {
    padding: 7px 13px;
    font-size: 12px;
    letter-spacing: .5px;
  }

  .btn-help {
    width: 34px;
    height: 34px;
    font-size: .95rem;
  }

  .header-logo-img {
    height: 32px;
  }

  .game-badge {
    font-size: 12px;
    padding: 7px 13px;
    letter-spacing: 0.5px;
  }

  .score-num,
  .draw-num {
    font-size: 1.9rem;
  }

  .score-lbl {
    font-size: .68rem;
    letter-spacing: .4px;
  }

  .cell {
    border-radius: 14px;
    font-size: clamp(1.8rem, 10vw, 2.8rem);
  }

  .name-badge {
    width: 28px;
    height: 28px;
    font-size: .85rem;
    border-radius: 8px;
  }

  .name-input {
    font-size: .8rem;
    padding: 6px 10px;
  }

  .btn-edit {
    width: 28px;
    height: 28px;
  }

  .btn-edit svg {
    width: 13px;
    height: 13px;
  }

  .action-btns {
    grid-template-columns: 1fr 1fr;
    gap: .4rem;
  }

  .btn {
    font-size: 10.5px;
    padding: 10px 8px;
    letter-spacing: .8px;
  }

  .timer-detail {
    font-size: .68rem;
  }

  #btn-pause {
    padding: 7px 12px;
    font-size: .72rem;
  }

  .modal {
    padding: 1.5rem 1.2rem 1.4rem;
    border-radius: 22px;
  }

  .modal-title {
    font-size: 1.1rem;
  }

  .step-desc {
    font-size: .78rem;
  }

  .modal-tip {
    font-size: .75rem;
  }
}

/* ── ≤360px: small Android phones ── */
@media(max-width:360px) {
  .action-btns {
    grid-template-columns: 1fr;
  }

  .btn {
    font-size: 11px;
    padding: 11px 14px;
  }

  .score-num,
  .draw-num {
    font-size: 1.6rem;
  }

  .name-input {
    font-size: .75rem;
    padding: 5px 9px;
  }

  .game-badge {
    font-size: 12px;
    padding: 8px 12px;
    letter-spacing: 0.3px;
  }
}

/* ── ≤344px ── */
@media(max-width:344px) {
  .app {
    padding: 64px .5rem 1rem;
  }

  .card {
    padding: 1rem .9rem;
    border-radius: 18px;
    border-width: 1.5px;
  }

  header {
    padding: 7px 10px;
    gap: 5px;
  }

  .btn-back {
    padding: 6px 11px;
    font-size: 11px;
    letter-spacing: 0;
    gap: 4px;
  }

  .btn-help {
    width: 30px;
    height: 30px;
    font-size: .85rem;
  }

  .header-logo-img {
    height: 28px;
  }

  .game-badge {
    font-size: 11px;
    padding: 6px 11px;
    letter-spacing: 0.3px;
  }

  .score-grid {
    gap: 0;
  }

  .score-num,
  .draw-num {
    font-size: 1.45rem;
  }

  .score-lbl {
    font-size: .6rem;
    letter-spacing: 0;
  }

  #board {
    gap: 7px;
  }

  .cell {
    border-radius: 12px;
    font-size: clamp(1.5rem, 11vw, 2rem);
    border-width: 1.5px;
  }

  .name-rows {
    gap: .4rem;
  }

  .name-badge {
    width: 26px;
    height: 26px;
    font-size: .78rem;
    border-radius: 7px;
    border-width: 1.5px;
  }

  .name-input {
    font-size: .74rem;
    padding: 5px 9px;
  }

  .btn-edit {
    width: 26px;
    height: 26px;
    border-width: 1.5px;
  }

  .btn-edit svg {
    width: 11px;
    height: 11px;
  }

  .timer-row {
    gap: .5rem;
    flex-wrap: wrap;
  }

  .countdown-ring svg {
    width: 46px;
    height: 46px;
  }

  #timer-disp {
    font-size: .95rem;
  }

  .timer-detail {
    font-size: .62rem;
  }

  #btn-pause {
    padding: 6px 10px;
    font-size: .68rem;
  }

  .theme-lbl {
    font-size: .65rem;
  }

  .theme-sel {
    font-size: .75rem;
    padding: 5px 28px 5px 10px;
  }

  .action-btns {
    grid-template-columns: 1fr;
    gap: .38rem;
  }

  .btn {
    font-size: 10.5px;
    padding: 10px 12px;
    letter-spacing: .4px;
  }

  .sec-lbl {
    font-size: .78rem;
    letter-spacing: .8px;
    margin-bottom: .38rem;
  }

  .modal-overlay {
    padding: .75rem;
  }

  .modal {
    padding: 1.2rem 1rem 1.1rem;
    border-radius: 18px;
  }

  .modal-title {
    font-size: 1rem;
  }

  .step-num {
    width: 28px;
    height: 28px;
    font-size: .8rem;
  }

  .step-title {
    font-size: .88rem;
  }

  .step-desc {
    font-size: .74rem;
  }

  .modal-tip {
    font-size: .7rem;
  }

  .modal-steps {
    gap: .8rem;
  }

  .modal-step {
    gap: .7rem;
  }
}

/* ── ≤280px ── */
@media(max-width:280px) {
  .app {
    padding: 60px .4rem .9rem;
  }

  .card {
    padding: .8rem .7rem;
    border-radius: 14px;
  }

  header {
    padding: 5px 8px;
    gap: 4px;
  }

  .btn-back {
    padding: 5px 9px;
    font-size: 10px;
    letter-spacing: 0;
    gap: 3px;
  }

  .btn-help {
    width: 27px;
    height: 27px;
    font-size: .78rem;
    border-width: 1.5px;
  }

  .header-logo-img {
    height: 24px;
  }

  .game-badge {
    font-size: 10px;
    padding: 5px 9px;
    letter-spacing: 0;
  }

  .score-num,
  .draw-num {
    font-size: 1.25rem;
  }

  .score-lbl {
    font-size: .57rem;
  }

  #board {
    gap: 5px;
  }

  .cell {
    border-radius: 9px;
    font-size: clamp(1.2rem, 13vw, 1.8rem);
    border-width: 1.5px;
  }

  .name-badge {
    width: 22px;
    height: 22px;
    font-size: .7rem;
    border-radius: 5px;
    border-width: 1.5px;
  }

  .name-input {
    font-size: .67rem;
    padding: 4px 7px;
  }

  .btn-edit {
    width: 23px;
    height: 23px;
    border-width: 1.5px;
  }

  .btn-edit svg {
    width: 10px;
    height: 10px;
  }

  .timer-info {
    display: none;
  }

  .countdown-ring svg {
    width: 40px;
    height: 40px;
  }

  #timer-disp {
    font-size: .85rem;
  }

  #btn-pause {
    padding: 5px 8px;
    font-size: .65rem;
  }

  .action-btns {
    grid-template-columns: 1fr;
    gap: .32rem;
  }

  .btn {
    font-size: 9.5px;
    padding: 8px 10px;
    letter-spacing: 0;
  }

  .sec-block {
    padding: .65rem 0;
  }

  .sec-lbl {
    font-size: .7rem;
    letter-spacing: .5px;
    margin-bottom: .3rem;
  }

  .theme-sel {
    font-size: .68rem;
    padding: 4px 22px 4px 8px;
  }

  .modal {
    padding: 1rem .85rem 1rem;
  }

  .modal-title {
    font-size: .9rem;
  }

  .step-desc {
    font-size: .67rem;
  }

  .modal-steps {
    gap: .6rem;
  }
}