/* =====================================================================
   Curling — fixed "frozen rink" theme.
   Like Air Hockey, Breakout & Flappy Bird, this page deliberately ignores
   the center's light/dark mode and its shared glass chrome (no glass.css
   is loaded); every color is hardcoded, taken from the game's own canvas
   palette: arena navy, glacier ice, hog-line red, player gold handle, CPU
   crimson handle and broom cyan.
   The c-* chrome block is copied here because each fixed-theme arcade
   game owns its own copy of it.
   ===================================================================== */
:root {
  --cu-bg1:     #081124;   /* deep arena navy */
  --cu-bg2:     #12243f;
  --cu-ice:     #dceefb;   /* sheet base (canvas paints its own gradient) */
  --cu-neon:    #6fd6ff;   /* cold cyan accents */
  --cu-gold:    #ffd23a;   /* player stones / stats */
  --cu-red:     #ff5470;   /* CPU stones */
  --cu-text:    #eaf3fb;
  --cu-muted:   #93b0cf;
  --cu-line:    rgba(111, 214, 255, .4);
}

html, body { height: 100%; }
body.cu-page {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, var(--cu-bg1) 0%, var(--cu-bg2) 100%);
  color: var(--cu-text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
body.cu-page *,
body.cu-page *::before,
body.cu-page *::after { box-sizing: border-box; }

/* ---------- App frame ---------- */
.c-app {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Top bar ---------- */
.c-bar {
  flex: none;
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px 18px;
  flex-wrap: wrap;
  padding: 12px clamp(12px, 3vw, 28px);
  padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(0, 0, 0, .38);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  z-index: 20;
}
/* a frosted centre line along the bottom edge of the bar */
.c-bar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cu-neon) 20%, var(--cu-neon) 80%, transparent);
  box-shadow: 0 0 12px var(--cu-neon);
  opacity: .8;
}
.c-bar__brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.c-bar__brand svg { filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .4)); }
.c-bar__title {
  margin: 0;
  font-size: clamp(19px, 3.4vw, 26px);
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
  color: #fff;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, .5), 0 0 18px rgba(111, 214, 255, .55);
}
.c-bar__stats { display: flex; align-items: center; gap: 8px 18px; margin-left: auto; }
.c-bar__controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stat { font-size: 14px; font-weight: 700; letter-spacing: .03em; white-space: nowrap; color: var(--cu-muted); }
.stat b { color: var(--cu-gold); font-size: 16px; text-shadow: 0 0 10px rgba(255, 210, 58, .4); }

