:root {
  --ink: #180b06;
  --panel: #26130c;
  --paper: #f6d0b7;
  --accent: #ff6b31;
  --muted: #b9866e;
  --line: rgba(246, 208, 183, 0.2);
  --success: #73d99b;
  --danger: #ff8a70;
  --sans: Helvetica, Arial, sans-serif;
  --mono: "Courier New", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--paper);
  background: var(--ink);
  font-family: var(--sans);
}

button, input, select, textarea { font: inherit; }

[hidden] { display: none !important; }
.filter-definitions { position: absolute; width: 0; height: 0; overflow: hidden; }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.gate-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 80% 10%, rgba(255, 107, 49, 0.14), transparent 30%),
    var(--ink);
}

.gate-card {
  width: min(620px, 100%);
  padding: clamp(28px, 6vw, 62px);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.35);
}

.gate-identity {
  width: min(500px, 100%);
  margin: 0 auto 18px;
  isolation: isolate;
}

.gate-identity img {
  display: block;
  height: auto;
  mix-blend-mode: screen;
}

.gate-saujana-logo {
  width: 29%;
  margin: 0 auto 15px;
}

.gate-house-logo { width: 100%; }
.gate-index { margin: 0; color: var(--accent); font: 700 9px/1.4 var(--mono); letter-spacing: 0.12em; }
.gate-copy { max-width: 440px; margin: 20px 0 26px; color: var(--muted); font-size: 15px; line-height: 1.5; }
.gate-copy strong { display: block; margin-bottom: 3px; color: var(--paper); font-size: 20px; line-height: 1.25; }
.gate-copy span { display: block; }
.gate-card form { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 10px; }
.gate-card form button, .preview-button {
  min-height: 46px;
  padding: 0 22px;
  color: var(--ink);
  background: var(--accent);
  border: 0;
  font-weight: 800;
  cursor: pointer;
}
.gate-card form button { min-width: 150px; }
.gate-card input::placeholder { color: var(--muted); opacity: 0.72; }
.preview-button { width: 100%; margin-top: 10px; color: var(--paper); background: transparent; border: 1px solid var(--line); }
.gate-result { min-height: 20px; margin: 12px 0 0; color: var(--danger); font-size: 13px; }

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding: 22px clamp(20px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
}

.brand-button { margin: 0; padding: 0; background: transparent; border: 0; cursor: pointer; }

.admin-header img {
  display: block;
  width: min(330px, 48vw);
  height: auto;
}

.admin-header .admin-house-logo {
  width: min(350px, 48vw);
  filter: brightness(0) saturate(100%) invert(87%) sepia(18%) saturate(665%) hue-rotate(326deg) brightness(105%) contrast(93%);
}

.header-tools { display: flex; align-items: center; gap: 18px; text-align: right; }
.admin-header p, .admin-header h1 { margin: 0; }
.admin-header p { color: var(--muted); font: 700 10px/1.4 var(--mono); letter-spacing: 0.12em; }
#lock-button { padding: 10px 13px; color: var(--muted); background: transparent; border: 1px solid var(--line); font: 700 9px/1 var(--mono); cursor: pointer; }

.room-nav { display: flex; gap: 0; padding: 0 clamp(18px, 4vw, 60px); border-bottom: 1px solid var(--line); }
.room-nav button { padding: 13px 16px; color: var(--muted); background: transparent; border: 0; border-left: 1px solid var(--line); font: 700 9px/1 var(--mono); letter-spacing: 0.08em; cursor: pointer; }
.room-nav button:last-child { border-right: 1px solid var(--line); }
.room-nav button.is-active { color: var(--ink); background: var(--paper); }

main { width: min(1440px, 100%); margin: 0 auto; padding: 28px clamp(18px, 4vw, 60px) 80px; }

.status-panel {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  padding: 14px 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
}

.status-panel strong, .status-panel p { margin: 0; }
.status-panel strong { color: var(--paper); font: 700 11px/1.4 var(--mono); letter-spacing: 0.1em; }
.status-panel p { margin-top: 2px; font-size: 13px; }

