:root {
  color-scheme: light;
  --paper: #f2f0e9;
  --panel: #e5e1d6;
  --ink: #171717;
  --muted: #706c63;
  --accent: #ed4c30;
  --on-accent: #f2f0e9;
  --edge: #c9c4b7;
  --cup: #a2a19d;
  --floor: #b3b4a7;
  --font: "Roboto", "Noto Sans", Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--font); }
body[data-theme=night] {
  color-scheme: dark;
  --paper: #0b2f26;
  --panel: #20553e;
  --ink: #f6e8be;
  --muted: #a5bcb0;
  --accent: #e8bf70;
  --on-accent: #0b2f26;
  --edge: #426354;
  --cup: #1a4634;
  --floor: #194431;
}
body[data-theme=pop] {
  --paper: #ffdb5b;
  --panel: #ff8167;
  --ink: #30243e;
  --muted: #654b4d;
  --accent: #30243e;
  --on-accent: #ffdb5b;
  --edge: #c6865d;
  --cup: #cc6a57;
  --floor: #c76750;
}
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button { border: 0; color: inherit; }
button:disabled { cursor: not-allowed; opacity: .45; }
button:focus-visible, input:focus-visible, select:focus-visible, [role=button]:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
a { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1 { font: bold 30px/1.2 Georgia, "Noto Serif", serif; margin-bottom: 12px; }
h2 { font: bold 20px/1.25 Georgia, "Noto Serif", serif; }
h3 { font-size: 17px; }
.app { width: 100%; max-width: 500px; min-height: 100dvh; margin: auto; padding: calc(16px + env(safe-area-inset-top)) 22px calc(28px + env(safe-area-inset-bottom)); }
.masthead { display: flex; flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 18px; }
.wordmark { text-decoration: none; font: bold 12px/1.5 Georgia, "Noto Serif", serif; letter-spacing: .25px; }
.wordmark span { font: inherit; }
.quiet { background: var(--panel); padding: 12px 16px; border-radius: 18px; font-size: 15px; min-height: 48px; }
.edition { display: block; font-size: 12px; line-height: 1.5; color: var(--muted); font-weight: bold; }
.lobby { display: flex; flex-direction: column; gap: 18px; }
.lobby-title p { margin: 0; font-size: 16px; }
.room-form label { display: block; font-size: 12px; font-weight: bold; margin-bottom: 2px; }
.room-form input { background: transparent; border: 0; border-bottom: 1px solid var(--edge); border-radius: 0; width: 100%; padding: 12px 2px; color: var(--ink); margin-bottom: 8px; min-height: 48px; font-size: 16px; }
input::placeholder { color: var(--muted); opacity: 1; }
.primary, .secondary { display: block; width: 100%; min-height: 48px; padding: 12px 16px; border-radius: 18px; font-size: 15px; font-weight: normal; text-align: center; }
.primary { background: var(--accent); color: var(--on-accent); }
.secondary { background: var(--panel); }
.divider { margin: 22px 0 10px; font: bold 18px/1.4 Georgia, "Noto Serif", serif; }
.join-row { display: flex; flex-direction: column; gap: 0; }
.join-row input { min-width: 0; }
.fine { font-size: 12px; color: var(--muted); line-height: 1.5; }
.room-form > .fine { margin: 16px 0 0; }
.notice { border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; background: var(--panel); color: var(--ink); font-size: 14px; overflow-wrap: anywhere; }
.table-top { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 0 0 16px; }
.table-top .edition { color: var(--ink); font: bold 15px Georgia, "Noto Serif", serif; }
.room-code { background: transparent; font: bold 30px/1.3 Georgia, "Noto Serif", serif; padding: 4px 0; letter-spacing: 1px; }
.table-actions { display: flex; flex-direction: column; text-align: right; gap: 6px; }
.table-actions .quiet { min-height: 40px; padding: 8px 16px; }
.connection { font-size: 12px; color: var(--muted); max-width: 160px; }
.players-panel { padding: 14px 12px 12px; background: var(--panel); border-radius: 18px; }
.panel-title { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 12px; }
.panel-title h2 { font: bold 12px/1.5 var(--font); text-transform: uppercase; margin: 0; }
.panel-title h2 span { margin-left: 6px; font-weight: normal; }
.panel-title .fine { font-size: 11px; }
.players { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px 7px; }
.player { text-align: center; min-width: 0; }
.player-number { height: 55px; background: var(--paper); border-radius: 12px; display: flex; align-items: center; justify-content: center; font: bold 27px Georgia, "Noto Serif", serif; }
.player-number span { display: block; transition: transform .25s ease-out; }
.player.pending .player-number span { transform: rotate(-90deg); }
.player.current .player-number { background: var(--accent); color: var(--paper); }
.player-name { font-size: 11px; margin-top: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-meta { color: var(--muted); font-size: 10px; line-height: 1.5; }
.player.eliminated { opacity: .55; }
.remove-player { background: transparent; color: var(--ink); padding: 4px 0; font-size: 10px; text-decoration: underline; }
.play-layout { display: flex; flex-direction: column; gap: 16px; padding-top: 18px; }
.cup-column, .game-controls { width: 100%; }
.turn-heading { text-align: center; }
.turn-heading h1 { font-size: 20px; margin: 4px 0 0; }
.cup { position: relative; width: 100%; max-width: 320px; margin: 0 auto; aspect-ratio: 1; isolation: isolate; overflow: hidden; touch-action: pan-y; }
#scene { display: block; width: 100%; height: 100%; }
.coaster { position: absolute; inset: 3.8%; border-radius: 50%; background: linear-gradient(135deg, #ead7aa99, #9c855c80, #e8d6aea6); border: 2px solid #ffffffcf; box-shadow: inset 0 0 0 5px #7e623d33; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; will-change: transform; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.coaster[aria-disabled=true] { cursor: default; }
.coaster:active { cursor: grabbing; }
.coaster-ring { position: absolute; inset: 9px; border: 1px solid #7e623d99; border-radius: 50%; display: flex; flex-direction: column; align-items: center; color: #664b2e; background-image: radial-gradient(#ffffff22 .7px, transparent .7px); background-size: 12px 12px; }
.coaster-brand { margin-top: 17%; font: bold 20px Georgia, "Noto Serif", serif; letter-spacing: 2px; }
.coaster-caption { font-size: 10px; letter-spacing: 2px; margin-top: 4%; }
.grip { margin: auto; font-size: 24px; line-height: 1; letter-spacing: 5px; opacity: .7; }
.coaster-bottom { margin-bottom: 17%; font-size: 9px; letter-spacing: .6px; }
.cup-hint { margin: 0; font-size: 13px; line-height: 1.5; text-align: left; }
.scene-error { position: absolute; inset: 20%; z-index: 3; background: var(--paper); border-radius: 12px; padding: 14px; font-size: 14px; }
.device-panel { padding: 14px 16px; background: var(--panel); border-radius: 18px; }
.device-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.device-top .edition { font-size: 11px; }
.text-button { background: transparent; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; padding: 5px 0; }
.device-panel p { font-size: 13px; margin: 8px 0; }
.device-bottom { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--muted); }
.toggle { white-space: nowrap; }
.toggle input { accent-color: var(--accent); vertical-align: middle; }
.game-message { font: bold 18px/1.4 Georgia, "Noto Serif", serif; margin: 18px 0 12px; }
.actions { display: grid; gap: 8px; margin-bottom: 16px; }
.public-result { background: var(--panel); padding: 14px 16px; border-radius: 18px; margin-bottom: 12px; font-size: 14px; }
.public-result strong { display: block; font: bold 30px/1.4 Georgia, "Noto Serif", serif; margin-top: 4px; }
footer { display: flex; flex-direction: column; align-items: stretch; gap: 12px; margin-top: 24px; padding-top: 8px; color: var(--muted); font-size: 11px; }
footer > span { text-align: center; order: 2; }
footer label { display: flex; gap: 12px; align-items: center; color: var(--ink); font-size: 14px; }
select { flex: 1; font-size: 14px; color: var(--ink); background: var(--panel); border: 0; padding: 12px 14px; border-radius: 18px; min-height: 48px; }
dialog { background: var(--paper); color: var(--ink); border: 0; border-radius: 24px; padding: 24px; width: min(460px, calc(100% - 32px)); max-height: 85dvh; box-shadow: 0 12px 45px #0003; }
dialog::backdrop { background: #0006; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.dialog-head h2 { margin: 0; }
.dialog-head .quiet { padding: 8px 12px; min-height: 40px; font-size: 13px; }
.rules-copy p { font-size: 15px; }
.rules-copy h3 { margin: 22px 0 8px; }
.ranking { line-height: 1.9; }
.claim-choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.claim-choices button { background: var(--panel); border: 0; border-radius: 12px; min-height: 64px; font: bold 25px Georgia, "Noto Serif", serif; }
.claim-choices button small { display: block; font: 10px var(--font); margin-top: 3px; }
.claim-choices button:last-child { background: var(--accent); color: var(--on-accent); }
[hidden] { display: none !important; }
@media (max-width: 359px) {
  .app { padding-left: 16px; padding-right: 16px; }
  .players-panel { padding-left: 8px; padding-right: 8px; }
  .players { gap: 8px 5px; }
  .player-name { font-size: 10px; }
  .player-number { font-size: 24px; height: 49px; }
  .device-panel { padding: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *:before, *:after { transition: none !important; scroll-behavior: auto !important; }
}
