:root {
  --bg: #121a2b;
  --bg2: #1b2740;
  --panel: #182238;
  --line: #2c3a56;
  --ink: #f1e4c8;
  --ink2: #b8ab92;
  --brass: #c9a24d;
  --brass2: #e7c56e;
  --wood: #5a3a22;
  --red: #e04b3c;
  --green: #3fbf55;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --radius: 12px;
  --header: 48px;
  --panel-w: 320px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", system-ui, sans-serif;
  font-size: 15px; line-height: 1.45; overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 700; }

header#top {
  height: var(--header); display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
  background: linear-gradient(#1b2740, #121a2b); border-bottom: 1px solid var(--line);
}
header#top h1 { font-size: 18px; letter-spacing: .5px; color: var(--brass2); font-family: "Nanum Myeongjo", "Noto Serif KR", Georgia, serif; }
header#top .right { display: flex; gap: 8px; align-items: center; }
.chip {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 13px; color: var(--ink);
}
.chip b { color: var(--brass2); letter-spacing: 1px; }
#btn-lang { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px; font-size: 12px; color: var(--ink2); }
#btn-lang span.on { color: var(--brass2); font-weight: 700; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; color: var(--ink2); }
.icon-btn:hover { color: var(--ink); border-color: var(--brass); }
.icon-btn.on { color: var(--brass2); border-color: var(--brass); }

/* ---- landing ---- */
#landing {
  height: calc(100vh - var(--header)); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px;
  background: radial-gradient(ellipse at 50% 70%, rgba(255, 210, 122, .14), transparent 60%);
}
#landing .tagline { color: var(--ink2); margin: 0 0 10px; }
.field { display: flex; flex-direction: column; gap: 6px; width: 300px; font-size: 13px; color: var(--ink2); }
.field input, .join-row input {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--ink); outline: none;
}
.field input:focus, .join-row input:focus { border-color: var(--brass); }
.primary {
  background: linear-gradient(#e7c56e, #c9a24d); color: #2c1b0e; border: none; border-radius: 10px; padding: 10px 18px; font-weight: 700;
}
.primary:disabled { opacity: .45; cursor: default; }
.ghost { background: none; border: 1px solid var(--line); border-radius: 10px; padding: 9px 16px; color: var(--ink); }
.ghost:hover { border-color: var(--brass); }
.danger { background: none; border: 1px solid #7d2727; color: #ff8a80; border-radius: 10px; padding: 9px 16px; }
.or { color: var(--ink2); font-size: 13px; }
.join-row { display: flex; gap: 8px; width: 300px; }
.join-row input { flex: 1; text-transform: uppercase; letter-spacing: 3px; }
.link { background: none; border: none; color: var(--brass2); text-decoration: underline; }

/* ---- hub ---- */
#hub { height: calc(100vh - var(--header)); display: grid; grid-template-columns: minmax(0, 1fr) var(--panel-w); }
#hub-stage { position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #0b0f18; }
#hub-art { position: relative; aspect-ratio: 16 / 9; width: 100%; max-height: 100%; }
#hub-art > img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hub-spot {
  position: absolute; border: 2px solid transparent; border-radius: 10px; background: none; padding: 0;
  transition: border-color .2s, box-shadow .2s;
}
.hub-spot:hover, .hub-spot:focus-visible { border-color: rgba(255, 210, 122, .8); box-shadow: 0 0 24px rgba(255, 210, 122, .35), inset 0 0 24px rgba(255, 210, 122, .15); outline: none; }
.hub-spot .tip {
  position: absolute; left: 50%; bottom: 100%; transform: translate(-50%, -6px); white-space: nowrap; font-size: 13px;
  background: rgba(18, 26, 43, .92); border: 1px solid var(--brass); color: var(--ink); padding: 4px 10px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .15s;
}
.hub-spot:hover .tip, .hub-spot:focus-visible .tip { opacity: 1; }
.hub-spot.pulse { animation: spotpulse 1.6s ease-in-out infinite; }
@keyframes spotpulse { 0%, 100% { border-color: rgba(255, 210, 122, .15); } 50% { border-color: rgba(255, 210, 122, .8); } }
.shelf-slot {
  position: absolute; display: flex; align-items: center; justify-content: center; pointer-events: none;
}
.shelf-slot img { height: 100%; width: auto; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .6)); }
.shelf-slot span { font-size: 2.6vw; }
#hub-parts { position: absolute; display: flex; align-items: center; justify-content: center; pointer-events: none; color: var(--brass2); font-weight: 700; font-size: 1.1vw; }
#hub-badge { position: absolute; width: 1.4vw; height: 1.4vw; border-radius: 50%; background: var(--red); box-shadow: 0 0 10px var(--red); pointer-events: none; }

