/* ============================================================
   PUBLISH OR PERISH — CRT Terminal Stylesheet
   ============================================================ */

/* --- Reset & Base ------------------------------------------ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --phosphor: #00ff41;
  --phosphor-dim: #00aa2a;
  --phosphor-bright: #ccffcc;
  --phosphor-glow: rgba(0, 255, 65, 0.75);
  --screen-bg: #001400;
  --bezel-bg: #1c1c1c;
  --bezel-dark: #0f0f0f;
  --error-red: #ff4136;
  --error-glow: rgba(255, 65, 54, 0.7);
  --font-mono: 'Share Tech Mono', 'Courier New', Courier, monospace;
  --font-size: 14px;
  --line-height: 1.65;
}

html, body {
  height: 100%;
  width: 100%;
}

body.crt-body {
  background: #0a0a0a;
  background-image:
    radial-gradient(ellipse at center, #1a1a1a 0%, #050505 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  font-family: var(--font-mono);
}

/* --- Monitor Outer Shell ------------------------------------ */
.monitor-outer {
  width: 100%;
  max-width: 860px;
}

.monitor-bezel {
  background: var(--bezel-bg);
  border-radius: 20px 20px 16px 16px;
  padding: 28px 28px 0 28px;
  box-shadow:
    inset 0 2px 6px rgba(255,255,255,0.04),
    inset 0 -4px 12px rgba(0,0,0,0.8),
    0 8px 32px rgba(0,0,0,0.9),
    0 24px 80px rgba(0,0,0,0.7),
    0 2px 0 #2a2a2a;
  position: relative;
}

/* Subtle top highlight on bezel */
.monitor-bezel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 16px;
  right: 16px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
  border-radius: 50%;
}

/* --- Screen Inner ------------------------------------------- */
.screen-inner {
  background: var(--screen-bg);
  border-radius: 10px 10px 8px 8px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 72vh;
  min-height: 440px;
  max-height: 680px;

  /* Inner glow on the screen edges */
  box-shadow:
    inset 0 0 30px rgba(0, 30, 0, 0.9),
    inset 0 0 60px rgba(0, 0, 0, 0.5),
    0 0 20px rgba(0, 255, 65, 0.08);

  /* Subtle CRT curvature illusion via slight perspective */
  border: 1px solid #002200;

  animation: crt-flicker 5s infinite;
}

/* --- CRT Flicker -------------------------------------------- */
@keyframes crt-flicker {
  0%   { opacity: 1.0; }
  91%  { opacity: 1.0; }
  92%  { opacity: 0.97; }
  93%  { opacity: 1.0; }
  95%  { opacity: 0.985; }
  96%  { opacity: 1.0; }
  100% { opacity: 1.0; }
}

/* Occasional stronger flicker for realism */
@keyframes crt-flicker-strong {
  0%   { opacity: 1.0; }
  50%  { opacity: 0.92; }
  100% { opacity: 1.0; }
}

/* --- Scanlines Overlay -------------------------------------- */
.scanlines {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.12) 2px,
    rgba(0, 0, 0, 0.12) 4px
  );
  pointer-events: none;
  z-index: 20;
  border-radius: inherit;
}

/* --- Vignette Overlay --------------------------------------- */
.vignette {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 50%,
    rgba(0, 0, 0, 0.45) 100%
  );
  pointer-events: none;
  z-index: 15;
  border-radius: inherit;
}

/* --- Status Bar --------------------------------------------- */
#status-bar {
  flex-shrink: 0;
  background: #000e00;
  border-bottom: 1px solid #002800;
  padding: 5px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 0 6px;
  font-size: 11px;
  color: var(--phosphor-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  position: relative;
  z-index: 5;
}

#status-bar span {
  white-space: nowrap;
}

.status-sep {
  color: #004400;
  user-select: none;
}

/* --- Output Log --------------------------------------------- */
#output-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 8px 20px;
  position: relative;
  z-index: 5;
  scroll-behavior: smooth;
}

