:root {
  color-scheme: light;
  font-family: Nunito, "Trebuchet MS", system-ui, sans-serif;
  color: #252742;
  background: #f8f5e9;
  --ink: #252742;
  --muted: #66677c;
  --line: #e8e1d3;
  --cream: #fffcf6;
  --pink: #f65d88;
  --pink-deep: #a92c52;
  --navy: #283151;
  --green: #dce9cb;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button, input { font: inherit; }
button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 46px;
  border: 1px solid transparent; border-radius: 13px; padding: 0 14px;
  font-weight: 850; color: var(--ink); background: var(--cream); cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible, input:focus-visible { outline: 3px solid #4b64a1; outline-offset: 2px; }
button:active { translate: 0 1px; }
button:disabled { cursor: default; opacity: .55; translate: 0; }
.app { max-width: 1360px; margin: auto; padding: 0 clamp(14px, 3vw, 40px) max(18px, env(safe-area-inset-bottom)); }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 76px; padding: max(8px, env(safe-area-inset-top)) 0 8px;
}
h1 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: clamp(22px, 4vw, 33px); letter-spacing: -.055em; }
h2 { margin: 0 0 16px; font-size: clamp(23px, 4vw, 29px); line-height: 1.08; letter-spacing: -.055em; }
.brand-ball {
  width: .82em; height: .82em; border-radius: 50%; flex-shrink: 0;
  background: radial-gradient(circle at 32% 26%, #ffb2c6, #f9608c 49%, #cf365c 80%);
  box-shadow: 0 2px 0 #95294b;
}
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.coins { color: #5b470f; font-weight: 850; white-space: nowrap; background: #f7e8a8; padding: 8px 11px; border-radius: 999px; font-size: 13px; }
.quiet { border-color: var(--line); }
.secondary { background: #e7eedc; border-color: #d8e4cc; }
.primary { color: #24172b; background: #ff83a4; border-color: #f26d94; box-shadow: 0 3px 0 #d45577; }
.wide { width: 100%; }
.shell { display: grid; grid-template-columns: minmax(0, 1fr) minmax(290px, 335px); gap: clamp(12px, 2vw, 24px); align-items: start; }
.arena-column { min-width: 0; }
.arena {
  position: relative; isolation: isolate; width: 100%; aspect-ratio: 1.72;
  overflow: hidden; background: #d5e7b5; border: 1px solid #aec18d; border-radius: 25px;
  box-shadow: 0 6px 0 #a6b98b, 0 16px 34px #454a2720;
}
canvas { display: block; width: 100%; height: 100%; }
.hud {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: stretch; gap: 4px;
  background: #fffcf6; border: 1px solid #fff; border-radius: 15px; padding: 4px;
  box-shadow: 0 4px 0 #282c4625; white-space: nowrap;
}
.score, .clock { display: flex; align-items: center; justify-content: center; gap: 7px; border-radius: 10px; padding: 3px 10px; }
.score strong, .clock strong { font-variant-numeric: tabular-nums; font-size: 20px; line-height: 1.1; }
.score span, .clock span { font-size: 11px; font-weight: 850; }
.score-pink { background: #ffe2e9; color: #8d2b49; }
.score-blue { background: #dcecff; color: #265378; }
.clock { min-width: 98px; flex-direction: column; gap: 2px; padding: 4px 8px; }
.connection-overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  padding: 20px; text-align: center; color: white; background: #24283dbb;
  font-size: clamp(16px, 3vw, 24px); font-weight: 850;
}
.panel { padding: clamp(16px, 3vw, 24px); border-radius: 24px; border: 1px solid var(--line); background: var(--cream); box-shadow: 0 5px 0 #eae3d6; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.modes button { justify-content: flex-start; padding: 9px 10px; text-align: left; font-size: 13px; border-color: var(--line); }
.modes button[aria-pressed="true"] { border-color: #f07199; color: #782b49; background: #ffe8ee; box-shadow: inset 0 0 0 1px #f07199; }
.mode-hint, .muted { color: var(--muted); font-size: 14px; line-height: 1.4; }
.mode-hint { min-height: 38px; margin: 12px 0; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.join-form { margin-top: 19px; padding-top: 15px; border-top: 1px solid var(--line); }
.join-form label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 800; }
.join-form > div { display: flex; gap: 8px; }
.join-form input {
  min-width: 0; flex: 1; min-height: 46px; padding: 9px 11px;
  border: 1px solid #d4cbbb; border-radius: 12px; color: var(--ink); background: #fff;
  text-transform: uppercase; font-size: 16px; letter-spacing: .08em; font-weight: 800;
}
.join-form input::placeholder { text-transform: none; letter-spacing: normal; font-weight: 550; }
.room-code {
  display: block; margin: 16px 0 13px; padding: 12px 8px; text-align: center; letter-spacing: .13em;
  color: var(--navy); background: #e9eddf; border: 1px solid #dbe4cb; border-radius: 14px;
  font: 800 clamp(27px, 7vw, 37px)/1.1 ui-monospace, monospace; user-select: all;
}
.room-status, .notice { margin: 13px 0 0; font-size: 14px; font-weight: 750; line-height: 1.4; }
.room-status { color: #474f65; }
.room-status + button { margin-top: 14px; }
.notice { color: #922c43; }
.notice[data-tone="success"] { color: #376247; }
.result-score { font-weight: 850; font-size: 20px; margin: 0 0 8px; }
.is-playing .shell { grid-template-columns: minmax(0, 1fr); }
.is-playing .arena-column { width: min(100%, calc((100dvh - 108px) * 1.72)); margin: auto; }
.controls {
  display: none; align-items: center; justify-content: space-between; gap: 8px;
  padding: 16px 4px 0; min-height: 112px; touch-action: none; user-select: none;
}
.joystick {
  position: relative; display: grid; place-items: center; width: 96px; height: 96px;
  flex-shrink: 0; border-radius: 50%; background: #e2ead7; border: 2px solid #bcc9af;
  box-shadow: inset 0 0 0 8px #eaf0e2, 0 3px 0 #c7cfbe;
}
.joystick-axis { width: 72px; height: 72px; border: 1px dashed #afc0a1; border-radius: 50%; }
.knob {
  position: absolute; width: 42px; height: 42px; border-radius: 50%;
  background: radial-gradient(circle at 32% 22%, #7483ae, #3b496f 65%, #2c3555);
  border: 2px solid #536189; box-shadow: 0 3px 0 #1f2949;
  transform: translate(var(--x, 0), var(--y, 0));
  pointer-events: none;
}
.action {
  flex-shrink: 0; min-width: 88px; width: 88px; height: 88px; border-radius: 50%; padding: 6px;
  color: #391b2e; background: radial-gradient(circle at 36% 26%, #ffacc1, #f8789c 70%);
  border: 2px solid #e56085; box-shadow: 0 5px 0 #c95174; touch-action: none; user-select: none;
}
.controls p, .keyboard-hint { color: var(--muted); font-size: 13px; font-weight: 800; text-align: center; }
.keyboard-hint { margin: 16px 0 0; }

@media (max-width: 760px) {
  .topbar { min-height: 62px; }
  .shell { grid-template-columns: minmax(0, 1fr); gap: 15px; }
  .arena { border-radius: 18px; }
  .hud { top: 6px; border-radius: 11px; padding: 3px; gap: 3px; }
  .score, .clock { border-radius: 8px; padding: 3px 7px; }
  .score strong, .clock strong { font-size: 16px; }
  .score span, .clock span { font-size: 9px; }
  .clock { min-width: 77px; }
  .panel { border-radius: 18px; }
}
@media (pointer: coarse), (max-width: 760px) {
  .controls { display: flex; }
  .keyboard-hint { display: none; }
  .is-playing .arena-column { width: min(100%, calc((100dvh - 190px) * 1.72)); }
}
@media (pointer: coarse) and (orientation: landscape) and (max-height: 560px) {
  .app { padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right)); }
  .topbar { min-height: 44px; }
  .topbar h1 { font-size: 23px; }
  .topbar .quiet { min-height: 34px; }
  .is-playing .arena-column { width: min(calc(100% - 166px), calc((100dvh - 65px) * 1.72)); }
  .is-playing .controls { position: fixed; inset: auto max(8px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); pointer-events: none; padding: 0; min-height: 0; }
  .is-playing .controls p { visibility: hidden; }
  .is-playing .joystick, .is-playing .action { width: 76px; min-width: 76px; height: 76px; pointer-events: auto; }
  .is-playing .joystick-axis { width: 56px; height: 56px; }
  .is-playing .knob { width: 32px; height: 32px; }
}
