:root {
  --stone-light: #d7cfbe;
  --stone-mid: #a79c86;
  --stone-dark: #5c5342;
  --stone-shadow: #29241c;
  --gold-bright: #ffe066;
  --gold-mid: #d4a338;
  --gold-dark: #7d5714;
  --parchment-bg: #f5ebd1;
  --parchment-border: #8b6528;
  --sierra-crimson: #9e1b24;
  --sierra-royal: #232a5c;
  --text-ink: #23180d;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  background: radial-gradient(circle at center, #1b1726 0%, #09070e 100%);
  color: #f4ecd8;
  font-family: "Georgia", "Palatino Linotype", "Book Antiqua", serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  overflow: hidden;
}

#crt-wrapper {
  width: 1280px;
  max-width: 100%;
  background: #1a1612;
  border: 4px solid var(--gold-mid);
  box-shadow:
    0 0 0 3px #2e200a,
    0 18px 50px rgba(0, 0, 0, 0.85),
    inset 0 0 18px rgba(0, 0, 0, 0.7);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
}

/* Sierra SCI1.1 Top Icon Bar */
#sierra-bar {
  height: 62px;
  background: linear-gradient(180deg, #cfc5b0 0%, #9f937c 48%, #7d725d 100%);
  border-bottom: 3px solid #3a3225;
  box-shadow: inset 0 2px 0 #ede6d6, inset 0 -2px 0 #524838;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  gap: 8px;
}

.icon-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.sierra-btn {
  height: 46px;
  padding: 3px 10px;
  background: linear-gradient(180deg, #e2d9c5 0%, #b5a992 55%, #8f836d 100%);
  border-top: 2px solid #f7f2e7;
  border-left: 2px solid #ebe3d1;
  border-right: 2px solid #4d4436;
  border-bottom: 2px solid #3b3327;
  border-radius: 3px;
  color: #1f1912;
  font-family: "Courier New", Courier, monospace;
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 0.4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.1s ease;
}

.sierra-btn:hover {
  filter: brightness(1.08);
}

.sierra-btn:active,
.sierra-btn.active {
  background: linear-gradient(180deg, #6e634f 0%, #8f836c 60%, #aca089 100%);
  border-top: 2px solid #362e22;
  border-left: 2px solid #42392b;
  border-right: 2px solid #dfd6c3;
  border-bottom: 2px solid #f0e8d8;
  color: #fff6c2;
  text-shadow: 1px 1px 0 #000;
}

.sierra-btn.highlight-btn {
  background: linear-gradient(180deg, #f5da82 0%, #c9962c 55%, #9c6f16 100%);
  border-top-color: #fff3c4;
  color: #211402;
}

.btn-glyph {
  font-size: 16px;
  line-height: 1.05;
}

.btn-label {
  margin-top: 2px;
  white-space: nowrap;
}

#inv-badge {
  display: inline-block;
  background: var(--sierra-crimson);
  color: #fff;
  font-style: normal;
  padding: 0 4px;
  border-radius: 6px;
  font-size: 10px;
}

.bar-divider {
  width: 3px;
  height: 44px;
  background: #4a4132;
  border-right: 1px solid #dfd6c3;
}

/* Active Item Box */
#active-item-slot {
  height: 46px;
  min-width: 104px;
  padding: 2px 8px;
  background: #231e29;
  border-top: 2px solid #120f16;
  border-left: 2px solid #120f16;
  border-right: 2px solid #d8ceb8;
  border-bottom: 2px solid #d8ceb8;
  border-radius: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.slot-caption {
  font-family: "Courier New", monospace;
  font-size: 10px;
  font-weight: 800;
  color: #c7bca5;
}

#active-item-img {
  width: 36px;
  height: 36px;
  image-rendering: pixelated;
}

#active-item-none {
  font-family: "Courier New", monospace;
  font-size: 11px;
  font-weight: 800;
  color: #887e6a;
}

