* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #000; color: #f2efe4; overflow: hidden; overscroll-behavior: none;
  font-family: "Galmuri11", ui-monospace, "Apple SD Gothic Neo", sans-serif; user-select: none; -webkit-user-select: none; }
#video { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
#out { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button, [role="button"] { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* 시작 화면 — 옛 콘솔 게임 타이틀 */
#start { position: fixed; inset: 0; display: grid; grid-template-rows: 1fr auto auto; justify-items: center; text-align: center;
  padding: calc(24px + env(safe-area-inset-top)) 20px calc(16px + env(safe-area-inset-bottom)); background: #0b0c10; overflow: hidden; }
#city { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.lines { position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.22) 0 1px, transparent 1px 3px); }
#start > :not(#city):not(.lines) { position: relative; }
.title { align-self: center; margin-top: -6vh; }
.pre { margin: 0 0 10px; font-size: 13px; letter-spacing: 3px; color: #f2efe4; text-shadow: 2px 2px 0 #000; }
.title h1 { margin: 0; display: grid; font-family: "Anton", "Galmuri14", sans-serif; font-weight: 400; font-size: clamp(64px, 24vw, 128px); line-height: 0.92;
  letter-spacing: 1px; transform: skew(-7deg) rotate(-3deg); color: #f2efe4;
  text-shadow: 3px 0 0 #000, -3px 0 0 #000, 0 3px 0 #000, 0 -3px 0 #000, 3px 3px 0 #000, -3px -3px 0 #000, 3px -3px 0 #000, -3px 3px 0 #000, 8px 9px 0 #000; }
.title h1 .hl { color: #e8c84a; margin-left: 0.5em; }
.sub { margin: 22px 0 0; font-size: 15px; color: #f2efe4; text-shadow: 2px 2px 0 #000; }
.menu { display: grid; gap: 12px; justify-items: center; margin-bottom: 26px; }
#startBtn { padding: 12px 20px; font-size: 24px; letter-spacing: 3px; background: none; border: 0; color: #f2efe4; text-shadow: 3px 3px 0 #000;
  animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0.15; } }
#gptBtn { min-height: 48px; padding: 10px 16px; font-size: 15px; background: rgba(8, 9, 12, 0.82); border: 2px solid #f2efe4; }
#gptBtn.on { border-color: #7bdc6a; color: #7bdc6a; }
#startMsg { margin: 0; min-height: 1.5em; font-size: 14px; color: #ff9a88; text-shadow: 2px 2px 0 #000; }
.foot { display: grid; gap: 8px; max-width: 34em; }
#tip { margin: 0; min-height: 3em; font-size: 14px; line-height: 1.5; color: #e8c84a; text-shadow: 2px 2px 0 #000; }
.privacy { margin: 0; padding: 8px 10px; font-size: 13px; line-height: 1.5; color: #f2efe4; background: rgba(8, 9, 12, 0.82); border: 1px solid #7bdc6a; }
.legal { margin: 0; font-size: 13px; line-height: 1.5; color: #c9c5b8; text-shadow: 1px 1px 0 #000; }
@media (prefers-reduced-motion: reduce) { #startBtn { animation: none; } }

/* GPT 연결 창 */
#login { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; overflow-y: auto; background: rgba(0, 0, 0, 0.86); }
#login .box { width: min(100%, 420px); padding: 18px; background: #12140f; border: 3px solid #f2efe4; box-shadow: 6px 6px 0 #000; display: grid; gap: 12px; }
#login h2 { margin: 0; font-size: 20px; color: #e8c84a; }
#login ol { margin: 0; padding-left: 1.4em; font-size: 14px; line-height: 1.7; color: #dcd8cb; }
#code { display: block; padding: 14px 8px; text-align: center; font-family: "Galmuri14", ui-monospace, monospace; font-size: 30px; letter-spacing: 3px;
  color: #7bdc6a; background: #000; border: 2px solid #7bdc6a; user-select: all; -webkit-user-select: all; }
#login .row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
#login .row > *, #loginClose { min-height: 48px; display: grid; place-items: center; padding: 8px; font-size: 15px; text-decoration: none; background: #1d2019; border: 2px solid #f2efe4; }
#openaiBtn { background: #e8c84a !important; color: #14140f; border-color: #000 !important; }
#loginMsg { margin: 0; min-height: 1.5em; font-size: 14px; color: #f2efe4; }
#login .note { margin: 0; padding: 10px 10px 10px 26px; font-size: 13px; line-height: 1.6; color: #dcd8cb; border: 1px solid #7bdc6a; }

/* 조작 줄 */
#bar { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); }
#bar button { min-height: 48px; padding: 8px 10px; font-size: 14px; background: rgba(12, 14, 11, 0.78); border: 2px solid #f2efe4; }
#modeBtn[aria-pressed="true"] { background: #e8c84a; color: #14140f; border-color: #000; }
#modeBtn { justify-self: start; }
.side { justify-self: end; display: flex; flex-direction: column; gap: 6px; }
.side button { min-height: 44px !important; }
#tuneBtn[aria-expanded="true"] { background: #e8c84a; color: #14140f; border-color: #000; }
#tune { position: fixed; left: 14px; right: 14px; bottom: calc(132px + env(safe-area-inset-bottom)); display: grid; gap: 8px; padding: 14px;
  background: rgba(12, 14, 11, 0.9); border: 2px solid #f2efe4; }
#tune label { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 10px; font-size: 14px; }
#tune input { width: 100%; height: 32px; accent-color: #e8c84a; }
.tune-row { display: flex; justify-content: space-between; gap: 10px; }
#tune button { justify-self: end; min-height: 44px; padding: 6px 12px; font-size: 14px; background: #1a1d17; border: 2px solid #f2efe4; }
#recBtn { width: 68px; height: 68px; padding: 0; border-radius: 50%; border: 4px solid #fff !important; background: rgba(0, 0, 0, 0.35) !important;
  display: grid; place-items: center; }
#recBtn span { width: 46px; height: 46px; border-radius: 50%; background: #e5372c; transition: all 0.15s; }
#recBtn[aria-pressed="true"] span { width: 26px; height: 26px; border-radius: 5px; }

/* 녹화 결과 */
#sheet { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 18px; background: rgba(0, 0, 0, 0.92); }
#clip { max-width: 100%; max-height: 66vh; border: 3px solid #f2efe4; background: #000; }
.sheet-actions { display: flex; gap: 10px; }
.sheet-actions > * { min-height: 48px; min-width: 88px; padding: 12px 16px; font-size: 16px; text-align: center; text-decoration: none;
  background: #1a1d17; border: 2px solid #f2efe4; }
#shareBtn { background: #e8c84a; color: #14140f; border-color: #000; }
#sheetMsg { margin: 0; min-height: 1.5em; font-size: 14px; color: #cfd3c8; }
