:root {
  --bg: rgba(18, 22, 16, 0.82);
  --bg2: rgba(32, 38, 28, 0.9);
  --line: rgba(190, 200, 160, 0.18);
  --text: #e6e9dc;
  --muted: #a3aa92;
  --accent: #c7d36b;
  --ok: #7ed37a;
  --warn: #f0b84a;
  --err: #ff6b5a;
  --cyan: #7fd4ff;
  --panel-w: 320px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1b2016; color: var(--text);
  font-family: 'Noto Sans KR', 'Malgun Gothic', 'Apple SD Gothic Neo', system-ui, sans-serif; font-size: 13px; }
#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; outline: none; }

button { font: inherit; color: var(--text); background: #39422c; border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 10px; cursor: pointer; transition: background .15s, border-color .15s; }
button:hover { background: #4a5638; border-color: rgba(199, 211, 107, .5); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.wide { width: 100%; }
button.ghost { background: transparent; }
select, input[type=number] { font: inherit; color: var(--text); background: #262c1f; border: 1px solid var(--line);
  border-radius: 5px; padding: 5px 6px; width: 100%; }
input[type=number] { width: 80px; text-align: right; }
input[type=range] { width: 100%; accent-color: var(--accent); }

#topbar { position: fixed; top: 0; left: 0; right: 0; height: 48px; display: flex; align-items: center; gap: 16px;
  padding: 0 14px; background: linear-gradient(180deg, rgba(10, 12, 8, .9), rgba(10, 12, 8, .55)); z-index: 5;
  border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.logo { font-weight: 700; font-size: 20px; color: var(--accent); letter-spacing: 1px; }
.sub { color: var(--muted); font-size: 12px; }
.chips { display: flex; gap: 8px; flex: 1; justify-content: center; flex-wrap: nowrap; overflow: hidden; }
.chip { background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 9px; white-space: nowrap; }
.chip span { color: var(--muted); font-size: 11px; margin-right: 6px; }
.chip b { font-variant-numeric: tabular-nums; }
.chip.ok b { color: var(--ok); }
.chip.warn b { color: var(--warn); }
.chip.err b { color: var(--err); }
.topbtns { display: flex; gap: 6px; }

.panel { position: fixed; top: 56px; bottom: 236px; width: var(--panel-w); overflow-y: auto; z-index: 4;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; backdrop-filter: blur(6px);
  scrollbar-width: thin; }
#left { left: 8px; }
#right { right: 8px; }
body.nopanels .panel, body.nopanels #bottom { display: none; }
.panel section { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.panel section:last-child { border-bottom: none; }
.panel h2 { margin: 0 0 10px; font-size: 14px; color: var(--accent); font-weight: 700; }
.panel h2 small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.panel label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.panel label em { float: right; color: var(--text); font-style: normal; font-variant-numeric: tabular-nums; }
.field { margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.row.gap { gap: 8px; margin: 10px 0 8px; }
.row .unit { color: var(--muted); font-size: 11px; margin-right: 2px; }
.nudge { padding: 4px 7px; font-size: 12px; min-width: 34px; }
.hint { color: var(--muted); font-size: 11px; margin-top: 4px; }
.check { display: flex !important; align-items: center; gap: 6px; color: var(--text) !important; cursor: pointer; margin: 6px 0 !important; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid2 label select { margin-top: 3px; }
.panel > section > label > select { margin-top: 3px; margin-bottom: 8px; }
.info { background: rgba(0, 0, 0, .25); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin: 8px 0;
  line-height: 1.6; font-size: 12px; }
.info b { color: var(--cyan); font-weight: 500; }
.info .w { color: var(--warn); }

#steps { list-style: none; padding: 0; margin: 0; counter-reset: s; }
#steps li { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
#steps li .dot { width: 10px; height: 10px; border-radius: 50%; background: #555; flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
#steps li.done .dot { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
#steps li.next .dot { background: var(--warn); box-shadow: 0 0 6px var(--warn); }
#steps li button { flex: 1; text-align: left; display: flex; justify-content: space-between; }
#steps li button kbd { color: var(--muted); font-size: 11px; font-family: inherit; }
#steps li.next button { border-color: rgba(240, 184, 74, .6); }

.fire { width: 100%; margin-top: 4px; padding: 12px; font-size: 18px; font-weight: 700; letter-spacing: 6px;
  background: linear-gradient(180deg, #8d2a1f, #5e1a13); border-color: #c0473a; }
.fire:hover { background: linear-gradient(180deg, #a83426, #6e2017); }
.fire.ready { animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 90, 70, .6); } 50% { box-shadow: 0 0 0 8px rgba(255, 90, 70, 0); } }

.solution { margin-top: 8px; }
.solution .opt { display: flex; align-items: center; justify-content: space-between; gap: 6px; background: rgba(0,0,0,.25);
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; margin-bottom: 6px; font-size: 12px; line-height: 1.5; }
.solution .opt b { color: var(--cyan); font-weight: 500; }
.solution .opt button { flex: none; }

#results { width: 100%; border-collapse: collapse; font-size: 11px; font-variant-numeric: tabular-nums; }
#results th { color: var(--muted); font-weight: 400; text-align: right; padding: 3px 2px; border-bottom: 1px solid var(--line); }
#results td { text-align: right; padding: 3px 2px; border-bottom: 1px dashed rgba(255,255,255,.06); }
#results th:nth-child(2), #results td:nth-child(2) { text-align: left; }
#results td.hit { color: var(--ok); }

#bottom { position: fixed; left: 8px; right: 8px; bottom: 8px; height: 220px; display: grid; z-index: 4;
  grid-template-columns: 1.4fr 1fr 1fr; gap: 8px; }
.card { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; position: relative; overflow: hidden; }
.card .cap { position: absolute; top: 6px; left: 10px; color: var(--muted); font-size: 11px; z-index: 1; pointer-events: none; }
.card canvas { width: 100%; height: 100%; display: block; }
#minimap { cursor: crosshair; }
.logcard #log { position: absolute; inset: 24px 8px 8px; overflow-y: auto; font-size: 12px; line-height: 1.55; scrollbar-width: thin; }
#log div { border-bottom: 1px dashed rgba(255,255,255,.05); }
#log .t { color: var(--muted); margin-right: 6px; font-variant-numeric: tabular-nums; }
#log .ok { color: var(--ok); }
#log .warn { color: var(--warn); }
#log .err { color: var(--err); }
#log .shot { color: #ffb347; font-weight: 500; }

#camBar { position: fixed; bottom: 236px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; z-index: 4;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 4px; }
#camBar button { padding: 5px 10px; font-size: 12px; }
#camBar button.on { background: #66733d; border-color: var(--accent); }

#toast { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 6; pointer-events: none;
  background: rgba(0,0,0,.75); border: 1px solid var(--warn); color: var(--warn); padding: 8px 16px; border-radius: 8px;
  opacity: 0; transition: opacity .25s; font-size: 14px; }
#toast.show { opacity: 1; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 10; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal.hidden { display: none; }
.modal-body { background: #20261a; border: 1px solid var(--line); border-radius: 12px; max-width: 640px; width: 100%;
  padding: 20px 24px; max-height: 90vh; overflow-y: auto; line-height: 1.7; }
.modal-body h2 { color: var(--accent); margin-top: 0; }
.modal-body .warn { color: var(--warn); font-size: 12px; }

@media (max-width: 1100px) {
  :root { --panel-w: 280px; }
  .sub { display: none; }
  .chip:nth-child(n+5) { display: none; }
  #bottom { grid-template-columns: 1fr 1fr; height: 170px; }
  .logcard { display: none; }
  .panel { bottom: 186px; }
  #camBar { bottom: 186px; }
}
@media (max-width: 760px) {
  :root { --panel-w: calc(100vw - 16px); }
  #right { display: none; }
  #left { bottom: auto; max-height: 45vh; }
  .chips { display: none; }
  #bottom { height: 140px; }
  #camBar { bottom: 156px; flex-wrap: wrap; justify-content: center; width: calc(100vw - 16px); }
}

/* 우측 패널 탭 */
.tabs { display: flex; gap: 4px; padding: 8px 10px 0; position: sticky; top: 0; background: var(--bg); z-index: 2; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; border-radius: 6px 6px 0 0; border-bottom: none; font-size: 12px; padding: 7px 4px; background: transparent; }
.tabs button.on { background: #4a5638; border-color: rgba(199, 211, 107, .5); color: var(--accent); }
.fire-sm { background: linear-gradient(180deg, #8d2a1f, #5e1a13); border-color: #c0473a; font-weight: 700; }
.fire-sm:hover { background: linear-gradient(180deg, #a83426, #6e2017); }
.tablewrap { max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; scrollbar-width: thin; }
#bnTable { width: 100%; border-collapse: collapse; font-size: 11px; font-variant-numeric: tabular-nums; }
#bnTable th { position: sticky; top: 0; background: #262c1f; color: var(--muted); font-weight: 400; padding: 4px 3px; text-align: right; }
#bnTable td { padding: 3px; text-align: right; border-bottom: 1px dashed rgba(255,255,255,.06); white-space: nowrap; }
#bnTable th:first-child, #bnTable td:first-child, #bnTable td:last-child, #bnTable th:last-child { text-align: left; }
#bnTable td.x { color: var(--muted); }
#bnTable td.st-ready { color: var(--ok); }
#bnTable td.st-wait { color: var(--warn); }
#bnTable td.st-done { color: var(--muted); }
#bnTable .b0 { color: #7fd4ff; } #bnTable .b1 { color: #ffb347; } #bnTable .b2 { color: #b8f27a; } #bnTable .bx { color: #c9c9c9; }
.bigclock { font-size: 20px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }

#camBar { align-items: center; flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 2 * var(--panel-w) - 40px); }
#camBar select { width: auto; padding: 4px 6px; font-size: 12px; }
#camBar .camhint { color: var(--muted); font-size: 11px; padding: 0 6px; white-space: nowrap; }
@media (max-width: 1100px) { #camBar .camhint { display: none; } }

body.nopanels #camBar { bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