/* Score & Subscriber Plaque */
#score-plaque {
  height: 48px;
  min-width: 215px;
  padding: 4px 10px;
  background: linear-gradient(180deg, #1b1528 0%, #0d0a14 100%);
  border: 2px solid var(--gold-mid);
  box-shadow: inset 0 0 8px rgba(255, 224, 102, 0.25);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-family: "Courier New", Courier, monospace;
}

.sub-counter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 900;
  font-size: 13px;
  color: var(--gold-bright);
  text-shadow: 1px 1px 0 #000;
}

.yt-gem {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 14px;
  background: #e01b24;
  color: #fff;
  font-size: 10px;
  border-radius: 3px;
}

.score-sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 700;
  color: #cfc4dc;
}

.room-tag {
  background: #352b47;
  color: #ffe066;
  padding: 0 5px;
  border-radius: 2px;
}

/* Viewport & Canvas */
#viewport-frame {
  position: relative;
  width: 100%;
  background: #000;
}

#canvas-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 116px);
  margin: 0 auto;
  overflow: hidden;
  background: #0d0b10;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

/* Edge Navigation Buttons */
.edge-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(28, 22, 16, 0.84);
  border: 2px solid var(--gold-mid);
  color: var(--gold-bright);
  padding: 10px 8px;
  font-family: "Courier New", monospace;
  font-weight: 900;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  z-index: 12;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.7);
  transition: background 0.15s ease, transform 0.15s ease;
}

.edge-nav:hover {
  background: rgba(145, 32, 40, 0.94);
  color: #fff;
}

#edge-flip-left {
  left: 8px;
  border-radius: 0 6px 6px 0;
}

#edge-flip-right {
  right: 8px;
  border-radius: 6px 0 0 6px;
}

.edge-arrow {
  font-size: 15px;
}

.edge-caption {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 1px;
  font-size: 10px;
}

/* Hover Hotspot Banner */
#hotspot-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(24, 18, 34, 0.92);
  border: 2px solid var(--gold-mid);
  color: #fff6cc;
  padding: 5px 18px;
  border-radius: 4px;
  font-family: "Courier New", Courier, monospace;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 0.4px;
  pointer-events: none;
  z-index: 15;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.75);
}

/* Classic Sierra King's Quest VI Portrait Dialog Box */
#sierra-dialog {
  position: absolute;
  inset: 0;
  background: rgba(8, 6, 14, 0.42);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 26px;
  z-index: 30;
}

.dialog-inner {
  width: min(920px, 92%);
  background: linear-gradient(180deg, #f7efd8 0%, #eadbb8 100%);
  border: 4px solid #78541b;
  outline: 3px solid #2b1d07;
  box-shadow:
    inset 0 0 0 3px #c89e47,
    0 18px 44px rgba(0, 0, 0, 0.85);
  border-radius: 6px;
  display: flex;
  gap: 18px;
  padding: 14px 18px;
  color: var(--text-ink);
}

#dialog-portrait-wrap {
  flex-shrink: 0;
  width: 158px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#dialog-portrait-img {
  width: 152px;
  height: 215px;
  object-fit: contain;
  image-rendering: pixelated;
  background: #27173b;
  border: 3px solid #b5852b;
  border-radius: 4px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

#dialog-speaker-plate {
  margin-top: 6px;
  width: 100%;
  text-align: center;
  background: #2b1d3d;
  color: var(--gold-bright);
  border: 2px solid #a87b24;
  padding: 3px 6px;
  font-family: "Courier New", monospace;
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.dialog-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

#dialog-title {
  font-family: "Courier New", Courier, monospace;
  font-weight: 900;
  font-size: 13px;
  color: #7d1922;
  letter-spacing: 0.7px;
  border-bottom: 2px solid #c9b07d;
  padding-bottom: 4px;
  margin-bottom: 8px;
  text-transform: uppercase;
}