aside.side { background: var(--panel); border-left: 1px solid var(--line); padding: 14px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.side h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--ink2); margin-bottom: 6px; }
.seat { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 6px; }
.seat .role { font-size: 12px; color: var(--brass2); width: 42px; font-weight: 700; }
.seat .name { flex: 1; }
.seat .name.empty { color: var(--ink2); font-style: italic; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #566; }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.muted { color: var(--ink2); font-size: 13px; }
.side .row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- play ---- */
#play { height: calc(100vh - var(--header)); display: grid; grid-template-columns: minmax(0, 1fr) var(--panel-w); }
#stage { position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #0b0f18; }
#scene-wrap { position: relative; width: 100%; aspect-ratio: 16 / 9; max-height: 100%; overflow: hidden; border-radius: 4px; }
#scene { position: absolute; inset: 0; }
#scene svg { width: 100%; height: 100%; display: block; }
#hs-layer { position: absolute; inset: 0; width: 100%; height: 100%; }
#hs-layer .hs { fill: rgba(255, 210, 122, 0); stroke: rgba(255, 210, 122, 0); stroke-width: 4; cursor: pointer; transition: stroke .15s, fill .15s; }
#hs-layer .hs:hover { stroke: rgba(255, 210, 122, .85); fill: rgba(255, 210, 122, .08); }
#hs-layer .hs.hs-lock:hover { stroke: rgba(231, 197, 110, 1); }
#hs-layer .hs.hs-sync:hover { stroke: rgba(255, 107, 90, .9); }
#scene-wrap.peek #hs-layer .hs { animation: hspulse 1.2s ease-in-out infinite; }
@keyframes hspulse { 0%, 100% { stroke: rgba(255, 210, 122, .2); } 50% { stroke: rgba(255, 210, 122, .95); fill: rgba(255, 210, 122, .1); } }
#scene-wrap.using #hs-layer .hs { cursor: cell; }
#scene-wrap.using #hs-layer .hs:hover { stroke: rgba(90, 210, 110, .9); fill: rgba(90, 210, 110, .12); }
#hs-tip {
  position: absolute; pointer-events: none; font-size: 13px; background: rgba(18, 26, 43, .92); border: 1px solid var(--brass);
  color: var(--ink); padding: 4px 10px; border-radius: 8px; transform: translate(12px, 14px); white-space: nowrap;
}
#scene-name { position: absolute; left: 14px; top: 12px; font-size: 13px; color: var(--ink2); background: rgba(11, 15, 24, .6); padding: 3px 10px; border-radius: 999px; }
#btn-back-scene { position: absolute; left: 14px; bottom: 12px; background: rgba(18, 26, 43, .9); border: 1px solid var(--brass); color: var(--ink); border-radius: 999px; padding: 6px 14px; }
#bubble {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); max-width: 70%; background: rgba(241, 228, 200, .96); color: #2c1b0e;
  padding: 10px 16px; border-radius: 14px; box-shadow: var(--shadow); opacity: 0; transition: opacity .2s; pointer-events: none; font-size: 15px;
}
#bubble.show { opacity: 1; }
#sync-banner {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); background: rgba(224, 75, 60, .92); color: #fff; padding: 8px 18px;
  border-radius: 999px; font-weight: 700; box-shadow: var(--shadow); animation: bannerpulse 1s ease-in-out infinite;
}
@keyframes bannerpulse { 0%, 100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.04); } }
#scene-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--ink2); background: #0b0f18; }

