:root {
  --ink: #14283b;
  --muted: #657084;
  --paper: #fff8ea;
  --panel: rgba(255, 255, 255, 0.94);
  --line: rgba(20, 40, 59, 0.14);
  --blue: #20aee9;
  --blue-dark: #087fbd;
  --yellow: #fff0c9;
  --orange: #f58219;
  --green: #168755;
  --coral: #d86b5d;
  --purple: #6955da;
  --red: #d93b4a;
  --shadow: 0 24px 70px rgba(20, 40, 59, 0.18);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  background:
    linear-gradient(90deg, rgba(32, 174, 233, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(32, 174, 233, 0.08) 1px, transparent 1px),
    radial-gradient(circle at 18% 12%, rgba(255, 240, 201, 0.42), transparent 28%),
    radial-gradient(circle at 84% 18%, rgba(245, 130, 25, 0.22), transparent 28%),
    var(--paper);
  background-size: 34px 34px, 34px 34px, auto, auto, auto;
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.app-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px clamp(12px, 3vw, 28px) 20px;
  display: grid;
  grid-template-rows: auto auto minmax(430px, 1fr) auto;
  gap: 12px;
}

.game-header,
.game-footer,
.hud-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-lockup {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 48px;
  height: auto;
  flex: 0 0 auto;
}

.brand-name,
.brand-subtitle {
  display: block;
}

.brand-name {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.brand-subtitle {
  font-size: clamp(1.35rem, 4vw, 2.45rem);
  font-weight: 900;
  line-height: 1;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.icon-btn.is-off {
  background: #eff2f7;
  color: var(--muted);
  box-shadow: none;
}

.tool-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--panel);
  box-shadow: 3px 3px 0 var(--ink);
  font-weight: 900;
  text-decoration: none;
}

.hud-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.hud-item {
  min-height: 68px;
  padding: 10px 8px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.8);
}

.hud-item strong {
  font-size: clamp(1.25rem, 4vw, 2.1rem);
  line-height: 1;
}

.hud-item span {
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 900;
  text-transform: uppercase;
}

.game-stage {
  position: relative;
  min-height: 430px;
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(20, 40, 59, 0.95), rgba(17, 31, 47, 0.96)),
    #14283b;
  box-shadow: var(--shadow);
  isolation: isolate;
}

#arena {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.mission-panel,
.boss-panel,
.health-panel,
.slash-tip {
  position: absolute;
  z-index: 3;
  pointer-events: none;
}

.mission-panel {
  top: 16px;
  left: 16px;
  width: min(480px, calc(100% - 32px));
  padding: 14px 16px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
}

.mission-label,
.kicker {
  margin: 0 0 6px;
  color: var(--blue-dark);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.mission-panel h1 {
  margin: 0;
  font-size: clamp(1.25rem, 4vw, 2rem);
  line-height: 1;
}

.mission-panel p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.boss-panel {
  top: 16px;
  right: 16px;
  width: min(330px, calc(100% - 32px));
  display: none;
  padding: 12px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
}

.boss-panel.show {
  display: block;
}

.boss-copy {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 900;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 99px;
  background: #ffffff;
}

.bar-fill {
  width: 100%;
  height: 100%;
  border-radius: 99px;
  background: var(--red);
  transition: width 180ms ease;
}

.health-panel {
  left: 16px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-weight: 900;
}

.heart-row {
  display: flex;
  gap: 5px;
}

.heart {
  width: 18px;
  height: 18px;
  clip-path: polygon(50% 92%, 8% 49%, 8% 22%, 28% 8%, 50% 21%, 72% 8%, 92% 22%, 92% 49%);
  background: var(--coral);
}

.heart.empty {
  background: #c7ceda;
}

.slash-tip {
  right: 16px;
  bottom: 16px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(255, 240, 201, 0.96);
  color: var(--ink);
  font-weight: 900;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(20, 40, 59, 0.72);
}

.overlay.show {
  display: grid;
}

.overlay-panel {
  width: min(620px, 100%);
  max-height: min(92vh, 650px);
  overflow: auto;
  padding: clamp(20px, 5vw, 34px);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 8px 8px 0 var(--ink);
  text-align: center;
}

.overlay-panel h2 {
  margin: 0;
  font-size: clamp(2.35rem, 9vw, 5rem);
  line-height: 0.94;
}

.overlay-panel p {
  color: var(--muted);
  font-size: clamp(1rem, 2.5vw, 1.1rem);
  font-weight: 700;
}

.mini-rules,
.result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 20px 0;
}

.mini-rules span,
.result-stats div,
.leaderboard li {
  min-height: 54px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #f7faff;
  color: var(--ink);
  font-weight: 900;
}

.result-stats strong {
  font-size: 1.6rem;
}

.result-stats span {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.primary-btn,
.secondary-btn {
  min-height: 54px;
  padding: 12px 18px;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  color: #ffffff;
  background: var(--orange);
  box-shadow: 4px 4px 0 var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.primary-btn.small {
  min-width: 94px;
  min-height: 48px;
  padding: 9px 14px;
}

.secondary-btn {
  margin-top: 12px;
  color: var(--ink);
  background: var(--yellow);
}

.score-form {
  margin: 18px 0;
  text-align: left;
}

.score-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
}

.score-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.score-input-row input {
  min-width: 0;
  min-height: 48px;
  padding: 10px 12px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  color: var(--ink);
  background: #ffffff;
  font-weight: 900;
}

.leaderboard h3 {
  margin: 8px 0 10px;
}

.leaderboard ol {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  list-style: none;
  counter-reset: rank;
}

.leaderboard li {
  min-height: 44px;
  grid-template-columns: auto 1fr auto;
  justify-items: start;
  gap: 10px;
  padding: 8px 12px;
  counter-increment: rank;
}

.leaderboard li::before {
  content: counter(rank) ".";
  color: var(--blue-dark);
}

.game-footer {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.studio-credit a {
  color: var(--blue-dark);
  font-weight: 900;
  text-decoration: none;
}

.studio-credit a:hover {
  color: var(--ink);
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-rows: auto auto minmax(560px, 1fr) auto;
  }

  .game-header,
  .game-footer {
    align-items: flex-start;
  }

  .hud-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hud-item {
    min-height: 58px;
  }

  .mission-panel,
  .boss-panel {
    left: 10px;
    right: 10px;
    width: auto;
  }

  .boss-panel {
    top: 128px;
  }

  .health-panel {
    left: 10px;
    bottom: 10px;
  }

  .slash-tip {
    right: 10px;
    bottom: 62px;
    max-width: 170px;
    font-size: 0.8rem;
  }

  .mini-rules,
  .result-stats {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 460px) {
  .brand-mark {
    width: 42px;
    height: auto;
  }

  .header-actions {
    margin-left: auto;
  }

  .mission-panel h1 {
    font-size: 1.12rem;
  }

  .mission-panel p:last-child {
    font-size: 0.86rem;
  }
}
