/* =====================================================
   ROBCO INDUSTRIES TERMLINK - CRT Terminal Stylesheet
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap');

:root {
  --green: #33ff33;
  --green-dim: #1a8c1a;
  --green-glow: rgba(51, 255, 51, 0.4);
  --green-faint: rgba(51, 255, 51, 0.08);
  --bg: #0a0a0a;
  --bg-panel: #0d120d;
  --amber: #ff9900;
  --red-flash: #ff3333;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--green);
  font-family: 'Share Tech Mono', 'Courier New', Courier, monospace;
  font-size: 16px;
  overflow: hidden;
}

/* ---- CRT Effects ---- */
.crt-overlay {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: radial-gradient(ellipse at center,
    transparent 60%,
    rgba(0,0,0,0.7) 100%);
}

.scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 99;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 3px,
    rgba(0, 0, 0, 0.18) 3px,
    rgba(0, 0, 0, 0.18) 4px
  );
  animation: flicker 0.15s infinite;
}

@keyframes flicker {
  0%   { opacity: 1; }
  92%  { opacity: 1; }
  93%  { opacity: 0.93; }
  94%  { opacity: 1; }
  98%  { opacity: 1; }
  99%  { opacity: 0.96; }
  100% { opacity: 1; }
}

/* ---- Terminal Shell ---- */
#terminal {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
}

/* ---- Header ---- */
#terminal-header {
  border-bottom: 1px solid var(--green-dim);
  padding-bottom: 8px;
}

.header-line {
  text-shadow: 0 0 8px var(--green-glow);
  line-height: 1.6;
  letter-spacing: 0.05em;
}

.attempts-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.mute-btn {
  margin-left: auto;
  font-size: 0.8em;
}

.attempts-pips {
  display: flex;
  gap: 6px;
}

.pip {
  font-size: 1.1em;
  text-shadow: 0 0 8px var(--green-glow);
  transition: color 0.3s, text-shadow 0.3s;
}

.pip.used {
  color: var(--green-dim);
  text-shadow: none;
}

/* ---- Screen Switcher ---- */
.screen {
  display: none;
  flex: 1;
  overflow: hidden;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* ---- Difficulty / Boot Screen ---- */
#difficulty-screen {
  gap: 20px;
}

.boot-text p {
  line-height: 2;
  text-shadow: 0 0 6px var(--green-glow);
  letter-spacing: 0.05em;
}

#difficulty-menu {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-left: 20px;
}

/* ---- Buttons ---- */
.menu-btn {
  background: transparent;
  border: none;
  color: var(--green);
  font-family: inherit;
  font-size: 1em;
  cursor: pointer;
  text-align: left;
  padding: 4px 8px;
  text-shadow: 0 0 6px var(--green-glow);
  letter-spacing: 0.05em;
  transition: background 0.1s, color 0.1s;
  width: fit-content;
}

.menu-btn:hover,
.menu-btn:focus {
  background: var(--green);
  color: var(--bg);
  text-shadow: none;
  outline: none;
}

/* ---- Game Screen ---- */
#game-screen {
  flex-direction: row;
  gap: 16px;
}

/* ---- Word Grid ---- */
#grid-container {
  display: flex;
  gap: 24px;
  flex: 1;
  align-self: flex-start;
  min-width: 0;
  border-right: 1px solid var(--green-dim);
  padding-right: 16px;
}

.grid-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.grid-row {
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.9;
  white-space: pre;
}

.row-addr {
  color: var(--green-dim);
  font-size: 0.85em;
  min-width: 6ch;
  user-select: none;
}

.row-content {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
}

/* Clickable word */
.word-token {
  cursor: pointer;
  letter-spacing: 0.08em;
  text-shadow: 0 0 5px var(--green-glow);
  transition: background 0.1s, color 0.1s;
}

.word-token:hover,
.word-token:focus {
  background: var(--green);
  color: var(--bg);
  text-shadow: none;
  outline: none;
}

.word-token.removed {
  color: var(--green-dim);
  pointer-events: none;
  text-decoration: line-through;
  cursor: default;
}

/* Bracket pair */
.bracket-token {
  cursor: pointer;
  color: var(--green);
  text-shadow: 0 0 5px var(--green-glow);
  transition: background 0.1s, color 0.1s;
}

.bracket-token:hover,
.bracket-token:focus {
  background: var(--green);
  color: var(--bg);
  text-shadow: none;
  outline: none;
}

.bracket-token.used {
  color: var(--green-dim);
  pointer-events: none;
  cursor: default;
}

/* Filler chars */
.filler-char {
  user-select: none;
}

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

/* ---- Feedback Panel ---- */
#feedback-panel {
  width: 200px;
  flex-shrink: 0;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-left: 14px;
  overflow-y: auto;
}

#feedback-log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.feedback-entry {
  line-height: 1.5;
  text-shadow: 0 0 4px var(--green-glow);
  font-size: 0.9em;
}

.feedback-entry .fb-word {
  display: block;
}

.feedback-entry .fb-likeness {
  display: block;
  color: var(--green-dim);
}

.feedback-entry.hint-entry {
  color: var(--amber);
  text-shadow: 0 0 6px rgba(255,153,0,0.5);
}

/* ---- End Screen ---- */
#end-screen {
  align-items: center;
  justify-content: center;
  gap: 30px;
}

#end-message {
  text-align: center;
  font-size: 1.3em;
  letter-spacing: 0.1em;
  line-height: 2;
  text-shadow: 0 0 12px var(--green-glow);
}

#end-message.denied {
  color: var(--red-flash);
  text-shadow: 0 0 12px rgba(255,51,51,0.6);
  animation: glitch 0.4s steps(1) 3;
}

#end-message.granted {
  color: var(--green);
  animation: pulse-glow 1s ease-in-out infinite alternate;
}

@keyframes glitch {
  0%   { transform: translate(0); }
  25%  { transform: translate(-3px, 1px); }
  50%  { transform: translate(3px, -1px); }
  75%  { transform: translate(-2px, 2px); }
  100% { transform: translate(0); }
}

@keyframes pulse-glow {
  from { text-shadow: 0 0 8px var(--green-glow); }
  to   { text-shadow: 0 0 24px var(--green-glow), 0 0 40px var(--green-glow); }
}

/* ---- Wrong guess flash ---- */
.flash-deny {
  animation: deny-flash 0.5s ease-out;
}

@keyframes deny-flash {
  0%   { background: rgba(255,51,51,0.15); }
  100% { background: transparent; }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--green-dim);
}

/* ---- Cursor blink ---- */
.cursor::after {
  content: '█';
  animation: blink 1s step-end infinite;
}
@keyframes blink {
  50% { opacity: 0; }
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
  html, body { font-size: 11px; }

  #feedback-panel {
    width: 120px;
    padding-left: 8px;
  }

  #grid-container {
    gap: 12px;
    padding-right: 8px;
  }
}
