:root {
  --bg: #0b0a09;
  --bg-2: #141210;
  --panel: #161310;
  --line: #2c2722;
  --text: #efe6d8;
  --muted: #9a8e80;
  --gold: #e0c08a;
  --gold-2: #b8945a;
  --seat: #6a3a40;
  --seat-hover: #8a5058;
  --seat-on: #e0c08a;
  --aisle: #1a1714;
  --danger: #c15a4a;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --font: "Nanum Gothic", "Gothic A1", "Noto Sans CJK KR", "Noto Sans KR",
    "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
button, input { font-family: inherit; }

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #161310, #100e0c);
  flex: 0 0 auto;
  z-index: 5;
}

header h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

header .sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  word-break: keep-all;
}

.header-actions { display: flex; gap: 8px; flex-shrink: 0; }

header button, #stats button {
  appearance: none;
  border: 1px solid #3a332c;
  background: #221e1a;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
header button:hover, #stats button:hover {
  border-color: var(--gold-2);
  color: var(--gold);
}
header button.primary, #btn-overview {
  background: #2a2318;
  border-color: #5a4a32;
  color: var(--gold);
}
.mobile-only { display: none; }

main {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

#stage {
  flex: 1;
  position: relative;
  min-width: 0;
  min-height: 240px;
  background: #070605;
}
#stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#view-chip, #hint {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  text-align: center;
}
#view-chip {
  top: 14px;
  background: rgba(12, 10, 9, 0.72);
  border: 1px solid rgba(224, 192, 138, 0.35);
  color: var(--gold);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  letter-spacing: 0.02em;
  backdrop-filter: blur(8px);
}
#view-chip[hidden] { display: none; }
#hint {
  bottom: 16px;
  max-width: min(92vw, 520px);
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(12, 10, 9, 0.72);
  border: 1px solid rgba(224, 192, 138, 0.22);
  color: #e8dcc8;
  font-size: 12px;
  line-height: 1.45;
  word-break: keep-all;
  overflow-wrap: anywhere;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9), 0 0 12px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
}

#panel {
  width: 420px;
  max-width: 46vw;
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 4;
}

.screen-bar {
  margin: 12px 14px 6px;
  background: linear-gradient(180deg, #d8c4a0, #8a7350);
  color: #1a140c;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  padding: 6px 8px 7px;
  border-radius: 3px;
  box-shadow: 0 0 0 1px #5a4a32;
}
.screen-bar small {
  display: block;
  letter-spacing: 0;
  font-weight: 500;
  opacity: 0.8;
  margin-top: 1px;
}

#seatmap {
  flex: 1;
  overflow: auto;
  padding: 4px 8px 8px;
  min-height: 0;
}

.map-row {
  display: grid;
  grid-template-columns: 18px 1fr 18px;
  gap: 4px;
  align-items: center;
  margin: 0 0 2px;
}
.row-lab {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}
.row-track {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr)) 1.7fr repeat(14, minmax(0, 1fr)) 1.7fr repeat(12, minmax(0, 1fr)) 1.7fr repeat(2, minmax(0, 1fr));
  gap: 1.5px;
  min-width: 280px;
}
.row-track .seat,
.row-track .empty,
.row-track .aisle {
  aspect-ratio: 1;
  min-height: 7px;
  border: 0;
  padding: 0;
  border-radius: 2px;
}
.row-track .seat {
  background: var(--seat);
  cursor: pointer;
}
.row-track .seat:hover { background: var(--seat-hover); }
.row-track .seat.on {
  background: var(--seat-on);
  box-shadow: 0 0 0 1px #fff6de;
}
.row-track .empty { background: transparent; }
.row-track .aisle { background: var(--aisle); border-radius: 1px; }

.num-ruler {
  display: grid;
  grid-template-columns: 18px 1fr 18px;
  gap: 4px;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 9px;
}
.num-ruler .ticks {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr)) 1.7fr repeat(14, minmax(0, 1fr)) 1.7fr repeat(12, minmax(0, 1fr)) 1.7fr repeat(2, minmax(0, 1fr));
  gap: 1.5px;
  text-align: center;
}

