/* Colors and fonts live in tokens.css (Pinball Passport brand, D-18). */
:root { --peek: 76px; --head: 56px; --panel-w: 380px; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.4 var(--body-font);
  display: flex; flex-direction: column; min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-x: hidden;
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: 0.85rem; }
.row { display: flex; align-items: center; } .between { justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.gap { gap: 8px; } .wrap { flex-wrap: wrap; }

/* Brand band: the same dark band in both themes, so the PP logo artwork "for black bg" always fits. */
.top { height: var(--head); flex: none; display: flex; align-items: center; gap: 10px; padding: 0 16px; background: var(--band); color: var(--band-text); border-bottom: 3px solid var(--pp-red); }
.brand-logo { height: 42px; width: auto; flex: none; display: block; }
.top h1 { margin: 0; font: 700 1.3rem/1 var(--brand-font); letter-spacing: 0.06em; padding-top: 3px; white-space: nowrap; }
.title-input { flex: 1; min-width: 0; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: inherit; }

.app { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; padding: 8px 16px 0; }
.readout { height: 1.6em; font-weight: 700; font-size: 1.05rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.wheel-wrap { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
#wheel { display: block; touch-action: manipulation; cursor: pointer; max-width: 100%; }
.note { margin: 4px 0 0; font-size: 0.8rem; color: var(--muted); text-align: center; }
.spin {
  margin: 10px 0; min-width: 220px; height: 56px; border: 0; border-radius: 28px; cursor: pointer;
  background: var(--accent); color: var(--accent-text); font: 700 1.35rem/1 var(--brand-font); letter-spacing: 0.2em; padding-top: 4px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.35);
}
.spin:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.35); }
.spin:disabled { opacity: 0.55; cursor: progress; }

/* Partner band (D-19): white tiles on the dark band, because one partner logo has a white background
   baked in and every logo in the row is legible on white (BRAND_KIT.md section 4). */
