/* Dragon Stones — Terminal Stylesheet
   Dark terminal aesthetic with monospace font, clickable options, and semantic color classes.
*/

:root {
  --bg:      #0a0e14;
  --panel:   #0d1117;
  --border:  #30363d;
  --text:    #c8a882;
  --accent:  #39bae6;
  --success: #7fd962;
  --danger:  #f07171;
  --warning: #ffb454;
  --dim:     #7a6a52;
  --strong:  #f0e2c8;
  --gold:    #e6b539;
  --hover:   #1c2127;
  --active:  #2d333b;
}

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

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  line-height: 1.65;
  min-height: 100vh;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */

#app {
  max-width: 860px;
  margin: 24px auto;
  padding: 0 16px;
}

#terminal {
  background-color: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

/* ── Terminal Header Bar ─────────────────────────────────────────────────── */

#terminal-header {
  background-color: #161b22;
  border-bottom: 1px solid var(--border);
  padding: 9px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-red    { background-color: #f47067; }
.dot-yellow { background-color: #f6b566; }
.dot-green  { background-color: #57ab5a; }

#terminal-title {
  margin-left: 10px;
  color: var(--dim);
  font-size: 12px;
}

/* ── Output Area ─────────────────────────────────────────────────────────── */

#terminal-output {
  min-height: 520px;
  max-height: 74vh;
  overflow-y: auto;
  padding: 22px 28px;
  scroll-behavior: smooth;
}

#terminal-output::-webkit-scrollbar       { width: 6px; }
#terminal-output::-webkit-scrollbar-track { background: transparent; }
#terminal-output::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Input Area ──────────────────────────────────────────────────────────── */

#terminal-input-area {
  border-top: 1px solid var(--border);
  padding: 11px 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: #0f1419;
}

#terminal-prompt-indicator {
  color: var(--accent);
  font-weight: bold;
  flex-shrink: 0;
  font-size: 16px;
}

@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

#terminal-prompt-indicator.typing::after {
  content: '▋';
  animation: blink-cursor 1.1s step-end infinite;
  color: var(--accent);
  margin-left: 1px;
}

#terminal-input {
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: inherit;
  outline: none;
  flex: 1;
  display: none; /* shown only when text input is expected */
  caret-color: var(--accent);
}

#terminal-input::placeholder {
  color: var(--dim);
}

/* ── Text Lines ──────────────────────────────────────────────────────────── */

.line {
  margin-bottom: 3px;
}

.blank-line {
  margin-bottom: 6px;
}

.line strong { color: var(--strong); }
.line em     { color: var(--accent); font-style: normal; }
.line code   { color: var(--warning); background: #1c2127; padding: 0 3px; border-radius: 2px; }

.separator {
  color: var(--border);
  margin: 6px 0;
  user-select: none;
  letter-spacing: 1px;
}

/* ── Semantic Text Classes ───────────────────────────────────────────────── */

.title       { color: var(--accent); font-size: 17px; font-weight: bold; letter-spacing: 3px; margin-bottom: 3px; white-space: pre; }
.subtitle    { color: var(--dim); font-style: italic; }
.narration   { color: var(--text); font-style: italic; }
.step-header { color: var(--warning); font-weight: bold; }
.section-header { color: var(--warning); }
.prompt      { color: var(--accent); }
.player-input { color: var(--accent); font-style: italic; }

.success  { color: var(--success); }
.danger   { color: var(--danger); }
.warning  { color: var(--warning); }
.dim      { color: var(--dim); }
.bonus    { color: var(--success); }
.penalty  { color: var(--danger); }

/* Character sheet */
.char-name     { color: var(--accent); font-size: 15px; font-weight: bold; }
.char-subtitle { color: var(--dim); }
.char-stats    { color: var(--text); }
.char-xp       { color: var(--dim); font-size: 13px; }
.attributes    { color: var(--text); letter-spacing: 1px; }
.item          { color: var(--text); }
.hud           { color: var(--text); font-size: 13px; }

/* Class / race cards */
.card-title  { color: var(--accent); font-size: 15px; font-weight: bold; }
.card-quote  { color: var(--dim); font-style: italic; }
.card-desc   { color: var(--text); }
.card-stats  { color: var(--dim); }
.ability     { color: var(--text); margin-left: 2px; }

/* Attribute set lines */
.attr-set { color: var(--text); font-size: 13px; line-height: 1.5; }

/* ── Options ─────────────────────────────────────────────────────────────── */

.options-container {
  margin: 8px 0 12px 0;
}

.option {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 4px;
  margin-bottom: 2px;
  cursor: pointer;
  color: var(--accent);
  transition: background-color 0.08s ease, color 0.08s ease;
  user-select: none;
}

.option:hover {
  background-color: var(--hover);
  color: var(--strong);
}

.option:active {
  background-color: var(--active);
}

.option-focused {
  background-color: var(--active);
  color: var(--strong);
}

.option-selected {
  color: var(--success) !important;
}

.option-dimmed {
  color: var(--dim) !important;
  cursor: default;
}

.opt-num {
  color: var(--dim);
  min-width: 22px;
  flex-shrink: 0;
  font-size: 13px;
}

.opt-label {
  color: inherit;
}

.opt-sub {
  color: var(--dim);
  font-size: 12px;
  white-space: normal;
}

/* ── Tooltips ─────────────────────────────────────────────────────────────── */

.abbr {
  border-bottom: 1px dotted var(--dim);
  cursor: help;
  position: relative;
}

.abbr::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #161b22;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 100;
}

