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

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

:root {
  --rust: #8B4513;
  --rust-dark: #5C2D0A;
  --rust-light: #A0522D;
  --green: #33ff33;
  --green-dim: #1a8c1a;
  --amber: #ffaa00;
  --red: #ff2222;
  --screen-bg: #0a0e08;
  --screen-glow: rgba(51, 255, 51, 0.03);
  --text-shadow: 0 0 8px rgba(51, 255, 51, 0.6);
}

html, body {
  height: 100%;
  background: #1a1208;
  font-family: 'VT323', monospace;
  color: var(--green);
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 30px;
  background-image:
    radial-gradient(ellipse at 50% 30%, rgba(139,69,19,0.3) 0%, transparent 70%),
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.15) 2px, rgba(0,0,0,0.15) 4px);
}

/* ── Scanlines ── */
#scanlines {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    transparent, transparent 1px,
    rgba(0,0,0,0.12) 1px, rgba(0,0,0,0.12) 2px
  );
}

#crt-overlay {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 9998;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.5) 100%);
}

/* ── Terminal frame ── */
.terminal-frame {
  position: relative;
  width: 100%; max-width: 720px;
  background: linear-gradient(145deg, var(--rust-light), var(--rust-dark));
  border: 4px solid #3a2010;
  border-radius: 16px;
  padding: 18px;
  box-shadow:
    0 0 30px rgba(0,0,0,0.7),
    inset 0 0 20px rgba(0,0,0,0.4),
    0 0 60px rgba(139,69,19,0.3);
}

/* ── Rivets ── */
.rivet {
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #c0a080, #3a2010);
  border: 1px solid #2a1508;
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.2), 0 1px 3px rgba(0,0,0,0.5);
  z-index: 2;
}
.rivet-tl { top: 8px; left: 8px; }
.rivet-tr { top: 8px; right: 8px; }
.rivet-bl { bottom: 8px; left: 8px; }
.rivet-br { bottom: 8px; right: 8px; }

/* ── Screen ── */
.screen {
  position: relative;
  background: var(--screen-bg);
  border: 3px solid #2a3a1a;
  border-radius: 8px;
  padding: 24px 20px;
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.8);
}

.screen-glow {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 40%, var(--screen-glow), transparent 70%);
  pointer-events: none;
}

/* ── Titles ── */
.title {
  font-family: 'Share Tech Mono', monospace;
  font-size: clamp(1.2rem, 4vw, 2rem);
  text-align: center;
  color: var(--green);
  text-shadow: var(--text-shadow), 0 0 20px rgba(51,255,51,0.3);
  letter-spacing: 4px;
  margin-bottom: 4px;
  position: relative;
}

.subtitle {
  text-align: center;
  font-size: 0.95rem;
  color: var(--green-dim);
  letter-spacing: 2px;
  margin-bottom: 18px;
}

/* Glitch effect */
.glitch {
  animation: glitch-skew 4s infinite linear alternate-reverse;
}
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
}
.glitch::before {
  color: var(--red);
  animation: glitch-1 3s infinite linear alternate-reverse;
  clip-path: inset(0 0 80% 0);
}
.glitch::after {
  color: #00ccff;
  animation: glitch-2 2.5s infinite linear alternate-reverse;
  clip-path: inset(80% 0 0 0);
}

@keyframes glitch-1 {
  0%, 90% { transform: translate(0); }
  91% { transform: translate(-3px, 1px); }
  93% { transform: translate(3px, -1px); }
  95% { transform: translate(-1px, 2px); }
  97% { transform: translate(2px, 0); }
  100% { transform: translate(0); }
}
@keyframes glitch-2 {
  0%, 88% { transform: translate(0); }
  89% { transform: translate(2px, -1px); }
  92% { transform: translate(-2px, 1px); }
  96% { transform: translate(1px, -2px); }
  100% { transform: translate(0); }
}
@keyframes glitch-skew {
  0%, 95% { transform: skewX(0deg); }
  96% { transform: skewX(0.5deg); }
  98% { transform: skewX(-0.3deg); }
  100% { transform: skewX(0deg); }
}

/* ── Warning box ── */
.warning-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,170,0,0.08);
  border: 1px solid rgba(255,170,0,0.3);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 20px;
  animation: warning-pulse 2s ease-in-out infinite;
}
.warning-icon {
  font-size: 1.4rem;
  color: var(--amber);
  text-shadow: 0 0 10px rgba(255,170,0,0.6);
}
.warning-text {
  font-size: 1rem;
  color: var(--amber);
  text-shadow: 0 0 6px rgba(255,170,0,0.4);
  letter-spacing: 1px;
}

