/* =========================================================
  Retro Adventure Prototype Styles
  ---------------------------------------------------------
  Designed for a first-person point-and-click adventure UI.
  The main viewport is intentionally fixed at 466 x 200px,
  showing a slice of a 1864 x 200 panoramic background.
========================================================= */

:root {
  --page-bg: #101014;
  --panel-bg: #1b1b22;
  --panel-bg-dark: #121218;
  --panel-bg-light: #272733;
  --border-main: #626276;
  --border-bright: #a8a8c0;
  --text-main: #e8e3d0;
  --text-muted: #aaa48f;
  --accent: #d4b35f;
  --accent-dim: #7f6530;
  --danger: #9f3a3a;
  --success: #658f54;

  --viewport-width: 466px;
  --viewport-height: 200px;

  --ui-radius: 0;
  --pixel-border: 2px;
  --font-main: "Courier New", Courier, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(circle at top, #242433 0%, #101014 55%, #07070a 100%);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 14px;
  line-height: 1.4;
  image-rendering: pixelated;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

/* =========================================================
  Overall Game Shell
========================================================= */

.game-shell {
  width: min(100vw, 980px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px;
}

.game-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 12px;
}

.game-title-block,
.status-panel,
.viewport-panel,
.side-panel,
.dialog-panel,
.debug-panel {
  background: var(--panel-bg);
  border: var(--pixel-border) solid var(--border-main);
  box-shadow:
    0 0 0 2px #050507,
    inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.game-title-block {
  flex: 1;
  padding: 10px 12px;
}

.game-title {
  margin: 0;
  color: var(--accent);
  font-size: 22px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.game-subtitle {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

.status-panel {
  min-width: 210px;
  padding: 10px 12px;
  background: var(--panel-bg-dark);
}

.status-panel p {
  margin: 0 0 4px;
}

.status-panel p:last-child {
  margin-bottom: 0;
}

.status-panel strong {
  color: var(--accent);
}

/* =========================================================
  Main Layout
========================================================= */

.game-layout {
  display: grid;
  grid-template-columns: minmax(var(--viewport-width), 1fr) 280px;
  gap: 12px;
  align-items: start;
}

.viewport-panel {
  padding: 12px;
  background: linear-gradient(180deg, var(--panel-bg-light), var(--panel-bg));
}

/* =========================================================
  First-Person Viewport
  ---------------------------------------------------------
  JS should set:
    background-image: url(...)
    background-position: -Npx 0
========================================================= */

.viewport {
  position: relative;
  width: var(--viewport-width);
  height: var(--viewport-height);
  margin: 0 auto;
  overflow: hidden;
  background-color: #000;
  background-repeat: repeat-x;
  background-size: auto 200px;
  background-position: 0 0;
  border: 3px solid #050507;
  outline: 2px solid var(--border-bright);
  image-rendering: pixelated;
}

/* Optional overlay to make the viewport feel slightly CRT/old-screen. */
.viewport::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(
      rgba(255, 255, 255, 0.035) 50%,
      rgba(0, 0, 0, 0.055) 50%
    );
  background-size: 100% 4px;
  mix-blend-mode: soft-light;
}

.scene-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
}

/* =========================================================
  Scene Clickables
  These classes are intended for renderer.js-created elements.
========================================================= */

.scene-hotspot,
.scene-item,
.scene-npc,
.scene-shelf {
  position: absolute;
  border: 1px solid transparent;
  background: transparent;
  color: transparent;
  padding: 0;
}

.scene-hotspot:hover,
.scene-item:hover,
.scene-npc:hover,
.scene-shelf:hover,
.scene-hotspot:focus-visible,
.scene-item:focus-visible,
.scene-npc:focus-visible,
.scene-shelf:focus-visible {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 1px #000, 0 0 8px rgba(212, 179, 95, 0.75);
}

.scene-item img,
.scene-npc img {
  display: block;
  image-rendering: pixelated;
  pointer-events: none;
}

.scene-label {
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%);
  display: none;
  min-width: max-content;
  padding: 2px 5px;
  color: #101014;
  background: var(--accent);
  border: 1px solid #050507;
  font-size: 11px;
  white-space: nowrap;
}

.scene-hotspot:hover .scene-label,
.scene-item:hover .scene-label,
.scene-npc:hover .scene-label,
.scene-shelf:hover .scene-label {
  display: block;
}

/* =========================================================
  Movement Controls
========================================================= */

.movement-controls {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
}

.control-button {
  height: 48px;
  color: var(--text-main);
  background: linear-gradient(180deg, #38384a, #191920);
  border: 2px solid var(--border-main);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.12),
    inset -2px -2px 0 rgba(0, 0, 0, 0.55),
    0 2px 0 #050507;
  font-size: 22px;
}

.control-button:hover:not(:disabled),
.control-button:focus-visible:not(:disabled) {
  color: #101014;
  background: var(--accent);
  border-color: var(--border-bright);
  outline: none;
}

.control-button:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.08),
    inset -2px -2px 0 rgba(0, 0, 0, 0.5);
}