.abbr:hover::after {
  opacity: 1;
}

/* ── Map Overlay ─────────────────────────────────────────────────────────── */

#map-overlay {
  display:         none;
  position:        fixed;
  inset:           0;
  background:      rgba(0, 0, 0, 0.75);
  z-index:         100;
  align-items:     center;
  justify-content: center;
  outline:         none;
}

#map-panel {
  background:    var(--panel);
  border:        1px solid var(--border);
  border-radius: 6px;
  width:         min(960px, 92vw);
  height:        min(88vh, 700px);
  max-height:    88vh;
  display:       flex;
  flex-direction: column;
  overflow:      hidden;
  box-shadow:    0 8px 32px rgba(0, 0, 0, 0.6);
}

#map-header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         10px 16px;
  border-bottom:   1px solid var(--border);
  flex-shrink:     0;
}

#map-title {
  font-family:    monospace;
  font-size:      0.8rem;
  letter-spacing: 0.15em;
  color:          var(--strong);
}

#map-close {
  background:  transparent;
  border:      none;
  color:       var(--dim);
  font-size:   1rem;
  cursor:      pointer;
  padding:     2px 6px;
  border-radius: 3px;
  line-height: 1;
}
#map-close:hover { color: var(--strong); background: var(--border); }

#map-legend {
  display:      flex;
  gap:          16px;
  padding:      8px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink:  0;
}

.legend-item {
  font-size:   0.72rem;
  padding:     2px 8px;
  border-radius: 3px;
  font-family: monospace;
}
.legend-town       { background: #3a6b3a; color: #b8f0a8; border: 1px solid #7fd962; }
.legend-wilderness { background: #3a4a2a; color: #c8d8a0; border: 1px solid #a0b870; }
.legend-dungeon    { background: #4a2a2a; color: #e8b8b8; border: 1px solid #c87070; }
.legend-cave       { background: #2a2a3a; color: #b0b8e0; border: 1px solid #7080b8; }

#map-layer-tabs,
#map-level-tabs {
  display:      none; /* shown only in designer mode */
  gap:          6px;
  padding:      7px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink:  0;
  flex-wrap:    wrap;
}

.map-tab {
  background:    transparent;
  border:        1px solid var(--border);
  border-radius: 3px;
  color:         var(--dim);
  cursor:        pointer;
  font-family:   monospace;
  font-size:     0.72rem;
  padding:       2px 10px;
}
.map-tab:hover       { color: var(--text); border-color: var(--text); }
.map-tab-active      { background: var(--active); color: var(--strong); border-color: var(--accent); }

#map-svg-container {
  flex:     1;
  overflow: auto;
  padding:  8px;
}

#map-svg {
  width:  100%;
  height: 100%;
  min-height: 420px;
  display: block;
}

.map-edge {
  stroke:       #3a4040;
  stroke-width: 1.5;
}

.map-node { cursor: default; }

.map-node-pulse {
  fill:          none;
  stroke:        #f0e2c8;
  stroke-width:  1.5;
  opacity:       0.4;
  animation:     map-pulse 2s ease-in-out infinite;
}

@keyframes map-pulse {
  0%, 100% { opacity: 0.2; r: 28; }
  50%       { opacity: 0.6; r: 32; }
}

#map-tooltip {
  position:      fixed;
  display:       none;
  background:    #161b22;
  border:        1px solid var(--border);
  border-radius: 4px;
  padding:       8px 12px;
  max-width:     240px;
  pointer-events: none;
  z-index:       200;
  line-height:   1.55;
}

.map-tip-name {
  color:       var(--strong);
  font-weight: bold;
  font-size:   0.8rem;
  margin-bottom: 3px;
}

.map-tip-meta {
  color:     var(--dim);
  font-size: 0.7rem;
  margin-bottom: 4px;
}

.map-tip-desc {
  color:     var(--text);
  font-size: 0.75rem;
}

.map-label {
  font-family: monospace;
  font-size:   9px;
  pointer-events: none;
}

.map-label-id {
  font-size: 7px;
  opacity:   0.6;
}

/* ── Game Action Bar ─────────────────────────────────────────────────────── */

#game-action-bar {
  display:         none; /* shown only during game scene */
  justify-content: center;
  align-items:     center;
  flex-wrap:       wrap;
  gap:             2px;
  padding:         7px 16px;
  border-top:      1px solid var(--border);
  background:      #080c11;
}

.action-btn {
  display:     flex;
  align-items: center;
  gap:         5px;
  background:  transparent;
  border:      none;
  color:       var(--dim);
  font-family: 'Courier New', Courier, monospace;
  font-size:   12px;
  cursor:      pointer;
  padding:     3px 9px;
  border-radius: 3px;
  transition:  color 0.1s ease, background-color 0.1s ease;
  user-select: none;
}

.action-btn:hover {
  color:            var(--text);
  background-color: var(--hover);
}

.action-key {
  color:       #607060;
  font-size:   11px;
  flex-shrink: 0;
}

.action-sep {
  color:       #2a342a;
  font-size:   14px;
  user-select: none;
  padding:     0 2px;
}

.action-btn-active {
  color:            var(--strong);
  background-color: var(--hover);
}

.action-btn-active .action-key {
  color: var(--accent);
}

.action-btn-flash .action-label {
  color: var(--success);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  body { font-size: 13px; }
  #app { margin: 0; padding: 0; }
  #terminal { border-radius: 0; border-left: none; border-right: none; }
  #terminal-output { padding: 16px; }
  .opt-sub { display: none; } /* hide sub-labels on small screens */
}