#panel { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; }
#panel .top { padding: 12px 14px; border-bottom: 1px solid var(--line); }
#panel .top b { display: block; font-size: 15px; }
#timer { font-variant-numeric: tabular-nums; font-size: 26px; font-weight: 700; color: var(--brass2); line-height: 1.1; }
#timer.over { color: #ffb257; }
#timer small { font-size: 13px; color: var(--ink2); font-weight: 400; margin-left: 6px; }
#partner { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink2); margin-top: 6px; }
#panel .scroll { flex: 1; overflow: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 14px; }
#panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--ink2); margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }
#inv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
#inv .muted { grid-column: 1 / -1; }
.item {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; background: var(--bg2); border: 2px solid var(--line); border-radius: 10px;
  font-size: 12px; text-align: center; line-height: 1.2;
}
.item .ico { font-size: 28px; line-height: 1; }
.item .ico img { width: 32px; height: 32px; }
.item.sel { border-color: var(--brass2); box-shadow: 0 0 14px rgba(231, 197, 110, .4); }
.item.flash { animation: itemflash .8s; }
@keyframes itemflash { 0% { background: #e7c56e; } 100% { background: var(--bg2); } }
#inv-hint { font-size: 12px; color: var(--brass2); min-height: 16px; margin-top: 6px; }
#passage {
  border: 2px dashed var(--line); border-radius: 10px; padding: 10px; display: flex; align-items: center; gap: 10px; min-height: 64px; background: rgba(0, 0, 0, .15);
}
#passage.has { border-style: solid; border-color: var(--brass); }
#passage .ico { font-size: 28px; }
#passage .ico img { width: 32px; height: 32px; }
#passage .info { flex: 1; font-size: 13px; }
#passage .info small { display: block; color: var(--ink2); }
#passage button { font-size: 12px; padding: 6px 10px; }
#hint-box { background: rgba(0, 0, 0, .15); border-radius: 10px; padding: 10px; font-size: 13px; }
#hint-list { margin: 0 0 8px; padding-left: 18px; }
#hint-list li { margin-bottom: 4px; }
#hint-list li b { color: var(--brass2); }
#notes { width: 100%; min-height: 90px; resize: vertical; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; color: var(--ink); padding: 8px 10px; outline: none; }
#notes:focus { border-color: var(--brass); }
#log { list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--ink2); max-height: 160px; overflow: auto; }
#log li { padding: 2px 0; border-bottom: 1px dashed rgba(44, 58, 86, .6); }
#log li .t { color: var(--brass); margin-right: 6px; font-variant-numeric: tabular-nums; }
#panel .bottom { padding: 10px 14px; border-top: 1px solid var(--line); display: flex; gap: 6px; }

/* ---- dialogs ---- */
dialog {
  background: var(--panel); color: var(--ink); border: 1px solid var(--brass); border-radius: 16px; padding: 22px 24px; box-shadow: var(--shadow); max-width: min(92vw, 720px);
}
dialog::backdrop { background: rgba(5, 8, 14, .7); }
dialog h2 { font-size: 18px; margin-bottom: 12px; color: var(--brass2); }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: rgba(241, 228, 200, .96); color: #2c1b0e; padding: 10px 18px; border-radius: 999px;
  box-shadow: var(--shadow); opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 50; max-width: 80vw;
}
#toast.show { opacity: 1; }

