:root { --ink: #f3e7cf; --gold: #e2b45c; --blood: #b3261e; --night: #140505; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); color: var(--ink); font: 15px/1.4 -apple-system, BlinkMacSystemFont, system-ui, "Helvetica Neue", Arial, sans-serif; -webkit-user-select: none; user-select: none; }
#app { position: fixed; inset: 0; touch-action: none; }
#app canvas { display: block; width: 100%; height: 100%; }
button { font: inherit; cursor: pointer; }

#hud { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 16px; right: 16px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; pointer-events: none; }
.brand { font-weight: 800; letter-spacing: .08em; text-transform: uppercase; font-size: 12px; padding: 8px 12px; border: 1px solid rgba(226,180,92,.5); background: rgba(20,5,5,.6); border-radius: 6px; color: var(--gold); }
.ticket { text-align: right; font-size: 12px; padding: 8px 12px; background: rgba(20,5,5,.6); border-radius: 6px; }
.ticket b { color: var(--gold); font-size: 16px; }
.ticket span { display: block; opacity: .75; }
#hint { position: fixed; left: 50%; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 56px); transform: translateX(-50%); margin: 0; width: min(560px, calc(100% - 32px)); text-align: center; font-size: 13px; opacity: .8; text-shadow: 0 1px 4px #000; pointer-events: none; }

#prompt { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); padding: 14px 26px; border-radius: 999px; border: 1px solid var(--gold); background: linear-gradient(#8f1c15, #5a0e0a); color: var(--ink); font-weight: 700; box-shadow: 0 0 24px rgba(255,80,40,.45); }
#lens { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.55) 100%); }
#lens i { position: absolute; width: 34px; height: 34px; border: 2px solid rgba(243,231,207,.55); }
#lens i:nth-child(1) { left: 16px; top: 64px; border-right: 0; border-bottom: 0; }
#lens i:nth-child(2) { right: 16px; top: 64px; border-left: 0; border-bottom: 0; }
#lens i:nth-child(3) { left: 16px; bottom: 44px; border-right: 0; border-top: 0; }
#lens i:nth-child(4) { right: 16px; bottom: 44px; border-left: 0; border-top: 0; }
#lens .rec, #tc { position: absolute; top: 74px; font: 700 12px ui-monospace, Menlo, monospace; letter-spacing: .1em; text-shadow: 0 1px 3px #000; }
#lens .rec { left: 60px; color: #ff4a3a; animation: rec 1.2s steps(2) infinite; }
#lens .rec::before { content: '●'; margin-right: 6px; }
#tc { right: 60px; color: rgba(243,231,207,.8); }
@keyframes rec { 50% { opacity: .25; } }
@media (max-width: 600px) {
  .brand { font-size: 10px; max-width: 150px; }
  #lens i:nth-child(1), #lens i:nth-child(2) { top: 104px; }
  #lens .rec, #tc { top: 114px; }
  #toast { top: 150px; width: calc(100% - 32px); }
}
#toast { position: fixed; left: 50%; top: 104px; transform: translateX(-50%); padding: 12px 18px; border-radius: 8px; background: rgba(10,0,0,.8); border: 1px solid var(--blood); font-weight: 700; color: #ff9b8c; letter-spacing: .04em; text-align: center; }

#card { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 18px; background: rgba(10,0,0,.55); backdrop-filter: blur(3px); padding: 16px; }
#card[hidden], #gate[hidden], #prompt[hidden], #toast[hidden] { display: none; }
.id { width: min(440px, calc(100vw - 32px)); background: linear-gradient(135deg, #f1e7d1, #d9c9a6); color: #2a1410; border-radius: 14px; padding: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.6), inset 0 0 0 2px #8a1d16; animation: rise .5s ease-out; }
.id-head { display: flex; flex-direction: column; border-bottom: 2px solid #8a1d16; padding-bottom: 8px; margin-bottom: 12px; }
.id-head span { font-size: 10px; letter-spacing: .14em; color: #8a1d16; font-weight: 700; }
.id-head strong { font-size: 20px; letter-spacing: .06em; }
.id-body { display: grid; grid-template-columns: 84px 1fr; gap: 12px; position: relative; }
.photo { height: 108px; border-radius: 6px; background: #3a2420; color: #c9b48d; display: grid; place-content: center; text-align: center; font-size: 10px; letter-spacing: .1em; }
dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 12px; }
dt { opacity: .65; } dd { margin: 0; font-weight: 700; }
dd.unk { color: #a3170f; letter-spacing: .04em; }
.seal { position: absolute; right: -10px; bottom: -22px; width: 64px; height: 64px; border: 3px solid rgba(179,38,30,.8); border-radius: 50%; color: rgba(179,38,30,.85); font-size: 10px; font-weight: 800; display: grid; place-content: center; text-align: center; line-height: 1.1; transform: rotate(-14deg); }
#cardOk, #enter { padding: 13px 26px; border-radius: 999px; border: 1px solid var(--gold); background: linear-gradient(#8f1c15, #5a0e0a); color: var(--ink); font-weight: 700; }

#gate { position: fixed; inset: 0; display: grid; place-content: center; padding: 16px; background: radial-gradient(ellipse at 50% 40%, rgba(90,14,10,.55), rgba(10,0,0,.92)); }
.gate-box { width: min(460px, calc(100vw - 32px)); text-align: center; padding: 28px 22px; border: 1px solid rgba(226,180,92,.45); border-radius: 14px; background: rgba(20,5,5,.75); }
.gate-kicker { margin: 0 0 6px; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); }
.gate-box h1 { margin: 0 0 10px; font-size: 28px; }
.gate-box small { display: block; margin-top: 16px; opacity: .55; font-size: 11px; }

.joystick { position: fixed; left: 22px; bottom: 60px; width: 128px; height: 128px; border-radius: 50%; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.2); touch-action: none; }
.joystick span { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: rgba(226,180,92,.55); }
@keyframes rise { from { transform: translateY(24px) scale(.96); opacity: 0; } }

#lens[hidden], #dock[hidden], #dance-menu[hidden] { display: none; }
#lens .focus { position: absolute; left: 50%; top: 50%; width: 90px; height: 60px; margin: -30px 0 0 -45px; border: 1.5px solid rgba(243,231,207,.45); border-radius: 4px; }
#lens .focus::after { content: ''; position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px; border-radius: 50%; border: 1.5px solid rgba(255,90,60,.7); }
#lens .meta { position: absolute; left: 60px; bottom: 54px; font: 600 11px ui-monospace, Menlo, monospace; letter-spacing: .08em; color: rgba(243,231,207,.75); }
#lens .batt { position: absolute; right: 60px; bottom: 54px; width: 28px; height: 13px; border: 1.5px solid rgba(243,231,207,.75); border-radius: 2px; }
#lens .batt em { position: absolute; left: 2px; top: 2px; bottom: 2px; width: 40%; background: #ff5a3c; }
#lens .batt::after { content: ''; position: absolute; right: -4px; top: 3px; width: 2px; height: 5px; background: rgba(243,231,207,.75); }
#lens.cam { background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,.6) 100%), repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 3px); }
#dock { position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: flex-end; }
.gbtn { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid rgba(226,180,92,.35); background: rgba(20,8,6,.6); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); color: var(--ink); font-weight: 600; font-size: 14px; }
.gbtn svg { width: 18px; height: 18px; fill: none; stroke: var(--gold); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.gbtn[aria-pressed="true"], .gbtn[aria-expanded="true"] { background: rgba(120,24,14,.75); }
.gbtn:active { transform: scale(.97); }
.dance-wrap { position: relative; }
#dance-menu { position: absolute; right: 0; bottom: 52px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px; width: 240px; border-radius: 14px; background: rgba(20,8,6,.85); border: 1px solid rgba(226,180,92,.35); backdrop-filter: blur(16px); }
#dance-menu button { height: 38px; border-radius: 10px; border: 1px solid rgba(226,180,92,.25); background: rgba(255,255,255,.04); color: var(--ink); font-weight: 600; }
#dance-menu button.on { background: rgba(120,24,14,.85); border-color: var(--gold); }
#dance-menu .stop { grid-column: 1 / -1; }
@media (max-width: 600px) {
  #dock { flex-direction: column; align-items: flex-end; bottom: 200px; }
  .gbtn span { display: none; }
  .gbtn { width: 44px; padding: 0; justify-content: center; }
  #dance-menu { bottom: 0; right: 52px; }
  #hint { display: none; }
}