#stats {
  border-top: 1px solid var(--line);
  padding: 12px 14px 10px;
  background: #120f0d;
  flex: 0 0 auto;
}
#stats .seat-name {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 2px;
  letter-spacing: -0.03em;
}
#stats .seat-note {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}
.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.stat {
  background: #1c1916;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 8px 7px;
  text-align: center;
}
.stat .k {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 3px;
}
.stat .v {
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.stat .v small { font-size: 11px; font-weight: 600; color: #cbb58a; margin-left: 1px; }
#stats .empty-msg {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.disclaimer {
  margin: 0;
  padding: 0 14px 12px;
  color: #7a7168;
  font-size: 10.5px;
  line-height: 1.5;
  background: #120f0d;
}

@media (max-width: 800px) {
  header { padding: 8px 12px; }
  header h1 { font-size: 15px; }
  header .sub { font-size: 11px; max-width: 54vw; line-height: 1.4; }
  .mobile-only { display: inline-block; }
  #stage { min-height: 42dvh; }
  #panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    max-height: min(62dvh, 560px);
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    box-shadow: var(--shadow);
    transform: translateY(calc(100% - 148px));
    transition: transform 0.28s ease;
  }
  #panel.open { transform: translateY(0); }
  .screen-bar { margin: 8px 12px 4px; }
  .map-row { margin: 0; }
  .disclaimer { font-size: 10px; padding: 0 12px 10px; }
  #stats { padding: 8px 12px 8px; }
  #panel .drawer-handle {
    display: block;
    width: 42px;
    height: 4px;
    background: #3a342e;
    border-radius: 4px;
    margin: 8px auto 0;
  }
  #hint {
    bottom: 156px;
    max-width: min(88vw, 360px);
    font-size: 11px;
    padding: 6px 12px;
  }
  #seatmap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .row-track {
    min-width: 320px;
    gap: 1px;
  }
  .row-track .seat,
  .row-track .empty,
  .row-track .aisle {
    min-height: 6px;
  }
}

.drawer-handle { display: none; }


