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

body {
  background: #0c0c0c;
  color: #33ff33;
  font-family: 'Courier New', monospace;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  overflow-x: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 800px;
  padding: 10px;
}

#title {
  font-family: 'Courier New', monospace;
  font-size: 20px;
  color: #33ff33;
  letter-spacing: 8px;
  margin: 12px 0 8px;
  text-shadow: 0 0 8px #33ff3366, 0 0 20px #33ff3322;
  user-select: none;
}

#monitor-bezel {
  background: linear-gradient(145deg, #2a2a2a 0%, #1a1a1a 50%, #111 100%);
  border: 3px solid #333;
  border-radius: 22px;
  padding: 22px;
  box-shadow: 
    0 0 30px rgba(0,0,0,0.9),
    inset 0 0 40px rgba(0,0,0,0.6),
    0 2px 0 #444;
  margin-bottom: 10px;
}

#crt-container {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: #050805;
  box-shadow: 
    inset 0 0 60px rgba(0,0,0,0.9),
    inset 0 0 10px rgba(51,255,51,0.05);
}

#canvas {
  display: block;
  width: 640px;
  height: 440px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border-radius: 10px;
}

#scanlines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1px,
    rgba(0,0,0,0.12) 1px,
    rgba(0,0,0,0.12) 2px
  );
  pointer-events: none;
  border-radius: 10px;
}

#glow-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  pointer-events: none;
  box-shadow: inset 0 0 80px rgba(51,255,51,0.03);
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.3) 100%);
}

#controls-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
  flex-wrap: wrap;
  justify-content: center;
}

#reset-btn {
  background: linear-gradient(180deg, #dd3333, #aa1111);
  color: white;
  border: 2px solid #881111;
  border-bottom: 3px solid #661111;
  border-radius: 6px;
  padding: 6px 18px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  transition: all 0.1s;
  letter-spacing: 1px;
}
#reset-btn:active {
  transform: translateY(2px);
  border-bottom-width: 1px;
  box-shadow: 0 0px 2px rgba(0,0,0,0.5);
}

#paste-btn {
  background: linear-gradient(180deg, #555, #333);
  color: #ccc;
  border: 2px solid #555;
  border-bottom: 3px solid #222;
  border-radius: 6px;
  padding: 6px 18px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
  letter-spacing: 1px;
}
#paste-btn:active {
  transform: translateY(2px);
  border-bottom-width: 1px;
}

#paste-input {
  background: #111;
  border: 1px solid #33ff33;
  color: #33ff33;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 4px;
  width: 250px;
  outline: none;
}
#paste-input:focus {
  box-shadow: 0 0 6px #33ff3344;
}

#speed-indicator {
  color: #33ff3366;
  font-size: 12px;
  font-family: 'Courier New', monospace;
}

/* ============================================================
   TOOL PANELS
   ============================================================ */
#tool-panels {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 760px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.tool-panel {
  flex: 1;
  min-width: 280px;
  background: #0a0e0a;
  border: 1px solid #1a3a1a;
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-title {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  font-weight: bold;
  color: #33ff33;
  letter-spacing: 2px;
  text-align: center;
  text-shadow: 0 0 6px #33ff3344;
  border-bottom: 1px solid #1a3a1a;
  padding-bottom: 6px;
}

.panel-title-danger {
  color: #ff4444;
  text-shadow: 0 0 8px #ff444444;
  border-bottom-color: #3a1a1a;
}

#corruptor-panel {
  border-color: #3a1a1a;
}

.panel-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-label {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: #33ff33aa;
  white-space: nowrap;
  letter-spacing: 1px;
}

.input-label-danger {
  color: #ff6644aa;
}

