:root {
  --red: #e10600;
  --red-hi: #ff7a72;
  --yellow: #f5c400;
  --yellow-hi: #ffe56a;
  --ink: #f4f7fb;
  --muted: #c5d4ea;
  --board: #0d4cb5;
  --board-deep: #08398a;
  --hole: #07111f;
  --line: rgba(255, 255, 255, 0.16);
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 50% 18%, #1c4f8f 0%, transparent 52%),
    radial-gradient(ellipse at 50% 120%, #041018 0%, #07111f 58%);
}

button, input { font: inherit; color: inherit; }

button { cursor: pointer; }

.app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

.update-banner {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: #f5c400;
  color: #1a1400;
}

.update-banner[hidden] { display: none; }

.update-banner p { margin: 0; font-weight: 650; }

.update-banner button,
.actions button,
.primary {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  min-height: 44px;
  background: #12325f;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.update-banner button {
  background: #1a1400;
  color: #fff8dc;
  font-weight: 700;
}

.primary {
  background: linear-gradient(#2f7ae6, #1456c2);
  font-weight: 750;
  min-width: 160px;
}

.actions button:focus-visible,
.primary:focus-visible,
.choice:focus-visible,
.column:focus-visible,
.swatch:focus-visible,
.update-banner button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.setup {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 24px 16px 32px;
}

.card {
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 20px 20px;
  border-radius: 22px;
  background: rgba(8, 22, 44, 0.78);
  box-shadow: inset 0 0 0 1px var(--line), 0 18px 50px rgba(0, 0, 0, 0.35);
}

.card h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 2.6rem);
  letter-spacing: -0.04em;
}

.lede { margin: -8px 0 0; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 8px; }

.field span.label { font-size: 0.85rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }

.choices { display: flex; gap: 8px; }

.choice, .swatch {
  flex: 1;
  min-height: 48px;
  border-radius: 14px;
  border: 0;
  background: #10284a;
  box-shadow: inset 0 0 0 1px var(--line);
}

.choice[aria-pressed="true"] {
  background: #1d4e96;
  box-shadow: inset 0 0 0 2px #8eb7ff;
}

.swatches { display: flex; gap: 12px; }

.swatch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px;
}

.swatch i {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: block;
}

.swatch.red i { background: radial-gradient(circle at 35% 32%, var(--red-hi), var(--red) 55%, #6d0000); }
.swatch.yellow i { background: radial-gradient(circle at 35% 32%, var(--yellow-hi), var(--yellow) 55%, #8a6a00); }

.swatch[aria-pressed="true"] { box-shadow: inset 0 0 0 2px #fff; }

.game {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 4px;
}

.scores { display: flex; flex-wrap: wrap; gap: 6px; }

.pill {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(8, 22, 44, 0.72);
  box-shadow: inset 0 0 0 1px var(--line);
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.dot.red { background: radial-gradient(circle at 35% 32%, var(--red-hi), var(--red)); }
.dot.yellow { background: radial-gradient(circle at 35% 32%, var(--yellow-hi), var(--yellow)); }

.actions { display: flex; gap: 8px; }

.status {
  margin: 0;
  padding: 0 14px 6px;
  min-height: 1.4em;
  font-weight: 650;
}

.table {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 4px 10px 12px;
  container-type: size;
}

.board {
  width: min(100cqw, calc(100cqh * 7 / 6.55));
  height: min(100cqh, calc(100cqw * 6.55 / 7));
  max-width: 920px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: clamp(4px, 1.1cqw, 10px);
  padding: clamp(8px, 1.6cqw, 16px);
  border-radius: 18px;
  background:
    linear-gradient(180deg, #2a74e4 0%, var(--board) 28%, var(--board-deep) 100%);
  box-shadow:
    inset 0 0 0 4px #082e70,
    inset 0 8px 16px rgba(255, 255, 255, 0.18),
    0 16px 40px rgba(0, 0, 0, 0.4);
}

.column {
  display: grid;
  grid-template-rows: 0.55fr repeat(6, 1fr);
  gap: clamp(4px, 1.1cqw, 10px);
  padding: 0;
  border: 0;
  background: transparent;
  min-width: 0;
  min-height: 0;
}

.ghost, .slot {
  min-height: 0;
  border-radius: 50%;
}

.ghost {
  opacity: 0;
  transform: translateY(-6px);
  justify-self: center;
  width: 78%;
  height: 78%;
  align-self: end;
}

.column:hover .ghost,
.column:focus-visible .ghost,
.column.preview .ghost {
  opacity: 0.85;
  transform: none;
}

.column.red .ghost { background: radial-gradient(circle at 35% 32%, var(--red-hi), var(--red)); }
.column.yellow .ghost { background: radial-gradient(circle at 35% 32%, var(--yellow-hi), var(--yellow)); }

.column:disabled { cursor: default; }
.column:disabled .ghost { opacity: 0; }

.slot {
  position: relative;
  background: radial-gradient(circle at 50% 45%, var(--hole) 68%, rgba(0, 0, 0, 0.15) 70%, rgba(255, 255, 255, 0.18) 78%, transparent 80%);
  box-shadow: inset 0 6px 8px rgba(0, 0, 0, 0.35);
}

.disc {
  position: absolute;
  inset: 7%;
  border-radius: 50%;
  transform: translateY(0);
  transition: transform 0.34s cubic-bezier(0.15, 0.7, 0.2, 1);
  box-shadow: inset 0 -6px 8px rgba(0, 0, 0, 0.25);
}

.disc.red { background: radial-gradient(circle at 35% 32%, var(--red-hi), var(--red) 52%, #7a0500); }
.disc.yellow { background: radial-gradient(circle at 35% 32%, var(--yellow-hi), var(--yellow) 52%, #8a6a00); }

.slot.win .disc {
  box-shadow:
    inset 0 -6px 8px rgba(0, 0, 0, 0.25),
    0 0 0 3px #fff;
}

.end-dialog {
  border: 0;
  padding: 28px 26px 22px;
  border-radius: 22px;
  color: var(--ink);
  background: #10243f;
  box-shadow: inset 0 0 0 1px var(--line), 0 24px 60px rgba(0, 0, 0, 0.45);
  max-width: min(420px, calc(100vw - 32px));
}

.end-dialog::backdrop {
  background: rgba(4, 10, 20, 0.62);
}

.end-dialog h2 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  letter-spacing: -0.03em;
}

.end-dialog p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.end-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.end-actions button { flex: 1; min-width: 120px; }

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

@supports not (width: 1cqw) {
  .board {
    width: min(100%, 92vw);
    height: auto;
    aspect-ratio: 7 / 6.55;
  }
}
