/* Dot Scorer for TACTA. Tokens and rules are recorded in DESIGN.md. */
:root {
  --bg: #14171b;
  --outside: #0f1215;
  --surface: #1b1f24;
  --raised: #262b32;
  --line: #2f353d;
  --text: #edf0f3;
  --muted: #a3acb6;
  --on-light: #14171b;
  --focus: #9cc4ff;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--outside);
  color: var(--text);
  font: 400 15px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

#app {
  max-width: 430px; margin: 0 auto; height: 100dvh; background: var(--bg);
  position: relative; overflow: hidden;
}
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; overflow-y: auto; }

/* Buttons: one light primary per screen, raised secondary, plain text. */
.btn {
  min-height: 48px; padding: 0 16px; border-radius: 12px; border: 0;
  background: var(--raised); font-weight: 600; font-size: 16px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
}
.btn.primary { background: var(--text); color: var(--on-light); }
.btn.big { min-height: 56px; font-size: 17px; }
.btn.plain { background: transparent; color: var(--text); padding: 0 12px; font-weight: 500; }
.icon-btn { width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 22px; height: 22px; }
.btn svg { width: 20px; height: 20px; flex: none; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 4px; flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }

/* Start */
#startScreen { padding: calc(var(--safe-t) + 8px) 16px 0; }
#startScreen .top { display: flex; justify-content: flex-end; margin-right: -8px; }
#startScreen h1 { font-size: 28px; line-height: 1.2; font-weight: 650; margin: 8px 0; text-wrap: balance; }
.lede { color: var(--muted); margin: 0; font-size: 16px; text-wrap: pretty; max-width: 34ch; }
.slot { width: calc(100% + 32px); margin: 24px -16px 0; background: var(--surface); padding: 20px 16px 8px; }
.slot h2 { margin: 0 0 4px; font-size: 17px; font-weight: 600; }
.tips { list-style: none; margin: 0; padding: 0; counter-reset: tip; }
.tips li { counter-increment: tip; display: grid; grid-template-columns: 32px 1fr; padding: 12px 0; font-size: 16px; }
.tips li + li { border-top: 1px solid var(--line); }
.tips li::before { content: counter(tip); color: var(--muted); font-variant-numeric: tabular-nums; }
.start-note { margin: 16px 0 0; font-size: 15px; }
.spacer { flex: 1; min-height: 16px; }
.start-actions { display: grid; gap: 8px; margin: 24px -16px 0; padding: 12px 16px calc(var(--safe-b) + 12px); background: var(--surface); border-top: 1px solid var(--line); }

/* Game: answer, photo, strip, ranked players, thumb bar */
#gameScreen .top { display: flex; align-items: center; justify-content: space-between; padding: calc(var(--safe-t) + 4px) 8px 0 4px; min-height: 52px; flex: none; }
#headline { margin: 0; padding: 4px 16px 12px; font-size: 24px; line-height: 1.2; font-weight: 650; display: flex; align-items: center; gap: 10px; flex: none; min-height: 45px; text-wrap: balance; }
#headline .sw { width: 18px; height: 18px; border-radius: 5px; }
#frame { position: relative; flex: none; width: 100%; overflow: hidden; touch-action: none; background: var(--surface); cursor: zoom-in; user-select: none; -webkit-user-select: none; }
#frame.inspect { cursor: crosshair; }
#photo { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; }
#marks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
#scrim { position: absolute; inset: 0; background: rgba(20,23,27,.45); pointer-events: none; }

#strip { flex: none; display: flex; align-items: center; gap: 4px; min-height: 48px; padding: 0 4px 0 16px; border-bottom: 1px solid var(--line); }
#status { flex: 1; min-width: 0; color: var(--muted); font-size: 14px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#status b { color: var(--text); font-weight: 600; }

