:root {
  color-scheme: dark;
  color: #fff5f0;
  background: #211827;
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  --accent: #ff4e64;
  --muted: #dfcbd4;
  --panel: #201b2be8;
  --border: #ffffff2b;
  --mono: "Cascadia Mono", Consolas, monospace;
  --edge: clamp(12px, 3vw, 40px);
  --dock: 72px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
[hidden] { display: none !important; }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible { outline: 2px solid #ffe6ad; outline-offset: 3px; }

.game { position: relative; width: 100%; height: 100%; height: 100dvh; overflow: hidden; isolation: isolate; }
.scene, canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
canvas { display: block; }

.masthead {
  position: absolute;
  inset: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 15px var(--edge) 19px;
  background: linear-gradient(#1a1529e8, #201a2d82 74%, #201a2d00);
}

h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: clamp(1.2rem, 3.4vw, 2.3rem);
  font-weight: 900;
  letter-spacing: -.07em;
  line-height: 1;
  white-space: nowrap;
}
.wordmark {
  display: grid;
  place-items: center;
  min-width: 1.68em;
  height: 1.4em;
  padding-right: .08em;
  background: #e93651;
  color: #fff5f0;
  border-radius: 6px 6px 11px 6px;
  font: italic 950 .79em/1 system-ui, sans-serif;
  letter-spacing: -.14em;
}

.intro {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: clamp(24px, 5vh, 44px);
  padding: 26px var(--edge) clamp(46px, 12vh, 102px);
  background: radial-gradient(ellipse at 50% 45%, #21142535, #100c18a8 85%), linear-gradient(#1511224f, #2114285c 50%, #14101be0);
  -webkit-backdrop-filter: blur(8px) saturate(.75);
  backdrop-filter: blur(8px) saturate(.75);
}
.intro:not([hidden]) ~ .masthead { z-index: 2; justify-content: flex-end; background: none; }
.intro:not([hidden]) ~ .masthead h1,
.intro:not([hidden]) ~ .masthead #reset,
.intro:not([hidden]) ~ .dashboard,
.intro:not([hidden]) ~ .controls { display: none; }
.intro-logo {
  gap: .105em;
  color: #fff5ec;
  font: 900 clamp(2.75rem, min(15vw, 24vh), 8.5rem)/.93 Impact, Haettenschweiler, "Arial Narrow", sans-serif;
  letter-spacing: -.025em;
  text-transform: uppercase;
  text-shadow: 0 .045em #833d58, 0 .11em .25em #100c22c9;
  transform: skewX(-9deg);
  user-select: none;
}
.intro-logo-mark {
  display: grid;
  place-items: center;
  min-width: 1.56em;
  height: 1.01em;
  padding: 0 .10em .025em 0;
  background: linear-gradient(145deg, #fd5770, #df2448 72%, #a92042);
  clip-path: polygon(9% 0, 100% 0, 96% 43%, 86% 49%, 95% 49%, 89% 100%, 0 100%, 4% 58%, 14% 51%, 5% 51%);
  letter-spacing: -.045em;
  text-shadow: 0 .045em #a91c39;
}
#start {
  display: flex;
  align-items: center;
  gap: .65em;
  min-height: 57px;
  padding: 8px clamp(15px, 4vw, 22px);
  border: 1px solid #ff91a3;
  border-radius: 8px;
  background: linear-gradient(#e83b5b, #bd2142);
  color: #fff7f2;
  font-size: clamp(1rem, 3vw, 1.25rem);
  font-weight: 850;
  box-shadow: 0 4px 0 #7e203d, 0 10px 28px #100c18a8;
}
#start:hover { background: linear-gradient(#ef4c68, #d1294b); }
#start kbd { min-width: 38px; height: 36px; font-size: 1.12em; }

.settings { display: flex; gap: 6px; }
.settings button {
  min-height: 39px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #211a2ad9;
  font-size: .875rem;
  white-space: nowrap;
}
.settings button:hover, .settings button[aria-pressed="true"] { border-color: #f48d9b; }

.dashboard {
  position: absolute;
  inset: clamp(66px, 10vh, 98px) var(--edge) auto;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}
.panel {
  width: clamp(158px, 19vw, 226px);
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 3px 0 #2319284f;
}
.fighter-row, .stat-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.fighter-row { margin-bottom: 9px; }
.fighter { display: flex; align-items: center; gap: 6px; color: #fff7f3; font-size: 1rem; font-weight: 850; letter-spacing: -.035em; white-space: nowrap; }
.fighter::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--fighter, var(--accent)); }
.hearts { display: inline-flex; gap: 3px; color: #765065; font-size: 1rem; line-height: 1; }
.hearts span::before { content: "♥"; }
.hearts .filled { color: #ff6a7e; }
.stat-row, .scores span { color: var(--muted); font-size: .875rem; font-weight: 700; }
.stat-row + progress { margin: 3px 0 0; }
progress + .stat-row { margin-top: 8px; }
#charge-value, #combo { color: #ffce91; font-family: var(--mono); }
#combo { color: #ffaab6; white-space: nowrap; }

progress { display: block; appearance: none; width: 100%; height: 6px; overflow: hidden; border: 0; border-radius: 3px; background: #514158; }
progress::-webkit-progress-bar { background: #514158; }
progress::-webkit-progress-value { background: #ffc679; }
progress::-moz-progress-bar { background: #ffc679; }
#guard-meter::-webkit-progress-value { background: #77c7d9; }
#guard-meter::-moz-progress-bar { background: #77c7d9; }

.floors strong { color: #ff9aa6; font: 800 1.4rem/1 var(--mono); white-space: nowrap; }
.floors span { white-space: nowrap; }
.floors small { color: var(--muted); font-size: .8rem; }
.floor-meter { display: grid; grid-template-columns: repeat(var(--floor-count, 10), minmax(0, 1fr)); gap: 2px; margin-top: 8px; }
.floor-meter span { height: 5px; border-radius: 2px; background: #514158; }
.floor-meter .filled { background: #fa6278; }
.scores { display: flex; justify-content: space-between; gap: 6px; margin-top: 10px; }
.scores div { display: grid; gap: 2px; }
.scores strong { font: 800 1rem/1.2 var(--mono); overflow-wrap: anywhere; }

.play-status {
  position: absolute;
  inset: auto 0 calc(var(--dock) + env(safe-area-inset-bottom)) 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.result-card button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 15px;
  border: 1px solid #ff8794;
  border-radius: 8px;
  background: #df304f;
  color: #fff5f0;
  font-weight: 850;
  box-shadow: 0 3px 0 #842643;
  pointer-events: auto;
}
.result-card button:hover { background: #f04862; }
#threat { padding: 4px 10px; color: #fff5f0; border-radius: 5px; background: #211a2ad9; font-size: .875rem; font-weight: 800; }
#threat[data-state="ready"] { display: none; }
#threat[data-state="warning"] { color: #ffdd9d; }
#threat[data-state="impact"] { color: #241724; background: #fcce8d; }

.controls {
  position: absolute;
  inset: auto var(--edge) calc(13px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  width: min(620px, 100% - 2 * var(--edge));
  margin-inline: auto;
}
.controls button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #211a2aee;
  font-size: .875rem;
  font-weight: 750;
}
.controls button:hover, .controls button.is-active { border-color: #ff94aa; background: #61344c; }
.controls button.is-charged { border-color: #ffd49c; color: #ffda97; background: #533821; }
kbd {
  display: inline-grid;
  min-width: 22px;
  height: 23px;
  place-items: center;
  border: 1px solid #ffffff40;
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #1a1421b3;
  color: #fff0f4;
  font: 700 .875rem/1 var(--mono);
}

.result {
  position: absolute;
  inset: min(16px, 4vh) 0 auto;
  width: min(420px, 100% - 24px);
  max-height: calc(100% - clamp(154px, 26vh, 250px));
  margin: 0 auto;
  overflow: auto;
  padding: 0;
  border: 1px solid #f48295;
  border-radius: 12px;
  background: #2d2032;
  color: inherit;
}
.result::backdrop { background: linear-gradient(#1b1421c9, #1b14215c 65%, transparent 87%); }
.result-card { padding: 16px 20px 20px; text-align: center; }
.result h2 { margin: 0; font-size: clamp(1.6rem, 5vw, 2.6rem); letter-spacing: -.05em; }
#result-detail { margin: 5px 0 14px; color: var(--muted); }
#rank-form, .ranking { text-align: left; }
#rank-form label, .ranking h3 { margin: 0 0 6px; font-size: .9rem; font-weight: 850; }
#rank-form label { display: block; }
.rank-form-row { display: flex; gap: 8px; }
#rank-nickname {
  flex: 1;
  min-width: 0;
  padding: 0 10px;
  border: 1px solid #a67e91;
  border-radius: 7px;
  background: #231929;
  color: inherit;
  font: inherit;
}
#rank-nickname:focus-visible { outline: 2px solid #ffe6ad; outline-offset: 2px; }
#rank-submit { white-space: nowrap; }
#rank-submit:disabled { opacity: .65; cursor: default; }
.ranking { margin: 14px 0 16px; }
.rank-message { margin: 7px 0 0; color: var(--muted); font-size: .85rem; }
.rank-message:empty { display: none; }
.rank-list {
  display: grid;
  max-height: min(31vh, 270px);
  margin: 0;
  overflow: auto;
  padding: 0 0 0 2.25rem;
  border-radius: 7px;
  background: #231929;
}
.rank-list:empty { display: none; }
.rank-list li { padding: 5px 9px 5px 2px; }
.rank-list li::marker { color: #f4a6b5; font: 700 .85rem var(--mono); }
.rank-list li + li { border-top: 1px solid #ffffff15; }
.rank-list li[data-own] { background: #75435b; }
.rank-row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.rank-row span { min-width: 0; overflow-wrap: anywhere; }
.rank-row strong { color: #ffce91; font: 800 .95rem var(--mono); }

@media (max-width: 600px) {
  :root { --dock: 106px; }
  .controls { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; inset-block-end: calc(8px + env(safe-area-inset-bottom)); }
  .controls button { min-height: 42px; }
  .settings button { padding-inline: 7px; }
  .panel { width: min(48%, 175px); padding: 9px; }
}

@media (max-width: 350px) {
  .fighter { gap: 4px; font-size: .875rem; }
  .hearts { gap: 1px; font-size: .875rem; }
  .floors strong { font-size: 1.14rem; }
}

@media (max-height: 440px) and (min-width: 601px) {
  .masthead { padding-block: 5px; }
  .dashboard { inset-block-start: 48px; }
  .panel { width: 153px; padding: 7px 8px; }
}
