:root {
  --bg: #fbf7ee;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-solid: #ffffff;
  --text: #1f2328;
  --muted: rgba(31, 35, 40, 0.68);

  --bg-accent-1: rgba(244, 185, 95, 0.35);
  --bg-accent-2: rgba(255, 122, 89, 0.22);
  --bg-accent-3: rgba(79, 166, 255, 0.16);

  --brand: #f4b95f;
  --brand-2: #ff7a59;

  --shadow: 0 12px 35px rgba(0, 0, 0, 0.12);
  --border: rgba(0, 0, 0, 0.08);

  --board-bg: rgba(57, 47, 39, 0.15);
  --cell-bg: rgba(255, 255, 255, 0.55);

  --gap: 12px;
  --radius: 18px;
  --board-size: min(92vw, 440px);

  --tile-text-dark: #2f2a27;
  --tile-text-light: #ffffff;

  --tile-2-bg: rgba(255, 255, 255, 0.75);
  --tile-2-fg: var(--tile-text-dark);
  --tile-4-bg: rgba(255, 236, 211, 0.92);
  --tile-4-fg: var(--tile-text-dark);
  --tile-8-bg: rgba(255, 192, 131, 0.92);
  --tile-8-fg: var(--tile-text-dark);
  --tile-16-bg: rgba(255, 160, 107, 0.92);
  --tile-16-fg: var(--tile-text-dark);
  --tile-32-bg: rgba(255, 122, 89, 0.92);
  --tile-32-fg: var(--tile-text-light);
  --tile-64-bg: rgba(255, 92, 92, 0.92);
  --tile-64-fg: var(--tile-text-light);
  --tile-128-bg: rgba(244, 185, 95, 0.92);
  --tile-128-fg: var(--tile-text-dark);
  --tile-256-bg: rgba(240, 210, 82, 0.92);
  --tile-256-fg: var(--tile-text-dark);
  --tile-512-bg: rgba(173, 237, 140, 0.92);
  --tile-512-fg: var(--tile-text-dark);
  --tile-1024-bg: rgba(79, 166, 255, 0.92);
  --tile-1024-fg: var(--tile-text-light);
  --tile-2048-bg: rgba(167, 139, 250, 0.92);
  --tile-2048-fg: var(--tile-text-light);
  --tile-super-bg: linear-gradient(135deg, rgba(255, 215, 0, 0.92), rgba(255, 122, 89, 0.75));
  --tile-super-fg: #0b0b12;
}

html[data-theme="ocean"] {
  --bg: #071b2d;
  --panel: rgba(10, 30, 48, 0.78);
  --panel-solid: #0b2236;
  --text: #e8f3ff;
  --muted: rgba(232, 243, 255, 0.72);

  --bg-accent-1: rgba(53, 208, 186, 0.22);
  --bg-accent-2: rgba(79, 166, 255, 0.16);
  --bg-accent-3: rgba(255, 255, 255, 0.08);

  --brand: #35d0ba;
  --brand-2: #4fa6ff;

  --board-bg: rgba(79, 166, 255, 0.18);
  --cell-bg: rgba(232, 243, 255, 0.12);

  --tile-2-bg: rgba(224, 251, 252, 0.92);
  --tile-2-fg: var(--tile-text-dark);
  --tile-4-bg: rgba(186, 244, 233, 0.92);
  --tile-4-fg: var(--tile-text-dark);
  --tile-8-bg: rgba(83, 214, 203, 0.92);
  --tile-8-fg: var(--tile-text-dark);
  --tile-16-bg: rgba(53, 208, 186, 0.92);
  --tile-16-fg: var(--tile-text-dark);
  --tile-32-bg: rgba(79, 166, 255, 0.92);
  --tile-32-fg: var(--tile-text-light);
  --tile-64-bg: rgba(52, 118, 213, 0.92);
  --tile-64-fg: var(--tile-text-light);
  --tile-128-bg: rgba(113, 79, 255, 0.92);
  --tile-128-fg: var(--tile-text-light);
  --tile-256-bg: rgba(167, 139, 250, 0.92);
  --tile-256-fg: var(--tile-text-light);
  --tile-512-bg: rgba(255, 122, 89, 0.88);
  --tile-512-fg: var(--tile-text-light);
  --tile-1024-bg: rgba(244, 185, 95, 0.90);
  --tile-1024-fg: var(--tile-text-dark);
  --tile-2048-bg: rgba(240, 210, 82, 0.92);
  --tile-2048-fg: var(--tile-text-dark);
  --tile-super-bg: linear-gradient(135deg, rgba(53, 208, 186, 0.92), rgba(79, 166, 255, 0.92));
  --tile-super-fg: var(--tile-text-light);
}

