:root {
  color-scheme: dark;
  --ink: #eef7fb;
  --muted: #98acb8;
  --panel: #0b1a25;
  --panel-2: #102532;
  --line: #24404e;
  --cyan: #57d7e8;
  --cyan-soft: #153b46;
  --amber: #ffb13b;
  --amber-dark: #bd6807;
  --danger: #ff756b;
  --green: #68df9b;
  --shadow: 0 24px 64px rgba(0, 0, 0, .38);
  font-family: Inter, Pretendard, "Noto Sans KR", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: #06111a; color: var(--ink); }

body {
  background:
    radial-gradient(circle at 8% 0%, rgba(50, 151, 174, .15), transparent 30rem),
    linear-gradient(180deg, #081822 0, #061019 70%);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(87, 215, 232, .5); outline-offset: 2px; }

.app-shell { width: min(1500px, 100%); margin: 0 auto; padding: 20px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.brand-block { display: flex; align-items: center; gap: 13px; }
.brand-mark { width: 42px; height: 42px; border: 1px solid #417384; border-radius: 12px; display: grid; place-items: center; background: #0c2530; box-shadow: inset 0 0 25px rgba(87, 215, 232, .08); }
.brand-mark::before, .brand-mark::after, .brand-mark span { content: ""; position: absolute; border: 2px solid var(--cyan); border-radius: 50%; }
.brand-mark { position: relative; }
.brand-mark::before { width: 18px; height: 18px; }
.brand-mark::after { width: 5px; height: 5px; background: var(--cyan); }
.brand-mark span { width: 30px; height: 30px; border-color: rgba(87, 215, 232, .22); }
.brand-block h1 { margin: 0; font-size: clamp(1.15rem, 2vw, 1.45rem); letter-spacing: -.02em; font-weight: 720; }
.brand-block h1 b { margin-left: 4px; color: var(--cyan); font-size: .76em; letter-spacing: .08em; }
.brand-block p { margin: 3px 0 0; color: var(--muted); font-size: .86rem; }
.run-state { display: flex; align-items: center; gap: 8px; color: #bed0d9; font-size: .82rem; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(104, 223, 155, .1); }
.run-state code { margin-left: 7px; color: var(--cyan); background: var(--cyan-soft); padding: 5px 8px; border-radius: 6px; font-size: .72rem; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 16px; align-items: start; min-width: 0; }
.stage-card, .control-panel { min-width: 0; background: rgba(11, 26, 37, .92); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.stage { position: relative; min-height: 560px; aspect-ratio: 16 / 10; background: #02070b; overflow: hidden; }
#worldCanvas { display: block; width: 100%; height: 100%; touch-action: none; }
.stage-shade { pointer-events: none; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.24), transparent 17%, transparent 72%, rgba(0,0,0,.32)); }
.hud-top { position: absolute; top: 16px; left: 16px; display: flex; gap: 8px; pointer-events: none; }
.hud-chip { min-width: 92px; padding: 8px 11px; background: rgba(4, 14, 20, .76); border: 1px solid rgba(139, 210, 221, .22); border-radius: 9px; backdrop-filter: blur(9px); }
.hud-chip span { display: block; color: #9eb2be; font-size: .68rem; letter-spacing: .06em; }
.hud-chip strong { display: block; margin-top: 2px; font-size: .96rem; font-variant-numeric: tabular-nums; }
.crosshair { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; transform: translate(-50%,-50%); pointer-events: none; opacity: .8; }
.crosshair::before { content: ""; position: absolute; inset: 19px; border: 1px solid rgba(255,255,255,.9); border-radius: 50%; }
.crosshair i { position: absolute; background: rgba(255,255,255,.75); }
.crosshair i:nth-child(1), .crosshair i:nth-child(2) { width: 8px; height: 1px; top: 23px; }
.crosshair i:nth-child(1) { left: 7px; } .crosshair i:nth-child(2) { right: 7px; }
.crosshair i:nth-child(3), .crosshair i:nth-child(4) { width: 1px; height: 8px; left: 23px; }
.crosshair i:nth-child(3) { top: 7px; } .crosshair i:nth-child(4) { bottom: 7px; }
.mini-map { position: absolute; right: 15px; top: 15px; width: 150px; height: 150px; border: 1px solid rgba(153, 210, 223, .38); border-radius: 10px; background: rgba(4, 13, 19, .82); backdrop-filter: blur(8px); transition: opacity .2s, transform .2s; }
.mini-map.is-hidden { opacity: 0; transform: translateY(-8px); pointer-events: none; }
.toast { position: absolute; left: 50%; bottom: 22px; transform: translate(-50%, 10px); max-width: 86%; padding: 9px 14px; border-radius: 8px; background: rgba(4,14,20,.9); border: 1px solid rgba(87,215,232,.38); color: #e8f6fa; opacity: 0; pointer-events: none; transition: .2s ease; text-align: center; }
.toast.is-visible { opacity: 1; transform: translate(-50%,0); }
.toast.is-warning { border-color: rgba(255,177,59,.55); }
.scan-layer { position: absolute; inset: 0; pointer-events: none; }
.scan-tag { position: absolute; min-width: 72px; aspect-ratio: 1.05; transform: translate(-50%,-50%); border: 2px solid var(--cyan); box-shadow: 0 0 20px rgba(87,215,232,.14); animation: scan-in .28s ease both; }
.scan-tag span { position: absolute; left: -2px; top: 100%; padding: 3px 6px; background: var(--cyan); color: #06202a; white-space: nowrap; font-size: .68rem; font-weight: 800; }
@keyframes scan-in { from { opacity: 0; transform: translate(-50%,-50%) scale(1.16); } }
.stage.is-flashing::after { content: ""; position: absolute; inset: 0; background: white; animation: flash .18s ease-out both; pointer-events: none; }
@keyframes flash { from { opacity: .7; } to { opacity: 0; } }

.help-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(1,7,11,.5); backdrop-filter: blur(2px); z-index: 5; transition: opacity .25s; }
.help-overlay.is-hidden { opacity: 0; pointer-events: none; }
.help-card { width: min(430px, calc(100% - 32px)); padding: 25px; border: 1px solid #2f5564; border-radius: 14px; background: rgba(8,24,34,.96); box-shadow: 0 20px 70px rgba(0,0,0,.5); }
.help-card h2 { margin: 5px 0 17px; font-size: 1.45rem; }
.eyebrow { color: var(--cyan); font-size: .7rem; letter-spacing: .13em; text-transform: uppercase; font-weight: 800; }
.key-guide { display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; margin-bottom: 20px; color: #b9cad2; font-size: .75rem; }
.key-guide span { display: flex; flex-direction: column; gap: 6px; padding: 9px; border-radius: 8px; background: #0e2632; }
kbd { padding: 2px 5px; border-radius: 4px; border: 1px solid #48606c; background: #152d38; color: #dbeaf0; box-shadow: inset 0 -1px 0 #07151c; font-size: .7rem; }
.webgl-error { position: absolute; inset: 0; display: grid; place-items: center; padding: 40px; background: #08131b; color: var(--danger); text-align: center; z-index: 10; }
.webgl-error[hidden] { display: none; }

.camera-console { min-width: 0; min-height: 84px; display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 17px; padding: 13px 16px; border-top: 1px solid var(--line); background: #0a1821; }
.movement-pad { display: grid; grid-template-columns: repeat(3, 34px); grid-template-rows: repeat(2, 31px); gap: 3px; }
.movement-pad button { border: 1px solid #294857; border-radius: 6px; background: #102733; color: #b9d7df; }
.movement-pad button[data-move="forward"] { grid-column: 2; }
.movement-pad button[data-move="left"] { grid-column: 1; grid-row: 2; }
.movement-pad button[data-move="back"] { grid-column: 2; grid-row: 2; }
.movement-pad button[data-move="right"] { grid-column: 3; grid-row: 2; }
.movement-pad button:active { background: var(--cyan-soft); color: var(--cyan); }
.console-note strong, .console-note span { display: block; }
.console-note strong { font-size: .88rem; }
.console-note span { margin-top: 3px; color: var(--muted); font-size: .72rem; }
.camera-actions { min-width: 0; display: flex; align-items: center; gap: 7px; }
.icon-button { width: 40px; height: 40px; border: 1px solid #2c4c5a; border-radius: 8px; background: #102631; color: #aac5d0; font-size: 1rem; }
.icon-button.is-active { color: var(--cyan); border-color: #397889; background: #133642; }
.capture-button { min-width: 145px; height: 48px; border: 0; border-radius: 9px; background: linear-gradient(135deg, #ffbd54, #ed890f); color: #261403; font-weight: 850; display: flex; justify-content: center; align-items: center; gap: 8px; box-shadow: 0 7px 25px rgba(242,140,18,.2); }
.capture-button:hover { filter: brightness(1.06); }
.capture-button:disabled { opacity: .45; cursor: not-allowed; }
.capture-button kbd { color: #51300b; background: rgba(255,255,255,.35); border-color: rgba(54,30,1,.2); box-shadow: none; }
.lens { width: 15px; height: 15px; border: 2px solid #352000; border-radius: 50%; box-shadow: inset 0 0 0 3px rgba(255,255,255,.3); }

.control-panel { min-height: 700px; }
.panel-tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); }
.panel-tab { position: relative; height: 52px; border: 0; background: #0a1821; color: var(--muted); font-weight: 720; }
.panel-tab.is-active { color: var(--ink); background: #0c1e29; }
.panel-tab.is-active::after { content: ""; position: absolute; left: 22%; right: 22%; bottom: -1px; height: 2px; background: var(--cyan); }
.panel-tab span { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 4px; border-radius: 10px; background: #173643; color: #a8d7df; font-size: .68rem; }
.tab-panel { padding: 20px; }
.panel-intro, .log-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-intro { margin-bottom: 18px; }
.panel-intro h2 { margin: 3px 0 0; font-size: 1.18rem; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-group, .range-field { margin-bottom: 15px; }
.field-group label, .range-field label { display: block; margin-bottom: 7px; color: #c5d6dd; font-size: .78rem; font-weight: 680; }
.field-row { display: grid; grid-template-columns: 1fr auto; gap: 7px; }
input[type="number"], select { width: 100%; height: 40px; padding: 0 10px; border: 1px solid #2b4857; border-radius: 7px; background: #091923; color: var(--ink); }
input[type="range"] { width: 100%; accent-color: var(--cyan); }
.range-field > div { display: flex; justify-content: space-between; align-items: center; }
.range-field output { color: var(--cyan); font-size: .75rem; font-variant-numeric: tabular-nums; }
.check-row { display: flex; gap: 10px; align-items: flex-start; padding: 11px; margin: 3px 0 15px; border: 1px solid #263f4d; border-radius: 8px; background: #0a1a24; cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--cyan); }
.check-row strong, .check-row small { display: block; }
.check-row strong { font-size: .78rem; }
.check-row small { margin-top: 3px; color: var(--muted); font-size: .68rem; line-height: 1.4; }
.primary-button, .apply-button, .small-button, .quiet-button { border-radius: 7px; font-weight: 750; }
.primary-button { min-height: 42px; padding: 0 16px; border: 0; background: var(--cyan); color: #06202a; }
.apply-button { width: 100%; min-height: 46px; border: 1px solid #4cc9d9; background: #0d414d; color: #bdf5fb; }
.small-button { min-height: 40px; padding: 0 12px; border: 1px solid #31515f; background: #102631; color: #c2d8e0; }
.quiet-button { padding: 6px 8px; border: 0; background: transparent; color: var(--cyan); font-size: .72rem; }
.method-note { margin: 12px 2px 0; color: #738d9a; font-size: .67rem; line-height: 1.5; }

.metric-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; }
.metric-grid > div { padding: 10px 8px; background: #0a1a24; border: 1px solid #263f4d; border-radius: 8px; }
.metric-grid span, .metric-grid strong { display: block; }
.metric-grid span { color: var(--muted); font-size: .65rem; }
.metric-grid strong { margin-top: 5px; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.group-results { margin-top: 20px; }
.group-results h3, .log-header h3 { margin: 0 0 10px; font-size: .88rem; }
.bar-row { display: grid; grid-template-columns: 78px 1fr 46px; align-items: center; gap: 7px; margin: 10px 0; color: #aebfc7; font-size: .68rem; }
.bar-row > div { height: 7px; border-radius: 4px; overflow: hidden; background: #19313d; }
.bar-row i { display: block; width: 0; height: 100%; background: var(--cyan); transition: width .35s ease; }
.bar-row b { text-align: right; color: #d8e5ea; font-size: .68rem; font-variant-numeric: tabular-nums; }
.log-header { margin-top: 22px; }
.shot-log { max-height: 420px; margin: 0; padding: 0; list-style: none; overflow: auto; }
.shot-log li { display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; align-items: center; padding: 10px 2px; border-bottom: 1px solid #203946; }
.shot-log .shot-number { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; background: #12303c; color: var(--cyan); font-size: .68rem; }
.shot-log strong, .shot-log small { display: block; }
.shot-log strong { font-size: .73rem; }
.shot-log small { margin-top: 2px; color: var(--muted); font-size: .64rem; }
.shot-log em { color: var(--green); font-style: normal; font-size: .68rem; }
.shot-log .empty-log { display: block; padding: 28px 0; color: #718994; text-align: center; font-size: .75rem; border: 0; }

.summary-dialog { width: min(470px, calc(100% - 30px)); padding: 28px; border: 1px solid #315464; border-radius: 16px; background: #0b1c27; color: var(--ink); box-shadow: 0 35px 100px rgba(0,0,0,.65); }
.summary-dialog::backdrop { background: rgba(0,7,11,.74); backdrop-filter: blur(4px); }
.summary-dialog h2 { margin: 5px 0 7px; font-size: 1.45rem; }
.summary-dialog p { margin: 0; color: var(--muted); line-height: 1.55; }
.dialog-close { position: absolute; right: 13px; top: 11px; border: 0; background: transparent; color: #9eb3bd; font-size: 1.5rem; }
.summary-score { margin: 23px 0 16px; }
.summary-score strong, .summary-score span { display: block; }
.summary-score strong { color: var(--cyan); font-size: 3rem; line-height: 1; }
.summary-score span { margin-top: 5px; color: var(--muted); font-size: .76rem; }
.summary-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.summary-grid div { padding: 10px; border: 1px solid #284553; border-radius: 8px; background: #0d2430; }
.summary-grid span, .summary-grid b { display: block; }
.summary-grid span { color: var(--muted); font-size: .67rem; }
.summary-grid b { margin-top: 3px; font-size: .85rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }

@media (max-width: 1050px) {
  .workspace { grid-template-columns: 1fr; }
  .control-panel { min-height: auto; }
  .tab-panel { max-width: 700px; }
}

@media (max-width: 720px) {
  .app-shell { padding: 10px; }
  .topbar { align-items: flex-start; }
  .brand-block p, #runLabel { display: none; }
  .run-state { padding-top: 6px; }
  .stage { min-height: 430px; aspect-ratio: auto; }
  .hud-chip { min-width: 72px; padding: 7px 8px; }
  .mini-map { width: 116px; height: 116px; top: 68px; }
  .camera-console { grid-template-columns: auto 1fr; gap: 10px; }
  .console-note { display: none; }
  .camera-actions { justify-content: flex-end; }
  .capture-button { min-width: 120px; }
  .capture-button kbd { display: none; }
}

@media (max-width: 440px) {
  .brand-mark { width: 36px; height: 36px; }
  .brand-block h1 { font-size: 1rem; }
  .run-state code { margin-left: 0; }
  .stage { min-height: 390px; }
  .hud-top { top: 8px; left: 8px; gap: 4px; }
  .hud-chip { min-width: 65px; }
  .hud-chip strong { font-size: .82rem; }
  .mini-map { right: 8px; top: 59px; width: 102px; height: 102px; }
  .camera-console { padding: 10px; }
  .camera-actions { gap: 4px; }
  .camera-actions .icon-button { display: none; }
  .capture-button { width: 118px; min-width: 118px; height: 42px; }
  .field-grid { grid-template-columns: 1fr; gap: 0; }
  .key-guide { grid-template-columns: 1fr; }
  .key-guide span { flex-direction: row; align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
