:root {
  --ink: #101e27;
  --ink-dark: #0c171f;
  --panel: #172d35;
  --cream: #f4ecdc;
  --gold: #e3ab70;
  --muted: #adbbb6;
  --rule: #43504c;
  --serif: "Nanum Myeongjo", "Noto Serif CJK KR", Batang, "AppleMyungjo", Georgia, serif;
  --sans: "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  --mono: "Courier New", monospace;
  color: var(--cream);
  background: var(--ink);
  font-family: var(--sans);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(ellipse at 11% 59%, #213b43 0%, transparent 52%), var(--ink); }
button, input { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: wait; opacity: .65; }
button, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, canvas:focus-visible { outline: 3px solid #daac56; outline-offset: 3px; }
button { touch-action: manipulation; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.symbols { position: absolute; height: 0; width: 0; pointer-events: none; }
[hidden] { display: none !important; }
.mast { height: 77px; margin: 0 clamp(24px, 5.5vw, 100px); border-bottom: 1px solid #61716666; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand, .mast-tools, .icon-button, .kicker, .plate-name, .ticket-top, .ticket-stub button, .stats, .stats > span, .action-tools > button, .touch-actions { display: flex; align-items: center; }
.brand { gap: 9px; color: var(--cream); font: 700 21px/1 var(--serif); letter-spacing: -.07em; }
.brand-mark { width: 41px; height: 41px; color: var(--gold); stroke-width: 1; }
.mast-tools { gap: 12px; }
.icon-button { background: transparent; border: 1px solid #77867c66; border-radius: 5px; padding: 8px 11px; min-height: 34px; justify-content: center; gap: 7px; color: #d7dfd4; font-size: 12px; }
.icon-button:hover, .action-tools > button:hover { background: #28403e; }
#sound svg { width: 16px; height: 16px; }
.network { color: #efd29a; font-size: 12px; }
#lobby { width: min(1160px, 89%); margin: clamp(42px, 6.7vh, 83px) auto 60px; display: grid; grid-template-columns: minmax(0,1.55fr) minmax(320px,.95fr); gap: clamp(38px, 5.5vw, 88px); align-items: center; }
.kicker, .ticket-top { gap: 11px; color: var(--gold); font-size: 11px; font-weight: 700; letter-spacing: .14em; }
.kicker-line { width: 29px; height: 1px; background: currentColor; }
h1, h2, h3, p, figure, fieldset { margin: 0; }
h1 { font: 600 clamp(53px, 5.6vw, 84px)/1.21 var(--serif); letter-spacing: -.075em; color: #f6ead0; margin: 13px 0 12px; }
h1 em { font-style: normal; color: var(--gold); }
.intro { font-size: clamp(14px,1.1vw,16px); color: #c1cdc5; line-height: 1.85; letter-spacing: -.035em; word-break: keep-all; }
.visit-info { color: #c2b58e; font-size: 12px; margin-top: 12px; word-spacing: .12em; }
.plate { margin-top: clamp(24px, 3.3vh, 40px); border: 1px solid #58706c; background: #122126; box-shadow: 0 18px 45px #0003; }
.preview-stage { width: 100%; height: clamp(250px, 34vh, 390px); position: relative; background: #14282c; }
#world { width: 100%; height: 100%; display: block; touch-action: none; }
#world-stage { position: absolute; inset: 0; }
.corner { width: 14px; height: 14px; position: absolute; border-color: #dbc58a; border-style: solid; pointer-events: none; opacity: .85; }
.tl { top: 9px; left: 9px; border-width: 1px 0 0 1px; }
.tr { top: 9px; right: 9px; border-width: 1px 1px 0 0; }
.bl { bottom: 9px; left: 9px; border-width: 0 0 1px 1px; }
.br { bottom: 9px; right: 9px; border-width: 0 1px 1px 0; }
figcaption { padding: 11px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid #475b59; color: #d3d6bf; font-size: 12px; }
#preview-slot canvas {cursor:grab;touch-action:pan-y;}
figcaption label {white-space:nowrap;}
#avatar-angle {width:clamp(64px,33%,170px);margin-right:auto;accent-color:var(--gold);}
#leave-exhibit {position:absolute;bottom:max(86px,env(safe-area-inset-bottom));left:50%;transform:translateX(-50%);padding:10px 18px;min-height:44px;background:var(--ink);border:1px solid var(--gold);border-radius:5px;}
#preview-name { font-size: 11px; color: #a2b5b0; }
.ticket { position: relative; color: #253b3a; padding-top: 28px; border: 1px solid #e5e2d4; border-top: 5px solid #d49359; background: linear-gradient(135deg,#f1f0e4,#dfdece); box-shadow: 0 22px 58px #0005; }
.ticket::before { content: ""; position: absolute; inset: 7px; pointer-events: none; border: 1px solid #97896175; }
.ticket-top, .ticket h2, .ticket-body, .ticket-stub { margin-inline: clamp(23px,2.5vw,39px); }
.ticket-top { float: right; color: #5c6c65; }
.ticket-top svg { width: 32px; height: 32px; stroke-width: 1.2; }
.ticket h2 { font: 700 clamp(32px, 2.8vw, 44px)/1.2 var(--serif); margin-top: 1px; letter-spacing: -.07em; }
.ticket-body { margin-top: 18px; border-top: 1px solid #ae9f7c; padding-top: 16px; }
.field-label, legend { font-weight: 700; font-size: 13px; letter-spacing: -.03em; }
#name, #code { display: block; width: 100%; color: #243830; border: 1px solid #918c73; border-radius: 3px; padding: 9px 12px; margin-top: 7px; background: #fcf6e5; font-size: 15px; }
#name::placeholder { color: #716d5c; }
.entry-name { display:grid; grid-template-columns:auto minmax(0,1fr); align-items:center; gap:14px; max-width:440px; margin-top:18px; }
.entry-name #name { margin:0; font-size:16px; }
.ticket-body > .wardrobe { margin-top:0; }
.wardrobe { border: 0; padding: 0; min-width: 0; margin-top: 18px; }
.wardrobe legend { padding: 0 0 7px; }
.option { display: grid; grid-template-columns: 65px 1fr; align-items: center; min-height: 34px; border-top: 1px solid #81785036; gap: 7px; }
.option-label { font-size: 12px; color: #534e3c; }
.selector { display: grid; grid-template-columns: 32px 1fr 32px; align-items: center; }
.selector output { font-size: 13px; text-align: center; font-weight: 600; }
.selector button { background: none; border: 0; color: #56543f; min-height: 33px; font-size: 22px; line-height: 1; }
.selector button:hover, .swatch:hover { background-color: #a99c7455; }
.swatches { display: flex; justify-content: center; gap: 4px; }
.swatch { width: 32px; height: 31px; border: 0; display: grid; place-items: center; border-radius: 2px; background: transparent; }
.swatch::before { content: ""; width: 16px; height: 16px; border: 1px solid #514f4544; border-radius: 50%; background: var(--swatch); }
.swatch[aria-pressed=true]::before { outline: 1.6px solid #32473e; outline-offset: 2px; }
.form-error { color: #8d3625; font-size: 13px; line-height: 1.6; margin-top: 8px; }
#visit-note { color: #344d42; font-size: 13px; line-height: 1.6; margin-top: 8px; }
.tear { margin: 15px clamp(23px,2.5vw,39px) 14px; border-top: 1px solid #9caa9c; }
.ticket-stub { margin-bottom: 22px; }
.ticket-stub button, .primary { width: 100%; min-height: 45px; justify-content: space-between; border: 1px solid #28493e; border-radius: 3px; background: #234a42; color: #faf0d3; font-weight: 700; padding: 10px 16px; }
.ticket-stub button:hover, .primary:hover { background: #315e51; }
body[data-mode=game] { width: 100%; height: 100dvh; overflow: hidden; }
body[data-mode=game] .mast { position: fixed; z-index: 3; top: max(12px,env(safe-area-inset-top)); right: max(16px,env(safe-area-inset-right)); height: auto; margin: 0; border: 0; }
body[data-mode=game] .brand, body[data-mode=game] .sound-label { display: none; }
body[data-mode=game] #sound, .stats, .action-tools > button, .keys, #nearby, #emoji-list, #toast { background: #112126ec; color: var(--cream); border: 1px solid #657366; border-radius: 5px; }
body[data-mode=game] #sound { width: 38px; height: 37px; }
body[data-mode=game] .network { background: #132323ee; padding: 5px 8px; }
#game, #game-slot { position: fixed; inset: 0; }
.hud-top { position: absolute; left: max(17px,env(safe-area-inset-left)); right: max(68px,calc(env(safe-area-inset-right) + 53px)); top: max(12px,env(safe-area-inset-top)); display: flex; align-items: start; justify-content: space-between; gap: 12px; pointer-events: none; }
.room-card { padding: 12px 15px; border-left: 2px solid var(--gold); border-radius: 2px; background: #102024ed; max-width: min(420px,60%); }
.room-card .kicker { font: 700 10px/1.2 var(--mono); }
.room-card h2 { font: 700 23px/1.3 var(--serif); letter-spacing: -.06em; margin: 4px 0; }
.stats { height: 37px; gap: 12px; padding: 6px 10px; }
.stats > span { gap: 5px; font: 12px var(--mono); }
.stats svg { width: 15px; height: 15px; color: var(--gold); }
.action-tools { position: absolute; top: max(61px,calc(env(safe-area-inset-top) + 48px)); right: max(15px,env(safe-area-inset-right)); display: flex; gap: 5px; }
.action-tools > button { justify-content: center; gap: 5px; padding: 7px 9px; min-height: 36px; font-size: 12px; }
.action-tools > button svg { width: 16px; height: 16px; }
#seen-count { color: var(--gold); font: bold 12px var(--mono); }
#emoji-list { display: grid; grid-template-columns: repeat(3,1fr); position: absolute; top: calc(100% + 6px); right: 0; padding: 4px; z-index: 2; }
#emoji-list button { border: 0; background: transparent; font-size: 22px; padding: 7px; border-radius: 4px; }
#emoji-list button:hover { background: #37524c; }
#toast, #nearby, .keys { position: absolute; left: 50%; transform: translateX(-50%); text-align: center; font-size: 12px; pointer-events: none; }
#toast { top: 23%; padding: 9px 14px; width: max-content; max-width: min(450px,calc(100% - 32px)); }
#discovery { position: absolute; left: max(16px,env(safe-area-inset-left)); bottom: max(68px,calc(48px + env(safe-area-inset-bottom))); width: max-content; max-width: calc(100% - 32px); pointer-events: none; }
.discovery-print { display: grid; gap: .3rem; justify-items: center; padding: .72rem 1.4rem; border: 1px solid #aa9978; border-radius: 5px; background: #f1e8d5; color: #27312e; box-shadow: 0 3px 15px #131a1840; text-align: center; overflow-wrap: anywhere; }
.discovery-print small { font: 600 .73rem var(--mono); }
.discovery-print strong { font-size: clamp(1.1rem,3.7vw,1.5rem); letter-spacing: .04em; }
.discovery-print span { font-size: .8rem; }
.discovery-print img { width: 96px; height: 46px; object-fit: none; object-position: 24% 45%; }
#panel-content .discovery-print { margin: .8rem 0; }
#nearby { bottom: 78px; padding: 10px 16px; color: #f4d899; max-width: 80%; }
.keys { bottom: 16px; padding: 8px 12px; white-space: nowrap; color: #cdd4c8; }
kbd { font: 11px var(--mono); color: #ebd198; }
kbd:not(:first-child) { margin-left: 7px; }
.touch-controls { display: none; }
.touch-actions { gap: 11px; }
.touch-actions button, #stick { border-radius: 50%; background: #14282bbd; border: 1px solid #d4c391a8; touch-action: none; }
.touch-actions button { width: 52px; height: 52px; display: grid; place-items: center; color: #eee2bd; pointer-events: auto; }
#inspect { width: 61px; height: 61px; background: #466050dc; }
#stick { width: 94px; height: 94px; position: relative; display: grid; place-items: center; pointer-events: auto; }
#thumb { width: 42px; height: 42px; border-radius: 50%; background: #c2c6ac87; border: 1px solid #e7dcabc7; pointer-events: none; }
#panel { width: min(405px, calc(100vw - 32px)); max-height: min(78dvh,660px); margin: auto; padding: 21px 23px 25px; color: var(--cream); border: 1px solid #ad955e; border-radius: 5px; background: #182b2e; box-shadow: 0 14px 60px #0007; }
#panel:modal { overscroll-behavior: contain; }
#panel::backdrop { background: #0a131ab8; overscroll-behavior: contain; overflow: hidden; }
#panel[data-kind=inspect], #panel[data-kind=door] { margin: auto max(4vw, 20px) max(32px,6vh) auto; }
#panel[data-kind=inspect]::backdrop, #panel[data-kind=door]::backdrop { background: transparent; }
#panel[data-kind=challenge] { margin: auto max(2vw,12px) max(3vh,12px) auto; }
#panel[data-kind=challenge]::backdrop { background: #0a171d35; }
@media (min-width: 850px) { body #panel[data-kind=challenge] { width: min(55vw,720px); } }
.panel-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.panel-head form { flex: none; }
#close-panel { width: 32px; height: 32px; min-height: 32px; padding: 5px; }
#close-panel svg { width: 15px; height: 15px; }
#panel h2 { font: 600 29px/1.4 var(--serif); letter-spacing: -.055em; margin: 6px 0 12px; }
#panel-content { font-size: 14px; line-height: 1.75; color: #d5dfd4; word-break: keep-all; overflow-wrap: anywhere; }
#panel-content p { white-space: pre-line; }
#panel-content article + article { border-top: 1px solid var(--rule); margin-top: 12px; padding-top: 10px; }
#panel-content h3 { font-size: 14px; color: #ebce91; }
#panel-content form { margin-top: 13px; }
#panel-content label { font-size: 12px; }
#panel-content .primary { margin-top: 13px; font-size: 14px; }
#code { font-size: 16px; }
#panel-content .form-error { color: #ffc1a8; }
.puzzle-secondary { border: 1px solid #6a8175; border-radius: 4px; background: #213636; padding: 7px 9px; min-height: 44px; color: var(--cream); line-height: 1.4; margin-top: 10px; font-size: 13px; }
.puzzle-secondary:hover { background: #314744; }
.record-time { font: 32px var(--mono); color: var(--gold); margin-top: 12px; }
@media (any-pointer:coarse), (max-width:700px) {
  body:has(#panel[open]) .action-tools { visibility: hidden; }
  .touch-controls { position: absolute; bottom: max(20px,env(safe-area-inset-bottom)); left: max(17px,env(safe-area-inset-left)); right: max(17px,env(safe-area-inset-right)); display: flex; align-items: end; justify-content: space-between; pointer-events: none; user-select: none; }
  .keys { display:none; }
  #toast { top: auto; bottom: max(125px,calc(110px + env(safe-area-inset-bottom))); }
  #nearby { bottom: max(124px,calc(108px + env(safe-area-inset-bottom))); }
  #discovery { left: 50%; transform: translateX(-50%); bottom: max(180px,calc(164px + env(safe-area-inset-bottom))); }
}
@media (max-width:800px) {
  #lobby { gap: 25px; width: 92%; grid-template-columns: minmax(0,1.05fr) minmax(300px,1fr); }
  .mast { margin-inline: 4%; }
  h1 { font-size: clamp(43px,6.5vw,56px); }
}
@media (max-width:650px) {
  .mast { height: 58px; margin-inline: 20px; }
  .brand { font-size: 19px; gap: 6px; }
  .brand-mark { width: 33px; height: 33px; }
  #lobby { width: auto; margin: 26px 20px 35px; gap: 22px; grid-template-columns: minmax(0,1fr); }
  h1 { font-size: clamp(41px,11.5vw,65px); margin: 8px 0; }
  .intro { font-size: 13px; line-height: 1.65; }
  .plate { margin-top: 15px; }
  .preview-stage { height: clamp(170px,43vw,238px); }
  figcaption { padding: 8px 12px; font-size: 11px; }
  .ticket { padding-top: 17px; }
  .ticket h2 { font-size: 31px; }
  .ticket-top, .ticket h2, .ticket-body, .ticket-stub { margin-inline: 22px; }
  .ticket-body { margin-top: 13px; }
  .ticket-top svg { width: 26px; height: 26px; }
  .hud-top { left: 10px; right: 55px; gap: 6px; }
  .room-card { padding: 7px 9px; max-width: min(54vw,250px); }
  .room-card h2 { font-size: 17px; }
  .stats { padding: 5px 7px; gap: 7px; }
  .stats svg { width: 13px; height: 13px; }
  .stats > span { font-size: 11px; gap: 3px; }
  .action-tools { flex-direction: column; right: max(11px,env(safe-area-inset-right)); }
  .action-tools > button { padding: 8px; min-width: 37px; }
  .action-tools > button span { display: none; }
  #emoji-list { top: auto; bottom: 0; right: calc(100% + 5px); }
  #panel[data-kind=inspect], #panel[data-kind=door] { width: calc(100% - 20px); max-height: 49dvh; margin: auto auto max(10px,env(safe-area-inset-bottom)); padding: 12px 16px 16px; }
  #panel[data-kind=inspect] h2, #panel[data-kind=door] h2 { font-size: 22px; margin: 2px 0 6px; }
  #panel[data-kind=challenge] { margin: auto auto max(4px,env(safe-area-inset-bottom)); }
  body #panel[data-kind=challenge] { max-height: 80dvh; }
  body[data-mode=game] .mast { right: max(10px,env(safe-area-inset-right)); }
  body[data-mode=game] .network { position: fixed; left: 10px; top: 111px; }
}
@media (max-height:500px) and (orientation:landscape) {
  .room-card { padding: 5px 9px; }
  .room-card h2 { font-size: 17px; }
  .touch-controls { bottom: 8px; }
  #stick { width: 76px; height: 76px; }
  #panel[data-kind=inspect], #panel[data-kind=door] { width: 40%; max-height: 85dvh; margin: auto 9px 9px auto; }
}
