/* Quest Engine v2 — Mobile-first landscape layout */

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

:root {
  --panel-width: 260px;
  --panel-bg: rgba(10, 10, 20, 0.92);
  --panel-border: rgba(100, 120, 140, 0.3);
  --text-primary: #d0d8e0;
  --text-muted: #708090;
  --accent: #4da6ff;
  --accent-dim: rgba(77, 166, 255, 0.3);
  --btn-bg: rgba(40, 50, 70, 0.8);
  --btn-hover: rgba(60, 80, 110, 0.9);
  --overlay-bg: rgba(5, 5, 15, 0.9);
  --radial-bg: rgba(15, 15, 30, 0.95);
  --danger: #ff4444;
  --success: #44ff88;
  --warning: #ffaa44;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text-primary);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#game-container {
  width: 100%;
  height: 100%;
  position: relative;
}

/* ==========================================
   UI BUTTONS (shared)
   ========================================== */

.ui-btn {
  display: block;
  width: 100%;
  max-width: 280px;
  margin: 8px auto;
  padding: 12px 24px;
  background: var(--btn-bg);
  color: var(--text-primary);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  font: 600 15px system-ui, sans-serif;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.ui-btn:hover, .ui-btn:active {
  background: var(--btn-hover);
  border-color: var(--accent);
}
.ui-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.ui-btn-secondary {
  background: transparent;
  border-color: var(--text-muted);
  color: var(--text-muted);
}

.panel-btn {
  width: 40px;
  height: 40px;
  background: var(--btn-bg);
  color: var(--text-primary);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.panel-btn:hover, .panel-btn:active {
  background: var(--btn-hover);
}

/* ==========================================
   TITLE SCREEN
   ========================================== */

#title-screen {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0a0a1a 0%, #1a1a3a 50%, #0a0a1a 100%);
}

.title-content {
  text-align: center;
  padding: 24px;
}

.title-content h1 {
  font-size: clamp(28px, 6vw, 56px);
  font-weight: 800;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
  color: #fff;
  text-shadow: 0 0 30px rgba(77, 166, 255, 0.4);
}

.title-content h2 {
  font-size: clamp(14px, 3vw, 24px);
  font-weight: 400;
  color: var(--text-muted);
  margin-bottom: 24px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.title-epigraph {
  font-style: italic;
  color: var(--text-muted);
  font-size: 14px;
  max-width: 400px;
  margin: 0 auto 32px;
  line-height: 1.5;
}

.title-menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* ==========================================
   CHARACTER CREATION
   ========================================== */

#char-creation {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  background: var(--overlay-bg);
  overflow-y: auto;
}

.char-panel {
  padding: 24px;
  max-width: 600px;
  text-align: center;
}

.char-panel h2 {
  font-size: 20px;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
  color: var(--accent);
}

.char-intro {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 20px;
}

.skill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.skill-option {
  background: var(--btn-bg);
  border: 2px solid var(--panel-border);
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  text-align: center;
}
.skill-option:hover { border-color: var(--accent-dim); }
.skill-option.selected {
  border-color: var(--accent);
  background: rgba(77, 166, 255, 0.1);
}

.skill-icon { font-size: 32px; margin-bottom: 8px; }
.skill-name { font-weight: 700; font-size: 13px; letter-spacing: 0.08em; margin-bottom: 6px; }
.skill-desc { font-size: 12px; color: var(--text-muted); line-height: 1.4; }

.char-status {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 12px;
}

/* ==========================================
   GAME SCREEN — landscape split layout
   ========================================== */

#game-screen {
  display: flex;
  width: 100%;
  height: 100%;
  flex-direction: row;
  background: #000;
}

/* --- Text Panel (left) --- */

#text-panel {
  width: var(--panel-width);
  min-width: var(--panel-width);
  height: 100%;
  background: var(--panel-bg);
  border-right: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  z-index: 10;
  transition: margin-left 0.25s ease;
}

#text-panel.collapsed {
  margin-left: calc(-1 * var(--panel-width));
}

#text-panel-header {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}

#text-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  font-size: 14px;
  line-height: 1.6;
  scrollbar-width: thin;
  scrollbar-color: var(--panel-border) transparent;
}

