:root {
  color-scheme: dark;
  --background: #0d0a16;
  --panel: #191328;
  --border: #382b4b;
  --text: #f7f2ff;
  --muted: #baafcc;
  --lime: #c4fa64;
  --violet: #bf98ff;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--text); background: var(--background); min-height: 100svh; }
.wrap { width: min(100% - 40px, 1200px); margin-inline: auto; }
.top { min-height: 86px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { display: inline-flex; gap: 10px; align-items: center; font-size: .875rem; font-weight: 850; letter-spacing: .095em; text-decoration: none; }
.brand span { background: var(--lime); color: #141a09; text-align: center; border-radius: 9px; width: 33px; line-height: 33px; font-size: 1.35rem; }
a { color: inherit; }
button { font: inherit; cursor: pointer; color: inherit; }
button:disabled { opacity: .48; cursor: default; }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 4px; }
.hero { position: relative; display: grid; align-items: center; isolation: isolate; overflow: hidden; min-height: clamp(510px, 53vw, 680px); border: 1px solid var(--border); border-radius: 27px; background: #090615; margin-bottom: 24px; }
.hero-art { position: absolute; inset: 0 0 0 auto; width: 74%; height: 100%; object-fit: cover; object-position: center; z-index: -2; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, #090615 20%, #090615e0 33%, #09061500 68%); z-index: -1; }
.hero-copy { padding: clamp(30px, 6vw, 85px); }
.eyebrow, small { color: var(--violet); font-family: ui-monospace, monospace; font-size: .875rem; font-weight: 700; letter-spacing: .14em; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(2.5rem, 7vw, 5.5rem); line-height: .98; letter-spacing: -.075em; margin-block: 15px 22px; }
h1 em { color: var(--lime); font-style: normal; }
.intro { color: var(--muted); line-height: 1.55; }
.primary, .secondary, .subtle { min-height: 46px; padding: 10px 18px; border-radius: 11px; font-weight: 750; border: 1px solid var(--border); }
.primary { color: #181e0b; background: var(--lime); border-color: transparent; }
.primary:hover:enabled { background: #ddff9f; }
.secondary, .subtle { background: var(--panel); }
.secondary:hover, .subtle:hover { background: #302243; }
#play { margin-top: 26px; min-height: 54px; padding-inline: 23px; }
#play span { margin-right: 8px; }
.page { padding: 36px 0 45px; }
.library { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; max-width: 820px; }
.game-card { padding: 0; text-align: left; background: var(--panel); border: 1px solid var(--border); overflow: hidden; border-radius: 20px; }
.game-card:hover { border-color: var(--violet); }
.cover { display: grid; place-items: center; min-height: 145px; font-size: 4.5rem; }
.ttt-cover { display: flex; justify-content: center; align-items: center; gap: 12px; background: radial-gradient(ellipse, #3b2359, #211331); color: var(--violet); }
.ttt-cover b:nth-child(2) { color: var(--lime); transform: translateY(-8px); }
.tap-cover { color: var(--lime); background: radial-gradient(ellipse, #323c1d, #161a13); text-shadow: 0 0 35px #b5ff5977; }
.card-copy { display: grid; gap: 6px; padding: 19px; }
.card-copy strong { font-size: 1.35rem; }
.card-copy > span { color: var(--muted); }
.game { max-width: 420px; margin-inline: auto; }
.game h1 { font-size: clamp(2.45rem, 9vw, 4rem); }
.back { display: inline-flex; align-items: center; min-height: 44px; color: var(--violet); text-underline-offset: 4px; }
.scores, .actions { display: flex; gap: 10px; }
.scores > div { flex: 1; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 15px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.scores strong { font-size: 1.3rem; }
.x { color: var(--lime); }
.o { color: var(--violet); }
.status { text-align: center; min-height: 24px; margin-block: 14px; font-weight: 700; }
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cell { aspect-ratio: 1; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); font-size: clamp(2rem, 12vw, 4.5rem); line-height: 1; font-weight: 750; }
.cell[aria-disabled="true"] { cursor: default; }
.cell[aria-disabled="false"]:hover { background: #302243; }
.cell.win { border-color: currentColor; background: #2d2340; }
.actions { margin-top: 16px; justify-content: space-between; flex-wrap: wrap; }
.tap-pad { width: 100%; min-height: 200px; margin-top: 20px; border: 1px solid var(--border); border-radius: 18px; background: #302243; font-size: 1.4rem; font-weight: 800; touch-action: manipulation; }
.tap-pad.ready { color: #181e0b; background: var(--lime); }
dialog { width: min(calc(100% - 36px), 450px); border: 1px solid var(--border); border-radius: 20px; padding: 25px; background: var(--panel); color: var(--text); }
dialog::backdrop { background: #080611b8; }
dialog h2 { margin-block: 10px; font-size: 1.65rem; }
#install-help { color: var(--muted); line-height: 1.55; }
@media (max-width: 650px) {
  .wrap { width: calc(100% - 28px); }
  .top { min-height: 66px; }
  .hero { align-items: end; min-height: auto; }
  .hero-art { position: relative; width: 100%; height: auto; aspect-ratio: 1.3; }
  .hero::after { background: linear-gradient(0deg, #090615 40%, transparent 76%); }
  .hero-copy { margin-top: -38px; padding: 0 23px 26px; }
  .hero-copy h1 { font-size: clamp(2.8rem, 11vw, 4.4rem); }
  .library { grid-template-columns: 1fr; }
  .page { padding-top: 23px; }
}
.card-copy { position: relative; }
.sticker {
  position: absolute;
  top: -22px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 32px;
  border-radius: 10px;
  background: var(--lime);
  color: #161b0b;
  font: 700 1rem system-ui, sans-serif;
}
.dots-cover { background: radial-gradient(ellipse, #37395b, #17172a); color: #babcff; }
.coin-cover { background: radial-gradient(ellipse, #4a351d, #251b17); color: #ffce76; }
.dice-cover { background: radial-gradient(ellipse, #50263d, #271627); color: #ffadca; }
.extra-scores { margin-top: 16px; }
.dots-board {
  display: grid;
  grid-template-columns: 18px repeat(var(--dot-intervals), minmax(0, 1fr) 18px);
  grid-template-rows: 18px repeat(var(--dot-intervals), minmax(0, 1fr) 18px);
  width: min(100%, 420px);
  aspect-ratio: 1;
  margin-inline: auto;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text); place-self: center; }
.edge { position: relative; padding: 0; border: 0; background: transparent; touch-action: manipulation; }
.edge::before { content: ""; position: absolute; inset: 50% 0 auto; height: 5px; border-radius: 5px; background: var(--border); transform: translateY(-50%); }
.edge.vertical::before { inset: 0 auto 0 50%; width: 5px; height: auto; transform: translateX(-50%); }
.edge:hover::before { background: var(--muted); }
.edge.p1::before { background: var(--lime); }
.edge.p2::before { background: var(--violet); }
.edge[aria-disabled="true"] { cursor: default; }
.claim { display: grid; place-items: center; margin: 1px; border-radius: 6px; font-size: clamp(.85rem, 4vw, 1.25rem); font-weight: 800; }
.claim.p1 { background: #292e19; color: var(--lime); }
.claim.p2 { background: #2e2045; color: var(--violet); }
.coin-stage { display: grid; place-items: center; height: 220px; perspective: 700px; }
.coin-face { position: relative; width: 145px; aspect-ratio: 1; transform-style: preserve-3d; }
.coin-face span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 7px double #81551d;
  background: radial-gradient(circle at 35% 30%, #fff0a4, #e6a43b);
  color: #38230c;
  box-shadow: inset 0 0 0 6px #ffda6d;
  font-size: 3.5rem;
  font-weight: 900;
  backface-visibility: hidden;
}
.coin-face span + span { transform: rotateY(180deg); }
.die { text-align: center; color: #ffadca; font-size: 9rem; line-height: 1.3; }
.wide { width: 100%; }

.scores label { min-width: 0; display: grid; gap: 4px; font-size: .875rem; font-weight: 700; }
.scores input {
  width: 100%;
  min-width: 0;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  background: var(--background);
  font: inherit;
  font-size: 1rem;
}
.scores input::placeholder { color: var(--muted); }
.edge::after { content: ""; position: absolute; inset: -4px 0; }
.edge.vertical::after { inset: 0 -4px; }
.edge:focus-visible { z-index: 1; outline-offset: 0; }
#offline-ready { color: var(--lime); margin-bottom: 10px; font-weight: 700; }
.memory-cover, .sequence-cover { background: radial-gradient(ellipse, #3b2359, #211331); color: var(--violet); }
.four-cover, .tug-cover { background: radial-gradient(ellipse, #323c1d, #161a13); color: var(--lime); }
.nim-cover, .target-cover { background: radial-gradient(ellipse, #50263d, #271627); color: #ffadca; }
.word-cover { background: radial-gradient(ellipse, #4a351d, #251b17); color: #ffce76; font-weight: 800; }
.mini-grid, .four-grid { display: grid; gap: 6px; }
.memory-board, .target-board { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mini-grid button, .four-grid button {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
  min-width: 0;
  min-height: 42px;
  touch-action: manipulation;
}
.mini-grid button[aria-disabled="true"], .four-grid button[aria-disabled="true"] { cursor: default; }
.memory-board button, .target-board button { aspect-ratio: 1; font-size: clamp(1.3rem, 6vw, 2.4rem); font-weight: 800; }
.memory-board button.revealed { background: #302243; color: var(--violet); }
.memory-board button.matched { color: var(--lime); border-color: var(--lime); }
.mode { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.mode select, .word-form input {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel);
  min-height: 44px;
  padding: 6px 10px;
}
.four-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.four-board { margin-top: 8px; padding: 8px; border-radius: 12px; background: var(--panel); }
.hole { aspect-ratio: 1; border-radius: 50%; background: var(--background); border: 2px solid var(--border); }
.hole.piece-1 { background: var(--lime); }
.hole.piece-2 { background: var(--violet); }
.hole.winning { border-color: white; }
.tokens { min-height: 4rem; font-size: 1.5rem; color: var(--lime); }
#nim-controls .primary { flex: 1; padding-inline: 8px; }
.sequence-pads { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sequence-pads button { min-height: 88px; font-weight: 800; border-color: var(--tone); color: var(--tone); }
.sequence-pads button.lit { background: var(--tone); color: #0d0a16; }
.sequence-pads button:nth-child(1) { --tone: #ff97a8; }
.sequence-pads button:nth-child(2) { --tone: #93c7ff; }
.sequence-pads button:nth-child(3) { --tone: #b7f988; }
.sequence-pads button:nth-child(4) { --tone: #ffdb80; }
.word-letters { margin-block: 25px; color: var(--lime); font-size: clamp(1.5rem, 8vw, 2.6rem); letter-spacing: .12em; font-weight: 850; }
.word-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.word-form label { grid-column: 1 / -1; }
.target-board button.active-target { background: var(--lime); color: #0d0a16; }
.tug-meter { width: 100%; height: 24px; accent-color: var(--lime); }
.tug-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
.tug-controls button { min-height: 110px; overflow-wrap: anywhere; touch-action: manipulation; user-select: none; }
#tug .scores label { width: 100%; }