html[data-theme="midnight"] {
  --bg: #0b0b12;
  --panel: rgba(22, 22, 36, 0.78);
  --panel-solid: #151527;
  --text: #f2f3ff;
  --muted: rgba(242, 243, 255, 0.68);

  --bg-accent-1: rgba(167, 139, 250, 0.22);
  --bg-accent-2: rgba(96, 165, 250, 0.16);
  --bg-accent-3: rgba(255, 122, 89, 0.08);

  --brand: #a78bfa;
  --brand-2: #60a5fa;

  --board-bg: rgba(167, 139, 250, 0.18);
  --cell-bg: rgba(242, 243, 255, 0.11);

  --tile-2-bg: rgba(231, 233, 255, 0.78);
  --tile-2-fg: var(--tile-text-dark);
  --tile-4-bg: rgba(200, 205, 255, 0.80);
  --tile-4-fg: var(--tile-text-dark);
  --tile-8-bg: rgba(167, 139, 250, 0.92);
  --tile-8-fg: var(--tile-text-light);
  --tile-16-bg: rgba(129, 140, 248, 0.92);
  --tile-16-fg: var(--tile-text-light);
  --tile-32-bg: rgba(96, 165, 250, 0.92);
  --tile-32-fg: var(--tile-text-dark);
  --tile-64-bg: rgba(59, 130, 246, 0.92);
  --tile-64-fg: var(--tile-text-light);
  --tile-128-bg: rgba(236, 72, 153, 0.90);
  --tile-128-fg: var(--tile-text-light);
  --tile-256-bg: rgba(244, 63, 94, 0.90);
  --tile-256-fg: var(--tile-text-light);
  --tile-512-bg: rgba(255, 122, 89, 0.86);
  --tile-512-fg: var(--tile-text-light);
  --tile-1024-bg: rgba(244, 185, 95, 0.88);
  --tile-1024-fg: var(--tile-text-dark);
  --tile-2048-bg: rgba(240, 210, 82, 0.92);
  --tile-2048-fg: var(--tile-text-dark);
  --tile-super-bg: linear-gradient(135deg, rgba(167, 139, 250, 0.92), rgba(236, 72, 153, 0.90));
  --tile-super-fg: var(--tile-text-light);
}

