/* Agent Arena (falling tokens). Page chrome follows DESIGN.md; the only agent-scope exception is in the mascot SVGs. */
:root {
  --bg: #EFEFF0; --card: #F5F5F6; --hover: #E4E4E6; --band: #DEDEE0; --line: #D0D0D2;
  --ink: #14130F; --muted: #413D35; --meta: #5C574D; --cobalt: #0B3FCF; --green: #07BE43;
  --sans: 'Sohne', 'Instrument Sans', system-ui, sans-serif;
  --mono: 'Array', ui-monospace, 'SF Mono', Menlo, monospace;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column; }
.scan { position: fixed; inset: 0; z-index: 60; pointer-events: none; background: repeating-linear-gradient(to bottom, rgba(20,19,15,.035) 0, rgba(20,19,15,.035) 1px, transparent 1px, transparent 3px); }
a { color: var(--cobalt); }
:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; }
[hidden] { display: none !important; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--ink); color: #fff; padding: 10px 14px; }
.skip:focus { top: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.bar { position: sticky; top: 0; z-index: 50; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 28px; background: var(--hover); border-bottom: 1px solid var(--line); }
.bar__left, .bar__right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bar__right { margin-left: auto; }
.bar__back { font-family: var(--mono); font-size: 14px; color: var(--ink); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.bar__back::before { content: '< '; white-space: pre; color: var(--cobalt); }
.bar__back:hover { text-decoration: underline; }
.bar__title { margin: 0; font-weight: 700; letter-spacing: -.02em; font-size: 17px; }
.bar__note { display: none; margin: 0; font-family: var(--mono); font-size: 12px; line-height: 1.3; color: var(--ink); flex: 1 1 150px; }
.is-playing .bar__note { display: block; }
.game-page .bar__note { display: block; }
.parody-note { display: inline-block; margin: 0 0 12px; padding: 3px 10px; border: 1px solid var(--ink); background: var(--card); font-family: var(--mono); font-size: 13px; line-height: 1.4; color: var(--ink); }
.bar__round { font-family: var(--mono); font-size: 14px; }
.bar__lang { display: flex; gap: 4px; }
.bar__lang a { font-family: var(--mono); font-size: 14px; color: var(--muted); text-decoration: none; min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.bar__lang a[aria-current] { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }

main { flex: 1; width: 100%; max-width: 1220px; margin: 0 auto; padding: clamp(24px, 4vw, 48px) 28px; }
main:focus { outline: none; }
.screen { scroll-margin-top: 80px; }
.display { font-size: clamp(32px, 5vw, 54px); font-weight: 600; letter-spacing: -.045em; line-height: 1.04; margin: 0 0 14px; text-wrap: balance; }
.display::before { content: ''; display: inline-block; width: .8em; height: .68em; margin-right: .3em; vertical-align: -.015em; background: var(--cobalt); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 34'%3E%3Cpath d='M3 5L14 15L3 25M23 29H37' fill='none' stroke='black' stroke-width='3.5'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 34'%3E%3Cpath d='M3 5L14 15L3 25M23 29H37' fill='none' stroke='black' stroke-width='3.5'/%3E%3C/svg%3E") center/contain no-repeat; }
.display--versus::before, #result-title.display::before { display: none; }
.h2 { font-size: 24px; font-weight: 600; letter-spacing: -.03em; margin: 28px 0 6px; }
.h3 { font-family: var(--mono); font-size: 14px; font-weight: 400; letter-spacing: .02em; margin: 0 0 6px; }
.lead { font-size: 18px; line-height: 1.5; color: var(--muted); max-width: 62ch; margin: 0 0 8px; text-wrap: pretty; }
.note { font-size: 14px; line-height: 1.5; color: var(--meta); margin: 6px 0; }
.label { font-family: var(--mono); font-size: 12px; letter-spacing: .04em; color: var(--ink); display: block; margin-bottom: 6px; padding: 0; }

.btn { font-family: var(--sans); font-size: 16px; font-weight: 500; color: var(--ink); background: var(--card); border: 1px solid var(--ink); padding: 10px 18px; min-height: 44px; cursor: pointer; box-shadow: 3px 3px 0 var(--ink); }
.btn:hover { background: var(--hover); }
.btn:active { box-shadow: 1px 1px 0 var(--ink); transform: translate(2px, 2px); }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
@media (max-width: 860px) { .btn, .bar__back, .bar__lang a { min-height: 48px; } .bar__lang a { min-width: 48px; } }
.btn--primary { background: var(--cobalt); color: #fff; }
.btn--primary:hover { background: #0A36B3; }
.btn--small { font-size: 14px; padding: 6px 12px; box-shadow: 2px 2px 0 var(--ink); }
.btn--wide { margin-top: 18px; min-width: 200px; }
.btn[aria-disabled='true'] { opacity: .6; cursor: not-allowed; box-shadow: none; }
.btn[aria-pressed='true'] { background: var(--hover); outline: 2px solid var(--ink); outline-offset: -2px; }


.onboard { margin: 10px 0 6px; padding-left: 22px; max-width: 62ch; }
.onboard li { margin: 2px 0; font-size: 16px; }

.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }

.detail { margin-top: 14px; background: var(--card); border: 1px solid var(--line); padding: 16px; }
.detail ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 20px; }
.detail li { font-size: 15px; line-height: 1.4; }
.slotname { font-family: var(--mono); font-size: 12px; color: var(--meta); display: block; }

.fieldset { border: 0; padding: 0; margin: 18px 0 0; }
.choice { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin-right: 20px; cursor: pointer; }
.choice input { width: 20px; height: 20px; accent-color: var(--cobalt); }
.howto { margin-top: 14px; background: var(--card); border: 1px solid var(--line); padding: 4px 14px; }
.howto summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-family: var(--mono); font-size: 14px; }
.keys-list { margin: 4px 0 8px; padding-left: 18px; font-size: 15px; columns: 2; }
.select-actions { margin-top: 16px; }

.roster-static { margin-top: 24px; }
.roster-static__item { background: var(--card); border: 1px solid var(--line); padding: 14px 16px; margin: 10px 0; }
.roster-static ul { margin: 6px 0 0; padding-left: 18px; }
.roster-static p { margin: 4px 0; }

/* ----- play ----- */
/* Skin tokens (07-agent-identity.md). Default = neutral skin shared by agents that have no identity yet; the canvas reads them once per run.
   Agent colours are fighter-scoped: they apply to the play stage only, never to page chrome. */
.play {
  --sk-surface: var(--card); --sk-stage: var(--card); --sk-stage-line: var(--line); --sk-stage-dot: transparent;
  --sk-well: #E4E4E6; --sk-texture: transparent; --sk-texture-kind: none; --sk-frame: #14130F; --sk-frame-w: 2; --sk-limit: #14130F;
  --sk-cell: #F5F5F6; --sk-cell-line: #14130F; --sk-cell-mark: #14130F;
  --sk-live: #0B3FCF; --sk-live-line: #14130F; --sk-live-mark: #F5F5F6;
  --sk-ghost: #14130F; --sk-ghost-alpha: .55; --sk-dump: #DEDEE0; --sk-fx: #07BE43; --sk-fx-2: #14130F; --sk-clear: #07BE43;
  --sk-accent: #0B3FCF; --sk-accent-ink: #F5F5F6; --sk-power-bg: #14130F; --sk-power-ink: #F5F5F6; --sk-power-shadow: #0B3FCF;
  --sk-bubble-bg: #FFFFFF; --sk-bubble-ink: #14130F; --sk-bubble-line: #14130F; --sk-bubble-shadow: transparent;
  --sk-corner: square; --sk-glyph: plain;
}
.play[data-agent='klaud'] {
  --sk-surface: #FAF3EA; --sk-stage: #F3E2CF; --sk-stage-line: #E2C7AC; --sk-stage-dot: rgba(184,96,60,.22);
  --sk-well: #FBF4EC; --sk-texture: rgba(184,96,60,.20); --sk-texture-kind: pixeldots; --sk-frame: #14130F; --sk-limit: #14130F;
  --sk-cell: #F2D2BC; --sk-cell-line: #14130F; --sk-cell-mark: #14130F;
  --sk-live: #D9784F; --sk-live-line: #14130F; --sk-live-mark: #14130F;
  --sk-ghost: #B8603C; --sk-ghost-alpha: .85; --sk-dump: #E6DDD2; --sk-fx: #D9784F; --sk-fx-2: #B8603C;
  --sk-accent: #D9784F; --sk-accent-ink: #14130F; --sk-power-bg: #D9784F; --sk-power-ink: #14130F; --sk-power-shadow: #B8603C;
  --sk-bubble-shadow: #B8603C; --sk-corner: notch; --sk-glyph: pixel;
}
.play { --cell: 36px; display: grid; grid-template-columns: 230px auto 190px; gap: 20px; align-items: start; justify-content: center; justify-items: center; max-width: 960px; margin: 0 auto; background: var(--sk-surface); border: 1px solid var(--line); padding: 20px; }
.stage { grid-column: 1; align-self: stretch; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 10px 12px; position: relative; overflow: hidden; background-color: var(--sk-stage); background-image: radial-gradient(var(--sk-stage-dot) 1.2px, transparent 1.4px); background-size: 10px 10px; border: 1px solid var(--sk-stage-line); }
.stage img { width: 180px; height: 180px; display: block; }
.stage__name { margin: 0; font-family: var(--mono); font-size: 13px; letter-spacing: .02em; }
.bubble { position: relative; max-width: 100%; margin: 0 0 8px; padding: 8px 12px; font-size: 15px; line-height: 1.3; color: var(--sk-bubble-ink); background: var(--sk-bubble-bg); border: 2px solid var(--sk-bubble-line); box-shadow: 4px 4px 0 var(--sk-bubble-shadow); text-wrap: balance; }
.bubble::after { content: ''; position: absolute; left: 24px; bottom: -12px; width: 12px; height: 10px; background: var(--sk-bubble-bg); border-left: 2px solid var(--sk-bubble-line); border-right: 2px solid var(--sk-bubble-line); border-bottom: 2px solid var(--sk-bubble-line); }
.bubble--over { display: inline-block; margin: 0 8px 14px 0; }
.bubble--over::after { display: none; }
.stage img[data-mood='idle'] { animation: bob 2.4s steps(1) infinite; }
.stage img[data-mood='happy'] { animation: hop .5s steps(4) 2; }
.stage img[data-mood='hit'] { animation: shake .3s steps(3) 2; }
@keyframes bob { 50% { transform: translateY(-3px); } }
@keyframes hop { 25% { transform: translateY(-10px); } 50% { transform: translateY(0); } 75% { transform: translateY(-4px); } }
@keyframes shake { 33% { transform: translateX(-4px); } 66% { transform: translateX(4px); } }
.wellbox { grid-column: 2; }
.memtab { display: inline-block; margin-left: 6px; padding: 0 6px; border: 1px solid var(--ink); background: var(--sk-accent); color: var(--sk-accent-ink); font-size: 11px; letter-spacing: 0; }
.wellbox__head { display: flex; justify-content: space-between; margin-bottom: 4px; }
.well { position: relative; width: calc(var(--cell) * 8); height: calc(var(--cell) * 12.5); background: var(--sk-well); box-shadow: 0 0 0 calc(var(--sk-frame-w) * 1px) var(--sk-frame); }
.well:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; box-shadow: 0 0 0 5px var(--card); }
.well canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.cover { position: absolute; inset: 0; background: var(--card); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 14px; text-align: center; background-image: repeating-linear-gradient(135deg, rgba(20,19,15,.06) 0 2px, transparent 2px 8px); }
.cover__text { font-weight: 600; font-size: 18px; margin: 0; }
.cover__count { font-family: var(--mono); font-size: 28px; margin: 0; min-height: 1.2em; }
.cover__actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.cover__note { font-size: 13px; }
.side { grid-column: 3; justify-self: start; display: flex; flex-direction: column; gap: 12px; width: 190px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat--row { flex-direction: row; justify-content: space-between; font-family: var(--mono); font-size: 14px; }
.stat__big { font-size: 34px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat__ctx { font-family: var(--mono); font-size: 14px; }
.stat__ctx.is-near { font-weight: 700; text-decoration: underline; text-decoration-style: wavy; text-underline-offset: 3px; }
.meter { position: relative; height: 14px; border: 2px solid var(--ink); background: var(--hover); }
.meter__fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--sk-accent); }
.meter__limit { position: absolute; top: -2px; bottom: -2px; left: 83.33%; border-left: 2px dashed var(--ink); }
.meter.is-near .meter__fill { background: repeating-linear-gradient(135deg, var(--sk-accent) 0 4px, #fff 4px 8px); }
.stat--next canvas { display: block; }
.power { display: flex; align-items: center; gap: 8px; justify-content: flex-start; text-align: left; min-height: 48px; min-width: 48px; padding: 6px 10px; }
.power__ring { width: 22px; height: 22px; flex: none; }
.power__text { display: flex; flex-direction: column; line-height: 1.15; }
.power__name { font-weight: 600; font-size: 15px; }
.power__state { font-family: var(--mono); font-size: 12px; }
.power.is-ready { background: var(--sk-power-bg); color: var(--sk-power-ink); box-shadow: 3px 3px 0 var(--sk-power-shadow); }
.swap { min-height: 48px; }
.status { font-family: var(--mono); font-size: 14px; min-height: 24px; margin: 10px auto 0; text-align: center; max-width: 960px; }
.controls { display: flex; gap: 8px; justify-content: center; margin: 8px auto 0; max-width: 960px; }
.ctl { flex: 1 1 0; max-width: 120px; min-width: 48px; min-height: 48px; height: 52px; background: var(--card); color: var(--ink); border: 1px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); cursor: pointer; display: flex; align-items: center; justify-content: center; touch-action: manipulation; }
.ctl:active, .ctl.is-down { background: var(--hover); box-shadow: 1px 1px 0 var(--ink); transform: translate(2px, 2px); }
.ctl svg { width: 26px; height: 26px; }
.hint { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.over { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.over img { width: 120px; height: 120px; }
.over__stats { display: grid; grid-template-columns: max-content auto; gap: 4px 20px; margin: 10px 0; }
.over__stats dt { font-family: var(--mono); font-size: 13px; color: var(--meta); }
.over__stats dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.over__best { font-family: var(--mono); font-weight: 700; border: 2px solid var(--ink); display: inline-block; padding: 2px 10px; margin: 4px 0; }
.result__actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 18px 0 8px; }
.share-field { width: 100%; max-width: 560px; font: inherit; padding: 8px; border: 1px solid var(--ink); background: var(--card); }
#over-title.display::before { display: none; }

.foot { background: var(--band); border-top: 1px solid var(--line); padding: 18px 28px 24px; }
.foot p { max-width: 1220px; margin: 0 auto 6px; font-size: 14px; color: var(--muted); }
.foot__disclaimer { font-weight: 500; color: var(--ink) !important; }
.foot a { color: var(--ink); }

@media (max-width: 860px) {
  .bar { padding: 6px 16px; gap: 4px 10px; }
  main { padding: 14px 16px; }
  .foot { padding: 16px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail ul { grid-template-columns: minmax(0, 1fr); }
  .keys-list { columns: 1; }
}
/* Under 861 px the mascot stage becomes a strip above the well: sprite, then the speech bubble (tail on the left). */
@media (max-width: 860px) {
  .play { grid-template-columns: auto auto; grid-template-areas: "stage stage" "well side"; gap: 8px 12px; }
  .stage { grid-area: stage; grid-column: auto; flex-direction: row; justify-content: flex-start; align-items: center; gap: 10px; height: 68px; padding: 6px 10px; }
  .stage img { order: -1; width: 56px; height: 56px; flex: none; }
  .stage__name { display: none; }
  .bubble { flex: 1 1 auto; margin: 0 0 0 8px; font-size: 14px; padding: 6px 10px; box-shadow: 3px 3px 0 var(--sk-bubble-shadow); }
  .bubble::after { display: none; }
  .wellbox { grid-area: well; grid-column: auto; }
  .side { grid-area: side; grid-column: auto; }
}
@media (max-width: 639px) {
  .play { grid-template-columns: auto 88px; padding: 0; background: none; border: 0; justify-content: center; }
  .side { width: 88px; gap: 6px; justify-self: stretch; }
  .stat--next .label { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
  .memtab { min-width: 0; margin-left: 0; padding: 0 4px; overflow: hidden; text-overflow: ellipsis; font-size: 10px; line-height: 1.5; }
  .stat__big { font-size: 20px; }
  .stat--row { flex-direction: column; font-size: 12px; }
  .stat__ctx, .label { font-size: 11px; }
  .power { padding: 4px 6px; gap: 4px; }
  .power__ring { width: 16px; height: 16px; }
  .power__name { font-size: 13px; }
  .power__state { font-size: 10px; }
  .wellbox__head { font-size: 11px; }
  .cover__text { font-size: 15px; }
  .cover__count { font-size: 22px; }
  .status { font-size: 13px; margin-top: 6px; }
  .controls { margin-top: 6px; }
  .ctl svg { width: 24px; height: 24px; }
  .over img { width: 72px; height: 72px; }
}
/* While playing on a phone the bar keeps only the two game buttons so the well and controls fit the first screen. */
@media (max-width: 639px) {
  .is-playing .bar__left, .is-playing .bar__title, .is-playing .bar__lang { display: none; }
  .is-playing .bar { padding: 4px 16px; justify-content: space-between; flex-wrap: nowrap; gap: 8px; }
  .is-playing .bar__right { margin-left: 0; flex-wrap: nowrap; }
  .is-playing .bar__note { font-size: 11px; flex: 1 1 auto; min-width: 0; }
  .is-playing .bar .btn { min-height: 48px; padding: 6px 10px; }
  .is-playing main { padding-top: 10px; }
}
@media (max-width: 860px) and (max-height: 640px) { .stage { height: 48px; padding: 4px 8px; } .stage img { width: 40px; height: 40px; } .bubble { font-size: 12px; padding: 3px 8px; } }
@media (max-width: 639px) and (max-height: 430px) { .stage { display: none; } }

.arena-reduced *, .arena-reduced *::before, .arena-reduced *::after { animation: none !important; transition: none !important; }
.arena-reduced .scan { display: none; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } .scan { display: none; } }
@media (forced-colors: active) {
  .meter__fill { background: CanvasText; }
  .power.is-ready { background: Highlight; color: HighlightText; }
}
/* Mode choices and the how-to disclosure are touch targets too (declared after their 44px base rules). */
@media (max-width: 860px) { .choice, .howto summary { min-height: 48px; } }