@keyframes warning-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ── Button panel ── */
.button-panel {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.term-btn {
  position: relative;
  font-family: 'VT323', monospace;
  font-size: 1.15rem;
  padding: 16px 22px;
  border: 3px solid;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 2px;
  min-width: 170px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  outline: none;
}

.btn-sub {
  font-size: 0.7rem;
  opacity: 0.5;
  letter-spacing: 3px;
}

.btn-repeat {
  background: linear-gradient(180deg, #1a2a3a, #0d1520);
  border-color: #3388cc;
  color: #66bbff;
  box-shadow: 0 0 15px rgba(51,136,204,0.2), inset 0 0 15px rgba(51,136,204,0.05);
}
.btn-repeat:hover {
  background: linear-gradient(180deg, #1e3448, #0f1a28);
  box-shadow: 0 0 25px rgba(51,136,204,0.4), inset 0 0 20px rgba(51,136,204,0.1);
  transform: translateY(-2px);
}
.btn-repeat:active {
  transform: translateY(2px);
  box-shadow: 0 0 8px rgba(51,136,204,0.3), inset 0 0 20px rgba(51,136,204,0.15);
}

.btn-ignore {
  background: linear-gradient(180deg, #2a1a1a, #1a0d0d);
  border-color: #cc4444;
  color: #ff6666;
  box-shadow: 0 0 15px rgba(204,68,68,0.2), inset 0 0 15px rgba(204,68,68,0.05);
}
.btn-ignore:hover {
  background: linear-gradient(180deg, #341e1e, #220f0f);
  box-shadow: 0 0 25px rgba(204,68,68,0.4), inset 0 0 20px rgba(204,68,68,0.1);
  transform: translateY(-2px);
}
.btn-ignore:active {
  transform: translateY(2px);
  box-shadow: 0 0 8px rgba(204,68,68,0.3), inset 0 0 20px rgba(204,68,68,0.15);
}

.btn-process {
  background: linear-gradient(180deg, #1a2a1a, #0d1a0d);
  border-color: #44cc44;
  color: #66ff66;
  box-shadow: 0 0 15px rgba(68,204,68,0.2), inset 0 0 15px rgba(68,204,68,0.05);
}
.btn-process:hover {
  background: linear-gradient(180deg, #1e341e, #0f220f);
  box-shadow: 0 0 25px rgba(68,204,68,0.4), inset 0 0 20px rgba(68,204,68,0.1);
  transform: translateY(-2px);
}
.btn-process:active {
  transform: translateY(2px);
  box-shadow: 0 0 8px rgba(68,204,68,0.3), inset 0 0 20px rgba(68,204,68,0.15);
}

.term-btn.used {
  opacity: 0.3;
  pointer-events: none;
  filter: grayscale(0.6);
}

/* ── Sequence display ── */
.sequence-display {
  text-align: center;
  margin-bottom: 16px;
}
.seq-label {
  font-size: 0.85rem;
  color: var(--green-dim);
  margin-bottom: 6px;
  letter-spacing: 1px;
}
.seq-slots {
  display: flex;
  gap: 16px;
  justify-content: center;
}
.seq-slot {
  width: 50px; height: 50px;
  border: 2px dashed var(--green-dim);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: var(--green);
  transition: all 0.3s;
}
.seq-slot.filled {
  border-style: solid;
  border-color: var(--green);
  background: rgba(51,255,51,0.08);
  text-shadow: var(--text-shadow);
  animation: slot-pop 0.3s ease-out;
}
.seq-slot.error {
  border-color: var(--red);
  color: var(--red);
  background: rgba(255,34,34,0.1);
  animation: slot-shake 0.4s ease-out;
}

@keyframes slot-pop {
  0% { transform: scale(0.7); opacity: 0.5; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes slot-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ── Log area ── */
.log-area {
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(51,255,51,0.15);
  border-radius: 6px;
  padding: 10px 12px;
  max-height: 120px;
  overflow-y: auto;
  margin-bottom: 12px;
  font-size: 0.85rem;
  line-height: 1.5;
}
.log-line {
  color: var(--green-dim);
}
.log-line.error {
  color: var(--red);
}
.log-line.success {
  color: var(--green);
  text-shadow: var(--text-shadow);
}

/* ── Status bar ── */
.status-bar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(51,255,51,0.15);
  font-size: 0.75rem;
  color: var(--green-dim);
  letter-spacing: 1px;
  flex-wrap: wrap;
}

.blink-slow {
  animation: blink 1.5s step-end infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ── Hint cards ── */
.hints-area {
  display: flex;
  gap: 20px;
  width: 100%; max-width: 720px;
  flex-wrap: wrap;
  justify-content: center;
}

.hint-card {
  flex: 1;
  min-width: 240px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid rgba(139,69,19,0.5);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.hint-header {
  padding: 8px 12px;
  font-size: 0.95rem;
  letter-spacing: 1px;
  color: #ddaa77;
}

.hint-printout {
  background: linear-gradient(180deg, #1a1508, #0e0d06);
}
.hint-printout .hint-header {
  background: linear-gradient(90deg, rgba(139,69,19,0.3), transparent);
  border-bottom: 1px solid rgba(139,69,19,0.3);
}

.hint-mouse {
  background: linear-gradient(180deg, #12101a, #0a0910);
}
.hint-mouse .hint-header {
  background: linear-gradient(90deg, rgba(100,80,160,0.2), transparent);
  border-bottom: 1px solid rgba(100,80,160,0.2);
}

.hint-body {
  padding: 12px;
}
.hint-body pre {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.85rem;
  color: var(--amber);
  line-height: 1.6;
  text-shadow: 0 0 4px rgba(255,170,0,0.3);
}
.mouse-quote {
  font-size: 1.05rem;
  color: #aa88dd;
  font-style: italic;
  text-shadow: 0 0 6px rgba(170,136,221,0.4);
  margin-bottom: 8px;
}
.mouse-ascii pre {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.8rem;
  color: #8866bb;
  line-height: 1.3;
  text-align: center;
}

/* ── Overload overlay ── */
.overload-overlay {
  position: fixed; inset: 0;
  background: rgba(20,0,0,0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.overload-overlay.active {
  opacity: 1;
  pointer-events: auto;
  animation: overload-flash 0.15s ease-in-out 6;
}

.overload-content {
  text-align: center;
}
.overload-title {
  font-family: 'Share Tech Mono', monospace;
  font-size: clamp(1.8rem, 6vw, 3.5rem);
  color: var(--red);
  text-shadow: 0 0 30px rgba(255,34,34,0.8), 0 0 60px rgba(255,34,34,0.4);
  animation: overload-flicker 0.1s infinite alternate;
}
.overload-msg {
  font-size: 1.2rem;
  color: #ff8888;
  margin: 16px 0 8px;
  letter-spacing: 2px;
}
.overload-penalty {
  font-size: 1.5rem;
  color: var(--red);
  font-weight: bold;
  margin-bottom: 12px;
}
.overload-timer {
  font-family: 'Share Tech Mono', monospace;
  font-size: 3rem;
  color: var(--red);
  text-shadow: 0 0 20px rgba(255,34,34,0.6);
}

@keyframes overload-flash {
  0%, 100% { background: rgba(20,0,0,0.92); }
  50% { background: rgba(60,0,0,0.95); }
}
@keyframes overload-flicker {
  0% { opacity: 1; }
  100% { opacity: 0.85; }
}

/* ── Victory overlay ── */
.victory-overlay {
  position: fixed; inset: 0;
  background: rgba(0,20,0,0.93);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s;
}
.victory-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.victory-content { text-align: center; }
.victory-title {
  font-family: 'Share Tech Mono', monospace;
  font-size: clamp(1.5rem, 5vw, 2.8rem);
  color: var(--green);
  text-shadow: 0 0 30px rgba(51,255,51,0.8), 0 0 60px rgba(51,255,51,0.4);
  animation: victory-glow 1s ease-in-out infinite alternate;
}
.victory-msg {
  font-size: 1.1rem;
  color: #88ff88;
  margin: 16px 0;
  letter-spacing: 1px;
}
.victory-ascii pre {
  font-family: 'Share Tech Mono', monospace;
  font-size: 1rem;
  color: var(--green);
  line-height: 1.4;
  margin-bottom: 24px;
  text-shadow: var(--text-shadow);
}
.btn-reset {
  font-family: 'VT323', monospace;
  font-size: 1rem;
  padding: 12px 24px;
  border: 2px solid var(--green);
  background: rgba(51,255,51,0.08);
  color: var(--green);
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 2px;
  transition: all 0.2s;
}
.btn-reset:hover {
  background: rgba(51,255,51,0.15);
  box-shadow: 0 0 20px rgba(51,255,51,0.3);
}

@keyframes victory-glow {
  from { text-shadow: 0 0 30px rgba(51,255,51,0.6); }
  to { text-shadow: 0 0 50px rgba(51,255,51,1), 0 0 80px rgba(51,255,51,0.5); }
}

/* ── Garland lights (decoration) ── */
.garland {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 6px;
  display: flex;
  z-index: 999;
  pointer-events: none;
}
.garland-dot {
  flex: 1;
  border-radius: 0 0 4px 4px;
}
.garland.active .garland-dot {
  animation: garland-blink 0.3s infinite alternate;
}

@keyframes garland-blink {
  0% { opacity: 0.2; filter: brightness(0.5); }
  100% { opacity: 1; filter: brightness(1.5); }
}

/* ── Global timer ── */
.global-timer {
  text-align: center;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(51,255,51,0.15);
  border-radius: 8px;
}
.timer-label {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 3px;
  color: var(--green-dim);
  margin-bottom: 4px;
}
.timer-digits {
  font-family: 'Share Tech Mono', monospace;
  font-size: clamp(2rem, 6vw, 3.2rem);
  color: var(--green);
  text-shadow: 0 0 12px rgba(51,255,51,0.6), 0 0 30px rgba(51,255,51,0.25);
  letter-spacing: 6px;
  transition: color 0.5s, text-shadow 0.5s;
}
.timer-digits.warn {
  color: var(--amber);
  text-shadow: 0 0 12px rgba(255,170,0,0.6), 0 0 30px rgba(255,170,0,0.25);
  animation: timer-warn-pulse 0.8s ease-in-out infinite;
}
.timer-digits.critical {
  color: var(--red);
  text-shadow: 0 0 16px rgba(255,34,34,0.7), 0 0 40px rgba(255,34,34,0.3);
  animation: timer-warn-pulse 0.4s ease-in-out infinite;
}

@keyframes timer-warn-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.timer-bar-track {
  margin-top: 8px;
  width: 100%;
  height: 6px;
  background: rgba(51,255,51,0.08);
  border-radius: 3px;
  overflow: hidden;
}
.timer-bar-fill {
  height: 100%;
  width: 100%;
  background: var(--green);
  border-radius: 3px;
  transition: width 1s linear, background 0.5s;
  box-shadow: 0 0 6px rgba(51,255,51,0.4);
}
.timer-bar-fill.warn {
  background: var(--amber);
  box-shadow: 0 0 6px rgba(255,170,0,0.4);
}
.timer-bar-fill.critical {
  background: var(--red);
  box-shadow: 0 0 8px rgba(255,34,34,0.5);
}

/* ── Game Over overlay ── */
.gameover-overlay {
  position: fixed; inset: 0;
  background: rgba(10,0,0,0.95);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s;
}
.gameover-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.gameover-content { text-align: center; }
.gameover-title {
  font-family: 'Share Tech Mono', monospace;
  font-size: clamp(1.5rem, 5vw, 2.8rem);
  color: var(--red);
  text-shadow: 0 0 30px rgba(255,34,34,0.8), 0 0 60px rgba(255,34,34,0.4);
  animation: gameover-pulse 1.2s ease-in-out infinite;
}
.gameover-msg {
  font-size: 1.1rem;
  color: #ff8888;
  margin: 16px 0;
  letter-spacing: 1px;
}
.gameover-ascii pre {
  font-family: 'Share Tech Mono', monospace;
  font-size: 1rem;
  color: var(--red);
  line-height: 1.4;
  margin-bottom: 24px;
  text-shadow: 0 0 6px rgba(255,34,34,0.4);
}

@keyframes gameover-pulse {
  0%, 100% { opacity: 1; text-shadow: 0 0 30px rgba(255,34,34,0.8); }
  50% { opacity: 0.7; text-shadow: 0 0 50px rgba(255,34,34,1); }
}

/* ── Responsive ── */
@media (max-width: 500px) {
  .terminal-frame { padding: 10px; }
  .screen { padding: 16px 10px; }
  .term-btn { min-width: 120px; padding: 12px 14px; font-size: 1rem; }
  .hints-area { flex-direction: column; }
}