/* ---------- Buttons (chunky arcade style) ---------- */
.c-btn {
  appearance: none;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
  text-decoration: none;
  display: inline-block;
  padding: 9px 16px;
  border-radius: 12px;
  border: 2px solid rgba(234, 243, 251, .5);
  background: rgba(234, 243, 251, .08);
  color: #fff;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .45);
  transition: transform .06s ease, background .15s ease, box-shadow .15s ease;
}
.c-btn:hover { background: rgba(111, 214, 255, .18); border-color: var(--cu-neon); }
.c-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .45); }
.c-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(111, 214, 255, .5); }
.c-btn--primary {
  background: linear-gradient(160deg, #7fd6ff 0%, #2f8fd8 45%, #14508e 100%);
  border-color: #cdeaff;
  color: #fff;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, .3);
}
.c-btn--primary:hover {
  /* Re-declare the gradient: `.c-btn:hover` (higher specificity) otherwise
     replaces it with its translucent wash, dropping the fill on hover. */
  background: linear-gradient(160deg, #9ae2ff 0%, #4aa6e8 45%, var(--cu-neon) 100%);
  border-color: #cdeaff;
  color: #fff;
}

/* ---------- Table / stage ---------- */
.c-table {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(8px, 2vh, 18px);
}
.cu-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 0;
}
.cu-stage {
  position: relative;
  /* 3:4 portrait; capped by viewport height minus the chrome, no fixed
     floor — small screens just get a smaller sheet (no horizontal scroll). */
  width: min(94vw, calc((100vh - 220px) * 0.75), 480px);
  width: min(94vw, calc((100dvh - 220px) * 0.75), 480px);
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  overflow: hidden;
  background: var(--cu-ice);
  border: 3px solid rgba(111, 214, 255, .55);
  box-shadow: 0 10px 0 rgba(0, 0, 0, .35), 0 22px 48px rgba(0, 0, 0, .55),
              0 0 34px rgba(111, 214, 255, .25);
  touch-action: none;
}
#screen { display: block; width: 100%; height: 100%; }

/* ---------- Handle switch + hint under the sheet ---------- */
.cu-tools {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 12.5px;
  color: var(--cu-muted);
}
.cu-tools__label {
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.cu-chip {
  appearance: none;
  cursor: pointer;
  font: inherit;
  font-size: 12.5px;
  font-weight: 800;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1.5px solid rgba(111, 214, 255, .45);
  background: rgba(111, 214, 255, .08);
  color: var(--cu-text);
  transition: background .15s ease, border-color .15s ease;
}
.cu-chip:hover { background: rgba(111, 214, 255, .2); }
.cu-chip.is-on {
  background: linear-gradient(160deg, #7fd6ff, #2f8fd8);
  border-color: #cdeaff;
  color: #06233c;
}
.cu-chip:disabled { opacity: .45; cursor: default; }
.cu-tools__sweep b { color: var(--cu-neon); }
.cu-hint {
  margin: 0;
  max-width: 480px;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--cu-muted);
}

/* ---------- Ready / match-over overlays ---------- */
.cu-overlay {
  touch-action: manipulation;
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
  background: rgba(6, 14, 30, .55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  cursor: default;
}
.cu-overlay[hidden] { display: none; }
.cu-card {
  touch-action: manipulation;
  max-width: 310px;
  text-align: center;
  padding: 22px 24px 20px;
  border-radius: 16px;
  background: linear-gradient(160deg, #1c3050, #0e1a30);
  border: 2px solid var(--cu-line);
  box-shadow: 0 8px 0 rgba(0, 0, 0, .35), 0 22px 50px rgba(0, 0, 0, .55);
  color: var(--cu-text);
  animation: cuPop .3s ease;
}
@keyframes cuPop { from { transform: scale(.88); opacity: 0; } }
.cu-card__big { font-size: 40px; line-height: 1.1; }
.cu-card__big svg { width: 80px; height: 80px; display: block; margin: 0 auto; }
.cu-card__big svg[hidden] { display: none; }
.cu-card h2 {
  margin: 6px 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, .5);
}
.cu-card p { margin: 0 0 14px; color: var(--cu-muted); font-size: 13.5px; line-height: 1.55; }
.cu-card p b { color: var(--cu-gold); }
.cu-card .c-btn { font-size: 14px; }
.cu-card kbd, .c-modal kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin: 0 1px;
  font: 700 12px/1.5 ui-monospace, "Segoe UI", monospace;
  text-align: center;
  color: #0e1a30;
  background: #eaf3fb;
  border-radius: 6px;
  border-bottom: 2px solid rgba(0, 0, 0, .4);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .35);
}
.c-win__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- Rules modal ----------
   Overlay-scroll pattern (AGENTS.md): the full-screen .c-modal scrolls,
   the backdrop stays fixed, and the panel centres itself with margin:auto
   so a too-tall card never grows an inner scrollbar. */
.c-modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.c-modal[hidden] { display: none; }
.c-modal__backdrop {
  position: fixed; inset: 0;
  background: rgba(4, 10, 22, .68);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.c-modal__panel {
  position: relative;
  z-index: 1;
  margin: auto;
  width: min(92vw, 470px);
  background: linear-gradient(160deg, #1c3050, #0b1426);
  color: var(--cu-text);
  border-radius: 16px;
  border: 2px solid var(--cu-line);
  box-shadow: 0 8px 0 rgba(0, 0, 0, .4), 0 24px 60px rgba(0, 0, 0, .6);
}
.c-modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(111, 214, 255, .28);
}
.c-modal__head h2 {
  margin: 0; font-size: 18px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .04em;
  color: #fff; text-shadow: 2px 2px 0 rgba(0, 0, 0, .45);
}
.c-modal__x {
  appearance: none; border: 0; background: none;
  color: var(--cu-text); font-size: 26px; line-height: 1;
  cursor: pointer; padding: 0 4px;
}
.c-modal__x:hover { color: var(--cu-gold); }
.c-modal__body { padding: 8px 20px 4px; font-size: 14px; line-height: 1.55; }
.c-modal__body h3 {
  margin: 16px 0 6px; font-size: 13px;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--cu-neon);
}
.c-modal__body ul { margin: 0; padding-left: 20px; }
.c-modal__body li { margin: 4px 0; }
.c-modal__body b { color: var(--cu-gold); }
.c-modal__lead { margin: 12px 0; }
.c-modal__note {
  margin: 14px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(47, 143, 216, .16);
  border: 1px solid rgba(111, 214, 255, .3);
  font-size: 13px;
  color: #bcdcf0;
}
.c-modal__foot { display: flex; justify-content: flex-end; padding: 12px 20px 16px; }

/* ---------- Responsive ---------- */
/* Phones and short windows: tighten the bar's type and padding so the
   controls never wrap into a tower taller than the header itself. */
@media (max-width: 700px), (max-height: 620px) {
  .c-bar { gap: 5px 12px; padding: 7px clamp(10px, 3vw, 18px); padding-top: max(7px, env(safe-area-inset-top)); }
  .c-bar__brand { gap: 8px; }
  .c-bar__title { font-size: 16px; }
  .c-bar__stats { gap: 4px 12px; margin-left: auto; }
  .stat { font-size: 12px; }
  .stat b { font-size: 13px; }
  .c-btn { padding: 8px 10px; font-size: 12px; }
  .c-bar__controls { gap: 6px; }
  .c-bar__controls .c-btn { padding: 9px 10px; white-space: nowrap; }
  .cu-stage { width: min(94vw, calc((100dvh - 200px) * 0.75), 480px); }
  .cu-tools { font-size: 11.5px; }
  .cu-hint { font-size: 11.5px; padding: 0 10px; }
}
/* Narrow screens only: the buttons drop to a row of their own and split it
   evenly into full-width thumb targets. */
@media (max-width: 700px) {
  .c-bar__controls { flex: 1 1 100%; flex-wrap: nowrap; }
  .c-bar__controls .c-btn { flex: 1 1 auto; min-width: 0; padding: 9px 6px; overflow: hidden; text-overflow: ellipsis; }
}
/* Smallest phones: labels scale down with the viewport. */
@media (max-width: 380px) {
  .c-bar { gap: 5px 8px; }
  .c-bar__title { font-size: 15px; }
  .stat { font-size: 11px; }
  .stat b { font-size: 12px; }
  .c-bar__controls { gap: 4px; }
  .c-bar__controls .c-btn { font-size: clamp(10px, 3.2vw, 12px); padding: 9px 4px; letter-spacing: .01em; }
}

@media (prefers-reduced-motion: reduce) {
  .c-btn, .cu-chip, .cu-card { transition: none; animation: none; }
}
