:root {
  --bg: #0b0d12;
  --panel: rgba(18, 21, 28, .84);
  --line: rgba(255, 255, 255, .10);
  --ink: #e9edf5;
  --ink-dim: #8b93a5;
  --red: #e0523c;
  --blue: #4a8ee6;
  --red-glow: rgba(224, 82, 60, .38);
  --blue-glow: rgba(74, 142, 230, .38);
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans KR", system-ui, -apple-system, "Apple SD Gothic Neo", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  min-height: 300px;
}

/* ── 상단 ──────────────────────────── */
#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 13, 18, .7);
  z-index: 3;
}

#modes { display: flex; gap: 6px; flex-wrap: wrap; }

.mode {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .03);
  color: var(--ink-dim);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}

.mode:hover:not(:disabled) { color: var(--ink); border-color: rgba(255, 255, 255, .26); }
.mode.is-on { color: #0b0d12; background: var(--ink); border-color: var(--ink); }
.mode:disabled { opacity: .42; cursor: default; }

#score { display: flex; gap: 16px; margin: 0; align-items: baseline; }
#score > div { display: flex; gap: 6px; align-items: baseline; }
#score dt { font-size: 11px; letter-spacing: .12em; color: var(--ink-dim); }
#score dd { margin: 0; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── 무대 ──────────────────────────── */
#stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#arena { position: absolute; inset: 0; }
#arena canvas { display: block; width: 100%; height: 100%; }
#arena::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(125% 95% at 50% 42%, transparent 38%, rgba(6, 7, 10, .78) 100%);
}

#top {
  position: absolute;
  top: 14px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 2;
}

#hint {
  margin: 0;
  font-size: 13px;
  color: var(--ink-dim);
  background: rgba(11, 13, 18, .62);
  border: 1px solid var(--line);
  padding: 6px 15px;
  border-radius: 999px;
  text-align: center;
  backdrop-filter: blur(6px);
}

#retry {
  pointer-events: auto;
  appearance: none;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 16px;
  cursor: pointer;
}

/* ── 결과 ──────────────────────────── */
#banner {
  position: absolute;
  top: 15%;
  left: 0;
  right: 0;
  text-align: center;
  padding: 0 20px;
  z-index: 2;
  animation: pop .32s cubic-bezier(.2, .9, .3, 1.2) both;
}

@keyframes pop {
  from { opacity: 0; transform: scale(.86); }
  to { opacity: 1; transform: scale(1); }
}

#bannerResult {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -.02em;
  text-shadow: 0 4px 26px rgba(0, 0, 0, .7);
}

#bannerResult.is-win { color: #ffd88a; }
#bannerResult.is-lose { color: #a9b2c4; }

#bannerDetail {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--ink-dim);
  text-shadow: 0 2px 12px rgba(0, 0, 0, .8);
}

/* ── 영화 카드 ─────────────────────── */
#cards {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 14px 14px;
  z-index: 2;
  animation: rise .35s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.card {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 3px 12px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(10px);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}

.card.is-red { --side: var(--red); --side-glow: var(--red-glow); }
.card.is-blue { --side: var(--blue); --side-glow: var(--blue-glow); }

.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--side);
}

.card:not(:disabled):hover { border-color: var(--side); box-shadow: 0 10px 30px -12px var(--side-glow); }
.card:not(:disabled):active { transform: translateY(1px); }
.card:disabled { cursor: default; }

.card-head { display: flex; align-items: center; gap: 7px; min-width: 0; }

.chip {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--side);
  box-shadow: 0 0 10px var(--side-glow);
  flex: none;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  grid-column: 1;
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--ink-dim);
}

.card-value {
  grid-column: 2;
  grid-row: 1 / 3;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink-dim);
  transition: color .2s;
}

.card.is-open .card-value { color: var(--side); }

/* ── 시작 흐름 ─────────────────────── */
[hidden] { display: none !important; }

#overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow: auto;
  background: radial-gradient(120% 90% at 50% 32%, rgba(20, 26, 40, .84), rgba(6, 8, 12, .95));
  backdrop-filter: blur(8px);
}

.flow {
  margin: auto;
  width: min(520px, 100%);
  padding: 26px 24px 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(16, 19, 26, .9);
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, .9);
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: .22em;
  color: var(--ink-dim);
}

.step h1 {
  margin: 0 0 12px;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.step h2 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
}

.step .lead {
  margin: 0 0 18px;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--ink-dim);
}

#loadError {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.6;
  color: #ffb4a4;
}

.primary {
  appearance: none;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #0b0d12;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 10px;
  padding: 11px 18px;
  width: 100%;
  cursor: pointer;
  transition: opacity .15s, transform .15s;
}

.primary:disabled { opacity: .4; cursor: default; }
.primary:not(:disabled):active { transform: translateY(1px); }

#modeChoices { display: grid; gap: 8px; margin-bottom: 16px; }

.choice {
  appearance: none;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 13px 15px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .03);
  color: var(--ink);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.choice span { font-size: 11.5px; font-weight: 400; color: var(--ink-dim); }
.choice:hover { border-color: rgba(255, 255, 255, .24); }
.choice.is-on { border-color: var(--ink); background: rgba(255, 255, 255, .1); }
.choice.is-on span { color: var(--ink); }

#retry.ghost { margin-top: 10px; width: 100%; background: rgba(255, 255, 255, .05); }

/* ── 상단 기준 표시 ─────────────────── */
#hudLeft { display: flex; align-items: center; gap: 10px; min-width: 0; }

.hud-mode {
  font-size: 12px;
  letter-spacing: .06em;
  color: var(--ink-dim);
  white-space: nowrap;
}

#changeMode {
  appearance: none;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-dim);
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}

#changeMode:hover:not(:disabled) { color: var(--ink); border-color: rgba(255, 255, 255, .24); }
#changeMode:disabled { opacity: .42; cursor: default; }

#nextRound {
  margin-top: 12px;
  appearance: none;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: rgba(255, 255, 255, .08);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 18px;
  cursor: pointer;
}

#nextRound:hover { background: rgba(255, 255, 255, .14); }

/* ── 좁은 화면 ─────────────────────── */
@media (max-width: 560px) {
  #hud { padding: 8px 10px; }
  #score { gap: 11px; }
  #cards { gap: 8px; padding: 0 10px 10px; }
  .card { padding: 10px 12px; gap: 2px 8px; }
  .card-title { font-size: 13px; }
  .card-value { font-size: 23px; }
  #bannerResult { font-size: 26px; }
  #hint { font-size: 12px; }
  .flow { padding: 20px 16px; }
  .step h1 { font-size: 21px; }
  .hud-mode { display: none; }
}

@media (max-height: 520px) {
  .card-value { font-size: 22px; }
  .card { padding: 8px 12px; }
  #bannerResult { font-size: 24px; }
  #banner { top: 10%; }
}