.status-dot { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: var(--muted); }
.status-panel.is-connected .status-dot { background: var(--success); box-shadow: 0 0 16px rgba(115, 217, 155, 0.7); }
.status-panel.is-error .status-dot { background: var(--danger); }

.admin-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.7fr); gap: 24px; }
.workspace, .library-panel { padding: clamp(20px, 3vw, 38px); background: var(--panel); border: 1px solid var(--line); }

.section-title { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 30px; }
.section-title > span { display: grid; place-items: center; width: 32px; height: 32px; color: var(--ink); background: var(--accent); font: 800 11px/1 var(--mono); }
.section-title p, .section-title h2, .section-title h3 { margin: 0; }
.section-title p { color: var(--muted); font: 700 9px/1.4 var(--mono); letter-spacing: 0.12em; }
.section-title h2, .section-title h3 { font-size: clamp(28px, 4vw, 52px); line-height: 0.95; letter-spacing: -0.04em; }
.section-title.compact h2, .section-title.compact h3 { font-size: 30px; }

.lobby-view { padding: clamp(20px, 4vw, 54px) 0; }
.lobby-heading { margin-bottom: 28px; }
.lobby-heading h2 { margin: 6px 0 0; font-size: clamp(54px, 9vw, 112px); line-height: 0.82; letter-spacing: -0.065em; }
.room-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.room-card { min-height: 430px; padding: clamp(24px, 4vw, 48px); color: var(--paper); background: var(--panel); border: 1px solid var(--line); text-align: left; cursor: pointer; }
.room-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.room-card > span { color: var(--accent); font: 700 9px/1.4 var(--mono); letter-spacing: 0.12em; }
.scan-room-index { display: flex; align-items: center; gap: 8px; }
.scan-room-index img {
  display: block;
  width: 104px;
  height: auto;
  filter: brightness(0) saturate(100%) invert(51%) sepia(87%) saturate(2846%) hue-rotate(338deg) brightness(101%) contrast(101%);
}
.room-card > strong { display: block; margin-top: 28px; font-size: clamp(55px, 8vw, 96px); line-height: 0.82; letter-spacing: -0.06em; }
.room-card p { max-width: 430px; margin: 32px 0; color: var(--muted); font-size: 15px; line-height: 1.55; }
.room-card b { display: block; margin-top: auto; color: var(--paper); font: 700 10px/1 var(--mono); letter-spacing: 0.08em; }
.library-card { background: #201916; }
.map-card { background: #302015; }
.room-grid .room-card { display: flex; flex-direction: column; min-height: 390px; }
.room-grid .room-card > strong { font-size: clamp(52px, 6vw, 82px); }

.room-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin: 18px 0 28px; }
.room-heading h2 { margin: 7px 0 0; font-size: clamp(54px, 9vw, 108px); line-height: 0.82; letter-spacing: -0.06em; }
.room-heading > p { width: min(410px, 42%); margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }

.library-blueprint { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.library-blueprint article { min-height: 230px; padding: 26px; background: var(--panel); border: 1px solid var(--line); }
.library-blueprint span { color: var(--accent); font: 700 9px/1 var(--mono); }
.library-blueprint h3 { margin: 30px 0 12px; font-size: 32px; letter-spacing: -0.04em; }
.library-blueprint p { max-width: 440px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.coming-soon { display: flex; justify-content: space-between; gap: 18px; margin-top: 14px; padding: 18px; background: var(--accent); color: var(--ink); font: 700 9px/1.3 var(--mono); letter-spacing: 0.08em; }

.form-row { display: grid; grid-template-columns: 1fr 180px; gap: 14px; }
label > span:first-child { display: block; margin-bottom: 8px; color: var(--muted); font: 700 9px/1.3 var(--mono); letter-spacing: 0.1em; }
input[type="date"], input[type="text"], input[type="password"] {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 0;
}

.form-help { max-width: 680px; margin: 20px 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.upload-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.upload-card { position: relative; display: block; min-width: 0; padding: 12px; background: var(--ink); border: 1px solid var(--line); cursor: pointer; }
.upload-card:hover, .upload-card.has-file, .upload-card.is-dragging { border-color: var(--accent); }
.upload-card.is-dragging { background: rgba(255, 107, 49, 0.08); }
.upload-card strong { display: block; min-height: 38px; margin: 6px 0 10px; font-size: 15px; }
.upload-number { color: var(--accent) !important; font: 700 9px/1 var(--mono) !important; }
.upload-preview { position: relative; display: grid; place-items: center; aspect-ratio: 1; overflow: hidden; color: var(--muted); background: #0d0604; }
.upload-preview img { width: 100%; height: 100%; object-fit: contain; }
.upload-preview > span { font: 700 9px/1.4 var(--mono); letter-spacing: 0.08em; }
.upload-card input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.token-field { display: block; margin-top: 18px; }
.publish-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 20px; }
.publish-check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.publish-check span { margin: 0 !important; color: inherit !important; font: inherit !important; letter-spacing: normal !important; }

#publish-button {
  min-height: 50px;
  padding: 0 24px;
  color: var(--ink);
  background: var(--accent);
  border: 0;
  font-weight: 800;
  cursor: pointer;
}
#publish-button:disabled { cursor: wait; opacity: 0.55; }

progress { width: 100%; height: 6px; margin-top: 18px; accent-color: var(--accent); }
.form-result { min-height: 20px; margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.form-result.is-error { color: var(--danger); }
.form-result.is-success { color: var(--success); }

.comparison-list {
  display: grid;
  gap: 8px;
  max-height: clamp(340px, 58vh, 680px);
  padding-right: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--muted) transparent;
  scrollbar-width: thin;
}
.comparison-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px; background: var(--ink); border: 1px solid var(--line); }
.comparison-item strong, .comparison-item span { display: block; }
.comparison-item strong { font-size: 14px; }
.comparison-item span { margin-top: 3px; color: var(--muted); font: 700 9px/1.3 var(--mono); }
.comparison-item-actions { display: flex; align-items: center; gap: 8px; }
.comparison-item img { width: 52px; height: 52px; object-fit: contain; background: #0d0604; }
.comparison-remove {
  min-height: 52px;
  padding: 0 10px;
  color: var(--danger);
  background: transparent;
  border: 1px solid rgba(255, 138, 112, 0.35);
  font: 700 8px/1 var(--mono);
  letter-spacing: 0.08em;
  cursor: pointer;
}
.comparison-remove:hover { color: var(--ink); background: var(--danger); }
.comparison-remove:disabled { cursor: not-allowed; opacity: 0.4; }
.empty-state { color: var(--muted); font-size: 13px; }

.future-card { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.future-card p, .future-card h3 { margin: 0; }
.future-card p { color: var(--accent); font: 700 9px/1.4 var(--mono); letter-spacing: 0.12em; }
.future-card h3 { margin-top: 5px; font-size: 24px; line-height: 0.98; }
.future-card span { display: block; margin-top: 12px; color: var(--muted); font-size: 13px; line-height: 1.55; }

.map-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin: 30px 0 18px; background: var(--line); border: 1px solid var(--line); }
.map-stats div { min-height: 105px; padding: 17px 22px; background: var(--panel); }
.map-stats strong { display: block; font-size: 38px; line-height: 1; letter-spacing: -0.06em; }
.map-stats span, .map-journey span { display: block; margin-top: 10px; color: var(--accent); font: 700 9px/1.3 var(--mono); letter-spacing: 0.11em; }
.map-journey { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
.map-journey > div { padding: 21px 24px; background: rgba(255, 107, 49, 0.07); border: 1px solid rgba(255, 107, 49, 0.28); }
.map-journey span { margin-top: 0; }
.map-journey p { max-width: 580px; margin: 10px 0 0; font-size: 14px; line-height: 1.55; }
.map-toolbar { display: grid; grid-template-columns: minmax(210px, 1fr) 150px 190px auto; align-items: end; gap: 10px; padding: 20px; background: var(--panel); border: 1px solid var(--line); }
.map-toolbar label, .map-form-grid label { min-width: 0; }
.map-toolbar input, .map-toolbar select, .map-form-grid input, .map-form-grid select, .map-form-grid textarea { width: 100%; min-height: 46px; padding: 10px 12px; color: var(--paper); background: var(--ink); border: 1px solid var(--line); border-radius: 0; }
.map-form-grid textarea { resize: vertical; }
.map-toolbar input::placeholder, .map-form-grid input::placeholder { color: var(--muted); opacity: 0.75; }
#map-add, .map-form-actions button { min-height: 46px; padding: 0 16px; color: var(--ink); background: var(--accent); border: 0; font: 800 10px/1 var(--mono); cursor: pointer; }
.map-feedback { min-height: 18px; margin: 12px 0; color: var(--muted); font-size: 12px; }
.map-feedback.is-error, #map-save-status.is-error { color: var(--danger); }
.map-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.map-item { display: flex; flex-direction: column; min-width: 0; min-height: 305px; padding: 22px; background: var(--panel); border: 1px solid var(--line); }
.map-item:hover { border-color: rgba(255, 107, 49, 0.55); }
.map-item-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; color: var(--accent); font: 700 9px/1.3 var(--mono); letter-spacing: 0.08em; }
.map-item h3 { margin: 20px 0 8px; font-size: 27px; line-height: 1; letter-spacing: -0.035em; }
.map-item > p { margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.map-item-details { display: grid; gap: 9px; margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }
.map-item-details div { display: grid; grid-template-columns: 80px 1fr; gap: 8px; font-size: 12px; line-height: 1.4; }
.map-item-details b { color: var(--muted); font: 700 9px/1.5 var(--mono); }
.map-item-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.map-item-actions a, .map-item-actions button { display: inline-flex; align-items: center; min-height: 33px; padding: 0 10px; color: var(--paper); background: transparent; border: 1px solid var(--line); text-decoration: none; font: 700 9px/1 var(--mono); letter-spacing: 0.05em; cursor: pointer; }
.map-item-actions a:hover, .map-item-actions button:hover { color: var(--ink); background: var(--paper); }
.map-item-actions a:first-child { border-color: var(--accent); }
.map-empty { grid-column: 1 / -1; padding: 36px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); }
.map-editor { position: fixed; z-index: 50; inset: max(3vh, 14px) max(calc((100vw - 860px) / 2), 14px); padding: clamp(20px, 3vw, 36px); overflow-y: auto; color: var(--paper); background: #25120b; border: 1px solid var(--accent); box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.7); }
.has-map-editor { overflow: hidden; }
.map-editor-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; margin-bottom: 26px; }
.map-editor-head h3 { margin: 5px 0 0; font-size: 44px; line-height: 0.95; letter-spacing: -0.05em; }
#map-editor-close { padding: 9px; color: var(--muted); background: transparent; border: 1px solid var(--line); font: 700 10px/1 var(--mono); cursor: pointer; }
.map-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.map-form-grid .map-wide { grid-column: 1 / -1; }
.map-form-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 24px; }
#map-save-status { color: var(--muted); font-size: 12px; }

@media (max-width: 900px) {
  .room-grid, .map-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-grid { grid-template-columns: 1fr; }
  .upload-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .room-heading { display: block; }
  .room-heading > p { width: auto; margin-top: 18px; }
}

@media (max-width: 620px) {
  .admin-header { align-items: flex-start; }
  .header-tools > p { display: none; }
  .room-nav { overflow-x: auto; }
  .room-nav button { flex: 0 0 auto; }
  .gate-card form { grid-template-columns: 1fr; }
  .gate-card form button { width: 100%; }
  .room-grid, .library-blueprint, .map-grid, .map-journey { grid-template-columns: 1fr; }
  .map-stats { grid-template-columns: repeat(2, 1fr); }
  .map-toolbar, .map-form-grid { grid-template-columns: 1fr; }
  .map-editor { inset: 0; border: 0; }
  .map-form-actions { align-items: stretch; flex-direction: column; }
  .room-card { min-height: 330px; }
  .form-row, .upload-grid { grid-template-columns: 1fr; }
  .upload-card { display: grid; grid-template-columns: 36px 1fr 96px; align-items: center; gap: 8px; }
  .upload-card strong { min-height: 0; margin: 0; }
  .upload-preview { width: 96px; }
  .publish-row { align-items: stretch; flex-direction: column; }
}
