@font-face {
  font-family: "Bricolage Grotesque";
  src: url("../fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

@font-face {
  font-family: "Figtree";
  src: url("../fonts/figtree.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
}

/* ---------- Tokens ---------- */

:root {
  --display: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;

  --bg: #ecefe9;
  --surface: #ffffff;
  --surface-2: #e0e6dc;
  --ink: #14201a;
  --muted: #55625a;
  --line: #cdd5c8;
  --accent: #a87b12;
  --win: #0b7f5f;
  --loss: #c62a41;
  --brass: #b88a1c;

  /* Fixed casino colours, same in both themes. */
  --gold: #e9c460;
  --gold-deep: #c2942b;
  --gold-ink: #2a1c00;
  --felt: #115a40;
  --felt-light: #1d7a56;
  --felt-dark: #0a3a29;
  --chip-red: #d2364e;
  --chip-black: #1c2033;
  --chip-blue: #3478c6;
  --chip-green: #0e8a66;
  --chip-gold: #c99a2e;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0c100e;
  --surface: #151b18;
  --surface-2: #212a25;
  --ink: #f3eee2;
  --muted: #a2aaa0;
  --line: #2e3933;
  --accent: #e9c460;
  --win: #4fd08f;
  --loss: #ff7b7b;
  --brass: #e9c460;

  --chip-black: #070a13;

  color-scheme: dark;
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.5 var(--body);
  font-variant-numeric: tabular-nums;
}

main {
  flex: 1;
  padding-block: 2rem 3rem;
}

h1,
h2,
h3,
p,
dl,
dd,
ol,
ul {
  margin: 0;
}

ol,
ul {
  padding: 0;
  list-style: none;
}

h1,
h2 {
  font-family: var(--display);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 800;
}

a {
  color: inherit;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

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

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.shell {
  width: min(100% - 2.5rem, 70rem);
  margin-inline: auto;
}

[data-tone="win"] {
  color: var(--win);
}

[data-tone="loss"],
[data-tone="error"] {
  color: var(--loss);
}

/* ---------- Header ---------- */

.top {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.875rem 0.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font: 800 1.3rem/1 var(--display);
  letter-spacing: -0.03em;
  text-decoration: none;
}

/* A casino chip: gold disc with four white stripes on its edge. */
.brand::before {
  content: "";
  flex: none;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  background:
    radial-gradient(closest-side, var(--gold-deep) 70%, transparent 71%),
    repeating-conic-gradient(from -22.5deg, rgb(255 255 255 / 0.85) 0 45deg, var(--gold-deep) 0 90deg);
  box-shadow: 0 0 0 1px var(--gold-deep);
}

.wallet {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.balance {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  border-radius: 99px;
  background: var(--surface-2);
  font-weight: 700;
}

.balance.gain {
  animation: balance-gain 1.2s ease-out;
}

@keyframes balance-gain {
  15% {
    transform: scale(1.12);
    box-shadow: 0 0 0 0.35rem color-mix(in srgb, var(--gold) 55%, transparent);
    color: var(--win);
  }
  60% {
    color: var(--win);
  }
}

.balance::before {
  content: "";
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background: var(--brass);
  box-shadow: inset 0 0 0 2px rgb(255 255 255 / 0.45);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border: 0;
  border-radius: 50%;
  background: none;
}

.lang {
  font-size: 0.8125rem;
  font-weight: 700;
  text-decoration: none;
}

.icon-btn:hover {
  background: var(--surface-2);
}

.icon-btn svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:root[data-theme="dark"] .icon-moon,
:root:not([data-theme="dark"]) .icon-sun,
:root[data-sound="off"] .icon-sound-on,
:root:not([data-sound="off"]) .icon-sound-off {
  display: none;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: -1px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs a {
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.tabs a:first-child {
  margin-left: -0.75rem;
}

.tabs a:hover {
  color: var(--ink);
}

.tabs a[aria-current="page"] {
  border-bottom-color: var(--accent);
  color: var(--ink);
}

.tabs a:focus-visible {
  outline-offset: -2px;
}

.tabs-end {
  margin-left: auto;
}

.foot {
  padding-block: 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
}

/* ---------- Controls ---------- */

.btn {
  padding: 0.55rem 0.8rem;
  border: 0;
  border-radius: 10px;
  background: var(--surface-2);
  font-weight: 600;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--line);
}

.btn-play {
  width: 100%;
  padding: 0.9rem 1rem;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(var(--gold), var(--gold-deep));
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.55),
    0 2px 0 #8a6614;
  color: var(--gold-ink);
  font: 700 1.1rem/1.2 var(--display);
}

.btn-play:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-play:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-play:disabled,
.btn:disabled {
  opacity: 0.5;
}

.btn-danger {
  background: none;
  box-shadow: inset 0 0 0 1px var(--loss);
  color: var(--loss);
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field > label,
.field > .label {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
}

input[type="number"],
.sync-form input {
  width: 100%;
  min-width: 0;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-weight: 600;
}

.stake-row {
  display: flex;
  gap: 0.35rem;
}

.seg {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  padding: 3px;
  border-radius: 12px;
  background: var(--surface-2);
}

.seg label {
  position: relative;
  padding: 0.5rem 0.25rem;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.seg input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.seg label:has(input:checked) {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgb(10 15 35 / 0.18);
}

.seg label:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.seg label:has(input:disabled) {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Game page ---------- */

.game-head {
  margin-bottom: 1.5rem;
}

.game-head p {
  max-width: 60ch;
  margin-top: 0.4rem;
  color: var(--muted);
}

.game-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20rem;
  gap: 1.5rem;
  align-items: start;
}

/* The stage is a felt table in both themes. Tokens are re-pointed inside it so
   everything a game draws there (text, canvases, wheels) reads on green. */
.stage {
  --surface: #0d4a35;
  --surface-2: rgb(0 0 0 / 0.28);
  --ink: #f7f3e6;
  --muted: #b7cfc1;
  --line: rgb(255 255 255 / 0.18);
  --accent: var(--gold);
  --brass: var(--gold);
  --win: #86f0b9;
  --loss: #ffa3a3;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  min-height: 27rem;
  padding: 1.75rem;
  border: 1px solid var(--felt-dark);
  border-radius: 24px;
  background: radial-gradient(ellipse at 50% 30%, var(--felt-light), var(--felt) 55%, var(--felt-dark));
  /* Dark rail, then a thin gold line, like the edge of a table. */
  box-shadow:
    inset 0 0 0 6px var(--felt-dark),
    inset 0 0 0 7px rgb(233 196 96 / 0.6),
    0 18px 30px -22px rgb(0 0 0 / 0.7);
  color: var(--ink);
}

.panel,
.panel fieldset {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.panel fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.panel-row {
  display: flex;
  gap: 0.5rem;
}

.panel-row > * {
  flex: 1;
}

.outcome {
  min-height: 1.5em;
  font-weight: 700;
}

/* Live stats banner under every game. */
.live {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
}

.live-figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
  gap: 1rem 1.5rem;
}

.live-figures dt {
  color: var(--muted);
  font-size: 0.8125rem;
}

.live-figures dd {
  font: 700 1.25rem/1.3 var(--display);
}

.live-figures dd.bump {
  animation: bump 0.45s ease-out;
}

@keyframes bump {
  from {
    opacity: 0.25;
    transform: translateY(-0.3rem);
  }
}

.live-trend {
  grid-column: span 2;
}

.spark {
  display: block;
  width: 100%;
  height: 1.625rem;
  overflow: visible;
}

.spark-line {
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.spark-line[data-tone="win"] {
  stroke: var(--win);
}

.spark-line[data-tone="loss"] {
  stroke: var(--loss);
}

.spark-zero {
  stroke: var(--line);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  vector-effect: non-scaling-stroke;
}

.figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 1rem 1.5rem;
}

.figures dt {
  color: var(--muted);
  font-size: 0.875rem;
}

.figures dd {
  font: 700 1.5rem/1.2 var(--display);
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-height: 1.7rem;
}

.pills li {
  padding: 0.1rem 0.6rem;
  border-radius: 99px;
  background: var(--surface-2);
  font-size: 0.875rem;
  font-weight: 700;
}

/* ---------- Spinning wheel (roulette, wheel) ---------- */

.wheel-wrap {
  position: relative;
  width: min(100%, 22rem);
  aspect-ratio: 1;
}

.wheel {
  display: block;
  width: 100%;
  height: 100%;
}

.wheel text {
  font-family: var(--display);
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
}

.wheel-pointer {
  position: absolute;
  top: -0.5rem;
  left: 50%;
  z-index: 1;
  width: 0;
  height: 0;
  border: 0.7rem solid transparent;
  border-top: 1.2rem solid var(--ink);
  border-bottom: 0;
  transform: translateX(-50%);
}

.wheel-hub {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: auto;
  width: 38%;
  height: 38%;
  border-radius: 50%;
  background: var(--surface);
  font: 800 clamp(1.5rem, 6vw, 2.25rem) / 1 var(--display);
}

/* ---------- Lobby ---------- */

.hero {
  padding-block: 1.5rem 2.5rem;
}

.hero .suits {
  margin: 0 0 1rem;
  color: var(--ink);
  font-size: 1.5rem;
  letter-spacing: 0.35em;
}

.hero .suits span {
  color: var(--chip-red);
}

.hero h1 {
  max-width: 14ch;
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  line-height: 0.98;
  letter-spacing: -0.035em;
}

.hero p {
  max-width: 56ch;
  margin-top: 1.25rem;
  color: var(--muted);
  font-size: 1.125rem;
}

.lobby {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: 1rem;
}

.lobby-featured .tile {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.lobby-more {
  margin-top: 2.5rem;
  scroll-margin-top: 1.5rem;
}

.lobby-more > h2 {
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.tile {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1rem;
  height: 100%;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  text-decoration: none;
}

.tile:hover {
  border-color: var(--accent);
}

.tile svg {
  grid-row: span 2;
  width: 3.5rem;
  height: 3.5rem;
  padding: 0.7rem;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, var(--felt-light), var(--felt-dark));
  box-shadow: inset 0 0 0 2px rgb(233 196 96 / 0.55);
  color: var(--gold);
}

.tile h2 {
  font-size: 1.5rem;
}

.tile p {
  color: var(--muted);
}

.tile dl {
  grid-column: 1 / -1;
  display: flex;
  gap: 2rem;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
  font-size: 0.875rem;
}

.tile dt {
  color: var(--muted);
}

.tile dd {
  font-weight: 700;
}

/* ---------- Stats page ---------- */

.stats-head {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.table-scroll {
  margin-top: 2rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

th,
td {
  padding: 0.8rem 1rem;
  text-align: right;
}

th:first-child,
td:first-child {
  text-align: left;
}

thead th {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
}

tbody th {
  font-weight: 700;
}

tbody tr {
  border-top: 1px solid var(--line);
}

.chart {
  margin: 2rem 0 0;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
}

.chart h2 {
  font-size: 1.25rem;
}

.chart-plot {
  position: relative;
  height: 18rem;
  margin-top: 1rem;
}

.chart-plot svg {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-label {
  fill: var(--muted);
  font-size: 12px;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-dot {
  fill: var(--accent);
  stroke: var(--surface);
  stroke-width: 2;
}

.chart-cross {
  stroke: var(--muted);
  stroke-width: 1;
}

.chart-tip {
  position: absolute;
  display: grid;
  padding: 0.4rem 0.65rem;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.8125rem;
  white-space: nowrap;
  pointer-events: none;
}

.chart-tip b {
  font-size: 0.9375rem;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

/* ---------- Leaderboard page ---------- */

.lead {
  max-width: 42rem;
  margin-bottom: 1.5rem;
  color: var(--muted);
}

.leaderboard {
  display: grid;
  grid-template-columns: minmax(0, 22rem) minmax(0, 1fr);
  align-items: start;
  gap: 1.5rem;
}

.leaderboard .table-scroll {
  margin-top: 0;
}

.sync-card {
  display: grid;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
}

.sync-card > div {
  display: grid;
  gap: 1rem;
}

.sync-card h2 {
  font-size: 1.25rem;
}

.sync-card h3 {
  margin-top: 0.5rem;
  font-size: 1rem;
}

.sync-card .figures dd {
  font-size: 1.25rem;
}

.sync-form {
  display: flex;
  align-items: end;
  gap: 0.5rem;
}

.sync-form .field {
  flex: 1;
  min-width: 0;
}

/* Buttons keep their own width so the input next to them gets the rest. */
.sync-form > button {
  flex: none;
  width: auto;
}

.code-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* The buttons drop below the code when the card is too narrow for both. */
.sync-code {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  background: var(--surface-2);
  font-weight: 700;
  font-size: 0.875rem;
  white-space: nowrap;
}

.hint,
.sync-status,
.sync-message {
  color: var(--muted);
  font-size: 0.875rem;
}

.sync-message:empty {
  display: none;
}

.sync-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* The player's name reads better on the left, next to the place. */
.leaderboard th:nth-child(2) {
  text-align: left;
}

tr.mine {
  background: var(--surface-2);
}

.board-empty {
  padding: 2rem 1rem;
  color: var(--muted);
  text-align: center;
}

/* ---------- Responsive, motion ---------- */

@media (max-width: 54rem) {
  .game-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .leaderboard {
    grid-template-columns: minmax(0, 1fr);
  }

  .stage {
    min-height: 0;
    padding: 1rem;
  }
}

/* ---------- Top-up suggestion ---------- */

.refill {
  width: min(24rem, calc(100vw - 2rem));
  padding: 1.5rem;
  border: 0;
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1.5rem 3rem rgb(0 0 0 / 0.3);
}

.refill[open] {
  animation: refill-in 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.refill::backdrop {
  background: rgb(0 0 0 / 0.5);
  backdrop-filter: blur(3px);
}

.refill h2 {
  margin: 0 0 0.5rem;
  font: 800 1.5rem/1.2 var(--display);
}

.refill p {
  margin: 0 0 1.25rem;
  color: var(--muted);
}

.refill-actions {
  display: flex;
  gap: 0.5rem;
}

.refill-actions .btn-play {
  flex: 1;
}

@keyframes refill-in {
  from {
    opacity: 0;
    transform: translateY(1rem) scale(0.94);
  }
}

/* ---------- Win celebration ---------- */

.celebrate-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 100;
  pointer-events: none;
}

.celebrate-banner {
  position: fixed;
  inset: 0;
  z-index: 101;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  pointer-events: none;
  opacity: 0;
}

.celebrate-banner.show {
  animation: celebrate-pop 3.2s cubic-bezier(0.2, 0.9, 0.3, 1.2) forwards;
}

.celebrate-amount {
  font: 800 clamp(3rem, 12vw, 7rem) / 1 var(--display);
  color: var(--gold);
  -webkit-text-stroke: 2px var(--gold-ink);
  text-shadow:
    0 0.25rem 0 var(--gold-deep),
    0 0 2.5rem color-mix(in srgb, var(--gold) 70%, transparent);
}

.celebrate-title {
  font: 800 clamp(1.5rem, 5vw, 2.75rem) / 1 var(--display);
  color: var(--gold-ink);
  background: var(--gold);
  padding: 0.2em 0.6em;
  transform: rotate(-3deg);
  box-shadow: 0 0.25rem 0 var(--gold-deep);
}

.celebrate-streak {
  font: 700 clamp(1rem, 3vw, 1.375rem) / 1 var(--display);
  color: var(--win);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.35em 0.9em;
}

.celebrate-streak:empty {
  display: none;
}

.celebrate-shake {
  animation: celebrate-shake 0.5s ease-out;
}

@keyframes celebrate-shake {
  20% {
    transform: translate(-6px, 3px) rotate(-0.4deg);
  }
  40% {
    transform: translate(6px, -3px) rotate(0.4deg);
  }
  60% {
    transform: translate(-4px, 2px);
  }
  80% {
    transform: translate(3px, -1px);
  }
}

.celebrate-x {
  font: 700 clamp(1.25rem, 4vw, 2rem) / 1 var(--display);
  color: var(--gold-ink);
  background: var(--gold);
  border-radius: 999px;
  padding: 0.3em 0.8em;
}

.celebrate-banner[data-big="true"] .celebrate-amount {
  animation: celebrate-shimmer 0.4s ease-in-out 3 alternate;
}

@keyframes celebrate-pop {
  0% {
    opacity: 0;
    transform: scale(0.3) rotate(-8deg);
  }
  18% {
    opacity: 1;
    transform: scale(1.12) rotate(2deg);
  }
  30% {
    transform: scale(1) rotate(0);
  }
  75% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  100% {
    opacity: 0;
    transform: scale(0.9) translateY(-2rem);
  }
}

@keyframes celebrate-shimmer {
  to {
    filter: brightness(1.4) saturate(1.3);
    transform: scale(1.06);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ---------- Achievements ---------- */

.achievements {
  margin-top: 2.5rem;
}

.achievements h2 {
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.achievements-count {
  color: var(--muted);
  font: 600 1rem var(--body);
}

.badges {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 1rem;
}

.badge {
  display: grid;
  align-content: start;
  gap: 0.35rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
}

.badge[data-unlocked="true"] {
  border-color: color-mix(in srgb, var(--gold-deep) 70%, var(--line));
  background: linear-gradient(160deg, color-mix(in srgb, var(--gold) 18%, var(--surface)), var(--surface) 70%);
}

.badge[data-unlocked="false"] h3 {
  color: var(--muted);
}

.badge h3 {
  font-size: 1.125rem;
}

.badge p {
  color: var(--muted);
  font-size: 0.875rem;
}

.badge .badge-status {
  font-weight: 700;
}

.badge[data-unlocked="true"] .badge-status {
  color: var(--accent);
}

.badge meter,
.today meter {
  width: 100%;
  max-width: 28rem;
  height: 0.6rem;
}

/* ---------- Daily goal and unlock cards ---------- */

.today {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
  margin-bottom: 2rem;
  padding: 1.25rem 1.5rem;
  border: 1px solid color-mix(in srgb, var(--gold-deep) 70%, var(--line));
  border-radius: 20px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--gold) 18%, var(--surface)), var(--surface) 70%);
}

.today[hidden] {
  display: none;
}

.today-text {
  display: grid;
  gap: 0.4rem;
  flex: 1 1 18rem;
}

.today h2 {
  color: var(--accent);
  font-size: 0.875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.today-task {
  font: 700 1.375rem/1.25 var(--display);
}

.today-meta {
  color: var(--muted);
  font-size: 0.875rem;
}

.today .btn-play {
  width: auto;
  min-width: 10rem;
  padding-inline: 1.5rem;
  text-align: center;
  text-decoration: none;
}

.today-text {
  min-width: 0;
}

.today[data-done="true"] .today-task {
  text-decoration: line-through;
  text-decoration-color: var(--gold-deep);
}

.tile.tile-today {
  border-color: var(--gold-deep);
  box-shadow: 0 0 0 1px var(--gold-deep);
}

.unlock {
  position: fixed;
  top: 1rem;
  left: 50%;
  z-index: 102;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  width: max-content;
  max-width: calc(100vw - 2rem);
  padding: 0.6rem 1.5rem 0.6rem 0.6rem;
  overflow: hidden;
  border: 2px solid var(--gold-deep);
  border-radius: 999px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--gold) 28%, var(--surface)), var(--surface) 75%);
  box-shadow:
    0 0.75rem 2rem rgb(0 0 0 / 0.3),
    0 0 2rem color-mix(in srgb, var(--gold) 45%, transparent);
  color: var(--ink);
  text-decoration: none;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -1.5rem) scale(0.9);
  transition:
    opacity 0.3s,
    transform 0.3s,
    visibility 0s 0.3s;
}

.unlock.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  transition-delay: 0s;
  animation: unlock-drop 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

/* A shine sweeping across the card. */
.unlock::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgb(255 255 255 / 0.55) 50%, transparent 65%);
  transform: translateX(-100%);
  pointer-events: none;
}

.unlock.show::after {
  animation: unlock-shine 0.9s ease-in-out 0.55s;
}

.unlock-medal {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
}

.unlock-medal svg {
  position: relative;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0.15rem 0 var(--gold-deep));
}

.unlock-medal circle {
  fill: var(--gold);
  stroke: var(--gold-deep);
  stroke-width: 2.5;
}

.unlock-medal path {
  fill: var(--gold-ink);
}

.unlock[data-kind="daily"] .unlock-medal path {
  fill: var(--win);
}

.unlock.show .unlock-medal svg {
  animation: unlock-medal 0.8s cubic-bezier(0.2, 0.9, 0.3, 1.4) 0.15s backwards;
}

.unlock-rays {
  position: absolute;
  inset: -0.75rem;
  border-radius: 50%;
  background: repeating-conic-gradient(color-mix(in srgb, var(--gold) 60%, transparent) 0 12deg, transparent 12deg 30deg);
  mask: radial-gradient(closest-side, #000 40%, transparent);
}

.unlock.show .unlock-rays {
  animation: unlock-rays 6s linear infinite;
}

.unlock-text {
  display: grid;
  min-width: 0;
}

.unlock-label {
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.unlock-name {
  font: 800 1.25rem/1.2 var(--display);
}

.unlock-body {
  color: var(--muted);
  font-size: 0.875rem;
}

.unlock.show .unlock-text > * {
  animation: unlock-text 0.4s ease-out backwards;
}

.unlock.show .unlock-label {
  animation-delay: 0.25s;
}

.unlock.show .unlock-name {
  animation-delay: 0.35s;
}

.unlock.show .unlock-body {
  animation-delay: 0.45s;
}

@keyframes unlock-drop {
  from {
    opacity: 0;
    transform: translate(-50%, -150%) scale(0.8);
  }
}

@keyframes unlock-medal {
  from {
    opacity: 0;
    transform: scale(0.2) rotate(-200deg);
  }
  60% {
    opacity: 1;
    transform: scale(1.3) rotate(10deg);
  }
}

@keyframes unlock-rays {
  to {
    transform: rotate(1turn);
  }
}

@keyframes unlock-shine {
  to {
    transform: translateX(100%);
  }
}

@keyframes unlock-text {
  from {
    opacity: 0;
    transform: translateX(-0.5rem);
  }
}