/* --- Multi-hall picker & badge --- */
.title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.sim-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #1a140c;
  background: linear-gradient(180deg, #e0c08a, #b8945a);
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.hall-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.hall-picker label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10px;
  color: var(--muted);
}
.hall-picker select {
  appearance: none;
  background: #221e1a;
  color: var(--text);
  border: 1px solid #3a332c;
  border-radius: 8px;
  padding: 6px 28px 6px 10px;
  font-size: 12px;
  min-width: 7.5rem;
  max-width: 42vw;
  background-image: linear-gradient(45deg, transparent 50%, #9a8e80 50%),
    linear-gradient(135deg, #9a8e80 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
.hall-picker select:hover { border-color: var(--gold-2); }
.hall-picker select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.disclaimer strong { color: #cbb58a; font-weight: 700; }

.hall-picker .hp-short { display: none; }
.hall-picker .hp-full { display: inline; }

@media (max-width: 800px) {
  .hall-picker { gap: 6px; margin-top: 6px; }
  .hall-picker select {
    min-width: 5.5rem;
    padding: 5px 24px 5px 8px;
    font-size: 11px;
  }
  .sim-badge { font-size: 9px; padding: 2px 7px; }
  header { align-items: flex-start; }
  .header-actions { padding-top: 2px; }
}

/* P2-1: ~390px breathable picker — 2-row grid, short labels */
@media (max-width: 480px) {
  .header-left { min-width: 0; flex: 1; }
  .hall-picker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 10px;
    margin-top: 8px;
    width: 100%;
  }
  .hall-picker label {
    min-width: 0;
  }
  .hall-picker label:last-child {
    grid-column: 1 / -1;
  }
  .hall-picker .hp-full { display: none; }
  .hall-picker .hp-short { display: inline; }
  .hall-picker select {
    min-width: 0;
    max-width: none;
    width: 100%;
    font-size: 12px;
    padding: 8px 28px 8px 10px;
  }
}


/* --- Hall info card --- */
.hall-card {
  margin: 10px 12px 0;
  padding: 12px 12px 10px;
  background: #1a1612;
  border: 1px solid var(--line);
  border-radius: 12px;
  flex: 0 0 auto;
}
.hc-head h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: -0.02em;
}
.hc-op {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.hc-ref {
  margin: 2px 0 0;
  font-size: 10px;
  color: #6a635c;
}
.conf-high { color: #b8e0a8; font-weight: 700; }
.conf-mid { color: #e0c08a; font-weight: 700; }
.conf-none { color: #c15a4a; font-weight: 700; }
.hc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0 0;
}
.hc-grid > div {
  background: #120f0d;
  border: 1px solid #2a2420;
  border-radius: 8px;
  padding: 7px 8px;
}
.hc-grid .hc-span { grid-column: 1 / -1; }
.hc-grid dt {
  margin: 0 0 3px;
  font-size: 10px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.hc-grid dd {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  word-break: keep-all;
}
.hc-note, .hc-notes {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.4;
}
.tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.tag-ok { background: #243320; color: #b8e0a8; }
.tag-est { background: #3a2e18; color: #e0c08a; }
.tag-na { background: #2a2220; color: #9a8e80; }

.view-actions {
  margin: 8px 12px 4px;
  flex: 0 0 auto;
}
.btn-enter {
  appearance: none;
  width: 100%;
  border: 1px solid #5a4a32;
  background: #2a2318;
  color: var(--gold);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn-enter:hover { border-color: var(--gold); }
.va-block {
  margin: 0;
  text-align: center;
  padding: 10px 12px;
  border-radius: 10px;
  background: #2a1816;
  border: 1px solid #5a3030;
  color: #e0a090;
  font-weight: 700;
  font-size: 14px;
}
.va-hint {
  margin: 6px 2px 0;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
}

.stage-banner {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(92vw, 520px);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(40, 16, 14, 0.88);
  border: 1px solid rgba(193, 90, 74, 0.55);
  color: #f0c8bc;
  font-size: 12px;
  text-align: center;
  z-index: 3;
  pointer-events: none;
  backdrop-filter: blur(8px);
}
.stage-banner[hidden] { display: none; }

/* P2-3: solid guidance overlay for none / info-only halls */
.stage-empty {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px 20px;
  background: #0c0b0a;
  color: var(--text);
  text-align: center;
  pointer-events: none;
}
.stage-empty[hidden] { display: none; }
.stage-empty .se-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #e0a090;
}
.stage-empty .se-sub {
  margin: 0;
  max-width: 28rem;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  word-break: keep-all;
}
.hc-scale {
  margin: 8px 0 0;
  padding: 7px 10px;
  border-radius: 8px;
  background: #2a2318;
  border: 1px solid #5a4a32;
  color: #e0c08a;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  word-break: keep-all;
}
.hc-scale small {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

@media (max-width: 800px) {
  .hall-card { margin: 6px 10px 0; padding: 10px; }
  .stage-empty .se-title { font-size: 15px; }
  .stage-empty .se-sub { font-size: 12px; }
  .hc-head h2 { font-size: 15px; }
  .hc-grid { gap: 6px; }
  .view-actions { margin: 6px 10px 2px; }
  #panel {
    /* room for taller info card in peek state */
    transform: translateY(calc(100% - 168px));
  }
}


/* --- Credits overlay --- */
.credits-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(2px);
}
.credits-overlay[hidden] { display: none !important; }
.credits-panel {
  width: min(560px, 100%);
  max-height: min(82dvh, 720px);
  overflow: auto;
  background: #161310;
  border: 1px solid #3a332c;
  border-radius: 14px;
  box-shadow: var(--shadow);
  color: var(--text);
}
.credits-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: #161310;
  z-index: 1;
}
.credits-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.credits-body {
  padding: 12px 16px 18px;
  font-size: 13px;
  line-height: 1.55;
  color: #d8cfc0;
}
.credits-body h3 {
  margin: 14px 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--gold);
  text-transform: none;
}
.credits-body p { margin: 0 0 6px; word-break: keep-all; }
.credits-body ul {
  margin: 4px 0 8px;
  padding-left: 1.15em;
}
.credits-body li { margin: 0 0 4px; word-break: keep-all; }
.credits-body a { color: var(--gold); }
.credits-body code {
  font-size: 11.5px;
  background: #221e1a;
  padding: 1px 5px;
  border-radius: 4px;
  color: #e8dcc8;
}
.credits-disclaimer {
  margin: 0 0 8px !important;
  padding: 10px 12px;
  border-radius: 10px;
  background: #2a2318;
  border: 1px solid #5a4a32;
  color: #e0c08a;
  font-size: 12.5px;
  font-weight: 600;
}
.disclaimer .linkish,
button.linkish {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  margin-left: 4px;
  color: var(--gold);
  font: inherit;
  font-size: inherit;
  text-decoration: underline;
  cursor: pointer;
}
.disclaimer .linkish:hover,
button.linkish:hover { color: #f0d8a8; }

@media (max-width: 480px) {
  .header-actions { gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
  .header-actions button { padding: 6px 9px; font-size: 12px; }
  .credits-panel { max-height: 88dvh; }
  .credits-body { font-size: 12.5px; }
}
