:root {
  --bg: #2a1c16;
  --ink: #f8ecd8;
  --muted: #c4a888;
  --card: rgba(40, 28, 22, 0.82);
  --line: rgba(255, 220, 160, 0.16);
  --accent: #e8b060;
  --wine: #c04840;
  --cream: #f8ecd8;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
}

html,
body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: "IBM Plex Sans KR", "Pretendard", system-ui, sans-serif;
  background: #0b0908;
  color: var(--ink);
  display: flex;
  justify-content: center;
}

.stage {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

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

.hud {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  pointer-events: none;
}

.stat {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat.mid {
  align-items: center;
}

.stat.end {
  align-items: flex-end;
}

.stat em {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
}

.stat b {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.1;
}

.meter {
  position: absolute;
  top: max(76px, calc(env(safe-area-inset-top) + 66px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  width: min(210px, 56vw);
  pointer-events: none;
}

.meter.hidden {
  display: none;
}

.meter .bar {
  position: relative;
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line);
}

.meter .safe {
  position: absolute;
  inset: 0 34%;
  border-radius: 99px;
  background: rgba(240, 160, 90, 0.35);
}

.meter .knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
}

.meter p {
  margin: 8px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.toast {
  position: absolute;
  left: 50%;
  top: 36%;
  transform: translate(-50%, -50%);
  z-index: 6;
  margin: 0;
  padding: 8px 14px;
  border-radius: 8px;
  background: rgba(20, 14, 10, 0.9);
  border: 1px solid var(--line);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.toast.on {
  opacity: 1;
}

.pads {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.pads.hidden {
  display: none;
}

.pad {
  height: 56px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(28, 20, 16, 0.88);
  color: var(--cream);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.pad:active,
.pad.held {
  background: var(--accent);
  color: #1a1410;
  border-color: var(--accent);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: max(28px, env(safe-area-inset-top)) 24px max(28px, env(safe-area-inset-bottom));
  background:
    radial-gradient(ellipse at 50% 8%, rgba(255, 200, 100, 0.28), transparent 42%),
    linear-gradient(180deg, rgba(50, 32, 24, 0.96), rgba(24, 16, 12, 0.98));
}

.overlay.hidden {
  display: none;
}

.hero-art {
  width: min(42vw, 168px);
  height: min(42vw, 168px);
  object-fit: cover;
  border-radius: 28px;
  margin-bottom: 10px;
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.45),
    0 0 0 3px rgba(240, 160, 90, 0.28);
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--accent);
  font-weight: 600;
}

h1 {
  margin: 0;
  font-family: "Bagel Fat One", "IBM Plex Sans KR", cursive;
  font-weight: 400;
  font-size: clamp(44px, 12vw, 56px);
  color: var(--cream);
  line-height: 1;
}

.lead {
  margin: 14px 0 18px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--muted);
}

.tips {
  width: min(100%, 320px);
  margin: 0 0 22px;
  padding: 14px 16px;
  list-style: none;
  text-align: left;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.tips li {
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.tips li:last-child {
  margin-bottom: 0;
}

.tips b {
  color: var(--cream);
  font-weight: 600;
}

.rank-form {
  width: min(280px, 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.rank-form label {
  font-size: 13px;
  color: var(--muted);
}

.rank-form input {
  appearance: none;
  border: 2px solid rgba(255, 240, 210, 0.35);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
  text-align: center;
  background: rgba(26, 20, 16, 0.55);
  color: var(--cream);
}

.rank-msg {
  min-height: 1.2em;
  margin: 0;
  font-size: 13px;
  color: #b8e0a8;
}

.btn {
  appearance: none;
  border: none;
  min-width: 168px;
  height: 50px;
  border-radius: 10px;
  background: var(--accent);
  color: #1a1410;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.btn.soft {
  background: rgba(255, 240, 210, 0.18);
  color: var(--cream);
  border: 1px solid rgba(255, 240, 210, 0.28);
}

.btn:active {
  transform: translateY(1px);
  filter: brightness(0.95);
}

.overlay a {
  margin-top: 14px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}

#over-detail {
  margin: 10px 0 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

#over-detail b {
  color: var(--cream);
}
