/* Morpheus in the Punderworld — Terminal Aesthetic */

:root {
  --green: #00ff88;
  --green-dim: #00cc66;
  --green-dark: #004422;
  --amber: #ffb300;
  --amber-dim: #cc8800;
  --red: #ff4444;
  --red-dim: #cc2222;
  --bg: #0a0a0a;
  --bg-panel: #0f0f0f;
  --text: #c8ffd4;
  --text-dim: #6a9a74;
  --text-faint: #2a4a32;
  --border: #1a3a22;
  --cursor-blink: 0.8s;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Courier New', Courier, monospace;
  font-size: 15px;
  line-height: 1.6;
  overflow: auto;
}

/* Scanline overlay */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  pointer-events: none;
  z-index: 1000;
}

/* --- Layout --- */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
  gap: 12px;
}

/* --- Header --- */
#header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-shrink: 0;
}

#title {
  color: var(--green);
  font-size: 18px;
  font-weight: bold;
  letter-spacing: 2px;
  text-transform: uppercase;
}

#subtitle {
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 1px;
}

#run-info {
  text-align: right;
  font-size: 12px;
  color: var(--text-dim);
}

/* --- Status Bar --- */
#status-bar {
  display: flex;
  gap: 24px;
  align-items: center;
  flex-shrink: 0;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.status-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.status-label {
  color: var(--text-faint);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.status-value {
  color: var(--green);
}

/* Dignity Meter */
#dignity-container {
  flex: 1;
}

#dignity-bar-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

#dignity-bar {
  flex: 1;
  height: 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

#dignity-fill {
  height: 100%;
  background: var(--green);
  transition: width 0.6s ease, background-color 0.3s ease;
  position: relative;
}

#dignity-fill::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 4px,
    rgba(0,0,0,0.15) 4px,
    rgba(0,0,0,0.15) 5px
  );
}

#dignity-fill.high { background: var(--green); }
#dignity-fill.mid { background: var(--amber); }
#dignity-fill.low { background: var(--red); }
#dignity-fill.shaking {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

#dignity-value {
  font-size: 12px;
  color: var(--text-dim);
  min-width: 60px;
}

/* Attempts */
#attempts-pips {
  display: flex;
  gap: 4px;
  margin-top: 3px;
}

.attempt-pip {
  width: 14px;
  height: 14px;
  border: 1px solid var(--green-dim);
  background: var(--green-dark);
}

.attempt-pip.used {
  background: transparent;
  border-color: var(--text-faint);
}

/* --- Main Output --- */
#output {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

#output::-webkit-scrollbar {
  width: 4px;
}

#output::-webkit-scrollbar-track {
  background: var(--bg);
}

#output::-webkit-scrollbar-thumb {
  background: var(--border);
}

.output-block {
  margin-bottom: 16px;
}

/* Text styles */
.text-narration {
  color: var(--text);
  white-space: pre-wrap;
}

.text-god {
  color: var(--amber);
  padding-left: 16px;
  border-left: 1px solid rgba(204, 136, 0, 0.5);
  margin: 6px 0 8px 0;
  white-space: pre-wrap;
}

.text-god-name {
  color: var(--amber-dim);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 2px;
  opacity: 0.6;
}

.text-system {
  color: var(--text-dim);
  font-size: 15px;
  font-style: italic;
}

.text-damage {
  color: var(--green);
  font-size: 12px;
  margin: 4px 0;
}

.text-damage.big {
  color: var(--green);
  font-size: 15px;
  font-weight: bold;
  text-shadow: 0 0 10px var(--green);
}

.text-damage.miss {
  color: var(--text-dim);
}

.text-player {
  color: #ffffff;
  font-size: 15px;
  font-weight: 500;
  background: var(--green-dark);
  border-left: 3px solid var(--green);
  padding: 10px 16px;
  margin-top: 24px;
  white-space: pre-wrap;
}

.text-player::before {
  content: '> ';
  color: var(--green);
}

.text-title {
  color: var(--green);
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 3px;
  text-align: center;
  text-shadow: 0 0 20px var(--green);
  margin: 8px 0;
}

.text-hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

.text-error {
  color: var(--red);
}

