:root {
  --bg: #08131f;
  --panel-border: rgba(122, 182, 222, 0.26);
  --panel-highlight: rgba(182, 234, 255, 0.12);
  --text: #ebf7ff;
  --muted: #90b1c3;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  --button: linear-gradient(180deg, rgba(30, 61, 87, 0.98), rgba(11, 29, 43, 0.98));
  --button-hover: linear-gradient(180deg, rgba(42, 80, 110, 0.98), rgba(16, 36, 53, 0.98));
  --button-border: rgba(113, 174, 214, 0.38);
  --snake: #3de08b;
  --snake-deep: #13824b;
  --snake-scale: #8effbd;
  --head: #1db46c;
  --head-top: #a7ffcb;
  --food: #ff8f2b;
  --food-deep: #d94e1c;
  --food-stem: #7dc86f;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: 12px;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 18%, rgba(53, 150, 220, 0.18), transparent 28%),
    radial-gradient(circle at 84% 22%, rgba(0, 222, 163, 0.12), transparent 24%),
    radial-gradient(circle at 50% 100%, rgba(255, 146, 43, 0.12), transparent 30%),
    linear-gradient(180deg, #07111c 0%, #091828 55%, #07111b 100%);
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  opacity: 0.45;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(110, 188, 230, 0.34) rgba(7, 20, 31, 0.56);
}

*::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

*::-webkit-scrollbar-track {
  background:
    linear-gradient(180deg, rgba(8, 22, 33, 0.88), rgba(4, 13, 21, 0.92));
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  background:
    linear-gradient(180deg, rgba(89, 164, 209, 0.72), rgba(38, 98, 136, 0.82));
  border: 2px solid rgba(6, 18, 27, 0.9);
  border-radius: 999px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 0 12px rgba(58, 146, 199, 0.18);
}

*::-webkit-scrollbar-thumb:hover {
  background:
    linear-gradient(180deg, rgba(114, 193, 241, 0.84), rgba(48, 122, 168, 0.9));
}

*::-webkit-scrollbar-corner {
  background: rgba(6, 18, 27, 0.9);
}

.app-shell {
  width: min(98vw, 1460px);
  height: calc(100dvh - 24px);
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  gap: 18px;
}

.sidebar,
.stage,
.panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 16%),
    linear-gradient(180deg, rgba(10, 27, 41, 0.98), rgba(4, 14, 24, 0.98));
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(18px);
}

.sidebar::before,
.stage::before,
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 var(--panel-highlight), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  pointer-events: none;
}

.sidebar {
  border-radius: 24px;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 0;
}

.sidebar-brand {
  display: grid;
  gap: 8px;
}

.sidebar-kicker,
.stage-kicker {
  margin: 0;
  font-size: 15px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: #79cfff;
}

.sidebar-title {
  margin: 0;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.hall-title {
  font-size: 42px;
  line-height: 0.94;
  letter-spacing: 1.4px;
  text-shadow: 0 16px 32px rgba(0, 0, 0, 0.28);
}

.sidebar-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 12px;
}

.game-nav {
  display: grid;
  gap: 12px;
  overflow: auto;
  padding-right: 4px;
}

.game-nav-item {
  width: 100%;
  text-align: left;
  padding: 13px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(20, 46, 67, 0.96), rgba(8, 22, 34, 0.96));
  border: 1px solid rgba(108, 168, 206, 0.16);
  color: var(--text);
  display: grid;
  gap: 8px;
}

.game-nav-item.active {
  border-color: rgba(95, 214, 160, 0.52);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 16px 28px rgba(0, 0, 0, 0.26);
}

.game-nav-name {
  font-size: 16px;
  font-weight: 700;
}

