/* Angry Marble. Palette and type follow the Daily Marble site: paper, ink, house coral. */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }
textarea, button, input { font: inherit; }

:root {
  --paper: #F1EDE1;
  --paper-2: #E7E0CE;
  --ink: #14110B;
  --ink-2: #5E5647;
  --house: #FF6B6B;
  --house-ink: #B0332E;
  --rule: rgba(20, 17, 11, 0.16);
  --pill: rgba(241, 237, 225, 0.92);
  --gold: #D38C08;
  --scrim: rgba(20, 17, 11, 0.42);
  --display: 'Archivo', 'Arial Narrow', system-ui, sans-serif;
  --body: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0C0A06; --paper-2: #1B1812; --ink: #F1EDE1; --ink-2: #B4AB98;
    --house: #FF7A72; --house-ink: #FF9D95; --rule: rgba(241, 237, 225, 0.16);
    --pill: rgba(18, 15, 10, 0.88); --gold: #F2B233; --scrim: rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0C0A06; --paper-2: #1B1812; --ink: #F1EDE1; --ink-2: #B4AB98;
  --house: #FF7A72; --house-ink: #FF9D95; --rule: rgba(241, 237, 225, 0.16);
  --pill: rgba(18, 15, 10, 0.88); --gold: #F2B233; --scrim: rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

html, body { height: 100%; }
body { background: var(--paper); color: var(--ink); font-family: var(--body); overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--house-ink); outline-offset: 2px; }

#app { position: fixed; left: 0; right: 0; top: env(safe-area-inset-top, 0px); bottom: env(safe-area-inset-bottom, 0px); }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }

