:root {
  --ink: #17191b;
  --paper: #f1e9da;
  --teal: #00d6a5;
  --red: #ff4d5a;
  --gold: #ffc740;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--paper);
  background: #0d1114;
  background-image: linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px), linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 32px 32px;
  font-family: "DM Mono", monospace;
}

.game-shell { width: min(1400px, 100%); min-height: 100vh; margin: 0 auto; padding: 24px clamp(14px, 3vw, 48px) 16px; }
.game-screen { min-height: calc(100vh - 40px); display: grid; grid-template-rows: auto 1fr auto; gap: 16px; }
.lobby { min-height: calc(100vh - 40px); display: grid; align-content: center; gap: 24px; }
.game-screen[hidden], .lobby[hidden] { display: none; }
.lobby__header { display: grid; grid-template-columns: auto 1fr; align-items: end; gap: 28px; }
.eyebrow { margin: 0 0 6px; color: var(--gold); font-size: 11px; font-weight: 500; }
.lobby h1, .lobby h2 { margin: 0; font-family: "Bowlby One SC", sans-serif; letter-spacing: 0; }
.lobby h1 { max-width: 17ch; font-size: clamp(34px, 6vw, 72px); line-height: .94; }
.lobby h2 { font-size: 25px; line-height: 1; }
.lobby__notice { margin: 0; border: 2px solid var(--red); padding: 11px 14px; color: var(--paper); background: rgba(255,77,90,.12); font-size: 12px; }
.rematch-invitation { display: flex; align-items: center; gap: 14px; border: 3px solid var(--gold); padding: 14px 16px; color: var(--ink); background: var(--gold); box-shadow: 7px 7px 0 var(--teal); }
.rematch-invitation[hidden] { display: none; }
.rematch-invitation .eyebrow { margin: 0; color: #7f5410; }
.rematch-invitation strong { font: 20px/.95 "Bowlby One SC", sans-serif; }
.rematch-invitation span { flex: 1; font-size: 12px; }
.rematch-invitation__actions { display: flex; gap: 8px; }
.rematch-invitation .button { border-color: var(--ink); color: var(--ink); }
.rematch-invitation .button:last-child { color: var(--paper); background: var(--ink); }
.lobby__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.lobby-card { min-height: 238px; border: 3px solid var(--paper); padding: 22px; background: rgba(24,37,43,.9); box-shadow: 7px 7px 0 rgba(255,255,255,.12); }
.lobby-card--featured { background: var(--teal); color: var(--ink); box-shadow: 7px 7px 0 var(--gold); }
.lobby-card--featured .eyebrow { color: #255b52; }
.lobby-card--featured p:not(.eyebrow), .lobby-card > p:not(.eyebrow) { max-width: 38ch; line-height: 1.55; font-size: 13px; }
.lobby-card form { display: grid; gap: 10px; margin-top: 24px; }
.lobby-card label { font-size: 10px; color: #b8b7ae; }
.lobby-card input { width: 100%; border: 2px solid var(--paper); padding: 11px 12px; color: var(--paper); background: var(--ink); font: 500 13px "DM Mono", monospace; text-transform: uppercase; }
.lobby-card input[type="password"] { text-transform: none; }
.lobby-card input:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
.lobby-card--rooms { grid-column: 1 / -1; min-height: 0; }
.lobby-card__title-row { display: flex; justify-content: space-between; align-items: start; gap: 16px; }
.button, .icon-button, .leave-room { border: 2px solid var(--paper); padding: 10px 13px; color: var(--paper); background: transparent; font: 500 12px "DM Mono", monospace; cursor: pointer; }
.button:hover, .button:focus-visible, .icon-button:hover, .icon-button:focus-visible, .leave-room:hover, .leave-room:focus-visible { color: var(--ink); background: var(--teal); outline: 2px solid var(--paper); outline-offset: 3px; }
.button--primary { margin-top: 18px; border-color: var(--ink); color: var(--paper); background: var(--ink); }
.button--primary:hover, .button--primary:focus-visible { background: var(--paper); outline-color: var(--ink); }
.button--compact { padding: 7px 10px; font-size: 11px; }
.icon-button { padding: 7px 9px; font-size: 10px; }
.room-list { display: grid; gap: 8px; margin: 18px 0 0; padding: 0; list-style: none; }
.room-list__item { display: flex; justify-content: space-between; align-items: center; gap: 14px; border: 1px solid #586066; padding: 10px 12px; }
.room-list__details { display: grid; gap: 3px; }
.room-list__details strong { font-size: 13px; }
.room-list__details small, .room-list__empty { color: #b8b7ae; font-size: 11px; }
.room-list__lock { color: var(--gold); font-size: 12px; }
.room-list__empty { margin: 4px 0; }
.room-password { border: 3px solid var(--gold); padding: 18px 22px; background: var(--ink); box-shadow: 7px 7px 0 var(--teal); }
.room-password[hidden] { display: none; }
.room-password h2 { margin: 0; font: 24px/1 "Bowlby One SC", sans-serif; }
.room-password form { display: grid; gap: 10px; margin-top: 14px; }
.room-password label, .waiting-room__share label { color: #b8b7ae; font-size: 10px; }
.room-password input, .waiting-room__share input { width: 100%; border: 2px solid var(--paper); padding: 9px 10px; color: var(--paper); background: var(--ink); font: 12px "DM Mono", monospace; }
.room-password__actions { display: flex; gap: 8px; }
.hud { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px; }
.match-meta { display: flex; align-items: center; gap: 8px; }
.leave-room { padding: 7px 9px; font-size: 10px; }
.brand { color: var(--paper); font: 24px/.76 "Bowlby One SC", sans-serif; letter-spacing: 0; transform: skew(-5deg); }
.brand span { color: var(--teal); }
.status { border: 2px solid var(--paper); padding: 7px 12px; color: var(--gold); font-size: 12px; font-weight: 500; }
.controls { justify-self: end; color: #b8b7ae; font-size: 10px; text-align: right; line-height: 1.5; }
.arena-wrap { position: relative; min-height: 0; border: 3px solid var(--paper); background: #18252b; box-shadow: 8px 8px 0 var(--gold); overflow: hidden; }
canvas { display: block; width: 100%; height: 100%; min-height: 530px; object-fit: contain; }
.waiting-room { position: absolute; inset: 0; z-index: 3; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 24px; color: var(--paper); background: rgba(13,17,20,.82); text-align: center; }
.waiting-room[hidden] { display: none; }
.waiting-room h2 { max-width: 15ch; margin: 0; color: var(--teal); font: clamp(34px, 6vw, 68px)/.94 "Bowlby One SC", sans-serif; }
.waiting-room p:not(.eyebrow) { margin: 0; color: #b8b7ae; font-size: 13px; }
.waiting-room__share { width: min(100%, 520px); margin-top: 8px; text-align: left; }
.waiting-room__share[hidden] { display: none; }
.waiting-room__share label { display: block; margin-bottom: 6px; }
.waiting-room__share > div { display: flex; gap: 8px; }
.waiting-room__share input { min-width: 0; flex: 1; }
.notice { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; color: var(--paper); font: 24px "Bowlby One SC", sans-serif; letter-spacing: 0; text-shadow: 3px 3px var(--ink); }
.notice[hidden] { display: none; }
.overlay-layer { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.round-countdown { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 24px; color: var(--paper); background: rgba(13,17,20,.72); text-align: center; }
.round-countdown[hidden] { display: none; }
.round-countdown__eyebrow { margin: 0; color: var(--gold); font-size: 12px; font-weight: 500; }
.round-countdown__value { min-width: 1.05em; color: var(--teal); font: clamp(84px, 16vw, 184px)/.78 "Bowlby One SC", sans-serif; text-shadow: 7px 7px 0 var(--ink); }
.round-countdown__tutorial { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; max-width: 540px; }
.round-countdown__tutorial span { border: 1px solid #586066; padding: 7px 9px; color: #b8b7ae; font-size: 10px; }
.round-countdown__tutorial b { margin-right: 6px; color: var(--paper); font-weight: 500; }
.combat-banner { position: absolute; top: 44%; left: 50%; min-width: min(78vw, 520px); padding: 12px 26px 17px; border: 3px solid var(--paper); background: var(--ink); color: var(--paper); text-align: center; transform: translate(-50%, -50%) scale(.76) rotate(-2deg); opacity: 0; box-shadow: 7px 7px 0 var(--gold); }
.combat-banner.is-visible { animation: combat-banner-in 1s cubic-bezier(.18,.87,.38,1) both; }
.combat-banner[data-tone="knockout"].is-visible { animation: combat-banner-hold 2s cubic-bezier(.18,.87,.38,1) both; }
.combat-banner__eyebrow, .game-modal__eyebrow { display: block; color: var(--gold); font-size: 11px; font-weight: 500; }
.combat-banner__title { display: block; font: clamp(38px, 6vw, 78px)/.9 "Bowlby One SC", sans-serif; letter-spacing: 0; }
.combat-banner[data-tone="fight"] { color: var(--teal); }
.combat-banner[data-tone="knockout"], .combat-banner[data-tone="defeat"] { color: var(--red); box-shadow: 7px 7px 0 var(--red); }
.combat-banner[data-tone="victory"] { color: var(--gold); box-shadow: 7px 7px 0 var(--teal); }
.game-modal { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(13, 17, 20, .68); opacity: 0; transition: opacity 160ms ease-out; pointer-events: auto; }
.game-modal[hidden] { display: none; }
.game-modal.is-visible { opacity: 1; }
.game-modal__panel { width: min(100%, 440px); border: 3px solid var(--paper); padding: 28px; background: var(--ink); text-align: center; box-shadow: 8px 8px 0 var(--gold); transform: translateY(12px); transition: transform 160ms ease-out; }
.game-modal.is-visible .game-modal__panel { transform: translateY(0); }
.game-modal__panel h2 { margin: 8px 0; color: var(--paper); font: 38px/.95 "Bowlby One SC", sans-serif; letter-spacing: 0; }
.game-modal__panel p { margin: 0 auto 22px; max-width: 32ch; color: #b8b7ae; font-size: 13px; line-height: 1.55; }
.game-modal__actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.game-modal__action { min-width: 152px; border: 2px solid var(--paper); padding: 9px 13px; color: var(--ink); background: var(--gold); font: 500 12px "DM Mono", monospace; cursor: pointer; }
.game-modal__action--secondary { color: var(--paper); background: transparent; }
.game-modal__action:hover, .game-modal__action:focus-visible { color: var(--paper); background: var(--teal); outline: 2px solid var(--paper); outline-offset: 3px; }
.game-modal[data-tone="defeat"] .game-modal__panel { box-shadow: 8px 8px 0 var(--red); }
.game-modal[data-tone="victory"] .game-modal__panel { box-shadow: 8px 8px 0 var(--teal); }
@keyframes combat-banner-in { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.55) rotate(-8deg); } 16% { opacity: 1; transform: translate(-50%, -50%) scale(1.07) rotate(1deg); } 74% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-2deg); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(.96) rotate(-2deg); } }
@keyframes combat-banner-hold { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.55) rotate(-8deg); } 8% { opacity: 1; transform: translate(-50%, -50%) scale(1.07) rotate(1deg); } 18%, 100% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-2deg); } }
footer { display: flex; justify-content: space-between; gap: 16px; color: #8b928e; font-size: 10px; }
footer span:first-child { color: var(--teal); }

@media (max-width: 700px) {
  .game-shell { padding-top: 14px; }
  .game-screen { min-height: calc(100vh - 28px); gap: 12px; }
  .lobby { min-height: calc(100vh - 28px); align-content: start; gap: 18px; }
  .lobby__header, .lobby__grid { grid-template-columns: 1fr; gap: 16px; }
  .rematch-invitation { align-items: start; flex-wrap: wrap; }
  .rematch-invitation__actions { width: 100%; }
  .lobby__header { align-items: start; }
  .lobby-card { min-height: 0; padding: 18px; }
  .lobby-card--rooms { grid-column: auto; }
  .waiting-room__share > div { flex-direction: column; }
  .hud { grid-template-columns: 1fr auto; }
  .match-meta { flex-wrap: wrap; justify-content: end; }
  .controls { grid-column: 1 / -1; grid-row: 2; justify-self: start; text-align: left; }
  canvas { min-height: 440px; }
  .notice { font-size: 18px; text-align: center; padding: 16px; }
  .round-countdown__tutorial { max-width: 300px; }
  .combat-banner { padding: 10px 16px 14px; }
  .game-modal__panel { padding: 24px 18px; }
  footer span:last-child { display: none; }
}