html[data-theme="retro"] {
  --bg: #d8d7d2;
  --panel: rgba(245, 245, 242, 0.84);
  --panel-solid: #f5f5f2;
  --text: #101114;
  --muted: rgba(16, 17, 20, 0.68);

  --bg-accent-1: rgba(229, 57, 53, 0.18);
  --bg-accent-2: rgba(33, 33, 33, 0.12);
  --bg-accent-3: rgba(25, 118, 210, 0.12);

  --brand: #e53935;
  --brand-2: #2f2f33;

  --shadow: 0 12px 35px rgba(0, 0, 0, 0.14);
  --border: rgba(0, 0, 0, 0.16);

  --board-bg: rgba(16, 17, 20, 0.12);
  --cell-bg: rgba(255, 255, 255, 0.62);

  --tile-2-bg: rgba(249, 230, 90, 0.96);
  --tile-2-fg: var(--tile-text-dark);
  --tile-4-bg: rgba(185, 242, 124, 0.96);
  --tile-4-fg: var(--tile-text-dark);
  --tile-8-bg: rgba(82, 212, 106, 0.96);
  --tile-8-fg: var(--tile-text-dark);
  --tile-16-bg: rgba(79, 233, 217, 0.96);
  --tile-16-fg: var(--tile-text-dark);
  --tile-32-bg: rgba(74, 163, 255, 0.96);
  --tile-32-fg: var(--tile-text-light);
  --tile-64-bg: rgba(62, 79, 219, 0.96);
  --tile-64-fg: var(--tile-text-light);
  --tile-128-bg: rgba(139, 76, 255, 0.96);
  --tile-128-fg: var(--tile-text-light);
  --tile-256-bg: rgba(58, 58, 61, 0.96);
  --tile-256-fg: var(--tile-text-light);
  --tile-512-bg: rgba(43, 43, 47, 0.96);
  --tile-512-fg: var(--tile-text-light);
  --tile-1024-bg: rgba(31, 31, 35, 0.96);
  --tile-1024-fg: var(--tile-text-light);
  --tile-2048-bg: rgba(17, 17, 20, 0.96);
  --tile-2048-fg: var(--tile-text-light);
  --tile-super-bg: linear-gradient(135deg, rgba(17, 17, 20, 0.96), rgba(58, 58, 61, 0.96));
  --tile-super-fg: var(--tile-text-light);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji",
    "Segoe UI Emoji";
  color: var(--text);
  background-color: var(--bg);
  background-image: radial-gradient(1200px 700px at 20% 10%, var(--bg-accent-1), transparent 55%),
    radial-gradient(900px 600px at 85% 20%, var(--bg-accent-2), transparent 55%),
    radial-gradient(1100px 650px at 40% 95%, var(--bg-accent-3), transparent 55%);
  background-attachment: fixed;
  background-size: 100% 100%;
  min-height: 100%;
}

a {
  color: inherit;
  text-decoration-thickness: 0.1em;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 0.14em;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--panel-solid);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.topbar-nav {
  display: none;
  align-items: center;
  gap: 24px;
}

.topbar-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: color 0.2s;
}

.topbar-link:hover {
  color: var(--accent);
}

.topbar-theme-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid var(--border);
}

.topbar-theme-select .select-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.topbar-theme-select select {
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
}

.language-dropdown {
  position: relative;
}

.language-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.language-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.language-btn .flag {
  font-size: 1.1rem;
  line-height: 1;
}

.language-btn .language-text {
  font-size: 0.85rem;
}

.language-btn svg {
  width: 14px;
  height: 14px;
  opacity: 0.7;
}

.language-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  overflow: hidden;
}

.language-dropdown:hover .language-menu,
.language-dropdown:focus-within .language-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.language-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.language-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.language-item .flag {
  font-size: 1.2rem;
  line-height: 1;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 820;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(244, 185, 95, 0.7), rgba(255, 122, 89, 0.45));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.15);
}

.menu-toggle {
  appearance: none;
  border: 0;
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}

.menu-toggle:hover {
  background: rgba(255, 255, 255, 0.32);
}

.mobile-menu {
  position: fixed;
  top: 0;
  right: -100%;
  width: min(320px, 85vw);
  height: 100vh;
  background: var(--panel-solid);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.3);
  z-index: 100;
  transition: right 0.3s ease;
  overflow-y: auto;
}

.mobile-menu.open {
  right: 0;
}

.mobile-menu-content {
  padding: 20px;
}

.menu-close {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 8px;
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  margin-bottom: 20px;
}

.menu-section {
  margin-bottom: 24px;
}

.menu-heading {
  margin: 0 0 12px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.menu-item {
  display: block;
  padding: 12px 14px;
  margin-bottom: 6px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  transition: background 0.2s;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.14);
}

.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.menu-select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  outline: none;
}

