:root {
  --bg: #05060f;
  --panel: rgba(12, 18, 38, 0.82);
  --line: rgba(124, 231, 255, 0.18);
  --ink: #e8f0ff;
  --dim: #8ea3cc;
  --hot: #ff5a2b;
  --cool: #7ce7ff;
}

* {
  box-sizing: border-box;
}

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

body {
  background: radial-gradient(120% 90% at 50% 0%, #101a3a 0%, var(--bg) 60%);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

.wrap {
  display: flex;
  gap: 18px;
  height: 100%;
  padding: 18px;
  align-items: stretch;
  justify-content: center;
}

.stage {
  position: relative;
  flex: 0 1 auto;
  aspect-ratio: 760 / 1040;
  height: 100%;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.danger {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s linear;
  box-shadow: inset 0 -120px 120px -60px rgba(255, 90, 43, 0.85),
    inset 0 0 90px rgba(255, 90, 43, 0.35);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(4, 6, 16, 0.78);
  backdrop-filter: blur(3px);
  padding: 24px;
  cursor: pointer;
}

.overlay.hidden {
  display: none;
}

.panel {
  max-width: 460px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px 26px;
  text-align: center;
}

.panel h1 {
  margin: 0 0 12px;
  font-size: 42px;
  letter-spacing: 4px;
  background: linear-gradient(90deg, var(--cool), var(--hot));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.panel p {
  margin: 10px 0;
  line-height: 1.5;
  color: var(--ink);
  font-size: 15px;
}

.panel ul {
  text-align: left;
  margin: 12px auto;
  padding-left: 20px;
  color: var(--dim);
  font-size: 14px;
  line-height: 1.7;
}

.panel .hint {
  color: var(--dim);
  font-size: 13px;
}

.stat-line span {
  font-size: 34px;
  font-weight: 700;
  color: var(--cool);
}

.side {
  width: 250px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.side header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.side h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 3px;
  color: var(--cool);
}

.side h2 span {
  color: var(--hot);
}

button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--dim);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}

button:hover {
  color: var(--ink);
  border-color: var(--cool);
}

.row {
  display: flex;
  gap: 12px;
}

.stat {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.stat .label {
  display: block;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--dim);
}

.stat .value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.big-stat {
  flex: 0 0 auto;
}

.big-stat .value {
  font-size: 38px;
  color: var(--cool);
}

.legend,
.help {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-size: 12px;
  color: var(--dim);
}

.legend p {
  margin: 6px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.help p {
  margin: 6px 0;
  line-height: 1.8;
}

.help kbd {
  margin-right: 2px;
}

.chip {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.chip.plain {
  background: #5fd0ff;
}
.chip.boost {
  background: #ffd75e;
}
.chip.fragile {
  background: #ff6b8b;
}
.chip.mover {
  background: #b487ff;
}
.chip.shard {
  background: #8dffc4;
}

kbd {
  background: rgba(124, 231, 255, 0.12);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: var(--ink);
}

.help .tip {
  color: #8dffc4;
  display: block;
  line-height: 1.5;
}

@media (max-width: 900px) {
  .wrap {
    flex-direction: column;
    padding: 10px;
    gap: 10px;
  }

  .stage {
    height: auto;
    flex: 1 1 auto;
    width: 100%;
    aspect-ratio: auto;
  }

  .side {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .side header {
    width: 100%;
  }

  .big-stat,
  .row {
    flex: 1 1 140px;
  }

  .legend,
  .help {
    display: none;
  }
}
