:root {
  color-scheme: dark;
  --bg: #101820;
  --panel: #17242d;
  --panel-strong: #20323d;
  --text: #f7fbfc;
  --muted: #a8bac2;
  --line: #2b414b;
  --accent: #f7c948;
  --accent-strong: #f0a830;
  --cyan: #3dd6d0;
  --danger: #ff6b6b;
  --theme-color: #101820;
  --theme-tint: rgba(61, 214, 208, 0.14);
  --theme-tint-secondary: rgba(247, 201, 72, 0.16);
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.26);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--theme-color);
  overscroll-behavior-y: none;
  scrollbar-width: none;
}

body {
  height: 100vh;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(145deg, var(--theme-tint), transparent 38%),
    linear-gradient(315deg, var(--theme-tint-secondary), transparent 42%),
    var(--theme-color);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  text-rendering: optimizeLegibility;
  overflow: auto;
  scrollbar-width: none;
  transition: background-color 180ms ease-out;
}

body:is(:not(.is-playing), .is-small-game, .is-medium-game) {
  display: grid;
  overflow: hidden;
  place-items: center;
  background: #000;
}

body:is(:not(.is-playing), .is-small-game, .is-medium-game) .app-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 100dvh;
  aspect-ratio: auto;
  max-width: none;
  padding: 1dvh 4.3vw 23.1dvh;
  background: url("../images/retroHandheld3b.png") center / 100% 100% no-repeat;
}

body.is-medium-game .app-shell {
  padding-bottom: 10.5dvh;
}

body:is(:not(.is-playing), .is-small-game, .is-medium-game) .app-header h1 {
  color: #000;
  font-family: "Courier New", "Lucida Console", ui-monospace, monospace;
  font-weight: 900;
  letter-spacing: -0.09em;
  -webkit-text-stroke: 1px #000;
  text-shadow: 3px 3px 0 rgba(94, 94, 104, 0.5);
}

body:is(:not(.is-playing), .is-small-game, .is-medium-game) .app-version {
  color: #32383b;
}

.launcher-controls {
  display: none;
}

body:is(:not(.is-playing), .is-small-game) .launcher-controls {
  display: block;
  pointer-events: none;
}

body.is-small-game:has(:is(input, textarea, [contenteditable="true"]):focus) .launcher-controls {
  display: none;
}

.launcher-control {
  position: absolute;
  z-index: 1;
  display: block;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.launcher-dpad {
  bottom: calc(3.5dvh + 50px);
  left: 5vw;
  width: clamp(76px, 22vw, 190px);
}

.launcher-startselect {
  bottom: 5.5dvh;
  left: 50%;
  width: clamp(90px, 22vw, 190px);
  transform: translateX(-50%);
}

.launcher-buttons {
  position: absolute;
  z-index: 2;
  right: 5vw;
  bottom: calc(3.5dvh + 50px);
  width: clamp(84px, 23vw, 200px);
  aspect-ratio: 273 / 218;
}

.controller-button {
  position: absolute;
  display: block;
  padding: 0;
  border: 0;
  background-color: transparent;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  pointer-events: auto;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.controller-button-a {
  top: 0;
  right: 0;
  width: 46%;
  aspect-ratio: 118 / 129;
  background-image: url("../images/aButton.png");
}

.controller-button-b {
  bottom: 0;
  left: 0;
  width: 47%;
  aspect-ratio: 120 / 130;
  background-image: url("../images/bButton.png");
}

.controller-button:hover,
.controller-button:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.9);
  outline-offset: 2px;
  filter: brightness(1.1);
}

.controller-button:active {
  transform: translateY(3px);
}

.small-game-back {
  position: absolute;
  z-index: 3;
  top: calc(76.9dvh + 10px);
  left: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 96px;
  min-height: 42px;
  padding: 8px 16px;
  border: 2px solid #29282f;
  border-radius: 6px;
  background: #4c4a55;
  color: #fff;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.42);
  font-family: "Courier New", "Lucida Console", ui-monospace, monospace;
  font-weight: 900;
  cursor: pointer;
  transform: translateX(-50%);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.small-game-back:hover,
.small-game-back:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
  filter: brightness(1.12);
}

.small-game-back:active {
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.42);
  transform: translate(-50%, 2px);
}

.small-game-back[hidden] {
  display: none;
}

body.is-medium-game .small-game-back {
  top: calc(89.5dvh + 8px);
}

body::-webkit-scrollbar,
.game-library::-webkit-scrollbar,
.game-stage::-webkit-scrollbar,
.stage-content::-webkit-scrollbar {
  display: none;
}