/* Scrollbar styling */
#output-log::-webkit-scrollbar {
  width: 6px;
}
#output-log::-webkit-scrollbar-track {
  background: transparent;
}
#output-log::-webkit-scrollbar-thumb {
  background: #003300;
  border-radius: 3px;
}
#output-log::-webkit-scrollbar-thumb:hover {
  background: #005500;
}

/* --- Output Lines ------------------------------------------- */
.output-line {
  color: var(--phosphor);
  font-family: var(--font-mono);
  font-size: var(--font-size);
  line-height: var(--line-height);
  white-space: pre-wrap;
  word-break: break-word;
  text-shadow: 0 0 7px var(--phosphor-glow);
  margin-bottom: 0;
}

.output-line.blank {
  height: calc(var(--font-size) * var(--line-height));
}

.output-line.separator {
  color: #004400;
  text-shadow: none;
  letter-spacing: 0.2em;
}

.output-line.txt-bright {
  color: var(--phosphor-bright);
  text-shadow: 0 0 10px rgba(200,255,200,0.6);
  letter-spacing: 0.04em;
}

.output-line.txt-dim {
  color: var(--phosphor-dim);
  text-shadow: 0 0 4px rgba(0,170,42,0.4);
}

.output-line.txt-red {
  color: var(--error-red);
  text-shadow: 0 0 8px var(--error-glow);
}

.output-line.txt-red-bright {
  color: #ff6b5e;
  text-shadow: 0 0 12px var(--error-glow);
  font-size: calc(var(--font-size) * 1.05);
  letter-spacing: 0.05em;
}

.output-line.txt-input {
  color: #00cc33;
  text-shadow: 0 0 5px rgba(0,200,50,0.5);
}

.output-line.txt-title {
  color: var(--phosphor-bright);
  text-shadow: 0 0 14px rgba(200,255,200,0.7);
  letter-spacing: 0.1em;
  font-size: calc(var(--font-size) * 1.1);
}

.output-line.txt-ending {
  color: var(--phosphor-bright);
  text-shadow:
    0 0 10px rgba(200,255,200,0.8),
    0 0 30px rgba(0,255,65,0.3);
  letter-spacing: 0.05em;
}

/* --- Input Row ---------------------------------------------- */
#input-row {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 8px 14px 10px 14px;
  border-top: 1px solid #002200;
  background: #000c00;
  position: relative;
  z-index: 5;
}

.prompt {
  color: var(--phosphor);
  text-shadow: 0 0 8px var(--phosphor-glow);
  font-family: var(--font-mono);
  font-size: var(--font-size);
  margin-right: 8px;
  flex-shrink: 0;
  user-select: none;
}

#cmd-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid #004400;
  outline: none;
  color: var(--phosphor);
  caret-color: var(--phosphor);
  font-family: var(--font-mono);
  font-size: var(--font-size);
  line-height: var(--line-height);
  flex: 1;
  text-shadow: 0 0 6px var(--phosphor-glow);
  padding: 0 0 2px 0;
  letter-spacing: 0.03em;
}

#cmd-input::placeholder {
  color: #003800;
  text-shadow: none;
}

#cmd-input:focus {
  border-bottom-color: var(--phosphor-dim);
}

/* Input disabled state (terminal endpoints) */
#cmd-input:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  border-bottom-color: #001a00;
}

/* --- Bezel Bottom Bar --------------------------------------- */
.bezel-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 20px 20px;
}

.bezel-brand {
  font-family: var(--font-mono);
  font-size: 10px;
  color: #3a3a3a;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  user-select: none;
}

.bezel-controls {
  display: flex;
  gap: 8px;
}

.bezel-button {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2a2a2a;
  box-shadow:
    inset 0 1px 2px rgba(0,0,0,0.8),
    0 1px 0 rgba(255,255,255,0.04);
}

.bezel-button.active {
  background: #003300;
  box-shadow:
    inset 0 1px 2px rgba(0,0,0,0.6),
    0 0 6px rgba(0,100,0,0.5),
    0 0 12px rgba(0,80,0,0.3);
}