#dialog-text {
  font-size: 18px;
  line-height: 1.48;
  color: #21160b;
  min-height: 108px;
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px dashed #b89e6c;
}

.dialog-hint {
  font-family: "Courier New", monospace;
  font-size: 12px;
  font-weight: 700;
  color: #6b532b;
}

.sierra-parchment-btn,
#dialog-next-btn {
  background: linear-gradient(180deg, #9e1b24 0%, #6e1017 100%);
  color: #fff6cc;
  border: 2px solid #d4a338;
  padding: 6px 16px;
  font-family: "Courier New", monospace;
  font-weight: 900;
  font-size: 13px;
  border-radius: 4px;
  cursor: pointer;
}

.sierra-parchment-btn.active {
  background: linear-gradient(180deg, #273478 0%, #17204d 100%);
  border-color: #ffe066;
}

/* Inventory Modal */
#inventory-modal {
  position: absolute;
  inset: 0;
  background: rgba(10, 8, 16, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 35;
}

.inv-window {
  width: min(680px, 92%);
  background: linear-gradient(180deg, #f5ebd1 0%, #e4d3aa 100%);
  border: 4px solid #78541b;
  outline: 3px solid #2b1d07;
  box-shadow: inset 0 0 0 3px #c89e47, 0 20px 50px rgba(0, 0, 0, 0.9);
  border-radius: 6px;
  padding: 16px 20px;
  color: var(--text-ink);
}

.inv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #b59659;
  padding-bottom: 6px;
}

.inv-header h2 {
  font-family: "Courier New", monospace;
  font-size: 16px;
  color: #6e131b;
}

.inv-x {
  background: #78171f;
  color: #fff;
  border: 2px solid #d4a338;
  width: 28px;
  height: 28px;
  font-weight: 900;
  cursor: pointer;
}

.inv-instructions {
  font-size: 13px;
  margin: 8px 0 10px;
  color: #4d391b;
}

#inv-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  min-height: 112px;
  background: #21192b;
  border: 3px inset #8b6528;
  padding: 12px;
  border-radius: 4px;
}

.inv-cell {
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid #6b532b;
  border-radius: 4px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  color: #f7eed7;
  font-family: "Courier New", monospace;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.inv-cell:hover,
.inv-cell.selected {
  border-color: var(--gold-bright);
  background: rgba(255, 224, 102, 0.16);
}

.inv-cell img {
  width: 56px;
  height: 56px;
  image-rendering: pixelated;
}

#inv-desc-box {
  margin-top: 10px;
  background: #efe0bc;
  border: 2px solid #a8874c;
  padding: 10px 12px;
  font-size: 14px;
  min-height: 52px;
  border-radius: 4px;
}

.inv-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Status Bar */
#status-bar {
  height: 36px;
  background: #14111b;
  border-top: 2px solid #594b34;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-family: "Courier New", Courier, monospace;
  font-size: 11px;
  color: #dfd5c0;
}

#quest-tracker strong {
  color: var(--gold-bright);
}

#status-controls-hint {
  display: flex;
  gap: 12px;
  color: #b5aa96;
}

#status-controls-hint strong {
  color: #ffe066;
}

.hidden {
  display: none !important;
}

/* Quick Room Jump Bar */
#room-jump-bar {
  height: 30px;
  background: linear-gradient(180deg, #241d30 0%, #16111f 100%);
  border-bottom: 2px solid #5c4b32;
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 4px;
  overflow-x: auto;
  font-family: "Courier New", monospace;
}

.jump-title {
  font-size: 10px;
  font-weight: 900;
  color: var(--gold-bright);
  margin-right: 2px;
}