/* ---------- HUD ---------- */
.hud { position: absolute; inset: 0; pointer-events: none; }
.hud-top { position: absolute; top: 12px; left: 16px; right: 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.hud-top .spacer { flex: 1; }
.pill {
  background: var(--pill); border: 1px solid var(--rule); border-radius: 10px;
  padding: 7px 12px; font: 500 13px/1.25 var(--body); color: var(--ink);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.btn { cursor: pointer; pointer-events: auto; font-weight: 600; }
.btn:hover { border-color: var(--ink); }
.lvl-id { font-family: var(--mono); font-weight: 700; color: var(--house-ink); margin-right: 8px; }
.lvl-name { font-weight: 600; }
.shots { font-variant-numeric: tabular-nums; }
.score-row { display: flex; gap: 6px; align-items: center; font-variant-numeric: tabular-nums; }
.score-side { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 7px; border: 1px solid transparent; }
.score-side.on { border-color: var(--ink); font-weight: 700; }
.score-side b { font-family: var(--mono); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.hud-bottom { position: absolute; left: 16px; right: 16px; bottom: 12px; display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.queue { display: flex; gap: 6px; pointer-events: auto; }
.chip { width: 50px; height: 50px; padding: 0; border-radius: 50%; background: var(--pill); border: 1px solid var(--rule); cursor: pointer; }
.chip canvas { width: 100%; height: 100%; display: block; }
.chip[aria-pressed="true"] { border: 2px solid var(--house); box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.25); }
.chip:disabled { cursor: default; opacity: 0.8; }
.power { max-width: min(460px, 100%); display: flex; flex-direction: column; gap: 2px; }
.power strong { font-family: var(--display); font-stretch: 112%; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; font-size: 12.5px; }
.power span { color: var(--ink-2); font-size: 13px; }
.power.live { border-color: var(--house); box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.3); }
.power.live span { color: var(--ink); font-weight: 600; }
.toast {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  font-family: var(--display); font-weight: 900; font-stretch: 125%; text-transform: uppercase;
  font-size: clamp(16px, 2.6vw, 28px); color: #14110B; background: var(--house);
  padding: 6px 16px; border-radius: 6px; white-space: nowrap;
  animation: pop 0.35s cubic-bezier(.2,1.4,.4,1);
}
@keyframes pop { from { transform: translateX(-50%) scale(0.6); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
.turn-hint { position: absolute; top: 108px; left: 16px; right: 16px; text-align: center; font-size: 12px; color: var(--ink-2); }

/* ---------- menu ---------- */
.screen { position: absolute; inset: 0; z-index: 5; overflow-y: auto; overflow-x: hidden; background: var(--paper); }
.menu-inner { max-width: 1000px; margin: 0 auto; padding-inline: 16px; padding-block: 28px 56px; }
.eyebrow { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); margin: 0; }
.hero { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 24px; align-items: center; }
.hero h1 {
  font-family: var(--display); font-weight: 900; font-stretch: 125%;
  font-size: clamp(46px, 9.5vw, 116px); line-height: 0.84; letter-spacing: -0.025em;
  text-transform: uppercase; margin: 10px 0 18px;
}
.hero h1 .a { color: var(--house-ink); display: block; }
.lede { font-size: 17px; line-height: 1.55; max-width: 56ch; margin: 0 0 18px; text-wrap: pretty; }
.how { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13.5px; color: var(--ink-2); }
.how b { color: var(--ink); font-weight: 700; }
.key { font-family: var(--mono); font-size: 11px; font-weight: 700; border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; color: var(--ink); margin-right: 4px; }
#heroArt { width: 100%; max-width: 100%; aspect-ratio: 5 / 4; display: block; }

.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-top: 26px; }
.mode { border: 2px solid var(--ink); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: var(--paper); }
.mode.daily { background: var(--house); color: #14110B; border-color: #14110B; }
.mode.daily .eyebrow { color: rgba(20,17,11,0.7); }
.mode h3 { font-family: var(--display); font-weight: 900; font-stretch: 120%; text-transform: uppercase; font-size: 24px; line-height: 1; margin: 0; }
.mode p { margin: 0; font-size: 14px; line-height: 1.45; }
.mode .go { align-self: flex-start; margin-top: auto; }
.teampick { display: flex; flex-wrap: wrap; gap: 6px; }
.tbtn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--rule); background: transparent; cursor: pointer; font-size: 13px; font-weight: 600; }
.tbtn[aria-pressed="true"] { border: 2px solid var(--ink); padding: 5px 9px; }
.tbtn:hover { border-color: var(--ink); }

.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; border-top: 2px solid var(--ink); padding-top: 12px; margin-top: 34px; margin-bottom: 14px; }
.section-head h2 { font-family: var(--display); font-weight: 850; font-stretch: 118%; font-size: 26px; text-transform: uppercase; letter-spacing: 0.005em; margin: 0; text-wrap: balance; }
.swatch { width: 14px; height: 14px; border-radius: 50%; display: inline-block; flex: none; align-self: center; }
.team { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.doctrine { flex-basis: 100%; margin: 0; font-size: 14px; color: var(--ink-2); font-style: italic; }
.mech { font-size: 12.5px; color: var(--ink-2); }
.levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 10px; }
.tile { text-align: left; cursor: pointer; background: var(--paper-2); border: 1px solid var(--rule); border-radius: 10px; padding: 12px 12px 10px; display: flex; flex-direction: column; gap: 4px; transition: transform 0.12s ease, border-color 0.12s ease; }
.tile:hover { border-color: var(--ink); transform: translateY(-1px); }
.tid { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--house-ink); }
.tname { font-weight: 650; font-size: 15px; line-height: 1.25; }
.tstars { display: flex; gap: 2px; margin-top: 4px; }
.star { width: 16px; height: 16px; display: block; }
.star path { fill: none; stroke: var(--ink-2); stroke-width: 1.6; stroke-linejoin: round; opacity: 0.5; }
.star.on path { fill: var(--gold); stroke: var(--gold); opacity: 1; }
.squad-team { margin-bottom: 14px; }
.squad-team h4 { margin: 0 0 8px; display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 850; font-stretch: 112%; text-transform: uppercase; font-size: 15px; }
.squad { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 8px; }
.mcard { display: grid; grid-template-columns: 52px 1fr; gap: 2px 10px; align-items: start; padding: 10px; border-radius: 10px; background: var(--paper-2); border: 1px solid var(--rule); }
.mcard canvas { width: 52px; height: 52px; grid-row: span 3; }
.mcard .nm { font-family: var(--display); font-weight: 850; font-stretch: 112%; font-size: 15px; text-transform: uppercase; line-height: 1.1; }
.mcard .pw { font-weight: 700; font-size: 13px; }
.mcard .tx { font-size: 12.5px; color: var(--ink-2); line-height: 1.4; }
.foot { margin-top: 34px; font-size: 12.5px; color: var(--ink-2); line-height: 1.5; max-width: 72ch; }