/* --- Responsive --------------------------------------------- */
@media (max-width: 640px) {
  body.crt-body {
    padding: 10px;
    align-items: flex-start;
  }

  .monitor-bezel {
    border-radius: 12px 12px 8px 8px;
    padding: 16px 16px 0 16px;
  }

  .screen-inner {
    height: 80vh;
    min-height: 360px;
  }

  :root {
    --font-size: 12px;
  }

  #status-bar {
    font-size: 9px;
    gap: 0 4px;
  }

  #output-log {
    padding: 12px 14px 6px 14px;
  }

  #input-row {
    padding: 6px 10px 8px 10px;
  }

  .bezel-bottom {
    padding: 10px 14px 14px 14px;
  }

  .bezel-brand {
    font-size: 8px;
    letter-spacing: 0.06em;
  }
}

@media (max-width: 400px) {
  :root {
    --font-size: 11px;
  }

  .status-sep {
    display: none;
  }

  #status-bar {
    gap: 4px 10px;
  }
}

/* --- Utility: Hide on game over ----------------------------- */
.input-hidden {
  visibility: hidden;
}

/* --- Selection -------------------------------------------- */
::selection {
  background: rgba(0, 255, 65, 0.2);
  color: var(--phosphor-bright);
}

/* --- Leaderboard Modal ------------------------------------- */
#lb-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  font-family: 'Share Tech Mono', 'Courier New', monospace;
  animation: lb-fade-in 0.25s ease;
}

@keyframes lb-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

#lb-modal {
  background: #001400;
  border: 1px solid var(--phosphor);
  box-shadow:
    0 0 40px rgba(0, 255, 65, 0.25),
    0 0 80px rgba(0, 255, 65, 0.08),
    inset 0 0 30px rgba(0, 255, 65, 0.04);
  padding: 2rem 2.5rem 1.8rem;
  max-width: 440px;
  width: 92%;
  color: var(--phosphor);
  text-align: center;
  font-size: var(--font-size);
  line-height: 1.6;
}

#lb-title {
  color: var(--phosphor-bright);
  font-size: 1.05em;
  letter-spacing: 0.08em;
  margin-bottom: 1.1rem;
  text-shadow: 0 0 12px rgba(204, 255, 204, 0.65);
}

#lb-score {
  color: var(--phosphor);
  margin-bottom: 0.2rem;
}

#lb-flavor {
  color: var(--phosphor-dim);
  font-size: 0.82em;
  letter-spacing: 0.06em;
  margin-bottom: 1.4rem;
}

#lb-prompt {
  margin-bottom: 0.7rem;
  color: var(--phosphor);
}

#lb-initials {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--phosphor);
  color: var(--phosphor);
  font-family: inherit;
  font-size: 1.6em;
  text-align: center;
  letter-spacing: 0.45em;
  text-transform: uppercase;
  width: 5.8rem;
  outline: none;
  caret-color: var(--phosphor);
  text-shadow: 0 0 10px rgba(0, 255, 65, 0.85);
  padding-bottom: 2px;
}

#lb-initials::placeholder {
  color: #004400;
  letter-spacing: 0.5em;
}

#lb-buttons {
  margin-top: 1.4rem;
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

#lb-submit,
#lb-skip {
  background: transparent;
  border: 1px solid var(--phosphor);
  color: var(--phosphor);
  font-family: inherit;
  font-size: 0.9em;
  padding: 0.4rem 1.3rem;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: background 0.12s, color 0.12s;
}

#lb-submit:hover:not(:disabled) {
  background: var(--phosphor);
  color: var(--screen-bg);
}

#lb-submit:disabled,
#lb-skip:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#lb-skip {
  border-color: #005500;
  color: var(--phosphor-dim);
}

#lb-skip:hover:not(:disabled) {
  background: #003300;
  color: var(--phosphor);
}

#lb-status {
  margin-top: 0.9rem;
  font-size: 0.8em;
  color: var(--phosphor-dim);
  min-height: 1.3em;
}

#lb-status.lb-error {
  color: var(--error-red);
}

/* Mobile adjustments for modal */
@media (max-width: 480px) {
  #lb-modal {
    padding: 1.5rem 1.4rem;
  }

  #lb-initials {
    font-size: 1.3em;
  }
}