.jump-pill {
  background: #332944;
  color: #dfd5c0;
  border: 1px solid #6e5a3b;
  border-radius: 3px;
  padding: 2px 7px;
  font-family: "Courier New", monospace;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.jump-pill:hover {
  background: #4d3d66;
  color: #fff;
}

.jump-pill.active {
  background: linear-gradient(180deg, #d4a338 0%, #9c6f16 100%);
  color: #1c1204;
  border-color: #fff3c4;
  font-weight: 900;
}

/* Map & Checklist Modal */
#map-modal {
  position: absolute;
  inset: 0;
  background: rgba(10, 8, 16, 0.76);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 36;
}

.map-window {
  width: min(860px, 94%);
}

.map-columns {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 16px;
  margin-top: 10px;
}

.map-col h3 {
  font-family: "Courier New", monospace;
  font-size: 13px;
  color: #78171f;
  border-bottom: 2px solid #c4a975;
  padding-bottom: 3px;
  margin-bottom: 6px;
}

.sierra-checklist {
  list-style: none;
  font-size: 13px;
  line-height: 1.45;
}

.sierra-checklist li {
  padding: 3px 6px;
  border-bottom: 1px dashed #cbb587;
}

.sierra-checklist li.done {
  color: #195c2a;
  font-weight: 700;
}

.map-grid-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.map-room-btn {
  background: linear-gradient(180deg, #2b213a 0%, #1a1424 100%);
  color: #ffe89e;
  border: 2px solid #a87b24;
  padding: 7px 8px;
  font-family: "Courier New", monospace;
  font-size: 11px;
  font-weight: 800;
  text-align: left;
  border-radius: 4px;
  cursor: pointer;
}

.map-room-btn:hover,
.map-room-btn.current {
  background: linear-gradient(180deg, #9e1b24 0%, #6e1017 100%);
  border-color: #ffe066;
  color: #fff;
}

/* Sierra Ending / Game Over Screen */
#ending-modal {
  position: absolute;
  inset: 0;
  background: rgba(6, 4, 12, 0.84);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 45;
}

.ending-window {
  width: min(860px, 92%);
  background: linear-gradient(180deg, #f7efd8 0%, #e4d1a4 100%);
  border: 5px solid #8b6528;
  outline: 3px solid #231707;
  box-shadow: inset 0 0 0 3px #d4a338, 0 24px 60px rgba(0, 0, 0, 0.95);
  border-radius: 8px;
  overflow: hidden;
  color: #21160b;
}

.ending-banner {
  background: linear-gradient(90deg, #7d1118 0%, #b31d28 50%, #7d1118 100%);
  color: #ffe066;
  font-family: "Courier New", monospace;
  font-weight: 900;
  font-size: 18px;
  text-align: center;
  padding: 10px 16px;
  border-bottom: 3px solid #d4a338;
  letter-spacing: 0.8px;
}

.ending-window.victory .ending-banner {
  background: linear-gradient(90deg, #1b4d3e 0%, #2a7a5e 50%, #1b4d3e 100%);
}

.ending-content {
  display: flex;
  gap: 18px;
  padding: 18px 22px;
  align-items: center;
}

.ending-portraits {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.ending-portraits img {
  width: 116px;
  height: 168px;
  object-fit: contain;
  image-rendering: pixelated;
  background: #27173b;
  border: 3px solid #b5852b;
  border-radius: 4px;
}

.ending-story h3 {
  font-family: "Courier New", monospace;
  font-size: 16px;
  color: #7d1922;
  margin-bottom: 8px;
}

.ending-story p {
  font-size: 16px;
  line-height: 1.5;
  margin-bottom: 12px;
  white-space: pre-line;
}

.ending-score-pill {
  display: inline-block;
  background: #241936;
  color: #ffe066;
  border: 2px solid #c9962c;
  padding: 5px 14px;
  border-radius: 4px;
  font-family: "Courier New", monospace;
  font-weight: 900;
  font-size: 13px;
}

.ending-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 22px;
  background: rgba(139, 101, 40, 0.16);
  border-top: 2px solid #c4a975;
}