.layout {
  width: min(1100px, calc(100% - 24px));
  margin: 18px auto 28px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.headline {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.headline h1 {
  margin: 0;
  font-size: clamp(1.35rem, 3.8vw, 2rem);
  letter-spacing: -0.03em;
}

.subhead {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.game-panel {
  display: grid;
  gap: 14px;
  align-content: start;
}

.hud {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.hud-mobile-mode {
  display: none;
}

.leaderboard-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.leaderboard-modal.open {
  display: flex;
}

.leaderboard-modal-content {
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  background: var(--panel-solid);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  overflow-y: auto;
  padding: 20px;
}

.leaderboard-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.leaderboard-modal-title {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.leaderboard-modal-close {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 8px;
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}

.scores {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.score-box {
  padding: 14px 14px 12px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.score-label {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.score-value {
  font-size: 1.55rem;
  font-weight: 860;
  margin-top: 6px;
}

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

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 750;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #151515;
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.18);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.28);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: none;
}

.select {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid var(--border);
}

.select-label {
  font-size: 0.9rem;
  color: var(--muted);
}

.select-mobile {
  width: 100%;
  justify-content: space-between;
}

.text-input {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 12px;
  outline: none;
}

.text-input.input-highlight {
  border-color: rgba(244, 185, 95, 0.9);
  box-shadow: 0 0 0 4px rgba(244, 185, 95, 0.22);
}

.text-input::placeholder {
  color: var(--muted);
}

.leaderboard {
  display: grid;
  gap: 10px;
}

.leaderboards {
  display: grid;
  gap: 12px;
}

.leaderboard-block {
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.14);
}

.leaderboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.leaderboard-title {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -0.02em;
}


.leaderboard-status {
  min-height: 1.1em;
  color: var(--muted);
  font-size: 0.95rem;
}

.leaderboard-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
  line-height: 1.55;
}

.leaderboard-list li {
  padding: 6px 0;
}

.mode-status {
  margin: 0;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.18);
  color: var(--muted);
  font-weight: 650;
}

.highscore-notice {
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(244, 185, 95, 0.85), rgba(255, 122, 89, 0.75));
  color: #2f1b00;
  font-weight: 700;
  box-shadow: 0 12px 25px rgba(0, 0, 0, 0.15);
  display: none;
}

.highscore-notice.visible {
  display: block;
  animation: notice-pop 0.4s ease;
}

@keyframes notice-pop {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.leaderboard-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.leaderboard-name {
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-flag {
  display: inline-block;
  margin-right: 8px;
  transform: translateY(1px);
}

.leaderboard-score {
  color: var(--muted);
  font-weight: 800;
}

select {
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: none;
  padding: 6px 6px;
}

.board-wrap {
  position: relative;
  display: grid;
  justify-content: center;
}

.confetti-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: calc(var(--radius) + 8px);
}

.board {
  width: var(--board-size);
  aspect-ratio: 1;
  padding: var(--gap);
  border-radius: calc(var(--radius) + 8px);
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);

  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: var(--gap);

  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.cell {
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--cell-bg);
  font-weight: 900;
  font-size: clamp(1.1rem, 5.8vw, 2.25rem);
  letter-spacing: -0.02em;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.cell.empty {
  color: transparent;
}

.tile-2 {
  background: var(--tile-2-bg);
  color: var(--tile-2-fg);
}

.tile-4 {
  background: var(--tile-4-bg);
  color: var(--tile-4-fg);
}

.tile-8 {
  background: var(--tile-8-bg);
  color: var(--tile-8-fg);
}

.tile-16 {
  background: var(--tile-16-bg);
  color: var(--tile-16-fg);
}

.tile-32 {
  background: var(--tile-32-bg);
  color: var(--tile-32-fg);
}

.tile-64 {
  background: var(--tile-64-bg);
  color: var(--tile-64-fg);
}

.tile-128 {
  background: var(--tile-128-bg);
  color: var(--tile-128-fg);
  font-size: clamp(1rem, 5.1vw, 2rem);
}

.tile-256 {
  background: var(--tile-256-bg);
  color: var(--tile-256-fg);
  font-size: clamp(0.95rem, 4.7vw, 1.9rem);
}

.tile-512 {
  background: var(--tile-512-bg);
  color: var(--tile-512-fg);
  font-size: clamp(0.9rem, 4.3vw, 1.75rem);
}

.tile-1024 {
  background: var(--tile-1024-bg);
  color: var(--tile-1024-fg);
  font-size: clamp(0.85rem, 4vw, 1.6rem);
}

.tile-2048 {
  background: var(--tile-2048-bg);
  color: var(--tile-2048-fg);
  font-size: clamp(0.85rem, 4vw, 1.6rem);
}

.tile-super {
  background: var(--tile-super-bg);
  color: var(--tile-super-fg);
  font-size: clamp(0.8rem, 3.7vw, 1.5rem);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.22);
  border-radius: calc(var(--radius) + 8px);
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  width: min(360px, 92%);
  border-radius: 20px;
  background: var(--panel-solid);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  padding: 16px;
}

.overlay-title {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
}

.overlay-text {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.overlay-leaderboard-prompt {
  margin: 16px 0;
  padding: 16px;
  border-radius: 12px;
  background: rgba(244, 185, 95, 0.12);
  border: 1px solid rgba(244, 185, 95, 0.3);
}

.overlay-leaderboard-prompt.hidden {
  display: none;
}

.overlay-rank-text {
  margin: 0 0 12px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}

.overlay-name-input {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.28);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  outline: none;
  margin-bottom: 12px;
}

.overlay-name-input:focus {
  border-color: rgba(244, 185, 95, 0.9);
  box-shadow: 0 0 0 3px rgba(244, 185, 95, 0.18);
}

.overlay-name-input::placeholder {
  color: var(--muted);
}

.overlay-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.mini-info {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-pill {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 650;
  font-size: 0.9rem;
}

.sidebar {
  display: grid;
  gap: 14px;
  align-content: start;
}

.card {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 10px;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.card p {
  margin: 10px 0 0;
  line-height: 1.55;
  color: var(--muted);
}

.ad-slot {
  min-height: 250px;
  border-radius: var(--radius);
  border: 1px dashed rgba(0, 0, 0, 0.2);
  background: #f0f0f0;
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.desktop-ad {
  display: block;
}

.mobile-ad {
  display: none;
}

@media (max-width: 900px) {
  .desktop-ad {
    display: none;
  }
  
  .mobile-ad {
    display: block;
  }
}

.multiplex-ad {
  min-height: 400px;
  margin: 24px 0;
  display: block;
  clear: both;
}

.content {
  display: grid;
  gap: 14px;
  align-content: start;
}

.checklist {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.footer {
  width: min(1100px, calc(100% - 24px));
  margin: 0 auto 30px;
  padding: 16px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid var(--border);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  color: var(--muted);
}

.footer-sep {
  opacity: 0.6;
}

.mobile-toolbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 25;
  display: none;
  padding: 10px;
  background: var(--panel-solid);
  border-top: 1px solid var(--border);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(10px);
  gap: 8px;
  grid-template-columns: repeat(4, 1fr);
}

.toolbar-btn {
  flex: 1;
  border: 0;
  background: transparent;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
}

.toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.toolbar-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.toolbar-btn svg {
  flex-shrink: 0;
}

.desktop-ad {
  display: block;
}

.mobile-ad {
  display: none;
  width: min(1100px, calc(100% - 24px));
  margin: 0 auto 18px;
}

@media (min-width: 980px) {
  .layout {
    grid-template-columns: 1fr 340px;
    align-items: start;
  }

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

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

@media (max-width: 780px) {
  .menu-toggle {
    display: flex;
  }

  .headline {
    display: none;
  }

  .controls {
    display: none;
  }

  .mini-info {
    display: none;
  }

  .mode-status {
    display: none;
  }

  .highscore-notice {
    display: none;
  }

  .sidebar {
    display: none;
  }

  .desktop-ad {
    display: none;
  }

  .mobile-ad {
    display: block;
    margin-bottom: 80px;
  }

  .mobile-toolbar {
    display: grid;
  }

  .footer {
    margin-bottom: 80px;
  }

  .layout {
    margin: 12px auto 12px;
  }

  .game-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .hud {
    gap: 10px;
  }

  .scores {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .board-wrap {
    margin-top: 8px;
  }

  .hud-mobile-mode {
    display: flex;
  }
}

@media (min-width: 781px) {
  .menu-toggle {
    display: none;
  }

  .mobile-menu {
    display: none;
  }

  .topbar-nav {
    display: flex;
  }
}