#text-content::-webkit-scrollbar { width: 4px; }
#text-content::-webkit-scrollbar-track { background: transparent; }
#text-content::-webkit-scrollbar-thumb { background: var(--panel-border); border-radius: 2px; }

#text-content .text-entry {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(100, 120, 140, 0.1);
}

#text-content .text-description { color: var(--text-primary); }
#text-content .text-action { color: var(--accent); }
#text-content .text-item { color: var(--success); }
#text-content .text-failure { color: var(--danger); font-style: italic; }
#text-content .text-locked { color: var(--warning); font-style: italic; }

#text-panel-footer {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--panel-border);
  flex-shrink: 0;
  justify-content: space-between;
}

.panel-collapse-btn { margin-left: auto; }

/* Expand button (visible when panel collapsed) */
.panel-expand-btn {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 15;
  width: 28px;
  height: 60px;
  background: var(--panel-bg);
  color: var(--text-muted);
  border: 1px solid var(--panel-border);
  border-left: none;
  border-radius: 0 6px 6px 0;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.panel-expand-btn:hover { color: var(--accent); }

/* --- Scene Area (right, fills remaining space) --- */

#scene-area {
  flex: 1;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#scene-image {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#scene-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#hotspot-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#scene-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 6px 16px;
  background: rgba(0, 0, 0, 0.6);
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  pointer-events: none;
}

/* ==========================================
   HOTSPOTS
   ========================================== */

.hotspot-area {
  position: absolute;
  cursor: pointer;
  pointer-events: all;
  border-radius: 4px;
  transition: box-shadow 0.2s;
}

.hotspot-area:hover,
.hotspot-area:active {
  box-shadow: inset 0 0 0 2px rgba(77, 166, 255, 0.5);
}

.hotspot-indicator {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.hotspot-area:hover .hotspot-indicator,
.hotspot-area:active .hotspot-indicator {
  opacity: 1;
}

.indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-exit { background: var(--success); }
.dot-npc { background: var(--accent); }
.dot-item { background: var(--warning); }
.dot-usable { background: var(--text-primary); }

.indicator-label {
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  letter-spacing: 0.04em;
}
.label-exit { color: var(--success); }
.label-npc { color: var(--accent); }
.label-item { color: var(--warning); }
.label-usable { color: var(--text-primary); }

/* ==========================================
   RADIAL MENU (circular layout)
   ========================================== */

#radial-menu {
  position: fixed;
  z-index: 100;
  /* Center point is positioned via left/top; items are offset from center */
  pointer-events: none;
  transform: translate(-50%, -50%);
}

#radial-menu.closing {
  animation: radialClose 0.15s ease-in forwards;
}

.radial-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.6;
  pointer-events: none;
}

.radial-item {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: all;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 14px;
  background: var(--radial-bg);
  color: var(--text-primary);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  font: 600 13px system-ui, sans-serif;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.12s;
  white-space: nowrap;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  min-width: 60px;
  text-align: center;
  animation: radialPop 0.2s ease-out;
}

@keyframes radialPop {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes radialClose {
  to { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}

.radial-item:hover, .radial-item:active {
  background: rgba(77, 166, 255, 0.2);
  border-color: var(--accent);
  transform: translate(-50%, -50%) scale(1.08);
}

.radial-item .radial-icon {
  font-size: 22px;
  line-height: 1;
}

.radial-item .radial-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.radial-item.radial-locked {
  color: var(--text-muted);
  cursor: default;
  opacity: 0.4;
  border-style: dashed;
}
.radial-item.radial-locked:hover {
  background: var(--radial-bg);
  border-color: var(--panel-border);
  transform: translate(-50%, -50%) scale(1);
}

.radial-item .radial-hint {
  font-size: 9px;
  color: var(--warning);
  font-weight: 400;
  opacity: 0.8;
}

.radial-item.radial-exit { border-color: rgba(68, 255, 136, 0.3); }
.radial-item.radial-exit .radial-label { color: var(--success); }
.radial-item.radial-npc { border-color: rgba(77, 166, 255, 0.3); }
.radial-item.radial-npc .radial-label { color: var(--accent); }
.radial-item.radial-take { border-color: rgba(255, 170, 68, 0.3); }
.radial-item.radial-take .radial-label { color: var(--warning); }

/* ==========================================
   OVERLAYS (inventory, menu)
   ========================================== */

#inventory-overlay, #menu-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlay-panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 20px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.overlay-header h3 {
  font-size: 16px;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.overlay-close {
  width: 36px;
  height: 36px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--panel-border);
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.overlay-close:hover { color: var(--text-primary); border-color: var(--accent); }

/* Inventory grid */
#inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.inventory-card {
  background: var(--btn-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s;
}
.inventory-card:hover { border-color: var(--accent); }
.inventory-card.selected { border-color: var(--accent); background: rgba(77, 166, 255, 0.1); }

.inventory-card .inv-icon { font-size: 28px; margin-bottom: 6px; }
.inventory-card .inv-name { font-size: 12px; font-weight: 600; }
.inventory-card .inv-desc { font-size: 11px; color: var(--text-muted); margin-top: 4px; line-height: 1.3; }

.inventory-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  padding: 20px;
}

/* Menu buttons */
.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ==========================================
   DIALOGUE
   ========================================== */

#dialogue-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 5vh;
}