.text-transition {
  color: var(--text-dim);
  font-style: italic;
  text-align: center;
  padding: 8px 0;
}

.text-pun-analysis {
  color: var(--text-faint);
  font-size: 12px;
  margin-top: 2px;
}

/* Domain scan block */
.domain-scan {
  border: 1px solid var(--green-dark);
  background: #050f08;
  padding: 10px 14px;
  margin: 12px 0;
  font-size: 12px;
}

.scan-header {
  color: var(--green-dim);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.scan-row {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
  align-items: baseline;
}

.scan-label {
  color: var(--text-faint);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
  min-width: 80px;
}

.scan-value {
  color: var(--text-dim);
}

.scan-territory {
  color: var(--green-dim);
  line-height: 1.8;
}

.scan-territory .term {
  display: inline-block;
  margin-right: 12px;
  color: var(--green);
}

.scan-territory .term-note {
  color: var(--text-dim);
}

.scan-bio {
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.7;
  margin-top: 4px;
}

/* Encounter marker */
.encounter-header {
  color: var(--green-dim);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin-bottom: 12px;
}

/* --- Input Area --- */
#input-area {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

#input-prompt {
  display: flex;
  align-items: center;
  gap: 8px;
}

#input-prefix {
  color: var(--green);
  white-space: nowrap;
  font-size: 12px;
}

#pun-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  caret-color: var(--green);
}

#input-hint {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 6px;
  padding-left: 20px;
}

/* --- Screens --- */
#screen-title,
#screen-game-over,
#screen-victory {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  text-align: center;
  gap: 20px;
}

.screen-active {
  display: flex !important;
}

.big-text {
  color: var(--green);
  font-size: 22px;
  letter-spacing: 4px;
  text-transform: uppercase;
  text-shadow: 0 0 30px var(--green);
  line-height: 1.4;
}

.screen-body {
  color: var(--text-dim);
  max-width: 600px;
  line-height: 1.8;
}

.btn {
  background: transparent;
  border: 1px solid var(--green);
  color: var(--green);
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 10px 30px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:hover {
  background: var(--green);
  color: var(--bg);
}

.title-cursor {
  display: inline-block;
  margin-left: 4px;
  animation: cursor-blink 1s step-end infinite;
  font-weight: normal;
}

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

.btn-secondary {
  border-color: var(--text-dim);
  color: var(--text-dim);
}

.btn-secondary:hover {
  background: var(--text-dim);
  color: var(--bg);
}

/* Loading indicator */
#loading {
  display: none;
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 6px;
  padding-left: 20px;
}

#loading.visible {
  display: block;
}

.loading-dots::after {
  content: '...';
  animation: dots 1.2s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60% { content: '...'; }
  80%, 100% { content: ''; }
}

/* Flicker effect for damage */
@keyframes flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.flicker {
  animation: flicker 0.15s ease 3;
}

/* God-tier special effect */
@keyframes godtier {
  0% { text-shadow: 0 0 10px var(--green); }
  50% { text-shadow: 0 0 40px var(--green), 0 0 80px var(--amber); }
  100% { text-shadow: 0 0 10px var(--green); }
}

.godtier {
  animation: godtier 1s ease 2;
}

/* Doctrine knockout block — same treatment as player puns, used only for
   the home screen and opening narration doctrine lines */
.text-doctrine {
  color: #ffffff;
  font-size: 15px;
  font-weight: 500;
  background: var(--green-dark);
  border-left: 3px solid var(--green);
  padding: 10px 16px;
  margin: 16px 0;
  white-space: pre-wrap;
  font-style: italic;
}

/* Morpheus Notes footer reminder */
.scan-footer {
  color: var(--text-faint);
  font-size: 12px;
  font-style: italic;
  border-top: 1px solid var(--border);
  margin-top: 10px;
  padding-top: 8px;
}

/* Hide elements */
.hidden {
  display: none !important;
}

/* Ticker */
@keyframes ticker-scroll {
  0%   { transform: translateX(100vw); }
  100% { transform: translateX(-100%); }
}
#ticker-wrap:hover #ticker {
  animation-play-state: paused;
}