.hex-input {
  background: #050805;
  border: 1px solid #1a3a1a;
  color: #33ff33;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  font-weight: bold;
  padding: 5px 8px;
  border-radius: 3px;
  width: 90px;
  outline: none;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.hex-input:focus {
  border-color: #33ff33;
  box-shadow: 0 0 6px #33ff3322;
}

.danger-input {
  color: #ff6644;
  border-color: #3a1a1a;
}

.danger-input:focus {
  border-color: #ff6644;
  box-shadow: 0 0 6px #ff664422;
}

.file-label {
  display: inline-block;
  background: linear-gradient(180deg, #1a2a1a, #0a1a0a);
  border: 1px solid #33ff3344;
  border-radius: 4px;
  padding: 6px 14px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: #33ff33;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.15s;
  text-align: center;
}

.file-label:hover {
  background: linear-gradient(180deg, #2a3a2a, #1a2a1a);
  border-color: #33ff3388;
}

.file-label input[type="file"] {
  display: none;
}

.panel-readout {
  font-family: 'Courier New', monospace;
  font-size: 10px;
  color: #33ff33aa;
  background: #030503;
  border: 1px solid #0a1a0a;
  border-radius: 3px;
  padding: 4px 8px;
  min-height: 20px;
  letter-spacing: 0.5px;
  word-break: break-all;
}

.panel-readout.error {
  color: #ff4444;
}

.panel-readout.success {
  color: #33ff33;
}

.panel-btn {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  font-weight: bold;
  padding: 7px 16px;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 2px;
  transition: all 0.1s;
  text-align: center;
}

.load-btn {
  background: linear-gradient(180deg, #1a3a1a, #0a2a0a);
  color: #33ff33;
  border: 2px solid #33ff3366;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4), 0 0 8px #33ff3311;
}

.load-btn:hover {
  background: linear-gradient(180deg, #2a4a2a, #1a3a1a);
  border-color: #33ff33aa;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 12px #33ff3322;
}

.load-btn:active {
  transform: translateY(2px);
  box-shadow: 0 0px 2px rgba(0,0,0,0.4);
}

.corrupt-btn {
  background: linear-gradient(180deg, #3a1a0a, #2a0a0a);
  color: #ff4444;
  border: 2px solid #ff444466;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4), 0 0 8px #ff444411;
}

.corrupt-btn:hover {
  background: linear-gradient(180deg, #4a2a1a, #3a1a0a);
  border-color: #ff4444aa;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 14px #ff444422;
  text-shadow: 0 0 8px #ff4444;
}

.corrupt-btn:active {
  transform: translateY(2px);
  box-shadow: 0 0px 2px rgba(0,0,0,0.4);
}

.panel-status {
  font-family: 'Courier New', monospace;
  font-size: 10px;
  min-height: 14px;
  letter-spacing: 0.5px;
  color: #33ff33aa;
}

.panel-status.error {
  color: #ff4444;
}

.panel-status.success {
  color: #33ff33;
}

.panel-status.danger {
  color: #ff6644;
  text-shadow: 0 0 4px #ff664444;
}

/* ============================================================ */

#keyboard-housing {
  width: 100%;
  max-width: 760px;
  background: linear-gradient(180deg, #2e2e2e, #1e1e1e);
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.7);
  margin-bottom: 8px;
  border: 1px solid #3a3a3a;
}

#keyboard-surface {
  background: 
    repeating-linear-gradient(90deg, transparent, transparent 4px, rgba(0,0,0,0.04) 4px, rgba(0,0,0,0.04) 8px),
    linear-gradient(180deg, #8B7355 0%, #7a6345 40%, #6a5335 70%, #5a4325 100%);
  border-radius: 8px;
  padding: 10px 8px;
}

#keyboard {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

.key-row {
  display: flex;
  gap: 3px;
  justify-content: center;
}

.key {
  background: linear-gradient(180deg, #c0b8a0 0%, #a8a090 30%, #98907e 70%, #888070 100%);
  border: 1px solid #706860;
  border-radius: 5px;
  min-width: 44px;
  height: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  position: relative;
  box-shadow: 
    0 3px 0 #504840,
    0 4px 4px rgba(0,0,0,0.35),
    inset 0 1px 0 rgba(255,255,255,0.25);
  transition: all 0.05s;
  padding: 2px 3px;
}

.key:hover {
  background: linear-gradient(180deg, #ccc4ac 0%, #b4ac98 30%, #a49c8a 70%, #948c7c 100%);
}

.key:active, .key.pressed {
  transform: translateY(3px);
  box-shadow: 
    0 0px 0 #504840,
    0 0px 1px rgba(0,0,0,0.3),
    inset 0 2px 2px rgba(0,0,0,0.15);
  background: linear-gradient(180deg, #9a9280 0%, #8a8478 40%, #7a7468 100%);
}

.key .main-label {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 13px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.4);
  line-height: 1;
}

.key .shift-label {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 8px;
  color: #e0e0e0;
  line-height: 1;
  margin-bottom: 1px;
}

.key-space {
  min-width: 300px !important;
}

.key-shift-active,
.key-ctrl-active {
  background: linear-gradient(180deg, #d8d0b8 0%, #c0b8a8 40%, #b0a898 100%) !important;
  border-color: #999;
  box-shadow: 
    0 1px 0 #504840,
    0 2px 2px rgba(0,0,0,0.25),
    inset 0 2px 3px rgba(0,0,0,0.1);
  transform: translateY(1px);
}

#status-bar {
  display: flex;
  gap: 20px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: #33ff3366;
  margin: 6px 0;
  flex-wrap: wrap;
  justify-content: center;
}

footer {
  margin-top: 10px;
  padding: 10px;
}
footer a {
  color: #333;
  text-decoration: none;
  font-size: 12px;
  font-family: 'Courier New', monospace;
}
footer a:hover {
  color: #555;
}

@media (max-width: 700px) {
  #canvas {
    width: 100%;
    height: auto;
    aspect-ratio: 280/192;
  }
  #monitor-bezel {
    padding: 12px;
    width: 100%;
  }
  #keyboard-housing {
    width: 100%;
  }
  .key {
    min-width: 28px;
    height: 34px;
  }
  .key .main-label { font-size: 10px; }
  .key .shift-label { font-size: 6px; }
  .key-space { min-width: 160px !important; }
  #title { font-size: 15px; letter-spacing: 4px; }
  #controls-bar { gap: 6px; }
  #paste-input { width: 160px; }
  #tool-panels { flex-direction: column; }
  .tool-panel { min-width: unset; }
}