.game-nav-summary {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.stage {
  border-radius: 28px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.topbar {
  margin-bottom: 14px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.title {
  margin: 4px 0 0;
  font-size: 26px;
  line-height: 1.08;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  text-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.stage-title {
  font-size: 22px;
  line-height: 1.08;
  letter-spacing: 0.3px;
}

.subtitle {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.2px;
}

.stage-tag {
  align-self: start;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #d7f6ff;
  border: 1px solid rgba(125, 201, 243, 0.22);
  background: linear-gradient(180deg, rgba(50, 106, 144, 0.26), rgba(18, 42, 60, 0.3));
}

.game-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  min-width: 0;
  overflow: hidden;
}

.panel {
  border-radius: 24px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  scrollbar-gutter: stable;
}

.stats {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.stat-card {
  flex: 1;
  min-width: 120px;
  border: 1px solid rgba(125, 184, 220, 0.16);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(170, 228, 255, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(12, 28, 42, 0.86);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  padding: 12px 14px;
  display: grid;
  gap: 7px;
}

.label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.stat-card strong {
  font-size: 24px;
  line-height: 1;
}

.status-badge {
  justify-self: start;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(48, 203, 122, 0.22), rgba(16, 93, 57, 0.24));
  color: #cffff1;
  font-size: 13px;
  padding: 7px 12px;
  border: 1px solid rgba(89, 222, 149, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

body[data-status="paused"] .status-badge {
  background: linear-gradient(180deg, rgba(255, 190, 80, 0.2), rgba(121, 80, 22, 0.28));
  color: #ffe8b0;
  border-color: rgba(255, 199, 97, 0.26);
}

body[data-status="gameover"] .status-badge {
  background: linear-gradient(180deg, rgba(255, 111, 87, 0.22), rgba(126, 34, 26, 0.32));
  color: #ffd0c8;
  border-color: rgba(255, 135, 116, 0.28);
}

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

button {
  border: 1px solid var(--button-border);
  border-radius: 14px;
  background: var(--button);
  color: var(--text);
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 10px 22px rgba(0, 0, 0, 0.22);
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

button:hover {
  background: var(--button-hover);
  border-color: rgba(145, 210, 245, 0.52);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 14px 28px rgba(0, 0, 0, 0.28);
}

button:active {
  transform: translateY(1px) scale(0.99);
}

.board-area {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px 0 6px;
  padding: 8px;
  border-radius: 30px;
  background:
    linear-gradient(180deg, rgba(136, 214, 255, 0.05), rgba(255, 255, 255, 0.015)),
    rgba(5, 16, 26, 0.54);
  border: 1px solid rgba(126, 191, 226, 0.12);
}

.board {
  display: grid;
  grid-template-columns: repeat(var(--grid-width), 1fr);
  grid-template-rows: repeat(var(--grid-height), 1fr);
  gap: 2px;
  padding: 10px;
  border: 1px solid rgba(136, 206, 240, 0.16);
  border-radius: 26px;
  overflow: hidden;
  background:
    radial-gradient(circle at top, rgba(49, 115, 152, 0.18), transparent 38%),
    linear-gradient(180deg, rgba(15, 38, 56, 0.96), rgba(6, 20, 31, 0.98));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 0 0 1px rgba(255, 255, 255, 0.02),
    0 16px 38px rgba(0, 0, 0, 0.34);
  position: relative;
}

.board::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 26%),
    radial-gradient(circle at 50% 0%, rgba(110, 203, 255, 0.08), transparent 40%);
  pointer-events: none;
}

.cell {
  border-radius: clamp(3px, 0.42vw, 9px);
  background: linear-gradient(180deg, rgba(19, 45, 64, 0.86), rgba(10, 24, 36, 0.94));
}

.cell.snake {
  background:
    radial-gradient(circle at 28% 24%, rgba(226, 255, 240, 0.46), transparent 24%),
    linear-gradient(135deg, var(--snake-scale), var(--snake) 48%, var(--snake-deep) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    inset 0 -2px 4px rgba(4, 43, 24, 0.24);
}

.cell.head {
  background:
    radial-gradient(circle at 30% 36%, #ffffff 0 9%, transparent 10%),
    radial-gradient(circle at 68% 36%, #ffffff 0 9%, transparent 10%),
    radial-gradient(circle at 30% 36%, #112217 0 4%, transparent 5%),
    radial-gradient(circle at 68% 36%, #112217 0 4%, transparent 5%),
    radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.32), transparent 22%),
    linear-gradient(180deg, var(--head-top), var(--head) 48%, #0f673c 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    inset 0 -2px 4px rgba(5, 52, 29, 0.28);
}

.cell.food {
  background:
    linear-gradient(78deg, transparent 0 58%, var(--food-stem) 59% 63%, transparent 64%),
    radial-gradient(circle at 34% 26%, rgba(255, 250, 224, 0.72), transparent 20%),
    linear-gradient(160deg, #ffc65e, var(--food) 42%, var(--food-deep) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 245, 214, 0.38),
    inset 0 -2px 4px rgba(118, 36, 10, 0.24);
}

.controls {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 88px));
  gap: 9px;
  max-width: 282px;
}

.controls button {
  min-height: 44px;
}

.controls .empty {
  visibility: hidden;
}

.help {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  letter-spacing: 0.2px;
}

.reaction-stage {
  flex: 1;
  min-height: 280px;
  position: relative;
  border-radius: 28px;
  border: 1px solid rgba(126, 191, 226, 0.12);
  background:
    radial-gradient(circle at 50% 20%, rgba(74, 176, 224, 0.14), transparent 26%),
    linear-gradient(180deg, rgba(11, 27, 41, 0.96), rgba(5, 17, 27, 0.98));
  overflow: hidden;
}

.reaction-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

.reaction-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  text-align: center;
  padding: 24px;
  background: rgba(3, 10, 18, 0.38);
  color: var(--text);
}

.reaction-overlay strong {
  font-size: 28px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.reaction-target {
  font-size: 18px;
}

.reaction-overlay span {
  color: var(--muted);
  line-height: 1.5;
}

.reaction-target {
  position: absolute;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 1px solid rgba(255, 204, 126, 0.38);
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 250, 224, 0.8), transparent 24%),
    linear-gradient(180deg, rgba(255, 202, 96, 0.98), rgba(225, 94, 28, 0.98));
  color: #2d1308;
  box-shadow:
    0 14px 30px rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.hidden {
  display: none;
}

.memory-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 4px;
  max-width: 820px;
  width: 100%;
  align-self: center;
}

.memory-card {
  position: relative;
  aspect-ratio: 0.86;
  border-radius: 20px;
  border: 1px solid rgba(136, 206, 240, 0.16);
  background:
    linear-gradient(180deg, rgba(36, 76, 104, 0.92), rgba(10, 27, 40, 0.98));
  overflow: hidden;
  transform-style: preserve-3d;
}

.memory-card.revealed,
.memory-card.matched {
  color: #f5fffb;
}

.memory-card.matched {
  border-color: rgba(112, 229, 163, 0.42);
}

.memory-card[data-tone="aurora"].revealed,
.memory-card[data-tone="aurora"].matched {
  background:
    linear-gradient(180deg, rgba(84, 201, 156, 0.96), rgba(17, 93, 70, 0.98));
}

.memory-card[data-tone="ember"].revealed,
.memory-card[data-tone="ember"].matched {
  background:
    linear-gradient(180deg, rgba(255, 172, 84, 0.96), rgba(154, 69, 22, 0.98));
}

.memory-card[data-tone="tidal"].revealed,
.memory-card[data-tone="tidal"].matched {
  background:
    linear-gradient(180deg, rgba(89, 191, 232, 0.96), rgba(23, 89, 130, 0.98));
}

.memory-card[data-tone="violet"].revealed,
.memory-card[data-tone="violet"].matched {
  background:
    linear-gradient(180deg, rgba(175, 129, 255, 0.96), rgba(79, 41, 141, 0.98));
}

.memory-card-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(26px, 3vw, 38px);
  font-weight: 800;
  letter-spacing: 1px;
}

.memory-card-front {
  color: rgba(217, 240, 255, 0.88);
}

.memory-card-back {
  opacity: 0;
  color: #f4fff9;
}

.memory-card.revealed .memory-card-front,
.memory-card.matched .memory-card-front {
  opacity: 0;
}

.memory-card.revealed .memory-card-back,
.memory-card.matched .memory-card-back {
  opacity: 1;
}

.lights-wrap {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 10px 0 2px;
}

.lights-grid {
  width: min(100%, 480px);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.light-tile {
  aspect-ratio: 1;
  border-radius: 18px;
  border: 1px solid rgba(133, 197, 230, 0.14);
  background:
    linear-gradient(180deg, rgba(26, 53, 74, 0.95), rgba(8, 22, 34, 0.98));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 12px 24px rgba(0, 0, 0, 0.22);
}

.light-tile.lit {
  border-color: rgba(255, 197, 96, 0.42);
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 249, 211, 0.88), transparent 24%),
    linear-gradient(180deg, rgba(255, 191, 77, 0.98), rgba(219, 112, 30, 0.98));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 0 20px rgba(255, 165, 58, 0.25);
}

.minesweeper-wrap {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 8px 0 4px;
}

.minesweeper-board {
  display: grid;
  grid-template-columns: repeat(20, minmax(0, 30px));
  gap: 4px;
}

.mine-cell {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 9px;
  border: 1px solid rgba(133, 197, 230, 0.14);
  background:
    linear-gradient(180deg, rgba(26, 53, 74, 0.95), rgba(8, 22, 34, 0.98));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 10px 18px rgba(0, 0, 0, 0.2);
  font-size: 14px;
  font-weight: 800;
}

.mine-cell.revealed {
  background:
    linear-gradient(180deg, rgba(228, 241, 249, 0.95), rgba(185, 207, 221, 0.92));
  color: #173243;
}

.mine-cell.mine {
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 225, 220, 0.72), transparent 24%),
    linear-gradient(180deg, rgba(255, 123, 98, 0.95), rgba(152, 34, 25, 0.96));
  color: #fff3ef;
}

.mine-cell.flagged {
  background:
    linear-gradient(180deg, rgba(255, 205, 106, 0.96), rgba(194, 102, 34, 0.96));
  color: #2c1508;
}

.mine-cell[data-value="1"] {
  color: #265bc4;
}

.mine-cell[data-value="2"] {
  color: #0c8f52;
}

.mine-cell[data-value="3"] {
  color: #ca4a2a;
}

.mine-cell[data-value="4"] {
  color: #6d44d5;
}

.mine-cell[data-value="5"] {
  color: #a03232;
}

.mine-cell[data-value="6"] {
  color: #126f86;
}

.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 6px;
  max-width: 720px;
  width: 100%;
  margin: 4px auto 0;
  padding: 10px;
  border-radius: 24px;
  border: 1px solid rgba(136, 206, 240, 0.16);
  background:
    radial-gradient(circle at top, rgba(49, 115, 152, 0.18), transparent 38%),
    linear-gradient(180deg, rgba(15, 38, 56, 0.96), rgba(6, 20, 31, 0.98));
  flex-shrink: 0;
}

.sudoku-cell {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1px solid rgba(133, 197, 230, 0.14);
  background:
    linear-gradient(180deg, rgba(24, 50, 70, 0.94), rgba(9, 24, 36, 0.98));
  color: var(--text);
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  outline: none;
}

.sudoku-cell.given {
  background:
    linear-gradient(180deg, rgba(58, 108, 147, 0.9), rgba(21, 52, 76, 0.96));
  color: #f2fbff;
}

.sudoku-cell.invalid {
  border-color: rgba(255, 118, 97, 0.42);
  background:
    linear-gradient(180deg, rgba(120, 35, 31, 0.94), rgba(63, 19, 18, 0.98));
}

.link-board {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 4px;
  max-width: 940px;
  width: 100%;
  margin: 6px auto 0;
  flex-shrink: 0;
}

.link-tile {
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1px solid rgba(133, 197, 230, 0.14);
  background:
    linear-gradient(180deg, rgba(42, 84, 116, 0.96), rgba(12, 31, 46, 0.98));
  color: #eef9ff;
  font-size: clamp(12px, 1.3vw, 18px);
  font-weight: 800;
  letter-spacing: 0;
}

.link-tile.selected {
  border-color: rgba(255, 202, 104, 0.46);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 0 20px rgba(255, 180, 82, 0.2);
}

.link-tile.cleared {
  visibility: hidden;
  pointer-events: none;
}

.merge-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  max-width: 560px;
  width: 100%;
  margin: 8px auto 0;
  padding: 12px;
  border-radius: 24px;
  border: 1px solid rgba(136, 206, 240, 0.16);
  background:
    radial-gradient(circle at top, rgba(49, 115, 152, 0.18), transparent 38%),
    linear-gradient(180deg, rgba(15, 38, 56, 0.96), rgba(6, 20, 31, 0.98));
}

