/* Shared look for every game: colours, type, buttons, panels, menu, player chips, status line, share panel.
   The idea: the look the big phone games share. A deep violet-blue ground, white panels that sit on it,
   chunky buttons with a thick bottom edge, green for "play", yellow for "live / selected", rounded type.

   Two sets of colours:
   - on the ground (the page itself) writing is white;
   - on a panel (anything white: cards, buttons, playing cards, name chips) writing is dark.
   The second set is switched on by the "panels" rule below, so a game's own styles can keep saying var(--ink). */
@font-face {
  font-family: "Fredoka";
  src: url("/shared/fredoka.woff2") format("woff2");
  font-weight: 500 700; font-style: normal; font-display: swap;
}
:root {
  --ground-top: #5a2ee6;
  --ground-mid: #3b21b8;
  --ground-low: #1c1470;
  /* kept from the earlier designs so older styles keep working */
  --cloth: #2a1a96;
  --cloth-deep: #160d52;
  --on-cloth: #ffffff;

  /* on the ground */
  --ink: #ffffff;                       /* text */
  --muted: #d5d2ff;                     /* secondary text */
  --link: #ffe14a;
  --sand: rgba(255, 255, 255, .14);     /* quiet fills */
  --sand-deep: rgba(255, 255, 255, .22);/* quiet borders, chips */
  --line: #160d52;                      /* outlines */

  /* the same everywhere */
  --paper: #ffffff;                     /* panels */
  --panel-ink: #22185c;
  --clay: #1f7ae8;                      /* bright blue: card backs, bands, chosen names */
  --clay-dark: #1c5fd0;
  --dark-piece: #1c1c26;
  --light-piece: #ffffff;
  --gold: #ffd21f;                      /* live: your turn, can be tapped, selected */
  --go: #16973a;
  --go-light: #34cc57;
  --danger: #e5333f;
  --edge: rgba(8, 4, 48, .38);          /* the thick bottom edge under buttons and panels */
  --display: "Fredoka", ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}

/* Panels: everything with a white (or yellow) face gets the dark set of colours. */
.card, .share, dialog, .btn, .player, .tile-face,
.cs-card, .cs-choices, .cs-mine, .cs-results,
.c8-other.turn, .c8-need, .c8-card, .c8-picker, .c8-pick, .c8-mine, .c8-results, .c8-mark,
.dm-other, .dm-results, .dm-end,
.dr-board, .lu-board, .lu-dice, .mc-board,
.pg-pc, .pg-stat, .pg-scores li, .pg-result, .kg-pick, .kg-pip,
.pp-name {
  --ink: var(--panel-ink);
  --muted: #5d5791;
  --link: var(--clay-dark);
  --sand: #eef0ff;
  --sand-deep: #cdd0f2;
  --line: #22185c;
  color: var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
html { background: var(--ground-low); }
body {
  background: linear-gradient(180deg, var(--ground-top) 0, var(--ground-mid) 340px, var(--ground-low) 900px) var(--ground-low);
  color: var(--ink);
  font: 16px/1.45 var(--body);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
main { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
h1, h2 { font-family: var(--display); font-weight: 700; margin: 0; }

/* The name at the top: big rounded letters with a hard shadow, like a game's title screen. */
.hero { text-align: center; padding: 18px 4px 6px; margin-bottom: 18px; }
.hero h1 {
  font-size: clamp(42px, 13.5vw, 68px); line-height: 1; letter-spacing: .005em; text-wrap: balance;
  color: #fff; text-shadow: 0 2px 0 var(--gold), 0 6px 0 var(--cloth-deep), 0 10px 18px rgba(8, 4, 48, .5);
}
.lead { color: var(--muted); margin: 14px auto 0; max-width: 30ch; font-size: 17px; font-weight: 600; }
.kicker { display: none; }

.menu { display: grid; gap: 14px; }
.card { background: var(--paper); border: 0; border-radius: 18px; padding: 16px; box-shadow: 0 5px 0 var(--edge); }
.card h2 { font-size: 23px; line-height: 1.15; margin-bottom: 6px; }
.card p { margin: 0 0 12px; color: var(--muted); font-size: 15px; }
.levels { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 10px; }
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(52px, 1fr)); gap: 10px; }

/* Buttons: a face and a thick bottom edge. Pressing pushes the face down onto the edge. */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 9px 16px;
  border: 2px solid var(--line); border-radius: 14px;
  background: var(--paper); color: var(--ink);
  box-shadow: 0 4px 0 var(--edge);
  font: inherit; font-family: var(--display); font-weight: 600; font-size: 17px; text-decoration: none; cursor: pointer;
}
.btn.primary {
  background: linear-gradient(180deg, var(--go-light), var(--go)); border-color: #0c5c22; color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .28);
}
.btn[aria-pressed=true] { background: var(--gold); border-color: var(--line); color: var(--panel-ink); }
.btn:disabled { opacity: .5; cursor: default; }
.btn:not(:disabled):active { transform: translateY(3px); box-shadow: 0 1px 0 var(--edge); }
.btn:focus-visible, .link:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.link { background: none; border: 0; padding: 10px 4px; color: var(--link); font: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; justify-self: center; display: inline-block; }
.error { color: #fff; background: var(--danger); border-radius: 12px; padding: 10px 12px; font-weight: 700; text-align: center; margin: 0; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -6px -6px 12px; padding: 2px 6px; background: rgba(8, 4, 48, .42); border-radius: 16px; }
.topbar .link { color: #fff; padding: 8px 10px; min-height: 44px; text-decoration: none; }
.mode { display: inline-block; font-size: 14px; color: var(--gold); font-weight: 700; text-align: center; }
.mode::first-letter { text-transform: uppercase; }

.players { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.player { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; border: 3px solid transparent; background: var(--paper); min-width: 0; opacity: .82; }
.player.active { border-color: var(--line); background: var(--gold); opacity: 1; box-shadow: 0 4px 0 var(--edge); }
.player.active .who small { color: var(--ink); }
.swatch { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); }
.who { display: grid; min-width: 0; line-height: 1.2; }
.who strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: var(--muted); font-size: 12px; }

.status { text-align: center; font-family: var(--display); font-weight: 600; font-size: 18px; margin: 12px 0 8px; min-height: 2.9em; display: flex; align-items: center; justify-content: center; text-wrap: balance; }
.status.over { font-weight: 700; font-size: 30px; line-height: 1.1; color: var(--gold); text-shadow: 0 3px 0 var(--cloth-deep); }

.board-area { width: 100%; margin: 0 auto; }
.cover { text-align: center; padding: 28px 16px; }
.cover p { font-size: 20px; font-weight: 700; color: var(--ink); }

.share { background: var(--paper); border-radius: 18px; padding: 14px; margin-top: 14px; box-shadow: 0 5px 0 var(--edge); }
.share p { margin: 0 0 8px; font-weight: 700; }
.share input { width: 100%; padding: 10px; border: 2px solid var(--sand-deep); border-radius: 10px; font: inherit; font-size: 14px; background: var(--sand); color: var(--ink); margin-bottom: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }
.actions { margin-top: 16px; }

dialog { border: 0; border-radius: 20px; padding: 20px; max-width: min(520px, calc(100vw - 32px)); background: var(--paper); box-shadow: 0 6px 0 var(--edge); }
dialog::backdrop { background: rgba(12, 6, 60, .78); }
dialog h2 { margin-bottom: 10px; font-size: 30px; }
dialog ol, dialog ul { padding-left: 20px; margin: 0 0 16px; }
dialog li { margin-bottom: 8px; }
dialog .btn { width: 100%; }

@keyframes pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