#dialogue-box {
  background: var(--panel-bg);
  border: 1px solid var(--accent-dim);
  border-radius: 10px;
  padding: 20px 24px;
  max-width: 600px;
  width: 90%;
}

#dialogue-speaker {
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 8px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

#dialogue-text {
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 16px;
  color: var(--text-primary);
}

#dialogue-choices {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dialogue-speaker-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-right: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  vertical-align: middle;
  flex-shrink: 0;
}
.dialogue-speaker-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.dialogue-choice {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 16px;
  background: var(--btn-bg);
  color: var(--text-primary);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  font: 14px system-ui, sans-serif;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}
.dialogue-choice:hover, .dialogue-choice:active {
  background: var(--btn-hover);
  border-color: var(--accent);
}

.dialogue-choice .skill-tag {
  display: inline-block;
  padding: 1px 6px;
  margin-left: 6px;
  background: rgba(77, 166, 255, 0.2);
  color: var(--accent);
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  vertical-align: middle;
}

.dialogue-choice.dialogue-locked {
  color: var(--text-muted);
  cursor: default;
  opacity: 0.5;
}

/* ==========================================
   END / DEATH SCREENS
   ========================================== */

#end-screen, #death-screen {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

#end-screen { background: linear-gradient(135deg, #0a1a0a 0%, #1a2a1a 50%, #0a1a0a 100%); }
#death-screen { background: linear-gradient(135deg, #1a0a0a 0%, #2a1010 50%, #1a0a0a 100%); }

.end-panel, .death-panel {
  max-width: 500px;
}

.end-panel h2 { color: var(--success); font-size: 28px; margin-bottom: 16px; }
.death-panel h2 { color: var(--danger); font-size: 28px; margin-bottom: 16px; }
.death-icon { font-size: 64px; margin-bottom: 16px; }

#end-text, #death-text {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 24px;
}

#end-stats {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* ==========================================
   SCENE TRANSITIONS
   ========================================== */

.scene-fade-out {
  animation: fadeOut 0.35s ease-out forwards;
}
.scene-fade-in {
  animation: fadeIn 0.35s ease-in forwards;
}

@keyframes fadeOut { to { opacity: 0; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ==========================================
   ITEM FLASH (on pickup)
   ========================================== */

@keyframes itemFlash {
  0% { box-shadow: 0 0 0 0 rgba(255, 170, 68, 0.6); }
  50% { box-shadow: 0 0 15px 5px rgba(255, 170, 68, 0.3); }
  100% { box-shadow: none; }
}
.item-flash { animation: itemFlash 0.8s ease-out; }

/* ==========================================
   RESPONSIVE: portrait / narrow screens
   ========================================== */

@media (max-width: 600px), (max-aspect-ratio: 1/1) {
  :root { --panel-width: 200px; }

  #text-panel { display: none; }
  #text-panel.force-show { display: flex; }

  .panel-expand-btn { display: flex !important; }

  .radial-item { padding: 12px 16px; }
}

/* Landscape phones */
@media (max-height: 450px) {
  :root { --panel-width: 220px; }

  #scene-name {
    font-size: 11px;
    padding: 4px 12px;
  }

  .ui-btn { padding: 8px 16px; font-size: 13px; }
}
