/* General resets and root variables */
:root {
  --bg-color: #030803;
  --glow-color: rgba(0, 255, 51, 0.4);
  --text-color: #33ff66;
  --text-dim: #11aa33;
  --font-family: "Courier New", Courier, Monaco, monospace;
}

body {
  margin: 0;
  padding: 0;
  background-color: #121212;
  font-family: var(--font-family);
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  overflow: hidden;
}

/* CRT monitor housing (Bezel) */
.crt-bezel {
  background: radial-gradient(circle, #2d2d2d 0%, #151515 100%);
  border: 18px solid #3a3a3a;
  border-radius: 35px;
  box-shadow: 
    0 20px 40px rgba(0, 0, 0, 0.8),
    inset 0 4px 10px rgba(255, 255, 255, 0.2),
    inset 0 -4px 10px rgba(0, 0, 0, 0.5);
  padding: 10px;
  width: 90vw;
  max-width: 960px;
  height: 80vh;
  max-height: 640px;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Glass screen container */
.crt-screen {
  background-color: var(--bg-color);
  border-radius: 15px;
  overflow: hidden;
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 15px;
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 1);
  border: 4px solid #1a1a1a;
}

/* Vignette / Curve shadow simulation */
.crt-screen::after {
  content: " ";
  display: block;
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
  background: radial-gradient(circle, rgba(0,0,0,0) 60%, rgba(0,0,0,0.65) 100%);
  pointer-events: none;
  z-index: 10;
}

/* Scanlines overlay */
.scanlines {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%, 
    rgba(0, 0, 0, 0.3) 50%
  );
  background-size: 100% 4px;
  z-index: 8;
  pointer-events: none;
}

/* Screen flicker animation */
@keyframes flicker {
  0% { opacity: 0.985; }
  50% { opacity: 0.995; }
  100% { opacity: 0.985; }
}

.screen-flicker {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(18, 16, 16, 0.02);
  opacity: 0.95;
  z-index: 9;
  pointer-events: none;
  animation: flicker 0.15s infinite;
}

/* Themes configuration */
body.theme-green {
  --bg-color: #030803;
  --glow-color: rgba(0, 255, 51, 0.45);
  --text-color: #33ff66;
  --text-dim: #11aa33;
}

body.theme-amber {
  --bg-color: #0c0600;
  --glow-color: rgba(255, 176, 0, 0.45);
  --text-color: #ffb000;
  --text-dim: #b87c00;
}

body.theme-cyber {
  --bg-color: #0d010b;
  --glow-color: rgba(255, 0, 127, 0.45);
  --text-color: #ff007f;
  --text-dim: #aa0055;
}

body.theme-ansi {
  --bg-color: #0a0a0d;
  --glow-color: rgba(255, 255, 255, 0.15);
  --text-color: #eaeaea;
  --text-dim: #888888;
}

/* Custom Scrollbar adhering to modern standard guidelines */
.scrollable {
  --scrollbar-thumb: var(--text-dim);
  --scrollbar-track: rgba(0, 0, 0, 0.4);

  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  scrollbar-width: thin;
}

/* Legacy webkit scrollbar fallbacks */
@supports not (scrollbar-color: auto) {
  .scrollable::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }
  .scrollable::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
  }
  .scrollable::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
  }
}

/* Text styling, glow, colors */
* {
  box-sizing: border-box;
}

.terminal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  color: var(--text-color);
  text-shadow: 0 0 5px var(--glow-color);
  font-size: 15px;
  line-height: 1.4;
  overflow: hidden;
  z-index: 5;
}

/* Header status bars */
#game-header {
  color: var(--text-color);
  text-shadow: 0 0 5px var(--glow-color);
  font-size: 13px;
  margin-bottom: 10px;
  z-index: 5;
}

.header-line {
  display: flex;
  justify-content: space-between;
  margin-bottom: 3px;
}

.header-separator {
  overflow: hidden;
  white-space: nowrap;
}

