:root {
  --bg: #1a1814;
  --panel-border: #3d3830;
  --text: #f0ebe3;
  --muted: #9a9288;
  --accent: #e8c547;
  --danger: #d64545;
  --world-bg: #6b9b7a;
  --room-bg: #2c2824;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  display: grid;
  grid-template-rows: auto 1fr 1fr 1fr;
  height: 100dvh;
  max-height: 100dvh;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  padding-top: max(8px, env(safe-area-inset-top));
  font-size: 13px;
  border-bottom: 1px solid var(--panel-border);
  background: #12100e;
}

.hud-top #stage-name {
  letter-spacing: 0.08em;
}

.hud-top #progress-label {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.panel {
  position: relative;
  min-height: 0;
  border-bottom: 1px solid var(--panel-border);
  overflow: hidden;
}

.panel canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.panel-world {
  background: #0f0e0c;
}

#overlay-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  font-size: clamp(18px, 5vw, 24px);
  letter-spacing: 0.15em;
  pointer-events: none;
}

#overlay-msg.danger {
  color: var(--danger);
  animation: flash 0.35s ease;
}

#overlay-msg.clear {
  color: var(--accent);
}

@keyframes flash {
  from { background: rgba(214, 69, 69, 0.4); }
  to { background: rgba(0, 0, 0, 0.55); }
}

.panel-controls {
  border-bottom: none;
  padding: 8px 12px  max(12px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hint {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.controls-row {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 0;
}

.joystick {
  position: relative;
  width: min(42vw, 140px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid var(--panel-border);
  flex-shrink: 0;
}

.joystick-knob {
  position: absolute;
  width: 38%;
  height: 38%;
  left: 31%;
  top: 31%;
  border-radius: 50%;
  background: rgba(232, 197, 71, 0.85);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.btn-small {
  font-size: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: #252220;
  color: var(--text);
}

.btn-small:active {
  background: #353028;
}
