:root {
  color-scheme: dark;
  --night: #171d17;
  --wood: #30231b;
  --gold: #c7a364;
  --light-gold: #f2cf89;
  --paper: #ead7aa;
  --ink: #35251b;
  --cream: #f8eccd;
  --muted: #c9b99a;
  font-family: Georgia, serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--cream);
  background:
    radial-gradient(ellipse at 50% -12%, #5b5039 0%, transparent 58%),
    radial-gradient(ellipse at 0 55%, #343a29, transparent 63%),
    var(--night);
}
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; font: inherit; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--light-gold); outline-offset: 3px; }
[hidden] { display: none !important; }
.shell { max-width: 1120px; margin: auto; padding: 0 24px 24px; }
.mast {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 0; border-bottom: 1px solid #a486554f;
}
.brand { display: flex; align-items: center; gap: 11px; color: var(--cream); text-decoration: none; line-height: 1; letter-spacing: .1em; font-size: .7rem; }
.brand b { font-size: 1rem; }
.brand img { width: 38px; height: 44px; }
.mast-actions, .language { display: flex; align-items: center; gap: 8px; }
.language .quiet { padding: 5px 7px; }
.language [aria-pressed="true"] { color: #241a11; background: var(--light-gold); }
.quiet { padding: 8px 13px; border: 1px solid #96774f; border-radius: 3px; background: linear-gradient(#4b3729, #32231d); color: var(--cream); font-size: .88rem; white-space: nowrap; }
.quiet span { color: var(--light-gold); margin-left: 4px; }
.quiet:hover:not(:disabled) { border-color: var(--light-gold); background: #634830; }
.arena-label {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin: 12px 0 10px; color: var(--light-gold); font-size: .85rem; letter-spacing: .12em;
}
.arena-label::before, .arena-label::after { content: '✧'; color: var(--gold); }
.arena {
  border: 1px solid var(--gold); border-radius: 7px; overflow: hidden;
  box-shadow: 0 0 0 3px #1f1711, 0 0 0 4px #89683c, 0 14px 44px #0008;
  background: var(--wood);
}
.score {
  display: grid; grid-template-columns: 1fr minmax(100px, 142px) 1fr;
  min-height: 63px; border-bottom: 2px solid #bd985b;
}
.team, .clock { display: flex; align-items: center; justify-content: center; gap: 14px; }
.team span { font-size: .86rem; font-weight: bold; letter-spacing: .14em; }
.team strong, .clock strong { font-size: 1.95rem; line-height: 1; font-variant-numeric: lining-nums tabular-nums; }
.team i, .role > i { display: inline-block; width: 7px; height: 7px; background: currentColor; transform: rotate(45deg); margin-right: 4px; }
.blue { color: #d6f3e6; background: linear-gradient(110deg,#153e3a,#29554c); }
.orange { color: #ffe0b9; background: linear-gradient(250deg,#542635,#783c3a); }
.clock {
  flex-direction: column; gap: 2px; color: var(--ink);
  border-inline: 1px solid #ba945c;
  background: radial-gradient(ellipse at center, #f7e5bb, #d7b780);
}
.clock small, .role small, .label { font-size: .65rem; font-weight: bold; letter-spacing: .1em; }
.clock strong { font-size: 1.5rem; }
.field { position: relative; isolation: isolate; aspect-ratio: 960/490; background: #435035; }
.field:focus { outline: none; }
canvas { display: block; width: 100%; height: 100%; }
.overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  padding: 10px; text-align: center;
  background: radial-gradient(ellipse at center,#161d16dc 4%,#1822189b 43%,#161a141f 83%);
}
.intro { display: grid; justify-items: center; gap: 10px; }
.kicker { color: var(--light-gold); font-size: .72rem; text-transform: uppercase; letter-spacing: .19em; }
.kicker i::before { content: '✦'; font-style: normal; margin-right: 5px; }
.intro h1 {
  margin: 0; color: #fff0cc; font-size: clamp(2.9rem,8vw,6.45rem);
  font-weight: 700; text-transform: uppercase; line-height: .85;
  letter-spacing: -.045em; text-shadow: 0 3px 0 #3a2215, 0 5px 20px #111;
}
.intro h1 em { color: #f1c77c; font-style: normal; }
.intro p { max-width: 39ch; margin: 1px 0; color: #fff3d6; font-size: clamp(.85rem,2vw,1.05rem); text-shadow: 0 1px 5px #000; }
.primary {
  border: 1px solid #f3d393; border-radius: 3px; padding: 9px 19px;
  background: linear-gradient(#f6d890,#d1a75f); color: #2b1c12;
  font-size: 1rem; font-weight: bold; box-shadow: inset 0 0 0 2px #a67c493b, 0 2px 0 #664425;
}
.primary:hover { background: #ffe6ac; }
.primary span { margin-left: 9px; font-size: .73em; }
.play-options { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; }
.text-button { background: transparent; border: 0; color: #fff0cc; text-decoration: underline; text-shadow: 0 1px 4px #000; }
.trophy { font-size: clamp(2rem,8vw,5rem); line-height: 1; filter: drop-shadow(0 0 15px #e5b858a0); }
.intro:has(.trophy:not([hidden])) h1 { font-size: clamp(1.6rem,6vw,4rem); }
.tagline { color: #f0dcb4; font-size: .76rem; text-shadow: 0 1px 4px #000; }
.notice {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 92%; padding: 5px 12px; text-align: center;
  background: #f2deb1; color: var(--ink); border: 1px solid var(--gold);
  border-radius: 3px; font-size: .86rem; font-weight: bold;
}
.capture {
  position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 12px; width: max-content; max-width: calc(100% - 16px);
  padding: 5px 10px; border: 1px solid var(--gold); border-radius: 3px;
  background: #33251a; color: var(--cream); font-size: .75rem;
}
.capture label { display: grid; gap: 3px; }
.capture progress { width: clamp(65px, 13vw, 120px); height: 7px; accent-color: #85cdb6; }
.capture label + label progress { accent-color: #ea8177; }
.hud {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 54px; padding: 7px 13px; border-top: 2px solid #ba945c;
  background: radial-gradient(ellipse at center,#f2e0b5,#d7b984); color: var(--ink);
}
.role { display: flex; align-items: center; gap: 7px; }
.role span, .match-status { display: grid; gap: 2px; }
.role b, .match-status b { font-size: .89rem; }
.match-status { text-align: center; }
.match-status small { font-size: .76rem; }
.match-status .steal-ready { color: #19582d; }
.match-status .out-of-play { color: #862f2d; }
.below { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 11px; padding: 15px 0 0; }
.label { color: var(--light-gold); }
.key-row, .values { display: flex; flex-wrap: wrap; gap: 7px 12px; }
.key-row { margin-top: 6px; }
.key-row span, .values span { font-size: .83rem; color: var(--muted); white-space: nowrap; }
kbd { padding: 2px 4px; border: 1px solid #917247; border-radius: 3px; background: #34261e; color: var(--cream); font-size: .7rem; }
.values { gap: 6px; }
.values span { padding: 5px 8px; border: 1px solid #a486555c; border-radius: 3px; background: #2e251c; }
.values b { color: var(--light-gold); }
dialog {
  width: calc(100% - 30px); max-width: 530px; max-height: 90dvh; overflow: auto;
  padding: 19px; color: var(--ink); border: 3px double #855b31; border-radius: 6px;
  background: radial-gradient(ellipse at center, #f8e8c2, #dfbd83); box-shadow: 0 12px 80px #000a;
}
dialog::backdrop { background: #101410cf; }
.dialog-top { display: flex; justify-content: space-between; align-items: center; }
dialog .label { color: #6f4929; }
dialog h2 { margin: .2em 0 .4em; }
dialog p, dialog dd { font-size: .95rem; line-height: 1.45; }
dialog dt { font-weight: bold; color: #663e24; }
dialog dd { margin: 4px 0 12px; }
.touch { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; touch-action: none; user-select: none; }
.joystick {
  position: relative; display: grid; place-items: center;
  width: clamp(74px, 15vw, 112px); aspect-ratio: 1;
  border: 2px solid #a78650; border-radius: 50%;
  background: radial-gradient(circle, #322419 0 58%, #59432c 59% 61%, #3c2b20 62%);
  touch-action: none; cursor: grab;
}
.joystick-knob {
  width: 43%; aspect-ratio: 1; border: 1px solid #ffe4a3; border-radius: 50%;
  background: radial-gradient(circle at 38% 29%, #ffe4a3, #b88a49 75%);
  box-shadow: 0 2px 5px #140e07a0; pointer-events: none;
  transform: translate(var(--stick-x, 0px), var(--stick-y, 0px));
}
.touch button { min-height: 39px; padding: 3px 8px; border: 1px solid #a78650; border-radius: 4px; background: #3c2b20; color: var(--cream); font-weight: bold; font-size: .8rem; touch-action: none; }
.touch, .touch button { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.touch button.pressed, .touch .steal-ready { color: #182619; background: #c6eda7; border-color: #c6eda7; }
.rotate-hint { display:flex; flex-wrap:wrap; align-items:center; justify-content:center; gap:8px; margin:0 0 9px; font-size:.82rem; color:var(--light-gold); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
@media(max-width:650px) {
  .mast-actions { gap: 5px; }
  .language { gap: 3px; }
  #help { padding-inline: 6px; }
  .shell { padding: 0 11px 14px; }
  .mast { padding: 8px 0; }
  .brand img { width: 29px; height: 35px; }
  .arena-label { margin: 8px 0; font-size: .72rem; }
  .score { min-height: 46px; grid-template-columns: 1fr 78px 1fr; }
  .team { gap: 6px; }
  .team span { font-size: .62rem; }
  .team strong { font-size: 1.38rem; }
  .clock strong { font-size: 1.02rem; }
  .clock small { font-size: .49rem; }
  .field { min-height: 188px; }
  .intro { gap: 6px; }
  .intro h1 { font-size: clamp(2.25rem,10vw,3.7rem); }
  .intro p { font-size: .77rem; }
  .primary { padding: 6px 12px; font-size: .88rem; }
  .tagline, .kicker { font-size: .57rem; }
  .notice { top: 5px; font-size: .68rem; }
  .hud { min-height: 46px; padding: 5px; }
  .role small, .match-status small { font-size: .57rem; }
  .role b, .match-status b { font-size: .71rem; }
  .hud .quiet { font-size: .67rem; padding: 5px 6px; }
  .below { padding-top: 11px; }
}
@media(pointer:coarse) { .guide { display:none; } }
@media(orientation:landscape) and (max-height:600px) {
  .mobile-flight .shell {
    --stick-size:clamp(54px,20dvh,84px);
    --action-width:clamp(88px,14vw,112px);
    --top:max(4px,env(safe-area-inset-top));
    --bottom:max(4px,env(safe-area-inset-bottom));
    --left:max(4px,env(safe-area-inset-left));
    --right:max(4px,env(safe-area-inset-right));
    --field-height:calc(100dvh - var(--top) - var(--bottom) - 56px);
    display:grid; grid-template-columns:var(--stick-size) minmax(0,1fr) var(--action-width);
    align-items:center; gap:5px;
    height:100dvh;
    max-width:calc(var(--field-height) * 2.25 + var(--stick-size) + var(--action-width) + var(--left) + var(--right) + 12px);
    padding:var(--top) var(--right) var(--bottom) var(--left);
  }
  .mobile-flight .mast, .mobile-flight .arena-label, .mobile-flight .below { display:none; }
  .mobile-flight .field { min-height:0; aspect-ratio:auto; }
  .mobile-flight .field canvas { position:absolute; inset:0; }
  .mobile-flight .score { grid-template-columns:minmax(0,1fr) 72px minmax(0,1fr); min-height:0; border-bottom-width:1px; }
  .mobile-flight .team, .mobile-flight .clock { gap:4px; min-width:0; }
  .mobile-flight .team span { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .mobile-flight .team i { display:none; }
  .mobile-flight .clock strong, .mobile-flight .team strong { font-size:1rem; }
  .mobile-flight .team span { font-size:.57rem; letter-spacing:.04em; }
  .mobile-flight .clock small, .mobile-flight .role, .mobile-flight #lucero { display:none; }
  .mobile-flight .hud { min-height:0; padding:0 4px 0 7px; border-top-width:1px; }
  .mobile-flight .match-status { flex:1; min-width:0; }
  .mobile-flight .match-status b { font-size:.67rem; line-height:1; }
  .mobile-flight .hud .quiet { font-size:.64rem; padding:1px 8px; min-height:24px; }
  .mobile-flight .touch { display:contents; }
  .mobile-flight .arena {
    grid-area:1 / 2; min-width:0; height:min(100%,calc((100vw - var(--left) - var(--right) - var(--stick-size) - var(--action-width) - 12px) / 1.78 + 56px));
    display:grid; grid-template-rows:26px minmax(0,1fr) 28px;
    box-shadow:0 0 0 1px #211a13, 0 5px 16px #0007;
  }
  .mobile-flight .joystick { grid-area:1 / 1; width:var(--stick-size); }
  .mobile-flight .actions { grid-area:1 / 3; grid-template-columns:repeat(2,minmax(0,1fr)); }
  .mobile-flight .actions button { min-height:42px; padding-inline:0; font-size:.64rem; }
  .mobile-flight #touch-action[hidden] + button { grid-column:2; }
  .mobile-flight .notice { top:3px; padding:2px 6px; font-size:.66rem; }
  .mobile-flight .capture { bottom:3px; gap:7px; padding:2px 5px; font-size:.62rem; }
  .mobile-flight .capture label { gap:0; }
}