.merge-tile {
  aspect-ratio: 1;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: clamp(20px, 2.8vw, 34px);
  font-weight: 800;
  color: #f4fbff;
  background:
    linear-gradient(180deg, rgba(34, 66, 88, 0.96), rgba(10, 27, 39, 0.98));
}

.merge-tile.empty-tile {
  opacity: 0.42;
}

.merge-tile[data-value="2"] { background: linear-gradient(180deg, #4f88bf, #264a6d); }
.merge-tile[data-value="4"] { background: linear-gradient(180deg, #4ea6d7, #206387); }
.merge-tile[data-value="8"] { background: linear-gradient(180deg, #4ad0c6, #1f7b7e); }
.merge-tile[data-value="16"] { background: linear-gradient(180deg, #55cf8e, #24724d); }
.merge-tile[data-value="32"] { background: linear-gradient(180deg, #b5d552, #66751f); }
.merge-tile[data-value="64"] { background: linear-gradient(180deg, #ffb24d, #a8611e); }
.merge-tile[data-value="128"] { background: linear-gradient(180deg, #ff8f57, #ac4f1e); }
.merge-tile[data-value="256"] { background: linear-gradient(180deg, #f56c74, #9a2f45); }
.merge-tile[data-value="512"] { background: linear-gradient(180deg, #c47fff, #68349e); }
.merge-tile[data-value="1024"] { background: linear-gradient(180deg, #8d95ff, #414bb0); }
.merge-tile[data-value="2048"] { background: linear-gradient(180deg, #fff07e, #bd8928); color: #3c2a08; }

.ttt-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  max-width: 460px;
  width: 100%;
  margin: 8px auto 0;
}

.gomoku-wrap {
  overflow: auto;
  padding: 4px 0;
}

.ttt-board-gomoku {
  grid-template-columns: repeat(15, minmax(0, 32px));
  gap: 4px;
  max-width: none;
  width: max-content;
  margin: 0 auto;
}

.ttt-cell {
  aspect-ratio: 1;
  border-radius: 22px;
  border: 1px solid rgba(133, 197, 230, 0.14);
  background:
    linear-gradient(180deg, rgba(42, 84, 116, 0.96), rgba(12, 31, 46, 0.98));
  font-size: clamp(34px, 5vw, 56px);
  font-weight: 800;
  color: #f0fbff;
}

.ttt-gomoku-cell {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  font-size: 18px;
  padding: 0;
}

.ttt-gomoku-cell[data-player="sun"] {
  color: #101010;
  background:
    linear-gradient(180deg, rgba(242, 242, 242, 0.96), rgba(186, 186, 186, 0.92));
}

.ttt-gomoku-cell[data-player="moon"] {
  color: #eff7ff;
  background:
    linear-gradient(180deg, rgba(55, 82, 108, 0.96), rgba(15, 28, 40, 0.98));
}

.guess-input {
  min-width: 160px;
  border-radius: 14px;
  border: 1px solid rgba(133, 197, 230, 0.18);
  background:
    linear-gradient(180deg, rgba(23, 47, 67, 0.96), rgba(9, 24, 36, 0.98));
  color: var(--text);
  padding: 11px 14px;
  font-size: 15px;
  outline: none;
}

.guess-panel {
  margin-top: 8px;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(136, 206, 240, 0.16);
  background:
    linear-gradient(180deg, rgba(17, 38, 55, 0.96), rgba(6, 19, 30, 0.98));
}

.guess-message {
  margin: 0 0 14px;
  font-size: 18px;
  line-height: 1.5;
}

.guess-history {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.guess-log {
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(94, 167, 211, 0.16);
  border: 1px solid rgba(133, 197, 230, 0.18);
  color: #dff6ff;
  font-size: 13px;
}

.simon-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  max-width: 520px;
  width: 100%;
  margin: 10px auto 0;
}

.simon-board-large {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  max-width: 760px;
}

.simon-pad {
  aspect-ratio: 1;
  border-radius: 20px;
  display: grid;
  place-items: center;
  gap: 4px;
  text-align: center;
  border: 1px solid rgba(133, 197, 230, 0.14);
  color: #f4fbff;
  background:
    linear-gradient(180deg, hsla(var(--pad-hue), 72%, 63%, 0.96), hsla(var(--pad-hue), 66%, 34%, 0.98));
}

.simon-pad span {
  font-size: clamp(14px, 1.6vw, 20px);
  font-weight: 800;
}

.simon-pad.active {
  transform: scale(0.98);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.26),
    0 0 26px rgba(255, 255, 255, 0.18);
  filter: brightness(1.18);
}

.whack-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  max-width: 620px;
  width: 100%;
  margin: 10px auto 0;
}

.whack-hole {
  aspect-ratio: 1;
  border-radius: 26px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(133, 197, 230, 0.14);
  background:
    linear-gradient(180deg, rgba(20, 46, 68, 0.96), rgba(8, 22, 34, 0.98));
}

.whack-hole::before {
  content: "";
  position: absolute;
  inset: auto 14% 14% 14%;
  height: 26%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(11, 24, 36, 0.98), rgba(4, 10, 16, 0.98));
}

.whack-hole-inner {
  position: absolute;
  left: 50%;
  bottom: -42%;
  transform: translateX(-50%);
  width: 54%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: clamp(22px, 2.6vw, 34px);
  font-weight: 800;
  color: #2b1208;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 236, 215, 0.88), transparent 24%),
    linear-gradient(180deg, rgba(255, 191, 128, 0.98), rgba(199, 105, 42, 0.98));
  transition: bottom 140ms ease;
}

.whack-hole.active .whack-hole-inner {
  bottom: 18%;
}

.blackjack-table {
  display: grid;
  gap: 16px;
  margin-top: 8px;
}

.bridge-trick-area {
  display: grid;
  gap: 16px;
}

.bridge-hand .bridge-play-card {
  background: transparent;
  border: 0;
  padding: 0;
  box-shadow: none;
}

.bridge-trick {
  min-height: 132px;
}

.blackjack-hand {
  border-radius: 20px;
  padding: 16px;
  border: 1px solid rgba(136, 206, 240, 0.16);
  background:
    linear-gradient(180deg, rgba(17, 38, 55, 0.96), rgba(6, 19, 30, 0.98));
}

.blackjack-hand h3 {
  margin: 0 0 12px;
  font-size: 16px;
  color: #d9f3ff;
}

.blackjack-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.blackjack-card {
  width: 92px;
  height: 132px;
  border-radius: 18px;
  padding: 10px;
  border: 1px solid rgba(174, 196, 210, 0.42);
  background:
    linear-gradient(180deg, rgba(245, 250, 255, 0.96), rgba(198, 216, 229, 0.94));
  color: #203340;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: start;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.18);
  position: relative;
  overflow: hidden;
}

.card-back {
  background:
    linear-gradient(180deg, rgba(42, 84, 116, 0.96), rgba(12, 31, 46, 0.98));
  border-color: rgba(133, 197, 230, 0.22);
}

.card-back::before {
  content: "◆";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(235, 247, 255, 0.6);
  font-size: 36px;
}

.placeholder-card {
  opacity: 0.3;
}

.solitaire-top {
  display: grid;
  grid-template-columns: auto 120px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.solitaire-stock {
  min-width: 92px;
  min-height: 132px;
}

.solitaire-waste {
  min-width: 92px;
  min-height: 132px;
}

.solitaire-foundations {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.solitaire-foundation {
  background: transparent;
  border: 0;
  padding: 0;
  box-shadow: none;
}

.solitaire-tableau {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  gap: 10px;
  align-items: start;
}

.solitaire-column {
  min-height: 240px;
}

.solitaire-column-hit {
  width: 100%;
  min-height: 240px;
  background:
    linear-gradient(180deg, rgba(13, 31, 46, 0.42), rgba(7, 18, 28, 0.42));
  border: 1px dashed rgba(126, 191, 226, 0.18);
  padding: 10px 8px;
  box-shadow: none;
}

.solitaire-card-wrap {
  display: block;
  margin-top: -92px;
}

.solitaire-card-wrap:first-child {
  margin-top: 0;
}

.selected-card {
  box-shadow:
    0 0 0 3px rgba(255, 199, 97, 0.42),
    0 10px 18px rgba(0, 0, 0, 0.18);
}

.blackjack-card.enter {
  animation: cardDealIn 260ms ease;
}

.blackjack-card.red {
  color: #aa2f38;
}

.blackjack-card-rank {
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.blackjack-card-corner {
  display: grid;
  justify-items: start;
  gap: 3px;
  z-index: 2;
}

.blackjack-card-corner.bottom {
  justify-items: end;
  align-self: end;
  transform: rotate(180deg);
}

.blackjack-card-suit {
  font-size: 18px;
  line-height: 1;
}

.blackjack-card-center {
  align-self: center;
  justify-self: center;
  font-size: 38px;
  line-height: 1;
}

.blackjack-card-face {
  position: absolute;
  inset: 26px 16px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
}

.blackjack-card-face-rank {
  font-size: 48px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 1px;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.15);
}

.blackjack-card-face-suit {
  font-size: 26px;
  line-height: 1;
  opacity: 0.9;
}

@keyframes cardDealIn {
  from {
    opacity: 0;
    transform: translateY(-16px) rotate(-6deg) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(0deg) scale(1);
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .sidebar {
    padding: 18px;
    gap: 16px;
  }

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

  .stage {
    padding: 16px;
  }

  .panel {
    padding: 16px;
  }

  .memory-board {
    gap: 10px;
  }

  .minesweeper-board {
    gap: 3px;
    grid-template-columns: repeat(20, minmax(0, 24px));
  }

  .mine-cell {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  .merge-board,
  .ttt-board,
  .simon-board,
  .whack-board {
    max-width: 100%;
  }

  .link-board {
    max-width: 100%;
    gap: 3px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    height: calc(100dvh - 16px);
    gap: 12px;
  }

  body {
    padding: 8px;
  }

  .sidebar,
  .stage,
  .panel {
    border-radius: 20px;
  }

  .sidebar-title,
  .title {
    font-size: 24px;
  }

  .sidebar-title {
    font-size: 30px;
  }

  .hall-title {
    font-size: 34px;
  }

  .stage-title {
    font-size: 20px;
  }

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

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

  .panel {
    padding: 14px;
  }

  .sidebar {
    padding: 14px 12px;
  }

  .board {
    padding: 7px;
    border-radius: 20px;
  }

  .board-area {
    padding: 6px;
    border-radius: 24px;
  }

  .controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-width: none;
  }

  .memory-board {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .lights-grid {
    gap: 10px;
  }

  .minesweeper-board {
    grid-template-columns: repeat(20, minmax(0, 18px));
    gap: 2px;
  }

  .mine-cell {
    width: 18px;
    height: 18px;
    border-radius: 6px;
    font-size: 9px;
  }

  .sudoku-board {
    gap: 4px;
    padding: 6px;
  }

  .sudoku-cell {
    font-size: 18px;
    border-radius: 8px;
  }

  .link-board {
    gap: 2px;
  }

  .link-tile {
    border-radius: 7px;
    font-size: 10px;
  }

  .merge-board {
    gap: 8px;
    padding: 8px;
  }

  .ttt-board {
    gap: 6px;
  }

  .ttt-board-gomoku {
    grid-template-columns: repeat(15, minmax(0, 24px));
  }

  .ttt-gomoku-cell {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    font-size: 14px;
  }

  .guess-input {
    min-width: 120px;
    width: 100%;
  }

  .simon-board,
  .whack-board {
    gap: 10px;
  }

  .simon-board-large {
    gap: 6px;
  }

  .blackjack-card {
    width: 74px;
    height: 108px;
    padding: 8px;
  }

  .blackjack-card-center {
    font-size: 30px;
  }

  .blackjack-card-rank {
    font-size: 16px;
  }

  .blackjack-card-face-rank {
    font-size: 38px;
  }

  .blackjack-card-face-suit {
    font-size: 22px;
  }

  .solitaire-top {
    grid-template-columns: 1fr;
  }

  .solitaire-foundations {
    justify-content: start;
  }

  .solitaire-tableau {
    grid-template-columns: repeat(4, minmax(90px, 1fr));
  }

  .solitaire-card-wrap {
    margin-top: -74px;
  }

  .sidebar-kicker {
    font-size: 13px;
  }
}
