body.ark-page {
  overflow: hidden;
  height: 100dvh;
  overscroll-behavior: none;
  touch-action: manipulation;
}

.ark-app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.ark-stage {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(140px, 200px) minmax(220px, auto) minmax(150px, 220px);
  gap: 16px;
  align-items: center;
  justify-content: center;
  padding: 12px 18px 8px;
  min-height: 0;
}

.side {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 100%;
}

.panel {
  background: rgba(15, 22, 38, 0.85);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}

.panel-label {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.stat-row + .stat-row { margin-top: 6px; }
.stat-row strong {
  font-family: var(--mono);
  color: var(--paper);
  font-size: 18px;
  font-weight: 700;
}

#fx-list {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  min-height: 1.4em;
}

.well-frame {
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
  min-height: 0;
  height: 100%;
}
.well-wrap {
  --chrome: 150px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(100%, calc(min(calc(100dvh - var(--chrome)), 760px) * 0.758));
  aspect-ratio: 546 / 720;
  height: auto;
  background: #05080f;
  border-radius: 8px;
  box-shadow:
    0 0 0 3px #1a2438,
    0 0 0 8px #0e1524,
    0 18px 50px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
#well {
  display: block;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 16, 0.74);
  text-align: center;
  padding: 12px;
  overflow: auto;
}
.overlay.is-on { display: flex; }
.overlay-card h2 {
  margin: 0 0 8px;
  font-size: clamp(26px, 5vw, 44px);
  letter-spacing: 0.06em;
}
.overlay-card p { margin: 0 0 14px; color: var(--muted); }

#toast {
  position: absolute;
  left: 50%;
  top: 14%;
  transform: translateX(-50%);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-shadow: 0 2px 12px #000;
  pointer-events: none;
  font-size: clamp(14px, 2.6vw, 20px);
  color: var(--gold-2);
  white-space: nowrap;
}
#toast.is-bad { color: #fb7185; }

.icon-row { display: flex; gap: 8px; }
.icon-btn {
  flex: 1;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #121a2c;
  color: var(--paper);
  cursor: pointer;
  font-family: inherit;
  font-weight: 650;
}
.icon-btn.is-off { opacity: 0.5; }
.icon-btn.is-hot { background: #5a2030; border-color: #e4453a; }

.help-list, .pu-legend {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
  color: var(--muted);
}
.help-list li, .pu-legend li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(243, 234, 212, 0.06);
  align-items: center;
}
.help-list kbd {
  font-family: var(--mono);
  color: var(--paper);
  background: #0b1020;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 5px;
  font-size: 11px;
}
.pu-legend {
  max-height: 220px;
  overflow: auto;
}
.pu-legend li { justify-content: flex-start; }
.pu-legend li.is-bad { opacity: 0.85; }
.pu-dot {
  display: inline-flex;
  width: 18px;
  height: 14px;
  border-radius: 7px;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 800;
  color: #111;
  margin-right: 8px;
  flex: 0 0 18px;
}
.how p { margin: 0; font-size: 13px; color: var(--muted); }

.touch-pad {
  display: none;
  padding: 8px 12px 16px;
  gap: 8px;
  grid-template-columns: 1fr 1.4fr 1fr;
}
.pad-btn {
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #151c2e;
  color: var(--paper);
  font-family: inherit;
  font-weight: 700;
  font-size: 16px;
  touch-action: manipulation;
  user-select: none;
}
.pad-fire { background: var(--gold); color: #1a1408; }

.over-score {
  font-family: var(--mono);
  font-size: 28px;
  color: var(--gold);
  margin: 0 0 4px !important;
}
.best-flag {
  display: inline-block;
  background: var(--gold);
  color: #1a1408;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  margin-bottom: 10px;
}

@media (pointer: coarse), (max-width: 900px) {
  .touch-pad { display: grid; }
  .help-panel, .how, .legend-panel { display: none; }
  .ark-stage { padding-bottom: 4px; }
  .well-wrap { --chrome: 230px; }
}

@media (max-width: 720px) {
  .ark-stage {
    grid-template-columns: 72px minmax(0, 1fr) 72px;
    gap: 8px;
    padding: 8px;
  }
  .panel { padding: 8px; }
  .stat-row strong { font-size: 13px; }
  .well-wrap {
    --chrome: 220px;
    box-shadow: 0 0 0 2px #1a2438, 0 0 0 5px #0e1524;
  }
}
