* { box-sizing: border-box }
:root { color-scheme: dark; font: 16px/1.45 system-ui, sans-serif; color: #fff5df; background: #091b26 }
body { margin: 0 }
main { max-width: 1040px; height: min(100dvh, 725px); margin: auto; display: flex; flex-direction: column }
.back { display: inline-block; padding: 12px; color: #a4e8d7 }
.game { flex: 1; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; border: 1px solid #457078; border-radius: 16px; overflow: hidden; background: #102832 }
.beach { container-type: size; display: grid; place-items: center; background: #091b26 }
.stage { position: relative; width: min(100cqw, 177.7778cqh); background: #9bdad7 url(strand.webp) center / cover }
header { position: absolute; z-index: 1; inset: 12px 14px auto; display: flex; justify-content: space-between; align-items: flex-start; gap: 5px; pointer-events: none }
h1, .score { margin: 0; border: 1px solid #e6bb76; border-radius: 12px; background: #102c37f5; box-shadow: 0 2px 6px #06212c44 }
h1 { padding: .18em .55em; font: bold italic clamp(18px, 3.2vw, 36px)/1.2 Georgia, serif; color: #ffe6aa }
.score { display: flex; gap: 14px; padding: 7px 12px; font-size: clamp(12px, 1.65vw, 17px); font-weight: 600 }
.score b { color: #ffda80; font-variant-numeric: tabular-nums }
canvas { width: 100%; aspect-ratio: 16/9; display: block; outline-offset: -3px }
footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px }
p { margin: 0 }
#rules { color: #d3e2e5; font-size: .9rem; max-width: 70ch }
#message { color: #ffdb88; font-weight: 650; margin-top: 3px }
.actions, .steer { display: flex; gap: 8px }
button { font: inherit; font-weight: 700; border: 1px solid #53808a; border-radius: 10px; padding: 9px 16px; background: #173c47; color: #fff; cursor: pointer; white-space: nowrap; touch-action: manipulation }
button:disabled { opacity: .6; cursor: wait }
button:focus-visible, canvas:focus-visible { outline: 3px solid #ffcc50 }
.gold { background: linear-gradient(#ffe69a, #edb04b); border-color: #ffcd73; color: #382919 }
.steer { display: none }
.steer button { min-width: 65px; min-height: 48px; touch-action: none; user-select: none; -webkit-user-select: none }
.steer button:active { background: #35716e }
dialog { padding: 0; width: min(94vw, 740px, 155dvh); max-width: none; border: 1px solid #e5bf76; border-radius: 15px; overflow: hidden; background: #173e48; box-shadow: 0 14px 40px #00101799 }
dialog::backdrop { background: #001721a8 }
#finale { width: min(96vw, 1000px, 162dvh); max-height: 96dvh; overflow-y: auto; color: #fff6dd; background: #102532 }
.finale-art { position: relative; aspect-ratio: 16/9; overflow: hidden }
.finale-shot { position: absolute; inset: 0; background: center / cover no-repeat; opacity: 0; transition: opacity 1.15s ease-in-out }
.finale-shot.visible { opacity: 1 }
.finale-shot:first-child::after { content: ""; position: absolute; inset: 0; background: inherit; mask-image: radial-gradient(ellipse 4.5% 11% at 9.4% 41.5%, black 70%, transparent); transform-origin: 13% 51%; animation: rudi-wag .38s ease-in-out infinite alternate }
@keyframes rudi-wag { from { transform: rotate(-3deg) } to { transform: rotate(4deg) } }
.finale-caption { position: absolute; right: 3%; bottom: 5%; width: 48%; padding: 1em; isolation: isolate; color: #fffaf0; font: 650 clamp(16px, 2.2vw, 23px)/1.45 system-ui, sans-serif; overflow-wrap: anywhere }
.finale-caption:not(.last)::before { content: ""; position: absolute; z-index: -1; inset: -.25em -.4em; border-radius: 1.4em; background: #05131ed9; filter: blur(.8em); pointer-events: none }
.finale-caption p { text-shadow: 0 1px 3px #07131d, 0 0 2px #07131d }
.finale-caption p:empty { display: none }
.finale-caption { opacity: 0; transition: opacity .35s ease }
.finale-caption.speaking, .finale-caption.last { opacity: 1 }
.finale-caption.last { right: 5%; width: 90%; text-align: center }
.finale-caption.last #finaleLine { margin-bottom: .45em }
#finaleClaim { color: inherit; background: #123849; border-color: #efc780; font-family: inherit }
#finaleStatus:not(:empty) { margin-top: .5em }
@media (max-width: 620px) {
  #finale { width: min(96vw, 150dvh) }
  #finale[open] { display: grid }
  .finale-art, .finale-caption { grid-area: 1 / 1 }
  .finale-art { width: 100%; min-height: 100% }
  .finale-caption, .finale-caption.last { position: relative; inset: auto; align-self: end; width: 100%; padding: .65em .8em }
}
@media (prefers-reduced-motion: reduce) {
  .finale-shot { transition: none }
  .finale-shot:first-child::after { animation: none }
}
dialog img { display: block; width: 100%; height: auto }
dialog form { position: absolute; top: 71%; left: 67%; transform: translate(-50%,-20%) }
dialog button { min-width: clamp(82px, 16vw, 155px); font-size: clamp(16px, 2.5vw, 23px); border-radius: 99px }
#roundBreak { container-type: inline-size; max-height: 95dvh; overflow-y: auto }
.round-copy { position: absolute; inset: 20% 5% 13% 48%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .45em; text-align: center; font-size: clamp(14px, 3.2cqw, 23px) }
.round-copy h2 { margin: 0; color: #ffdd88; font: bold 1.5em/1.05 Georgia, serif }
.round-copy p { line-height: 1.2 }
.round-copy form { position: static; transform: none; display: flex; flex-wrap: wrap; justify-content: center; gap: .35em }
.round-copy button { min-width: 3.3em; font-size: .9em; padding: .35em .65em }
@container (max-width: 370px) {
  .round-copy { position: static; padding: .7em }
  #roundBreak img { max-height: 26dvh; object-fit: cover; object-position: left 38% }
}
@media (pointer: coarse), (max-width: 760px) {
  footer { flex-wrap: wrap }
  footer > div:first-child { width: 100% }
  .steer { display: flex }
}
@media (max-width: 560px) {
  main { height: min(100dvh, calc(87vw + 205px)) }
  .stage { width: min(100cqw, 115cqh) }
  canvas { aspect-ratio: 1.15 }
  header { inset: 6px 6px auto; align-items: center }
  .score { gap: 6px; padding: 5px 6px; font-size: 11px }
  footer { padding: 9px; gap: 8px }
  button { padding: 8px 10px }
  .steer button { min-width: 48px }
}
#rudiStats { max-width: 1040px; margin: .6rem auto; padding: .8rem 1rem; border: 1px solid #457078; border-radius: 12px; background: #102832; display: flex; flex-wrap: wrap; align-items: center; gap: .75rem }
#rudiStats h2, #rudiStats dl, #rudiStats dd { margin: 0 }
#rudiStats h2 { font-size: 1rem }
#rudiStats p, #rudiStats dt { color: #a4e8d7; font-size: .75rem }
#rudiStats dl { flex: 1 1 320px; display: grid; grid-template-columns: repeat(4,1fr); gap: .35rem; text-align: center }
#rudiStats dd { color: #ffda80; font-weight: bold }