#panel { flex: 1 1 auto; min-height: 148px; overflow-y: auto; overscroll-behavior: contain; padding: 4px 0 8px; display: flex; flex-direction: column; }
.rank { list-style: none; margin: 0; padding: 0; flex: 1 1 0; min-height: 0; display: grid; grid-auto-rows: minmax(48px, 60px); align-content: start; }
.rank li { display: flex; }
.row {
  width: 100%; min-height: 48px; height: 100%; display: grid; grid-template-columns: 40px 14px 1fr auto 48px; align-items: center; gap: 0 12px;
  padding: 0 16px; border: 0; background: transparent; text-align: left; cursor: pointer;
}
.row[aria-pressed="true"], .row.hot { background: var(--raised); }
.row .place { color: var(--muted); font-size: 15px; }
.row .name { font-size: 17px; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .note { color: var(--muted); font-size: 13px; white-space: nowrap; }
.row .score { font-size: 22px; font-weight: 650; text-align: right; }
.row.lead .name { font-weight: 650; }
.progress { padding: 16px; }
.progress .label { display: flex; justify-content: space-between; gap: 12px; font-size: 16px; margin-bottom: 12px; }
.progress .label span:last-child { color: var(--muted); }
.track { height: 6px; border-radius: 3px; background: var(--raised); overflow: hidden; }
.fill { height: 100%; width: 100%; background: var(--text); transform-origin: 0 50%; transform: scaleX(0); }
.message { margin: 0; padding: 16px; font-size: 16px; text-wrap: pretty; }

#bar { flex: none; padding: 12px 16px calc(var(--safe-b) + 12px); background: var(--surface); border-top: 1px solid var(--line); }
.bar-row { display: flex; gap: 8px; align-items: center; }
.bar-row > .btn { flex: 1; min-width: 0; }
.bar-row > .btn.fixed { flex: none; min-width: 112px; }
.dot-head { display: flex; align-items: center; gap: 4px; min-height: 44px; margin: -8px -8px 0 0; }
.dot-head .title { flex: 1; min-width: 0; font-weight: 600; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.dot-head .title span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot-sub { color: var(--muted); font-size: 14px; margin: -6px 0 12px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg .btn[aria-pressed="true"] { background: var(--text); color: var(--on-light); }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 4px; }
.chip { min-height: 48px; border-radius: 12px; border: 0; background: var(--raised); display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 16px; font-weight: 500; cursor: pointer; padding: 0 8px; }
.chip.guess { box-shadow: inset 0 0 0 2px var(--text); font-weight: 650; }
.chip .count { color: var(--muted); font-variant-numeric: tabular-nums; }
.done-line { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 15px; flex: 1; min-width: 0; }
.done-line svg { width: 18px; height: 18px; flex: none; }

@media (max-width: 359px) {
  .bar-row > .btn.fixed { min-width: 88px; }
  #bar .btn { padding: 0 12px; font-size: 16px; }
  .chip { font-size: 15px; gap: 6px; }
}
@media (max-height: 700px) {
  #gameScreen .top { min-height: 44px; }
  #headline { font-size: 20px; padding-bottom: 8px; min-height: 36px; }
  #strip { min-height: 44px; }
  #panel { min-height: 76px; }
  .dot-sub { display: none; }
  .dot-head { margin-bottom: 4px; }
  #bar .btn.big { min-height: 48px; }
}
@media (max-height: 600px) {
  #panel { min-height: 48px; }
  .chip { min-height: 44px; }
}
.reveal { animation: reveal 220ms cubic-bezier(.2,0,0,1) both; }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .reveal { animation: none; } }

/* Dialogs are bottom sheets; Escape and Close dismiss them. */
dialog { border: 0; padding: 0; background: var(--surface); color: var(--text); width: min(430px, 100vw); max-width: 100vw; max-height: 100dvh; margin: auto auto 0; border-radius: 16px 16px 0 0; overscroll-behavior: contain; }
dialog::backdrop { background: rgba(8,10,12,.6); }
.sheet { padding: 8px 16px calc(var(--safe-b) + 16px); display: flex; flex-direction: column; gap: 16px; max-height: 100dvh; overflow-y: auto; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; min-height: 48px; margin-right: -8px; }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 650; display: flex; align-items: center; gap: 10px; }
.sheet-head h2:focus { outline: none; }
.sheet-head h2 .sw { width: 18px; height: 18px; border-radius: 5px; }
#cardImage { display: block; width: 100%; height: auto; max-height: 62dvh; object-fit: contain; border-radius: 12px; background: var(--bg); }
.recolor { border: 0; margin: 0; padding: 0; min-width: 0; }
.recolor legend { padding: 0; margin-bottom: 8px; font-weight: 600; font-size: 16px; }
.field label { display: block; font-weight: 600; font-size: 16px; margin-bottom: 4px; }
.field .ends { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
.help { color: var(--muted); font-size: 14px; margin: 8px 0 0; }
input[type=range] { width: 100%; height: 44px; accent-color: var(--text); margin: 0; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 16px; }
.privacy { margin: 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 15px; }
.privacy span { color: var(--muted); }
.prose { margin: 0; font-size: 15px; color: var(--text); }
.prose p { margin: 0 0 12px; }
.prose ol { margin: 0 0 12px; padding-left: 20px; }
.prose li { margin-bottom: 4px; }
.links { display: flex; flex-wrap: wrap; column-gap: 24px; }
.links a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; min-height: 44px; display: inline-flex; align-items: center; }
.links a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
#licenseList summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }
.license-text { font-family: var(--font); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; color: var(--muted); max-height: 40dvh; overflow-y: auto; margin: 0; }

.noscript { padding: 24px 16px; font-size: 16px; }