.foot { flex: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 16px; padding: 8px 16px; background: var(--band); color: var(--band-muted); font-size: 0.75rem; }
.partners { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.partners:empty { display: none; }
.partners li { background: #ffffff; border-radius: 6px; padding: 3px 6px; height: 32px; display: flex; align-items: center; }
.partners img { height: 26px; width: auto; display: block; }
.foot-text { display: flex; flex-direction: column; gap: 2px; text-align: center; }
.foot-line { margin: 0; }
.foot a { color: var(--band-text); white-space: nowrap; }
/* The bands are dark in both themes, so the focus ring keeps the dark-theme color there (WCAG 1.4.11). */
.top, .foot { --focus: #38bdf8; }
@media (min-width: 900px) { .partners li { height: 40px; } .partners img { height: 32px; } }
/* Short portrait phones (iPhone SE class): smaller tiles and text so the wheel keeps its room. */
@media (orientation: portrait) and (max-height: 740px) {
  .foot { padding: 5px 10px; gap: 4px 10px; font-size: 0.68rem; }
  .partners { gap: 4px; }
  .partners li { height: 24px; padding: 2px 4px; border-radius: 4px; }
  .partners img { height: 20px; }
}

/* ---- portrait phones: panel is a bottom sheet ---- */
.panel { background: var(--surface); border-top: 1px solid var(--border); }
@media (orientation: portrait) and (max-width: 899px) {
  body { padding-bottom: calc(var(--peek) + env(safe-area-inset-bottom)); }
  .panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    border-radius: 16px 16px 0 0; box-shadow: 0 -8px 24px rgba(0,0,0,0.35);
    height: calc(var(--peek) + env(safe-area-inset-bottom)); overflow: hidden; transition: height .2s ease;
  }
  .panel.open { height: min(55dvh, 520px); overflow: auto; }
  body.sheet-open .spin { position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: calc(min(55dvh, 520px) + 10px + env(safe-area-inset-bottom)); height: 46px; margin: 0; min-width: 180px; }
  body.sheet-open .spin:active { transform: translateX(-50%) translateY(2px); }
  .panel-body { padding: 0 16px 16px; }
  .panel:not(.open) .panel-body { visibility: hidden; }
}
.handle { width: 100%; height: var(--peek); background: none; border: 0; color: var(--text); font: 700 1rem/1 var(--body-font); display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center; cursor: pointer; }
.grip { width: 44px; height: 5px; border-radius: 3px; background: var(--border); }

/* ---- landscape and desktop: two columns ---- */
@media (orientation: landscape), (min-width: 900px) {
  .app { flex-direction: row; }
  .panel { width: var(--panel-w); flex: none; border-top: 0; border-left: 1px solid var(--border); overflow: auto; }
  .handle { display: none; }
  .panel-body { padding: 12px 16px 16px; }
  .stage { padding-top: 4px; }
}
/* short landscape (phones): drop chrome, pin SPIN over the top of the panel */
@media (orientation: landscape) and (max-height: 560px) {
  :root { --head: 44px; --panel-w: 360px; }
  .foot { display: none; }
  .top h1 { font-size: 1.05rem; }
  .brand-logo { height: 34px; }
  .readout { height: 1.3em; }
  .spin { position: fixed; top: calc(var(--head) + 8px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); width: calc(var(--panel-w) - 16px); margin: 0; height: 48px; z-index: 5; }
  .panel { padding-top: 64px; }
  .note { display: none; }
}

/* ---- panel contents ---- */
.tabs { display: flex; gap: 4px; position: sticky; top: 0; background: var(--surface); padding: 8px 0; z-index: 2; }
.tabs [role="tab"] { flex: 1; padding: 10px 4px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 8px; font: 600 0.85rem/1 var(--body-font); cursor: pointer; }
.tabs [aria-selected="true"] { background: var(--accent-ui); border-color: var(--accent-ui); color: var(--accent-text); }
.tabpanel { padding-top: 8px; display: flex; flex-direction: column; gap: 10px; }
.tabpanel[hidden] { display: none; }
textarea { width: 100%; min-height: 160px; resize: vertical; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font: 16px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 12px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; font: 600 0.85rem/1 var(--body-font); cursor: pointer; white-space: nowrap; }
.btn.primary { background: var(--accent-ui); border-color: var(--accent-ui); color: var(--accent-text); }
.btn.file { cursor: pointer; }
.check { display: flex; align-items: center; gap: 8px; font-size: 0.95rem; }
.check input { width: 20px; height: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.95rem; }
select { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font: inherit; }
.warnings { margin: 0; padding-left: 18px; color: var(--warn); font-size: 0.85rem; }
.warnings:empty { display: none; }
.h2 { font-size: 0.95rem; margin: 8px 0 0; }
fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 0; padding: 8px 10px 10px; }
legend { font-size: 0.8rem; color: var(--muted); padding: 0 6px; }
.strip { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: flex; flex-direction: column; gap: 4px; align-items: stretch; padding: 6px; background: var(--surface-2); border: 2px solid var(--border); border-radius: 10px; color: var(--text); font: 600 0.75rem/1.1 var(--body-font); cursor: pointer; min-width: 92px; }
.chip[aria-pressed="true"] { border-color: var(--accent); }
.chip .sw { display: flex; height: 18px; border-radius: 4px; overflow: hidden; }
.chip .sw i { flex: 1; }
.hue { width: 48px; height: 40px; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: none; cursor: pointer; }
.seglist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow: auto; }
.seglist li { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.dot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--text); cursor: pointer; flex: none; }
.segname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.segpop { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0 8px 36px; align-items: center; }
.segpop .dot { width: 24px; height: 24px; }
.segpop input[type="text"] { width: 92px; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 4px 6px; font: inherit; }
.warnchip { font-size: 0.7rem; background: #b45309; color: #fff; border-radius: 6px; padding: 2px 5px; }
.hist { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.hist li { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; font-size: 0.9rem; display: flex; justify-content: space-between; gap: 8px; }
.hist time { color: var(--muted); font-size: 0.8rem; flex: none; }

/* ---- winner dialog ---- */
dialog { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); padding: 0; width: min(92vw, 460px); }
dialog::backdrop { background: rgba(2, 6, 23, 0.7); }
.win-body { padding: 24px 20px 20px; text-align: center; }
.kicker { margin: 0; text-transform: uppercase; letter-spacing: 0.18em; font: 700 0.85rem/1 var(--brand-font); color: var(--muted); }
.win-name { margin: 8px 0 4px; font-size: clamp(1.8rem, 8vw, 2.8rem); line-height: 1.1; overflow-wrap: anywhere; }
dialog#winner { border-top: 4px solid var(--pp-red); }
.win-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.win-actions .btn { min-height: 48px; font-size: 1rem; }
@media (orientation: landscape) and (max-height: 560px) {
  .win-body { padding: 12px; } .win-name { font-size: 1.6rem; margin: 2px 0; }
  .win-actions { flex-direction: row; margin-top: 8px; } .win-actions .btn { flex: 1; min-height: 40px; font-size: 0.85rem; }
}

.toast { position: fixed; left: 50%; bottom: calc(var(--peek) + 16px); transform: translateX(-50%); background: #111; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 50; max-width: 90vw; }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }

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

/* ---- MatchPlay import ---- */
.btn.wide { width: 100%; }
.btn.grow { flex: 1; }
.h2.big { font-size: 1.1rem; margin: 0; }
dialog.mp { width: min(94vw, 520px); max-height: 88dvh; overflow: auto; }
.mp-actions { position: sticky; bottom: 0; background: var(--surface); padding: 10px 0 2px; border-top: 1px solid var(--border); }
.mp-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.mp-form input { flex: 1; min-width: 0; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font: inherit; }
.chiplink { align-self: flex-start; }
.mp-results, .mp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 38dvh; overflow: auto; }
.mp-results[hidden] { display: none; }
.mp-result { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 10px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; font: inherit; cursor: pointer; }
.mp-rname { font-weight: 600; overflow-wrap: anywhere; }
.mp-event { margin: 0; font-weight: 600; }
.mp-event a { color: var(--text); }
.mp-list li { padding: 2px 0; }
.mp-mode { display: flex; flex-direction: column; gap: 6px; }
a { color: var(--focus); }
