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

:root {
  --bg0: #05060f;
  --bg1: #0a1330;
  --cyan: #7df9ff;
  --cyan2: #9be7ff;
  --gold: #ffd24a;
  --red: #ff6b6b;
  --green: #5ad6a0;
  --ink: #dfeeff;
  --sub: #8fa8cc;
  --line: rgba(120, 180, 255, 0.16);
}

html, body {
  height: 100%;
  background: #03040a;
  color: var(--ink);
  font-family: "Pretendard", "Apple SD Gothic Neo", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 44px; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  background: linear-gradient(180deg, rgba(5, 8, 20, 0.92), rgba(5, 8, 20, 0));
  font-size: 13px; letter-spacing: .3px; font-weight: 700;
}
.topbar .back { color: var(--cyan2); text-decoration: none; opacity: .92; }
.topbar .back:hover { opacity: 1; }
.topbar .brand { color: var(--ink); opacity: .92; font-size: 13px; }
.topbar .hs { color: var(--cyan); font-size: 12px; }
.topbar .hs b { color: #fff; }

#stage {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
}

canvas#game {
  display: block;
  background: #05060f;
  border-radius: 12px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .7), 0 0 0 1px rgba(120, 200, 255, .14);
  touch-action: none;
}

.hint {
  position: fixed; bottom: 10px; left: 0; right: 0; text-align: center;
  font-size: 12px; color: var(--sub); z-index: 12; pointer-events: none;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .8); transition: opacity .8s;
  padding: 0 18px; font-weight: 600;
}

/* ── 오버레이(타이틀/사건/상점/결과) ── */
#overlay {
  position: absolute; inset: 0; z-index: 40;
  display: none; align-items: center; justify-content: center;
  background: radial-gradient(120% 90% at 50% 20%, rgba(20, 30, 70, .55), rgba(3, 5, 14, .9));
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  padding: 16px;
}
#overlay.show { display: flex; }

.panel {
  width: min(560px, 96vw); max-height: 92vh; overflow-y: auto;
  background: linear-gradient(180deg, #0d1734, #080e22);
  border: 1px solid var(--line); border-radius: 20px;
  padding: 24px 24px 26px; text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6), inset 0 0 60px rgba(80, 160, 255, .05);
}
.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: rgba(120, 200, 255, .25); border-radius: 8px; }

.logo {
  font-size: 38px; font-weight: 900; letter-spacing: -.5px;
  background: linear-gradient(90deg, #7df9ff, #b78bff);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  text-shadow: 0 0 30px rgba(120, 220, 255, .3);
}
.logo.small { font-size: 30px; }
.title .logo { font-size: 46px; }
.subtitle { color: var(--cyan2); font-weight: 700; font-size: 14px; margin-top: 4px; letter-spacing: 2px; }
.win .logo { background: linear-gradient(90deg, #ffd24a, #5aff9a); -webkit-background-clip: text; background-clip: text; }

.lead { color: #b9cce8; font-size: 14px; line-height: 1.65; margin: 16px 6px; }
.lead b { color: #fff; }

.rules {
  list-style: none; text-align: left; margin: 14px auto; max-width: 460px;
  display: flex; flex-direction: column; gap: 8px;
}
.rules li {
  font-size: 12.5px; color: #aebfdc; line-height: 1.5;
  background: rgba(255, 255, 255, .03); border: 1px solid rgba(120, 180, 255, .1);
  border-radius: 10px; padding: 8px 12px;
}
.rules li b { color: var(--cyan); }

button.big {
  margin-top: 14px; border: none; border-radius: 14px; padding: 15px 40px;
  font-size: 18px; font-weight: 900; letter-spacing: .5px; cursor: pointer;
  background: linear-gradient(180deg, #7df9ff, #36b6d6); color: #04202a;
  box-shadow: 0 5px 0 #1a7a92, 0 8px 22px rgba(80, 200, 255, .35);
}
button.big:active { transform: translateY(3px); box-shadow: 0 2px 0 #1a7a92; }
.best { margin-top: 14px; font-size: 12px; color: var(--sub); font-weight: 700; }

.resultGrid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0 6px;
}
.resultGrid > div {
  background: rgba(255, 255, 255, .04); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px;
}
.resultGrid span { display: block; font-size: 11px; color: var(--sub); text-transform: uppercase; letter-spacing: .5px; }
.resultGrid b { font-size: 24px; color: var(--cyan); font-weight: 900; }

/* ── 사건 ── */
.event, .store { text-align: left; }
.evhead {
  font-size: 18px; font-weight: 900; color: var(--cyan2); margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.evtext { font-size: 15px; line-height: 1.7; color: #c7d6ee; margin-bottom: 18px; }
.evtext.result { color: var(--green); font-weight: 700; }
.choices { display: flex; flex-direction: column; gap: 9px; }
button.choice {
  width: 100%; text-align: left; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04); color: var(--ink);
  border-radius: 12px; padding: 13px 16px; font-size: 14px; font-weight: 700; cursor: pointer;
  transition: background .15s, transform .1s;
}
button.choice:hover:not(:disabled) { background: rgba(120, 200, 255, .14); border-color: var(--cyan); }
button.choice:active:not(:disabled) { transform: translateY(2px); }
button.choice:disabled { opacity: .4; cursor: default; }
button.choice em { color: var(--red); font-style: normal; font-size: 12px; }
button.choice.leave { text-align: center; margin-top: 14px; background: rgba(120, 200, 255, .1); color: var(--cyan); }

/* ── 상점 ── */
.scrap { font-size: 13px; color: var(--gold); font-weight: 800; }
.store-sub { font-size: 12px; color: var(--sub); margin-bottom: 14px; font-weight: 600; }
.slist { display: flex; flex-direction: column; gap: 8px; }
.sitem {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, .04); border: 1px solid rgba(120, 180, 255, .1);
  border-radius: 12px; padding: 10px 12px;
}
.sitem.no { opacity: .55; }
.si-main { flex: 1; min-width: 0; }
.si-t { font-size: 14px; font-weight: 800; color: #fff; }
.si-d { font-size: 11.5px; color: var(--sub); margin-top: 3px; line-height: 1.4; }
.si-buy {
  flex: 0 0 auto; min-width: 78px; border: none; border-radius: 10px; padding: 9px 10px;
  font-size: 13px; font-weight: 800; cursor: pointer; line-height: 1.2;
  background: linear-gradient(180deg, #ffd76a, #f0a832); color: #2a1a02;
  box-shadow: 0 3px 0 #b97e16; display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.si-buy span { font-size: 10px; opacity: .85; }
.si-buy:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #b97e16; }
.si-buy:disabled { background: #2a3450; color: #6a7795; box-shadow: none; cursor: default; }

@media (max-width: 680px) {
  .topbar .brand { display: none; }
  .logo, .title .logo { font-size: 34px; }
  .resultGrid b { font-size: 20px; }
}
