:root {
  color-scheme: dark;
  --ink: #f7f2ff;
  --muted: #c8bdd8;
  --panel: rgba(12, 12, 20, 0.78);
  --line: rgba(255, 255, 255, 0.16);
  --pink: #ff77b7;
  --mint: #66f2c8;
  --gold: #ffd86b;
  --danger: #ff5b63;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 119, 183, 0.16), transparent 24rem),
    linear-gradient(145deg, #101019 0%, #21162f 42%, #221a20 100%);
  color: var(--ink);
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

button {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.game-panel {
  position: relative;
  width: min(100%, 1180px);
  aspect-ratio: 16 / 9;
  background: #05050a;
  border: 1px solid var(--line);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}

.hud {
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  pointer-events: none;
}

.brand,
.meters {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  min-width: 154px;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(10px);
}

.title,
#stageName,
.meter {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
}

.title {
  min-height: 24px;
  padding: 3px 12px 0;
  font-weight: 800;
  color: white;
}

#stageName {
  min-height: 24px;
  padding: 0 12px 4px;
  color: var(--muted);
  font-size: 12px;
}

.meter {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(10px);
  min-width: 92px;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
}

.stack-meter {
  min-height: 48px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 1px;
  padding: 4px 10px;
}

.stack-meter span {
  display: none;
}

.stack-meter b,
.stack-meter small {
  line-height: 1.05;
}

.stack-meter small {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.magic-meter {
  min-width: 124px;
}

.bomb-meter {
  min-width: 88px;
}

.meter span {
  font-size: 12px;
  color: var(--muted);
}

.meter b {
  font-size: 14px;
  color: white;
}

.gauge-meter {
  min-width: 124px;
}

.gauge {
  position: relative;
  width: 74px;
  height: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.34);
}

.gauge i {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: left center;
  transform: scaleX(1);
}

.hp-gauge i {
  background: linear-gradient(90deg, #ff5b63, #ffd86b);
}

.mp-gauge i {
  background: linear-gradient(90deg, #66f2c8, #79f0ff);
}

.boss {
  min-width: 156px;
}

.boss b {
  min-width: 32px;
  color: var(--danger);
  font-size: 12px;
}

.boss-gauge {
  width: 78px;
}

.boss-gauge i {
  background: linear-gradient(90deg, #b07cff, #ff5b63);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  text-align: center;
  background: linear-gradient(180deg, rgba(8, 8, 14, 0.22), rgba(8, 8, 14, 0.72));
}

.overlay.hidden {
  display: none;
}

.cutin-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  padding: 20px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.42) 42%, rgba(0, 0, 0, 0.82));
  pointer-events: none;
}

.cutin-overlay.hidden {
  display: none;
}

.cutin-panel {
  height: 100%;
  width: min(42%, 360px);
  display: grid;
  place-items: center;
  border-left: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.58);
  box-shadow: -18px 0 48px rgba(0, 0, 0, 0.48);
}

.cutin-overlay video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.overlay.pause-mode .stage-select,
.overlay.pause-mode .stage-tools,
.overlay.pause-mode .shop,
.overlay.pause-mode #shopButton,
.overlay.gameover-mode .stage-select,
.overlay.gameover-mode .stage-tools,
.overlay.gameover-mode .shop,
.overlay.gameover-mode #shopButton,
.overlay.shop-mode .stage-select,
.overlay.shop-mode .stage-tools,
.overlay.shop-mode #startButton,
.overlay.shop-mode #shopButton,
.overlay:not(.shop-mode) .shop {
  display: none;
}

.overlay:not(.pause-mode):not(.gameover-mode):not(.shop-mode) .pause-quit,
.overlay.shop-mode .pause-quit,
.pause-quit.hidden {
  display: none;
}

.overlay h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 64px);
  letter-spacing: 0;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.55);
}

.overlay p {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
}

.overlay button {
  width: 160px;
  height: 48px;
  border: 0;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--pink), var(--gold));
  color: #170d17;
  font-weight: 900;
  cursor: pointer;
}

.stage-select {
  display: flex;
  gap: 8px;
  position: relative;
  z-index: 3;
}

.stage-select button {
  width: 104px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.stage-select button.active {
  border-color: var(--gold);
  background: rgba(255, 216, 107, 0.22);
  color: white;
}

.menu-selected {
  outline: 3px solid var(--mint);
  outline-offset: 3px;
  box-shadow: 0 0 18px rgba(102, 242, 200, 0.55);
}

.stage-tools {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stage-tools button,
.editor-link {
  width: 118px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.stage-tools input {
  display: none;
}

.stage-tools small {
  width: 100%;
  color: var(--muted);
  font-size: 12px;
}

.shop {
  width: min(92%, 760px);
  border: 1px solid var(--line);
  background: rgba(10, 10, 18, 0.72);
  backdrop-filter: blur(10px);
  padding: 12px;
}

.shop-head,
.shop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.shop-head {
  margin-bottom: 8px;
  color: var(--gold);
  font-weight: 900;
}

.shop-items {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.shop-row {
  min-height: 58px;
  padding: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  text-align: left;
}

.shop-row strong,
.shop-row small {
  display: block;
}

.shop-row strong {
  font-size: 13px;
  color: white;
}

.shop-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.shop-row button {
  width: 72px;
  height: 34px;
  border-radius: 5px;
  font-size: 12px;
}

.shop-row button:disabled {
  cursor: default;
  opacity: 0.46;
}

.shop-back {
  width: 96px;
  height: 34px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.reset-save {
  width: 138px;
  height: 34px;
  margin-top: 10px;
  border: 1px solid rgba(255, 91, 99, 0.5);
  border-radius: 5px;
  background: rgba(255, 91, 99, 0.14);
  color: #ffd6d9;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.controls-help {
  width: min(92%, 760px);
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.controls-help b {
  color: var(--mint);
  font-size: 12px;
}

.audio-settings {
  width: min(92%, 760px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.audio-settings label {
  min-height: 34px;
  display: grid;
  grid-template-columns: auto minmax(90px, 1fr) 34px;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.06);
  font-weight: 900;
}

.audio-settings input[type="range"] {
  width: 100%;
  accent-color: var(--mint);
}

.audio-settings b {
  color: white;
  text-align: right;
}

.audio-settings .mute-setting {
  grid-template-columns: auto auto;
  justify-content: center;
  color: var(--gold);
}

.audio-settings input[type="checkbox"] {
  accent-color: var(--pink);
}

.credits {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  color: var(--muted);
  font-size: 11px;
}

.credits span {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.06);
}

@media (max-width: 760px) {
  .shell {
    padding: 10px;
  }

  .hud {
    padding: 8px;
    gap: 8px;
    flex-direction: column;
    align-items: stretch;
  }

  .brand,
  .meters {
    flex-wrap: wrap;
  }

  .title,
  #stageName,
  .meter {
    min-height: 28px;
  }

  .title {
    font-size: 13px;
  }

  #stageName,
  .meter {
    font-size: 12px;
  }

  .shop-items {
    grid-template-columns: 1fr;
  }

  .audio-settings {
    grid-template-columns: 1fr;
  }
}
