:root {
  color-scheme: dark;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  background: #100d21;
  color: #f5ecff;
  --dim: #b5a7cc;
  --lime: #dbff86;
  --mint: #78ffd1;
  --pink: #ff80ac;
  --line: #503a70;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100svh; min-height: 100dvh; overflow: hidden; }
body::after {
  content: ""; position: fixed; inset: 0; z-index: 6; pointer-events: none;
  background: repeating-linear-gradient(transparent 0 3px, #0705161a 3px 4px);
}
body.flat::after { display: none; }
canvas { display: block; image-rendering: pixelated; }
#sky { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.top {
  position: relative; z-index: 4; height: 60px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 max(24px, env(safe-area-inset-right)) 0 max(24px, env(safe-area-inset-left));
  border-bottom: 1px solid #63528366; background: #100d21f2;
}
.brand { display: inline-flex; align-items: center; gap: 14px; text-decoration: none; color: #f4e8ff; font-size: .79rem; font-weight: 800; letter-spacing: .19em; }
.brand-mark {
  height: 17px; width: 24px; flex: none; background: var(--mint);
  clip-path: polygon(0 24%, 16% 24%, 16% 0, 83% 0, 83% 24%, 100% 24%, 100% 76%, 83% 76%, 83% 100%, 16% 100%, 16% 76%, 0 76%, 0 24%, 25% 24%, 25% 45%, 41% 45%, 41% 58%, 25% 58%, 25% 76%, 16% 76%, 16% 58%, 3% 58%, 3% 45%, 16% 45%, 16% 24%, 0 24%, 100% 24%, 72% 24%, 72% 41%, 89% 41%, 89% 61%, 72% 61%, 72% 41%, 72% 24%, 100% 24%);
}
button, select {
  color: #efe6ff; background: #211631; border: 1px solid #715692; cursor: pointer;
  min-height: 40px; padding: .6em 1em; font: inherit; font-size: .78rem; font-weight: 750;
  text-transform: uppercase; letter-spacing: .08em;
}
button:hover:not(:disabled) { color: #fff; background: #37284f; border-color: var(--mint); }
button:disabled { opacity: .47; cursor: default; }
button:focus-visible, canvas:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible, select:focus-visible {
  outline: 2px solid var(--mint); outline-offset: 3px;
}
.actions, .game-actions { display: flex; gap: 8px; }
.fullscreen { display: flex; align-items: center; gap: 9px; }
.fullscreen i {
  width: 13px; height: 13px; border: 2px solid currentColor;
  clip-path: polygon(0 0, 100% 0, 100% 30%, 75% 30%, 75% 70%, 100% 70%, 100% 100%, 0 100%, 0 70%, 25% 70%, 25% 30%, 0 30%);
}
main { position: relative; }
.title-screen {
  min-height: calc(100dvh - 60px); width: min(100%, 1390px); margin: 0 auto;
  display: grid; gap: clamp(4px, 2vw, 30px); grid-template-columns: 1.06fr 1fr; align-items: center;
  padding: 32px clamp(30px, 6vw, 105px) 56px;
}
.title-copy { position: relative; z-index: 1; }
h1 { margin: 0; }
#wordmark { width: 100%; max-width: 668px; }
.tagline { margin: .9rem 0 0; color: var(--mint); font-size: clamp(.85rem, 1.5vw, 1.2rem); font-weight: bold; letter-spacing: .24em; }
.intro { max-width: 37ch; color: #ccbedc; font-size: .93rem; line-height: 1.65; margin: 1.45rem 0 1.75rem; }
.title-actions { display: grid; grid-template-columns: 1fr 1fr; width: min(100%, 350px); gap: 10px; }
.title-actions .primary { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 56px; font-size: 1rem; }
.title-actions .sumo-entry { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; min-height: 44px; border-color: #b475a5; color: #ffb5db; }
.sumo-entry span { color: #c6b8e3; font-size: .66rem; }
.primary { background: #dfff89; border-color: #e7ffa8; color: #21152d; box-shadow: 4px 4px 0 #624a83; }
.primary:hover:not(:disabled) { background: #f2ffc9; color: #21152d; }
.cover { display: grid; place-items: center; min-width: 0; }
#title-art { width: min(118%, calc(100dvh - 85px)); height: auto; max-width: 690px; }
.game-screen {
  --game-height: calc(100dvh - 60px);
  position: relative; display: grid; height: var(--game-height);
  grid-template-columns: 155px minmax(0, 1fr) 172px; align-items: center; column-gap: 10px;
  padding: 0 max(20px, env(safe-area-inset-right)) 42px max(20px, env(safe-area-inset-left));
  max-width: 1500px; margin: 0 auto;
}
.field { min-width: 0; display: grid; place-items: center; container-type: inline-size; }
#arena { width: min(100cqw, calc(var(--game-height) - 44px)); height: auto; aspect-ratio: 1; touch-action: none; cursor: crosshair; }
.sumo #arena { width: min(100cqw, calc((var(--game-height) - 44px) * 5 / 3)); aspect-ratio: 5 / 3; }
#arena:focus-visible { outline: 1px dashed #78ffd19c; outline-offset: -3px; }
.scores { align-self: start; display: grid; gap: 25px; padding-top: 52px; }
.scores h2, .hud h2, .hud label {
  font-size: .72rem; font-weight: 750; color: #c6b8e3; margin: 0; letter-spacing: .13em; text-transform: uppercase;
}
.scores output { display: block; color: var(--lime); font-size: clamp(1.45rem, 3vw, 3rem); letter-spacing: -.08em; font-weight: 800; overflow-wrap: anywhere; }
.score-block:nth-child(2) output { color: #f7ebff; font-size: clamp(1.1rem, 2vw, 1.6rem); }
.tier-progress { border-top: 1px solid #8a6ba860; padding-top: 10px; }
.tier-heading { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
#tier-count { color: var(--dim); font-size: .62rem; white-space: nowrap; }
.tier-track { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; list-style: none; margin: 6px 0 0; padding: 0; }
.tier-track li { min-width: 0; border: 1px solid #64498284; background: #171021a8; }
.tier-track canvas { width: 100%; filter: grayscale(1); opacity: .31; }
.tier-track .discovered { background: #352345; border-color: #a183be; }
.tier-track .discovered canvas { filter: none; opacity: 1; }
.combo { position: absolute; left: 22px; bottom: 54px; width: 145px; border-left: 3px solid var(--lime); padding: 7px 9px; background: #241936e0; pointer-events: none; }
.combo strong { color: var(--lime); font-size: .86rem; letter-spacing: .09em; }
.combo progress { display: block; height: 4px; margin-top: 5px; }
.sumo .score-block, .sumo .tier-progress, .sumo .combo { display: none; }
.sumo-players { display: grid; gap: 10px; }
.sumo-player { --side: #69f9e0; border: 1px solid #715692; border-left: 3px solid var(--side); background: #211631d9; padding: 8px; min-width: 0; opacity: .72; }
.sumo-player[data-side="1"] { --side: #ff81bd; }
.sumo-player.active { border-color: var(--side); opacity: 1; }
.sumo-player h2 { color: var(--side); }
.sumo-player h2 { display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.sumo-player h2 span { font-size: .6rem; white-space: nowrap; }
.sumo-player h2 b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sumo-player strong { font-size: 1.15rem; }
.sumo-player .queue { margin: 2px 0 0; }
.sumo-player .queue canvas { width: 24px; height: 24px; }
.hud { display: grid; gap: 18px; padding: 14px 0; }
.ammo { display: grid; gap: 14px; }
.current { display: flex; align-items: center; gap: 6px; min-height: 36px; color: var(--lime); font-size: .83rem; }
.current canvas { width: 36px; height: 36px; flex: none; }
.queue { display: flex; gap: 5px; list-style: none; margin: 6px 0 0; padding: 0; }
.queue li { background: #211733b3; border: 1px solid #644a83; }
.queue canvas { width: 33px; height: 33px; }
.launch-power label { display: flex; justify-content: space-between; }
progress { appearance: none; width: 100%; height: 9px; margin: 6px 0 0; border: 1px solid var(--line); background: #211831; }
progress::-webkit-progress-bar { background: #211831; }
progress::-webkit-progress-value { background: var(--mint); }
progress::-moz-progress-bar { background: var(--mint); }
.game-actions { flex-wrap: wrap; }
.game-actions button { min-height: 34px; padding: .5em .65em; font-size: .68rem; }
.field-caption {
  position: absolute; inset: auto 20px 10px; height: 30px; border-top: 1px solid #63528366;
  display: flex; justify-content: space-between; align-items: end; gap: 12px; color: var(--dim); font-size: .75rem; letter-spacing: .08em; text-transform: uppercase;
}
#status { color: var(--mint); text-align: right; }
#status.warning { color: var(--pink); }
.overlay { z-index: 5; position: absolute; inset: 0; display: grid; place-items: center; background: #0a071ab8; text-align: center; }
.modal-frame, dialog {
  position: relative; background: #20162f; color: inherit; border: 2px solid #9477ba; padding: 26px; box-shadow: 7px 7px 0 #432a63;
}
.modal-frame { min-width: min(330px, 80vw); }
.modal-frame:has(#recap:not([hidden])) { width: min(440px, 90vw); max-height: 95%; overflow: auto; }
.recap-reason { margin: -10px 0 10px; color: #e0c3e8; font-size: .76rem; }
.rating-result { margin: 16px 0; color: var(--mint); font-size: .82rem; }
#online-clock { margin: 0; color: var(--mint); font-size: .75rem; text-transform: uppercase; }
#online-clock.warning { color: var(--pink); font-weight: 800; }
.recap-fruit { display: flex; gap: 8px; align-items: center; justify-content: center; min-height: 0; color: var(--mint); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; }
.recap-fruit canvas { width: 38px; }
.recap-score { margin: 10px 0 15px; padding: 12px 0; border: 1px solid #674e88; background: #160f25; }
.recap-score span { display: block; color: var(--dim); font-size: .72rem; text-transform: uppercase; letter-spacing: .13em; }
.recap-score strong { color: var(--lime); font-size: clamp(1.6rem, 7vw, 3rem); font-variant-numeric: tabular-nums; }
.recap-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0 0 19px; }
.recap-stats div { padding: 8px 2px; border-bottom: 1px solid #674e88; }
.recap-stats dt { color: var(--dim); font-size: .65rem; text-transform: uppercase; }
.recap-stats dd { font-weight: 750; margin: 4px 0 0; }
.modal-frame h2, dialog h2 { color: var(--lime); text-transform: uppercase; letter-spacing: .05em; margin: 0 0 18px; }
dialog { width: min(90%, 470px); max-height: 85dvh; overflow: auto; }
dialog::backdrop { background: #0b071bd9; }
dialog p { color: #e0d5ec; font-size: .87rem; line-height: 1.6; }
dialog label { display: flex; align-items: center; gap: 10px; margin: 12px 0; font-size: .84rem; }
dialog .range { justify-content: space-between; }
dialog button { margin-top: 10px; }
.online-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.online-buttons a { color: var(--mint); font-size: .78rem; margin: 8px 0; }
.online-join label, #online-invite label { display: grid; }
.online-join input, #online-invite input { width: 100%; padding: .68em; color: #f0e4ff; background: #160f25; border: 1px solid #715692; font: inherit; }
.online-join input { text-transform: uppercase; }
.online-join button { margin-top: 0; }
#online-identity { color: var(--mint); }
#online-lobby details { margin: 14px 0; padding: 10px 0 0; border-top: 1px solid var(--line); }
#online-lobby summary { cursor: pointer; color: var(--mint); font-size: .82rem; }
.online-list { list-style: none; padding: 0; margin: 8px 0; }
.online-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .8rem; }
.online-list small { display: block; margin-top: 3px; color: var(--dim); }
.online-list button { flex: none; margin: 0; min-height: 34px; }
.invite-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 4px; }
#online-incoming li > span { min-width: 0; overflow-wrap: anywhere; }
#sumo-replay { width: min(94%, 670px); }
#replay-arena { width: 100%; height: auto; background: #130e23; border: 1px solid var(--line); }
.replay-position input { flex: 1; min-width: 0; }
#sumo-rematch { margin: 8px 0 0; }
input { accent-color: var(--mint); }
#debug {
  position: fixed; z-index: 5; bottom: 46px; left: 10px; max-height: min(640px, calc(100dvh - 114px)); overflow: auto;
  max-width: min(280px, calc(100vw - 20px)); background: #20162ff5; border: 1px solid #9477ba; padding: 8px;
  font-size: .76rem;
}
#debug summary { cursor: pointer; }
.debug-controls { display: grid; gap: 6px; margin-top: 8px; }
.debug-controls label { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.debug-controls input { width: 42%; }
#diagnostics { white-space: pre-wrap; margin: 8px 0 0; }
@media (orientation: portrait) {
  body:not(.playing) { overflow: auto; }
  .top { height: 53px; padding: 0 12px; }
  .top button { font-size: .66rem; min-height: 34px; padding-inline: 7px; }
  .brand { font-size: .65rem; letter-spacing: .08em; gap: 6px; }
  .brand-mark { width: 18px; }
  .title-screen {
    min-height: calc(100dvh - 53px); grid-template-columns: 1fr; grid-template-rows: 1fr auto;
    gap: 0; padding: 14px clamp(18px, 6vw, 42px) max(22px, env(safe-area-inset-bottom));
  }
  .cover { grid-row: 1; }
  #title-art { width: min(100%, 380px, max(135px, calc(100dvh - 380px))); }
  .title-copy { justify-self: center; width: min(100%, 450px); }
  .intro { margin: .85rem 0 1rem; font-size: .83rem; }
  .tagline { margin-top: .55rem; }
  .title-actions { width: 100%; }
  .game-screen {
    --game-height: calc(100dvh - 53px);
    grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto;
    padding: 9px 10px max(38px, env(safe-area-inset-bottom)); gap: 4px;
  }
  .scores { padding: 0 4px; grid-template-columns: 1fr 1fr; gap: 4px 10px; }
  .score-block:nth-child(2) { text-align: right; }
  .tier-progress { grid-column: 1 / -1; padding-top: 5px; }
  .tier-track { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 3px; margin-top: 4px; }
  .tier-track canvas { max-width: 30px; margin: auto; }
  .sumo-players { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; gap: 5px; }
  .sumo-player { padding: 5px; }
  .sumo-player > div { display: flex; align-items: center; justify-content: space-between; gap: 3px; }
  .sumo-player .queue { gap: 2px; }
  .sumo-player .queue canvas { width: 18px; height: 18px; }
  .sumo-player strong { font-size: .85rem; }
  .combo { z-index: 2; bottom: auto; top: 98px; left: 50%; transform: translateX(-50%); width: auto; min-width: 96px; text-align: center; padding: 3px 8px; }
  .field { align-self: stretch; min-height: 0; container-type: size; }
  #arena { width: min(100cqw, 100cqh); }
  .sumo #arena { width: min(100cqw, 60cqh); aspect-ratio: 3 / 5; }
  .hud { display: grid; grid-template-columns: 1fr 1fr; padding: 0; gap: 5px 10px; align-items: end; }
  .ammo { grid-column: 1 / -1; display: flex; align-items: end; justify-content: space-between; gap: 6px; }
  .queue { margin-top: 2px; }
  .queue canvas, .current canvas { width: 28px; height: 28px; }
  .current { min-height: 27px; }
  .hud h2, .hud label { font-size: .63rem; }
  .launch-power { grid-column: 1 / -1; }
  .game-actions { grid-column: 1 / -1; justify-content: space-between; }
  #online-clock { grid-column: 1 / -1; }
  dialog { padding: clamp(12px, 4vw, 26px); }
  .game-actions button { flex: 1 1 auto; }
  .field-caption { inset-inline: 10px; font-size: .62rem; }
}
@media (max-height: 540px) and (orientation: landscape) {
  .top { height: 42px; }
  .top button { min-height: 30px; }
  .title-screen { min-height: calc(100dvh - 42px); padding-block: 10px; }
  .intro { margin: 10px 0; font-size: .8rem; }
  #title-art { width: min(100%, calc(100dvh - 48px)); }
  .game-screen { --game-height: calc(100dvh - 42px); grid-template-columns: 95px minmax(0, 1fr) 142px; }
  .scores { padding-top: 12px; gap: 12px; }
  .tier-track { gap: 2px; }
  .combo { left: 20px; width: 95px; bottom: 35px; }
  .hud, .ammo { gap: 6px; padding-block: 0; }
  .game-actions { gap: 4px; }
  .field-caption { height: 24px; }
}
@media (max-width: 360px) and (orientation: portrait) {
  .fullscreen span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .fullscreen { min-width: 34px; justify-content: center; }
}