button {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1120px, 100%);
  height: 100vh;
  min-height: 100vh;
  margin: 0 auto;
  overflow: auto;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  scrollbar-width: none;
}

@supports (height: 100dvh) {

  body,
  .app-shell {
    height: 100dvh;
    min-height: 100dvh;
  }
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0 8px;
}

body:is(:not(.is-playing), .is-small-game, .is-medium-game) .app-header {
  padding-top: max(2px, calc(env(safe-area-inset-top) - 1dvh));
  padding-right: max(0px, calc(env(safe-area-inset-right) - 4.3vw));
  padding-left: max(0px, calc(env(safe-area-inset-left) - 4.3vw));
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.network-status {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 3px rgba(61, 214, 208, 0.12);
}

.network-status.is-offline {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.1);
}

.app-version {
  display: inline-grid;
  min-height: 32px;
  place-items: center;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.app-version:focus-visible,
.app-version:hover {
  outline: none;
  color: var(--text);
}

.app-version.is-checking {
  opacity: 0.62;
}

.app-version.is-update-ready {
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(61, 214, 208, 0.45);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: var(--text);
  font-size: clamp(2.2rem, 10vw, 4.8rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 6px;
  font-size: 1.18rem;
}

p {
  color: var(--muted);
  line-height: 1.5;
}

.app-main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  gap: 12px;
}

body:is(.is-small-game, .is-medium-game) .app-main {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}

body:is(.is-small-game, .is-medium-game) .game-library {
  display: none;
}

body:is(.is-small-game, .is-medium-game) .game-stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

body:is(.is-small-game, .is-medium-game) .stage-topbar {
  min-height: 30px;
  padding: 4px 10px;
}

body:is(.is-small-game, .is-medium-game) .stage-topbar .eyebrow {
  display: none;
}

body:is(.is-small-game, .is-medium-game) .stage-topbar h2 {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.2;
}

body:is(.is-small-game, .is-medium-game) .app-shell {
  grid-template-rows: auto minmax(0, 1fr);
}

body:is(.is-small-game, .is-medium-game) .app-header {
  display: flex;
}

.is-playing .game-library {
  display: none;
}

.game-library,
.game-stage {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(23, 36, 45, 0.9);
  box-shadow: var(--shadow);
}

.game-library {
  padding: 12px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

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

.game-card {
  --cartridge-color: #ff6b6b;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  overflow: hidden;
  padding: 14% 12% 18%;
  border: 0;
  border-radius: 4px;
  background-color: transparent;
  background-image:
    linear-gradient(var(--cartridge-color), var(--cartridge-color)),
    url("../images/game.png");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  background-blend-mode: color, normal;
  color: #111;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
  -webkit-tap-highlight-color: transparent;
}

.game-card:nth-child(7n + 2) {
  --cartridge-color: #42d6c5;
}

.game-card:nth-child(7n + 3) {
  --cartridge-color: #a979e8;
}

.game-card:nth-child(7n + 4) {
  --cartridge-color: #ffd166;
}

.game-card:nth-child(7n + 5) {
  --cartridge-color: #5aa9ff;
}

.game-card:nth-child(7n + 6) {
  --cartridge-color: #ff78b7;
}

.game-card:nth-child(7n + 7) {
  --cartridge-color: #7bd66f;
}

.game-card:focus-visible,
.game-card:hover:not(:disabled) {
  outline: none;
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.game-card.is-launching {
  z-index: 1;
  animation: game-card-launch 220ms ease-out both;
  box-shadow: 0 0 0 3px rgba(61, 214, 208, 0.2), 0 8px 20px rgba(0, 0, 0, 0.22);
}

@keyframes game-card-launch {
  0% {
    transform: scale(1);
  }

  38% {
    transform: scale(0.94);
  }

  100% {
    transform: scale(1.04);
  }
}

.game-card-mark {
  color: var(--accent);
  font-size: clamp(1.1rem, 5vw, 1.6rem);
  font-weight: 900;
  line-height: 1;
}

.game-card-mark::before {
  content: attr(data-mark);
}

.game-card:nth-child(2) .game-card-mark {
  color: #68d39b;
}

.game-card:nth-child(3) .game-card-mark {
  color: #b995d0;
}

.game-card:nth-child(4) .game-card-mark {
  color: var(--cyan);
}

.game-card.is-placeholder {
  color: #4d5155;
  cursor: default;
  opacity: 0.62;
}

.game-card.is-placeholder .game-card-mark {
  color: var(--muted);
}

.game-card-title {
  max-width: 100%;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.game-stage {
  display: grid;
  min-height: 0;
  overflow: auto;
  scrollbar-width: none;
}

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

.stage-topbar h2 {
  margin-bottom: 0;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  color: var(--text);
  cursor: pointer;
}

.icon-button:focus-visible,
.icon-button:hover {
  outline: none;
  border-color: var(--accent);
}

.stage-content {
  display: grid;
  min-height: 0;
  padding: 12px;
  place-items: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body.is-medium-game .stage-content {
  padding: 8px 10px 10px;
}

.stage-content :is(input, textarea, [contenteditable="true"]) {
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
}

.stage-content:has(.snake-game) {
  align-items: stretch;
}

.empty-state {
  width: min(28rem, 100%);
  margin: 0;
  text-align: center;
}

.coming-soon {
  display: grid;
  width: min(32rem, 100%);
  gap: 14px;
  text-align: center;
}

.coming-soon h3 {
  margin: 0;
  font-size: 1.6rem;
}

.coming-soon p {
  margin-bottom: 0;
}

.primary-action {
  justify-self: center;
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #1a1504;
  font-weight: 850;
  cursor: pointer;
}

.primary-action:focus-visible,
.primary-action:hover {
  outline: 3px solid rgba(247, 201, 72, 0.34);
  background: var(--accent-strong);
}

.secondary-action {
  justify-self: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.secondary-action:focus-visible,
.secondary-action:hover {
  outline: none;
  border-color: var(--accent);
}

.tap-race {
  display: grid;
  width: min(34rem, 100%);
  gap: 12px;
}

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

.score-tile {
  display: grid;
  min-height: 68px;
  place-items: center;
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
}

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

.score-tile strong {
  color: var(--text);
  font-size: clamp(1.45rem, 8vw, 2.5rem);
  line-height: 1;
}

.tap-target {
  display: grid;
  width: min(280px, 58dvh, 100%);
  aspect-ratio: 1;
  place-self: center;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.32), transparent 28%),
    var(--accent);
  color: #1a1504;
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.tap-target span {
  font-size: clamp(2.2rem, 14vw, 4.2rem);
  font-weight: 950;
  line-height: 1;
}

.tap-target:focus-visible {
  outline: 4px solid rgba(61, 214, 208, 0.56);
  outline-offset: 4px;
}

.tap-target:active:not(:disabled) {
  transform: scale(0.98);
}

.tap-target:disabled {
  background: #41535d;
  color: var(--muted);
  cursor: default;
}

.game-message {
  min-height: 1.5em;
  margin: 0;
  text-align: center;
}

.reaction-time {
  display: grid;
  width: min(34rem, 100%);
  gap: 12px;
}

.reaction-stats {
  display: grid;
  min-height: 68px;
  place-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
}

.reaction-stats strong {
  font-size: clamp(1.45rem, 8vw, 2.5rem);
  line-height: 1;
}

.reaction-target {
  display: grid;
  width: min(320px, 58dvh, 100%);
  aspect-ratio: 1;
  place-self: center;
  place-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  text-align: center;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.reaction-target strong {
  font-size: clamp(2rem, 12vw, 4rem);
  line-height: 1;
}

.reaction-target span {
  font-size: 0.9rem;
  font-weight: 750;
}

.reaction-target:focus-visible {
  outline: 4px solid rgba(247, 201, 72, 0.55);
  outline-offset: 4px;
}

.reaction-target:active {
  transform: scale(0.99);
}

.reaction-target.is-ready,
.reaction-target.is-result {
  background: var(--panel-strong);
}

.reaction-target.is-waiting {
  background: #b63d3d;
}

.reaction-target.is-go {
  background: #16845b;
}

.reaction-target.is-early {
  background: #7e3547;
}

.memory-game {
  display: grid;
  width: min(34rem, 100%);
  gap: 10px;
}

.memory-score-grid .score-tile {
  min-height: 58px;
}

.memory-score-grid .score-tile strong {
  font-size: clamp(1.2rem, 6vw, 2rem);
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  width: min(420px, 52dvh, 100%);
  aspect-ratio: 1;
  place-self: center;
  gap: 6px;
}

.memory-card {
  display: grid;
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  place-items: center;
  border: 1px solid #46606c;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, transparent 42%, rgba(61, 214, 208, 0.16) 42% 58%, transparent 58%),
    var(--panel-strong);
  color: transparent;
  cursor: pointer;
  font-size: clamp(1.25rem, 8vw, 2.4rem);
  font-weight: 900;
  touch-action: manipulation;
  transform: scale(1);
  transform-origin: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.memory-card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.memory-card.is-activating {
  z-index: 1;
  animation: memory-card-pop 180ms ease-out;
}

@keyframes memory-card-pop {

  0%,
  100% {
    transform: scale(1);
  }

  55% {
    transform: scale(1.08);
  }
}

.memory-card.is-revealed {
  border-color: rgba(255, 255, 255, 0.36);
  color: #ffffff;
  background: #357b77;
}

.memory-card.pair-b {
  background: #a74352;
}

.memory-card.pair-c {
  background: #3c68a8;
}

.memory-card.pair-d {
  background: #8b5aac;
}

.memory-card.pair-e {
  background: #9b652f;
}

.memory-card.pair-f {
  background: #397d4d;
}

.memory-card.pair-g {
  background: #a34f8a;
}

.memory-card.pair-h {
  background: #5d6578;
}

.memory-card.is-matched {
  opacity: 0.58;
  cursor: default;
}

.quick-math {
  display: grid;
  width: min(34rem, 100%);
  gap: 12px;
}

.tic-tac-toe {
  display: grid;
  width: min(23rem, 100%);
  min-height: 0;
  gap: 8px;
  place-items: center;
}

.tic-score-grid {
  width: min(290px, 100%);
  gap: 6px;
}

.tic-score-tile {
  min-height: 42px;
  padding: 6px 4px;
}

.tic-score-tile .score-label {
  font-size: .62rem;
}

.tic-score-tile strong {
  font-size: clamp(1rem, 5vw, 1.5rem);
}

.tic-message {
  min-height: 1.35em;
  margin: 0;
  font-size: .86rem;
  font-weight: 850;
}

.tic-board {
  display: grid;
  width: min(280px, 100%, 42dvh);
  aspect-ratio: 1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  padding: 7px;
  border: 2px solid #3c5260;
  border-radius: 14px;
  background: #101820;
  box-shadow: inset 0 0 0 3px rgba(61, 214, 208, .08);
}

.tic-cell {
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  border: 2px solid #405765;
  border-radius: 10px;
  background: #17242d;
  color: #fff;
  font-size: clamp(2rem, 12vw, 4rem);
  font-weight: 950;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .22);
  -webkit-tap-highlight-color: transparent;
}

.tic-cell:not(:disabled):hover,
.tic-cell:not(:disabled):focus-visible {
  outline: none;
  border-color: var(--cyan);
  background: #203440;
  box-shadow:
    inset 0 -5px 0 rgba(0, 0, 0, .22),
    0 0 0 3px rgba(61, 214, 208, .16);
}

.tic-cell:disabled {
  cursor: default;
}

.tic-cell.is-x {
  color: #ffd166;
}

.tic-cell.is-o {
  color: #4cc9f0;
}

.tic-cell.is-winning {
  border-color: #06d6a0;
  background: #15372f;
  box-shadow:
    inset 0 -5px 0 rgba(0, 0, 0, .22),
    0 0 18px rgba(6, 214, 160, .28);
}

.tic-restart {
  min-height: 34px;
  padding: 7px 12px;
}

.tic-win-modal {
  border-color: #4cc9f0;
  background:
    radial-gradient(circle at 50% 0%, rgba(76, 201, 240, .2), transparent 42%),
    #161a2d;
}

.tic-win-modal > :not(.tic-fireworks) {
  position: relative;
  z-index: 3;
}

.tic-win-burst {
  color: #4cc9f0;
  text-shadow:
    0 0 14px rgba(76, 201, 240, .74),
    0 0 28px rgba(255, 209, 102, .38);
}

.tic-winner {
  color: #ffd166;
  text-shadow: 0 3px 0 rgba(0, 0, 0, .32);
}

.tic-fireworks {
  position: fixed;
  z-index: 2;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.tic-fireworks span {
  position: absolute;
  top: 0;
  left: 0;
  width: 12px;
  height: 20px;
  border-radius: 3px;
  background: var(--firework-color);
  box-shadow:
    0 0 10px var(--firework-color),
    0 0 24px var(--firework-color),
    0 0 42px rgba(255, 255, 255, .32);
  opacity: 0;
  animation: tic-firework-fall var(--firework-duration) var(--firework-delay) cubic-bezier(.18, .72, .3, 1) forwards;
  transform: translate3d(var(--firework-x), var(--firework-start-y), 0) rotate(0deg) scale(.7);
}

.tic-fireworks span:nth-child(4n) {
  width: 16px;
  height: 7px;
  border-radius: 999px;
}

.tic-fireworks span:nth-child(5n) {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.tic-fireworks span:nth-child(7n) {
  width: 18px;
  height: 18px;
  clip-path: polygon(50% 0%, 61% 34%, 98% 35%, 68% 56%, 79% 91%, 50% 70%, 21% 91%, 32% 56%, 2% 35%, 39% 34%);
}

.mines-game {
  display: grid;
  width: min(30rem, 100%);
  height: 100%;
  min-height: 0;
  grid-template-rows: auto auto minmax(0, auto) auto;
  align-content: center;
  gap: 8px;
  place-items: center;
}

.mines-stats {
  width: min(286px, 100%, 34dvh);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.mines-stat {
  min-height: 40px;
  padding: 5px 7px;
  border-radius: 9px;
}

.mines-stat .score-label {
  font-size: .62rem;
}

.mines-stat strong {
  font-size: clamp(1rem, 4.5vw, 1.4rem);
}

.mines-message {
  min-height: 1.3em;
  margin: 0;
  color: #d8e5ea;
  font-size: clamp(.72rem, 2.8vw, .88rem);
  font-weight: 850;
  line-height: 1.25;
  text-align: center;
}

.mines-board {
  display: grid;
  width: min(286px, 100%, 34dvh);
  aspect-ratio: 8 / 14;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(14, minmax(0, 1fr));
  gap: 3px;
  padding: 6px;
  border: 2px solid #3c5260;
  border-radius: 14px;
  background: #0d151b;
  box-shadow:
    inset 0 0 0 3px rgba(61, 214, 208, .08),
    0 10px 24px rgba(0, 0, 0, .2);
}

.mines-cell {
  display: grid;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid #405765;
  border-radius: 6px;
  background: linear-gradient(180deg, #263945, #172630);
  color: #f8fbff;
  font-size: clamp(.86rem, 4.2vw, 1.35rem);
  font-weight: 950;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  box-shadow:
    inset 0 -4px 0 rgba(0, 0, 0, .2),
    inset 0 1px 0 rgba(255, 255, 255, .08);
  -webkit-tap-highlight-color: transparent;
}

.mines-cell:not(:disabled):hover,
.mines-cell:not(:disabled):focus-visible {
  outline: none;
  border-color: var(--cyan);
  background: linear-gradient(180deg, #31505d, #1d333f);
  box-shadow:
    inset 0 -4px 0 rgba(0, 0, 0, .2),
    0 0 0 2px rgba(61, 214, 208, .18);
}

.mines-cell.is-long-press:not(:disabled) {
  border-color: #ffd166;
  transform: scale(.96);
  box-shadow:
    inset 0 -4px 0 rgba(0, 0, 0, .2),
    0 0 0 3px rgba(255, 209, 102, .2);
}

.mines-cell.is-revealed {
  border-color: #263945;
  background: #101a21;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .03);
  cursor: default;
}

.mines-cell.is-flagged {
  color: #ffd166;
}

.mines-cell.is-mine {
  color: #ff6b6b;
  background: #321923;
}

.mines-cell.near-1 {
  color: #4cc9f0;
}

.mines-cell.near-2 {
  color: #06d6a0;
}

.mines-cell.near-3 {
  color: #ffd166;
}

.mines-cell.near-4,
.mines-cell.near-5,
.mines-cell.near-6,
.mines-cell.near-7,
.mines-cell.near-8 {
  color: #ef476f;
}

.mines-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.mines-actions .secondary-action {
  min-height: 34px;
  padding: 7px 10px;
  font-size: .86rem;
}

.mines-flag-toggle.is-active {
  border-color: #ffd166;
  color: #ffd166;
  box-shadow: 0 0 0 3px rgba(255, 209, 102, .16);
}

.mines-confetti {
  z-index: 20;
}

.wordle-game {
  display: grid;
  width: min(31rem, 100%);
  height: 100%;
  min-height: 0;
  grid-template-rows: auto auto auto minmax(0, auto);
  align-content: center;
  gap: 6px;
  place-items: center;
}

.wordle-stats {
  display: grid;
  width: min(286px, 100%, 39dvh);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.wordle-stat {
  min-height: 36px;
  padding: 4px 6px;
  border-radius: 8px;
}

.wordle-stat .score-label {
  font-size: .68rem;
}

.wordle-stat strong {
  font-size: clamp(1rem, 4.6vw, 1.45rem);
  line-height: 1;
}

.wordle-board {
  display: grid;
  width: min(286px, 100%, 39dvh);
  min-height: 0;
  gap: 4px;
}

.wordle-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
}

.wordle-row.is-shaking {
  animation: wordle-shake 260ms ease-in-out;
}

.wordle-tile {
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  border: 2px solid #41535d;
  border-radius: 6px;
  background: #101820;
  color: #fff;
  font-size: clamp(1.1rem, 6.2vw, 1.8rem);
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .22);
}

.wordle-tile.is-filled {
  border-color: #6f8490;
}

.wordle-tile.is-active {
  border-color: var(--cyan);
  background: #13242d;
  box-shadow:
    inset 0 -4px 0 rgba(0, 0, 0, .22),
    0 0 0 2px rgba(61, 214, 208, .2),
    0 0 16px rgba(61, 214, 208, .26);
}

.wordle-tile.is-correct {
  border-color: #5fa35f;
  background: #4f8f4f;
}

.wordle-tile.is-present {
  border-color: #caa745;
  background: #b59f3b;
}

.wordle-tile.is-absent {
  border-color: #3f4b52;
  background: #3a434a;
}

.wordle-message {
  min-height: 1.35em;
  margin: 0;
  font-size: .82rem;
  font-weight: 800;
}

.wordle-keyboard {
  display: grid;
  width: min(340px, 100%);
  gap: 4px;
  touch-action: manipulation;
}

.wordle-key-row {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.wordle-key {
  display: grid;
  min-width: 0;
  height: 36px;
  flex: 1 1 0;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: #596773;
  color: #fff;
  font-size: .74rem;
  font-weight: 950;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.wordle-key.is-wide {
  flex: 1.3 1 0;
  font-size: .62rem;
}

.wordle-key.is-correct {
  background: #4f8f4f;
}

.wordle-key.is-present {
  background: #b59f3b;
}

.wordle-key.is-absent {
  background: #3a434a;
  color: #cbd5dc;
}

.wordle-key:focus-visible {
  outline: 3px solid rgba(61, 214, 208, .5);
  outline-offset: 2px;
}

.wordle-key:active {
  transform: translateY(1px);
}

.wordle-restart {
  min-height: 34px;
}

@keyframes wordle-shake {
  0%,
  100% {
    transform: translateX(0);
  }

  20%,
  60% {
    transform: translateX(-6px);
  }

  40%,
  80% {
    transform: translateX(6px);
  }
}

.snake-game {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 12px;
  place-items: center;
}

.snake-score-grid .score-tile {
  min-height: 56px;
}

.snake-score-grid .score-tile strong {
  font-size: clamp(1.15rem, 6vw, 1.9rem);
}

.snake-board {
  display: grid;
  width: min(100%, 78dvh, 640px);
  max-height: 100%;
  aspect-ratio: 1;
  place-self: center;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  gap: 2px;
  padding: 8px;
  border: 6px solid #1d3928;
  border-radius: 12px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
    #0b1710;
  background-size: calc(100% / 15) calc(100% / 15);
  box-shadow: inset 0 0 0 3px rgba(144, 190, 109, .22), 0 18px 28px rgba(0, 0, 0, .3);
  touch-action: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.snake-cell {
  min-width: 0;
  min-height: 0;
  border-radius: 4px;
}

.snake-cell.is-snake,
.snake-cell.is-head {
  background: #90be6d;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28);
}

.snake-cell.is-head {
  background: #06d6a0;
}

.snake-cell.is-food {
  border-radius: 50%;
  background: #ef476f;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .2), 0 0 10px rgba(239, 71, 111, .8);
}

.wheel-game {
  display: grid;
  width: min(880px, 100%);
  height: 100%;
  min-height: 0;
}

.wheel-layout {
  display: grid;
  grid-template-columns: minmax(260px, 1.35fr) minmax(220px, .8fr);
  align-items: start;
  min-height: 0;
  gap: clamp(18px, 4vw, 42px);
}

.wheel-wrap {
  position: relative;
  width: min(480px, 100%);
  aspect-ratio: 1;
  place-self: start center;
  filter: drop-shadow(0 20px 24px rgba(0, 0, 0, .35));
}

.prize-wheel {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  padding: 0;
  place-items: center;
  border: 10px solid #fff4cf;
  border-radius: 50%;
  background: #fff4cf;
  box-shadow: inset 0 0 0 5px #3d2448, 0 0 0 5px #3d2448;
  cursor: pointer;
  touch-action: manipulation;
}

.prize-wheel:focus-visible {
  outline: 5px solid var(--cyan);
  outline-offset: 8px;
}

.prize-wheel:disabled {
  cursor: wait;
}

#wheel-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  transition: transform 4.2s cubic-bezier(.12, .68, .08, 1);
}

.wheel-hub {
  position: absolute;
  display: grid;
  width: 22%;
  aspect-ratio: 1;
  place-items: center;
  border: 6px solid #fff4cf;
  border-radius: 50%;
  background: #3d2448;
  color: #fff;
  box-shadow: 0 5px 12px rgba(0, 0, 0, .35);
  font-size: clamp(.7rem, 2.5vw, 1.15rem);
  font-weight: 950;
  letter-spacing: .08em;
}

.wheel-pointer {
  --pointer-color: #ef476f;
  position: absolute;
  z-index: 3;
  top: -10px;
  left: 50%;
  width: 0;
  height: 0;
  border-right: 18px solid transparent;
  border-left: 18px solid transparent;
  border-top: 42px solid var(--pointer-color);
  filter: drop-shadow(0 4px 1px #3d2448);
  transform: translateX(-50%);
  transition: border-top-color 70ms linear;
}

.wheel-settings {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-height: 0;
  max-height: min(60vh, 520px);
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(23, 36, 45, .76);
}

.wheel-settings-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.wheel-settings h3 {
  margin: 2px 0 0;
  font-size: 1.45rem;
}

.wheel-add {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-strong);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.wheel-add:disabled {
  opacity: .45;
  cursor: default;
}

.wheel-prizes {
  display: flex;
  flex-direction: column;
  max-height: min(250px, 36vh);
  min-height: 0;
  gap: 7px;
  overflow-x: hidden;
  overflow-y: scroll;
  overscroll-behavior: contain;
  overscroll-behavior-y: contain;
  padding-right: 4px;
  scrollbar-width: thin;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  user-select: none;
  -webkit-user-select: none;
}

.wheel-new-prize {
  min-height: 0;
}

.wheel-new-prize:not(:empty) {
  margin-bottom: 8px;
}

.wheel-prize-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 34px;
  flex: 0 0 auto;
  gap: 7px;
  align-items: center;
  touch-action: pan-y;
}

.wheel-prize-row>* {
  touch-action: pan-y;
}

.wheel-prize-row>span {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  background: var(--prize-color);
  color: #fff;
  font-size: .72rem;
  font-weight: 900;
}

.wheel-prize-text,
.wheel-new-prize-input {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101820;
  color: var(--text);
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wheel-new-prize-input {
  display: block;
  font: inherit;
}

.wheel-new-prize-input:focus {
  outline: 2px solid var(--cyan);
  border-color: transparent;
}

.wheel-prize-row button {
  height: 34px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 1.3rem;
  cursor: pointer;
}

.wheel-prize-row button:disabled {
  visibility: hidden;
}

.wheel-hint {
  margin: 12px 0 0;
  font-size: .78rem;
}

.win-modal {
  width: min(390px, calc(100% - 32px));
  padding: 30px 24px 24px;
  overflow: visible;
  border: 2px solid #ffd166;
  border-radius: 16px;
  background: #24142d;
  color: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .65);
  text-align: center;
}

.win-modal::backdrop {
  background: rgba(5, 7, 12, .78);
  backdrop-filter: blur(4px);
}

.win-modal> :not(.win-confetti) {
  position: relative;
  z-index: 1;
}

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

.win-confetti span {
  position: absolute;
  top: -8vh;
  left: 0;
  width: 10px;
  height: 17px;
  border-radius: 2px;
  background: var(--confetti-color);
  opacity: 0;
  animation: confetti-fall var(--confetti-duration) var(--confetti-delay) cubic-bezier(.18, .72, .3, 1) forwards;
  transform: translate3d(var(--confetti-x), -8vh, 0) rotate(0deg);
}

.win-confetti span:nth-child(3n) {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.win-confetti span:nth-child(4n) {
  width: 13px;
  height: 6px;
}

.wordle-confetti {
  z-index: 20;
}

.win-burst {
  color: #ffd166;
  font-size: 3.6rem;
  line-height: 1;
  animation: win-pop 480ms cubic-bezier(.2, 1.6, .4, 1);
}

.win-kicker {
  margin: 12px 0 2px;
  color: #ffd166;
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.win-modal h3 {
  margin: 0;
  font-size: 1.2rem;
}

.win-prize {
  display: block;
  margin: 8px 0 24px;
  font-size: clamp(2rem, 9vw, 3.2rem);
  overflow-wrap: anywhere;
}

@keyframes win-pop {
  from {
    opacity: 0;
    transform: scale(.2) rotate(-45deg);
  }

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

@keyframes confetti-fall {
  0% {
    opacity: 1;
    transform: translate3d(var(--confetti-x), -8vh, 0) rotate(0deg);
  }

  100% {
    opacity: .92;
    transform: translate3d(calc(var(--confetti-x) + var(--confetti-drift)), 108vh, 0) rotate(var(--confetti-spin));
  }
}

@keyframes tic-firework-fall {
  0% {
    opacity: 1;
    transform: translate3d(var(--firework-x), var(--firework-start-y), 0) rotate(0deg) scale(.7);
  }

  18% {
    opacity: 1;
    transform: translate3d(calc(var(--firework-x) + (var(--firework-drift) * .18)), 16vh, 0) rotate(calc(var(--firework-spin) * .25)) scale(1.15);
  }

  100% {
    opacity: .94;
    transform: translate3d(calc(var(--firework-x) + var(--firework-drift)), var(--firework-end-y), 0) rotate(var(--firework-spin)) scale(1);
  }
}

@media (max-width: 700px) {
  .stage-content:has(.wheel-game) {
    padding: 4px 10px 8px;
    align-items: stretch;
    justify-items: center;
    overflow: hidden;
  }

  .wheel-game {
    width: min(480px, 100%);
  }

  .wheel-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    align-items: stretch;
    width: 100%;
    height: 100%;
    min-height: 0;
    gap: 0;
    overflow: hidden;
  }

  .wheel-wrap {
    width: min(320px, 78vw, 38dvh);
    margin-bottom: 2px;
    place-self: start center;
  }

  .wheel-settings {
    width: 100%;
    height: 100%;
    max-height: none;
    min-height: 0;
    padding: 0 8px 4px;
    overflow: hidden;
    place-self: stretch;
    border: none;
    background: none;
  }

  .wheel-settings-heading {
    gap: 8px;
    margin-bottom: 2px;
  }

  .wheel-settings h3 {
    font-size: 1.15rem;
  }

  .wheel-add {
    padding: 5px;
    padding-top: 0px;
    padding-bottom: 0px;
    margin-top: 0;
  }

  .wheel-new-prize:not(:empty) {
    margin-bottom: 4px;
  }

  .wheel-prizes {
    gap: 4px;
    max-height: none;
    min-height: 0;
    overflow-y: scroll;
    contain: content;
  }

  .wheel-prize-row {
    grid-template-columns: 24px minmax(0, 1fr) 30px;
    gap: 4px;
  }

  .wheel-prize-row>span {
    width: 22px;
    height: 22px;
  }

  .wheel-prize-text,
  .wheel-new-prize-input {
    height: 32px;
    padding: 0 8px;
  }

  .wheel-prize-row button {
    height: 30px;
  }

  .wheel-hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  #wheel-canvas {
    transition-duration: .01ms;
  }

  .win-burst {
    animation: none;
  }

  .win-confetti {
    display: none;
  }
}

.math-question {
  display: grid;
  min-height: 112px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  color: var(--text);
  font-size: clamp(2.4rem, 14vw, 5rem);
  font-weight: 900;
  line-height: 1;
}

.math-answers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(72px, 1fr));
  gap: 8px;
}

.math-answer {
  min-width: 0;
  min-height: 72px;
  border: 1px solid #46606c;
  border-radius: var(--radius);
  background: #25404c;
  color: var(--text);
  cursor: pointer;
  font-size: clamp(1.5rem, 8vw, 2.5rem);
  font-weight: 850;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.math-answer:focus-visible,
.math-answer:hover {
  outline: none;
  border-color: var(--accent);
  background: #2d4c58;
}

.math-answer:active:not(:disabled) {
  background: var(--cyan);
  color: #071817;
}

.math-answer:disabled {
  opacity: 0.5;
  cursor: default;
}

@media (min-width: 820px) {
  .app-shell {
    padding-top: 36px;
  }

  .app-main {
    grid-template-columns: 360px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
  }

  .is-playing .game-library {
    display: block;
  }

  .game-stage {
    min-height: 0;
  }

  .stage-content {
    min-height: 0;
  }
}

@media (max-width: 819px) {
  h1 {
    font-size: 2rem;
  }

  .icon-button {
    width: 40px;
    height: 40px;
  }

  .app-main {
    grid-template-rows: minmax(0, 1fr);
  }

  .game-stage {
    display: none;
  }

  .is-playing .game-stage {
    display: grid;
  }

  .is-playing .app-shell {
    grid-template-rows: minmax(0, 1fr);
  }

  .is-playing .app-header {
    display: none;
  }
}

@media (max-height: 680px) {
  h1 {
    font-size: clamp(1.8rem, 8vw, 3rem);
  }

  .eyebrow {
    margin-bottom: 3px;
    font-size: 0.7rem;
  }

  h2 {
    font-size: 1rem;
  }

  .game-card {
    gap: 4px;
    padding: 4px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }

  .tap-target {
    width: min(230px, 48dvh, 100%);
  }

  .reaction-target {
    width: min(260px, 48dvh, 100%);
  }

  .memory-grid {
    width: min(360px, 43dvh, 100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .game-card {
    transition: none;
  }

  .game-card.is-launching {
    animation: none;
  }
}