.forward-button {
  color: var(--accent);
}

/* =========================================================
  Side Panel
========================================================= */

.side-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  background: var(--panel-bg-dark);
}

.side-panel h2,
.dialog-speaker {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.action-panel,
.inventory-panel,
.local-panel {
  padding: 10px;
  background: var(--panel-bg);
  border: 1px solid var(--border-main);
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.action-button {
  min-height: 34px;
  color: var(--text-main);
  background: #20202a;
  border: 1px solid var(--border-main);
  box-shadow: inset -1px -1px 0 #050507;
}

.action-button:hover,
.action-button:focus-visible,
.action-button.is-selected {
  color: #101014;
  background: var(--accent);
  border-color: var(--border-bright);
  outline: none;
}

.selection-readout {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

.selection-readout strong {
  color: var(--text-main);
}

/* =========================================================
  Inventory and Visible Object Lists
========================================================= */

.inventory-list,
.visible-object-list {
  display: grid;
  gap: 6px;
  min-height: 72px;
}

.inventory-list:empty::before,
.visible-object-list:empty::before {
  content: "None";
  display: block;
  padding: 8px;
  color: var(--text-muted);
  background: var(--panel-bg-dark);
  border: 1px dashed var(--border-main);
  font-size: 12px;
}

.inventory-item,
.visible-object-button {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 36px;
  padding: 4px 6px;
  color: var(--text-main);
  text-align: left;
  background: #20202a;
  border: 1px solid var(--border-main);
}

.inventory-item:hover,
.visible-object-button:hover,
.inventory-item:focus-visible,
.visible-object-button:focus-visible,
.inventory-item.is-selected,
.visible-object-button.is-selected {
  color: #101014;
  background: var(--accent);
  border-color: var(--border-bright);
  outline: none;
}

.inventory-item img,
.visible-object-button img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  image-rendering: pixelated;
}

.inventory-item span,
.visible-object-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================================================
  Dialog / Description Panel
========================================================= */

.dialog-panel {
  margin-top: 12px;
  padding: 12px;
  background: #15151c;
}

.dialog-text {
  min-height: 72px;
  padding: 10px;
  color: var(--text-main);
  background: #08080c;
  border: 1px solid var(--border-main);
}

.dialog-choices {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.dialog-choice-button {
  width: 100%;
  padding: 8px 10px;
  color: var(--text-main);
  text-align: left;
  background: #20202a;
  border: 1px solid var(--border-main);
}

.dialog-choice-button:hover,
.dialog-choice-button:focus-visible {
  color: #101014;
  background: var(--accent);
  border-color: var(--border-bright);
  outline: none;
}

/* =========================================================
  Debug Panel
========================================================= */

.debug-panel {
  margin-top: 12px;
  padding: 10px 12px;
  color: var(--text-muted);
  background: #0d0d12;
}

.debug-panel summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: bold;
}

.debug-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.debug-grid p {
  margin: 0;
  padding: 6px;
  background: #050507;
  border: 1px solid #333342;
}

.debug-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.debug-buttons button {
  min-width: 72px;
  padding: 6px 10px;
  color: var(--text-main);
  background: #20202a;
  border: 1px solid var(--border-main);
}

.debug-buttons button:hover,
.debug-buttons button:focus-visible {
  color: #101014;
  background: var(--accent);
  outline: none;
}

/* =========================================================
  Utility State Classes
========================================================= */

.is-hidden {
  display: none !important;
}

.is-muted {
  opacity: 0.55;
}

.is-locked {
  color: var(--danger);
}

.is-unlocked {
  color: var(--success);
}

/* =========================================================
  Responsive Layout
  Keeps the viewport fixed but stacks panels on smaller screens.
========================================================= */

@media (max-width: 820px) {
  .game-shell {
    width: 100%;
    padding: 10px;
  }

  .game-header {
    display: grid;
  }

  .status-panel {
    min-width: 0;
  }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: 1fr;
  }

  .debug-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  :root {
    --viewport-width: 466px;
    --viewport-height: 200px;
  }

  .viewport-panel {
    overflow-x: auto;
  }

  .viewport {
    margin-left: 0;
    margin-right: 0;
  }
}