/* requests dialog: wide cards (poster left, text right) so each card, start button included, fits on a laptop screen */
#episodes-dialog { width: min(94vw, 900px); max-width: min(94vw, 900px); }
#ep-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; max-height: 68vh; overflow: auto; padding: 2px; }
.ep-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; }
.ep-card .poster { width: 132px; flex: none; aspect-ratio: 3 / 4; align-self: flex-start; background: #0b0f18; display: flex; align-items: center; justify-content: center; }
.ep-card .poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ep-card .body { padding: 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.ep-card .body b { font-size: 15px; }
.ep-card .meta { font-size: 12px; color: var(--ink2); }
.ep-card .tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 11px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; color: var(--ink2); }
.ep-card .rec { font-size: 12px; color: var(--brass2); background: none; border: 0; padding: 0; }
.ep-card .rec:empty { display: none; }
.ep-card .primary { margin-top: auto; align-self: flex-start; padding-left: 22px; padding-right: 22px; }
.stars { color: var(--brass2); letter-spacing: 1px; }

/* records dialog */
#rec-list { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow: auto; }
.rec { display: flex; gap: 12px; align-items: center; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.rec img { width: 42px; height: 56px; object-fit: cover; border-radius: 6px; }
.rec .body { flex: 1; font-size: 13px; }
.rec .body b { display: block; font-size: 14px; }

/* lock widgets */
#lock-dialog { min-width: 360px; text-align: center; }
#lock-prompt { color: var(--ink2); font-size: 14px; margin-bottom: 14px; }
.digits { display: flex; justify-content: center; gap: 10px; margin: 8px 0 14px; }
.digit { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.digit input {
  width: 54px; height: 64px; font-size: 32px; text-align: center; background: #0b0f18; border: 2px solid var(--line); border-radius: 10px; color: var(--brass2); outline: none;
  font-variant-numeric: tabular-nums;
}
.digit input:focus { border-color: var(--brass); }
.digit button { background: none; border: none; color: var(--ink2); font-size: 14px; padding: 0 10px; }
.digit button:hover { color: var(--ink); }
.text-lock input { width: 100%; font-size: 22px; text-align: center; background: #0b0f18; border: 2px solid var(--line); border-radius: 10px; color: var(--brass2); padding: 10px; outline: none; letter-spacing: 2px; }
.text-lock input:focus { border-color: var(--brass); }
.slots { display: flex; justify-content: center; gap: 10px; margin: 8px 0 14px; }
.slot { width: 54px; height: 54px; border-radius: 50%; border: 2px dashed var(--line); background: #0b0f18; cursor: pointer; }
.slot.filled { border-style: solid; border-color: var(--brass); }
.palette { display: flex; justify-content: center; gap: 10px; margin-bottom: 8px; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .25); cursor: pointer; }
.swatch:hover { transform: scale(1.08); border-color: #fff; }
.switches { display: flex; justify-content: center; gap: 14px; margin: 8px 0 14px; }
.switch { width: 46px; height: 90px; border-radius: 23px; background: #0b0f18; border: 2px solid var(--line); position: relative; cursor: pointer; }
.switch::after { content: ""; position: absolute; left: 5px; width: 32px; height: 32px; border-radius: 50%; background: var(--ink2); top: 50px; transition: top .15s, background .15s; }
.switch.on { border-color: var(--brass); }
.switch.on::after { top: 6px; background: var(--brass2); }
#lock-dialog.shake { animation: shake .4s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
#lock-msg { min-height: 20px; font-size: 13px; color: #ff8a80; margin-bottom: 6px; }
#lock-dialog.open { border-color: var(--green); }

/* intro / end */
#intro-text, #end-epilogue { font-size: 16px; line-height: 1.6; white-space: pre-line; }
#end-stats { display: flex; gap: 16px; margin: 12px 0; font-size: 15px; }
#end-stats b { color: var(--brass2); }
#end-reward { color: var(--brass2); margin-bottom: 8px; }

@media (max-width: 900px) {
  #hub, #play { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  aside.side, #panel { border-left: none; border-top: 1px solid var(--line); max-height: 45vh; }
}