/* Custom ANSI-like styling colors */
.ansi-green { color: #33ff66; text-shadow: 0 0 5px rgba(51,255,102,0.5); }
.ansi-red { color: #ff3333; text-shadow: 0 0 5px rgba(255,51,51,0.5); }
.ansi-yellow { color: #ffff33; text-shadow: 0 0 5px rgba(255,255,51,0.5); }
.ansi-cyan { color: #33ffff; text-shadow: 0 0 5px rgba(51,255,255,0.5); }
.ansi-magenta { color: #ff33ff; text-shadow: 0 0 5px rgba(255,51,255,0.5); }
.ansi-white { color: #ffffff; text-shadow: 0 0 5px rgba(255,255,255,0.5); }
.ansi-gray { color: #aaaaaa; }

.body-theme-ansi .ansi-green { color: #4af626; }
.body-theme-ansi .ansi-red { color: #ff4a4a; }
.body-theme-ansi .ansi-yellow { color: #f6e626; }
.body-theme-ansi .ansi-cyan { color: #26e6f6; }
.body-theme-ansi .ansi-magenta { color: #f626e6; }

/* Scrollable container for game messages */
.scrollable {
  flex: 1;
  overflow-y: auto;
  padding-right: 5px;
  white-space: pre-wrap;
  margin-bottom: 10px;
}

/* Keyboard prompt at the bottom of the screen */
#input-line {
  display: flex;
  align-items: center;
  border-top: 1px dashed var(--text-dim);
  padding-top: 8px;
}

.prompt {
  margin-right: 8px;
}

#console-input {
  background: transparent;
  border: none;
  color: var(--text-color);
  font-family: var(--font-family);
  font-size: 15px;
  width: 50px;
  outline: none;
  text-shadow: 0 0 5px var(--glow-color);
}

/* Authentication Layout */
#auth-screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  flex: 1;
}

.ascii-logo {
  font-size: 9px;
  white-space: pre;
  line-height: 1.1;
  margin-bottom: 25px;
  text-align: center;
}

#auth-form {
  width: 320px;
  border: 1px solid var(--text-color);
  padding: 15px;
  border-radius: 8px;
  background-color: rgba(0, 0, 0, 0.4);
}

.form-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.form-row label {
  width: 140px;
}

.form-row input, .form-row select {
  background-color: rgba(0, 0, 0, 0.8);
  border: 1px solid var(--text-dim);
  color: var(--text-color);
  font-family: var(--font-family);
  padding: 3px 5px;
  width: 150px;
  outline: none;
}

.form-row input:focus, .form-row select:focus {
  border-color: var(--text-color);
  box-shadow: 0 0 5px var(--glow-color);
}

.form-buttons {
  display: flex;
  justify-content: space-around;
  margin-top: 15px;
}

.btn-ansi {
  background-color: transparent;
  border: 1px solid var(--text-color);
  color: var(--text-color);
  font-family: var(--font-family);
  padding: 5px 12px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
}

.btn-ansi:hover {
  background-color: var(--text-color);
  color: var(--bg-color);
  box-shadow: 0 0 8px var(--text-color);
  text-shadow: none;
}

/* Utilities */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-10 { margin-top: 10px; }
.blink {
  animation: blink-animation 1.5s steps(2, start) infinite;
}

@keyframes blink-animation {
  to { visibility: hidden; }
}

/* Bezel Footer and settings panel */
.bezel-footer {
  border-top: 2px solid #222;
  margin-top: 8px;
  padding-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: #666;
  z-index: 5;
}

.controls-panel {
  display: flex;
  gap: 10px;
  align-items: center;
}

.bezel-button {
  background-color: #333;
  border: 1px solid #444;
  color: #999;
  font-family: var(--font-family);
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 3px;
  cursor: pointer;
  outline: none;
}

.bezel-button:hover {
  color: #fff;
  border-color: #666;
}

.bezel-button.active {
  background-color: #444;
  color: #33ff66;
  border-color: #555;
  box-shadow: 0 0 4px rgba(0, 255, 51, 0.4);
}

.bezel-select {
  background-color: #222;
  border: 1px solid #444;
  color: #999;
  font-family: var(--font-family);
  font-size: 10px;
  padding: 2px 4px;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.bezel-select:hover {
  color: #fff;
  border-color: #666;
}