/* ---------- modals ---------- */
.modal { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; background: var(--scrim); padding: 16px; overflow-y: auto; }
.card { background: var(--paper); color: var(--ink); border: 1px solid var(--rule); border-radius: 14px; width: 100%; max-width: 480px; padding: 22px 22px 20px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3); }
.card.wide { max-width: 720px; }
.card h2 { font-family: var(--display); font-weight: 900; font-stretch: 120%; font-size: clamp(26px, 5vw, 34px); line-height: 0.95; text-transform: uppercase; margin: 6px 0 10px; text-wrap: balance; }
.card h3 { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); margin: 16px 0 8px; font-weight: 700; }
.card p { margin: 0 0 14px; line-height: 1.5; font-size: 15px; }
.lineup { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 16px; }
.lu { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--paper-2); border: 1px solid var(--rule); }
.lu canvas { width: 34px; height: 34px; display: block; }
.lu span { font-size: 13px; font-weight: 600; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); margin-bottom: 18px; font-variant-numeric: tabular-nums; }
.meta b { color: var(--ink); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.b-primary, .b-ghost { cursor: pointer; border-radius: 10px; padding: 11px 18px; font-weight: 700; font-size: 15px; }
.b-primary { background: var(--house); color: #14110B; border: 1px solid transparent; }
.b-primary:hover { filter: brightness(1.05); }
.mode.daily .b-primary { background: #14110B; color: #F1EDE1; }
.b-ghost { background: transparent; border: 1px solid var(--rule); }
.b-ghost:hover { border-color: var(--ink); }
.bigstars { display: flex; gap: 6px; margin: 4px 0 12px; }
.bigstars .star { width: 42px; height: 42px; }
.share { width: 100%; font: 500 13px/1.5 var(--mono); padding: 10px; border-radius: 8px; border: 1px solid var(--rule); background: var(--paper-2); color: var(--ink); resize: none; margin-bottom: 10px; }
.teamgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.tcard { text-align: left; cursor: pointer; border: 1px solid var(--rule); border-radius: 10px; padding: 10px; background: var(--paper-2); display: flex; flex-direction: column; gap: 6px; }
.tcard[aria-pressed="true"] { border: 2px solid var(--ink); padding: 9px; }
.tcard:disabled { opacity: 0.35; cursor: not-allowed; }
.tcard .tn { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.tcard .faces { display: flex; gap: 2px; }
.tcard .faces canvas { width: 30px; height: 30px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { cursor: pointer; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--rule); background: transparent; font-weight: 600; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.btn:disabled { opacity: 0.45; cursor: default; }
.btn:disabled:hover { border-color: var(--rule); }
.coach {
  position: absolute; left: 50%; top: 42%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); border-radius: 12px; padding: 12px 18px;
  font-family: var(--display); font-weight: 800; font-stretch: 112%; font-size: clamp(15px, 2.4vw, 20px);
  text-transform: uppercase; letter-spacing: 0.02em; text-align: center; pointer-events: none;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25); max-width: calc(100% - 32px);
}
.inspect {
  position: absolute; pointer-events: none; max-width: 260px;
  background: var(--paper); color: var(--ink); border: 1px solid var(--ink); border-radius: 10px;
  padding: 9px 11px; font-size: 13px; line-height: 1.4; box-shadow: 0 8px 24px rgba(0,0,0,0.22);
}
.inspect b { display: block; font-family: var(--display); font-weight: 850; font-stretch: 112%; text-transform: uppercase; font-size: 13.5px; margin-bottom: 2px; }
.inspect .nx { display: block; margin-top: 4px; color: var(--house-ink); font-weight: 600; }
.starlist { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 6px; }
.starlist li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.starlist li .star { width: 20px; height: 20px; }
.starlist li.off { color: var(--ink-2); }
.replay-in { width: 100%; font: 500 12.5px/1.4 var(--mono); padding: 8px; border-radius: 8px; border: 1px solid var(--rule); background: var(--paper-2); color: var(--ink); resize: none; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.hero-cta { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.hero-cta .b-primary { font-size: 17px; padding: 13px 24px; }
.hero-cta span { font-size: 13px; color: var(--ink-2); }
.mode .err { color: var(--house-ink); font-size: 13px; min-height: 1em; }

@media (max-width: 720px) {
  .hero { grid-template-columns: 1fr; }
  #heroArt { max-width: 420px; }
  .power span { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  .tile { transition: none; }
}

/* ---------- app additions: mobile, precise aim, sharing ---------- */
html, body { overscroll-behavior: none; }
#stage { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.btn[aria-pressed="true"]#btnPrecise { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.aimpad {
  display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; pointer-events: auto;
  background: var(--pill); border: 1px solid var(--rule); border-radius: 12px; padding: 6px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.aimpad button {
  min-width: 48px; min-height: 44px; border-radius: 9px; border: 1px solid var(--rule);
  background: transparent; font: 700 14px/1 var(--mono); cursor: pointer; color: var(--ink);
}
.aimpad button:hover { border-color: var(--ink); }
.aimpad .fire { background: var(--house); color: #14110B; border-color: transparent; font-family: var(--display); font-stretch: 112%; text-transform: uppercase; letter-spacing: 0.03em; padding: 0 16px; }
.sharerow { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.b-share {
  cursor: pointer; border-radius: 10px; padding: 11px 16px; font-weight: 700; font-size: 15px;
  background: var(--ink); color: var(--paper); border: 1px solid var(--ink);
}
.b-share:hover { filter: brightness(1.15); }
.sharenote { font-size: 13px; color: var(--ink-2); min-height: 1em; margin: 0 0 10px; }
.ms-note { margin-top: 16px; font-size: 13.5px; color: var(--ink-2); }
.fancard { width: 100%; max-width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--rule); margin: 4px 0 12px; display: block; background: var(--paper-2); aspect-ratio: 4 / 5; }
.rotate {
  position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; text-align: center;
  background: var(--ink); color: var(--paper); padding: 24px 16px;
}
.rotate h2 { font-family: var(--display); font-weight: 900; font-stretch: 120%; text-transform: uppercase; font-size: 28px; line-height: 1; margin: 18px 0 10px; }
.rotate p { margin: 0 0 20px; font-size: 15px; line-height: 1.5; opacity: 0.85; max-width: 32ch; }
.rotate .b-ghost { color: var(--paper); border-color: rgba(241,237,225,0.4); }
.phone { width: 54px; height: 90px; border: 4px solid var(--paper); border-radius: 12px; margin: 0 auto; animation: tilt 2.4s ease-in-out infinite; }
@keyframes tilt { 0%, 30% { transform: rotate(0); } 55%, 85% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }
.recording {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 9;
  background: #14110B; color: #F1EDE1; border-radius: 999px; padding: 8px 16px; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; gap: 8px;
}
.dotrec { width: 10px; height: 10px; border-radius: 50%; background: #E23D28; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.2; } }
.install { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; font-size: 13.5px; color: var(--ink-2); }
.countdown { font-family: var(--mono); font-size: 12px; }
@media (hover: none) and (pointer: coarse) {
  .pill.btn { min-height: 40px; }
  .chip { width: 54px; height: 54px; }
}
@media (max-height: 460px) {
  .hud-top { top: 8px; gap: 6px; }
  .pill { padding: 5px 9px; font-size: 12px; }
  .hud-bottom { bottom: 8px; }
  .power { display: none; }
  .aimpad button { min-height: 38px; min-width: 42px; }
}
@media (prefers-reduced-motion: reduce) { .phone, .dotrec { animation: none; } }
