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

:root {
  --case-color: #C8BEB0;
  --case-dark: #A89E90;
  --bezel-color: #1A1A2E;
  --bg-color: #0D0D0D;
  --green-accent: #00FF33;
  --green-dim: #00AA22;
  --amber: #FFAA00;
  --text-mono: 'VT323', monospace;
  --text-pixel: 'Press Start 2P', monospace;
  --tandy-red: #E74C3C;
  --tandy-orange: #F39C12;
  --tandy-yellow: #F1C40F;
  --tandy-green: #2ECC71;
  --tandy-blue: #3498DB;
}

body {
  background: var(--bg-color);
  color: #CCC;
  font-family: var(--text-mono);
  overflow-x: hidden;
  min-height: 100vh;
}

#app-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px;
}

/* Header */
#header {
  text-align: center;
  padding: 12px 0 8px;
}
.header-title {
  font-family: var(--text-pixel);
  font-size: 20px;
  color: var(--green-accent);
  text-shadow: 0 0 10px rgba(0,255,51,0.5);
  margin-bottom: 4px;
}
.header-subtitle {
  font-family: var(--text-mono);
  font-size: 16px;
  color: #888;
}
.header-status {
  margin-top: 6px;
  display: flex;
  justify-content: center;
  gap: 20px;
  font-size: 14px;
}
.header-status span {
  color: var(--green-dim);
  background: #111;
  padding: 2px 8px;
  border: 1px solid #333;
  border-radius: 3px;
}

/* Tandy Rainbow Stripe */
.tandy-stripe {
  height: 5px;
  background: linear-gradient(to right, 
    var(--tandy-red) 0%, var(--tandy-red) 20%,
    var(--tandy-orange) 20%, var(--tandy-orange) 40%,
    var(--tandy-yellow) 40%, var(--tandy-yellow) 60%,
    var(--tandy-green) 60%, var(--tandy-green) 80%,
    var(--tandy-blue) 80%, var(--tandy-blue) 100%
  );
  margin: 6px 0;
  border-radius: 2px;
}

/* Main Area */
#main-area {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

/* CoCo Case */
#coco-case {
  flex: 1;
  background: var(--case-color);
  border-radius: 12px;
  padding: 12px;
  position: relative;
  box-shadow: 
    inset 0 2px 0 rgba(255,255,255,0.3),
    inset 0 -2px 0 rgba(0,0,0,0.2),
    0 4px 12px rgba(0,0,0,0.5);
}
.case-label {
  font-family: var(--text-pixel);
  font-size: 8px;
  color: #555;
  margin-bottom: 8px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

#screen-bezel {
  background: var(--bezel-color);
  border-radius: 8px;
  padding: 8px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.8);
}

#screen {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  border-radius: 4px;
}

#screen.crt-effect {
  filter: contrast(1.1) brightness(0.95);
  box-shadow: inset 0 0 60px rgba(0,0,0,0.3);
}

/* Debug Panel */
#debug-panel {
  width: 320px;
  background: #111;
  border: 1px solid #333;
  border-radius: 6px;
  transition: width 0.3s;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}
#debug-panel.collapsed {
  width: 40px;
}
#debug-panel.collapsed #debug-content {
  display: none;
}
#toggle-debug {
  position: absolute;
  top: 0;
  left: 0;
  width: 40px;
  height: 100%;
  background: #1A1A2E;
  border: none;
  color: var(--green-accent);
  font-family: var(--text-mono);
  font-size: 12px;
  cursor: pointer;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  z-index: 2;
  border-right: 1px solid #333;
}
#toggle-debug:hover { background: #2A2A3E; }

#debug-content {
  margin-left: 40px;
  padding: 8px;
  max-height: 500px;
  overflow-y: auto;
}
.debug-section {
  margin-bottom: 10px;
}
.debug-section h3 {
  font-family: var(--text-pixel);
  font-size: 8px;
  color: var(--amber);
  margin-bottom: 4px;
  border-bottom: 1px solid #333;
  padding-bottom: 2px;
}
#reg-display, #disasm-display, #mem-display, #vdg-status {
  font-family: var(--text-mono);
  font-size: 16px;
  color: var(--green-accent);
  background: #0A0A0A;
  padding: 4px 6px;
  border-radius: 3px;
  line-height: 1.3;
  white-space: pre;
  overflow-x: auto;
}
#mem-addr {
  font-family: var(--text-mono);
  font-size: 14px;
  width: 50px;
  background: #0A0A0A;
  color: var(--green-accent);
  border: 1px solid #444;
  padding: 1px 4px;
  border-radius: 2px;
  text-transform: uppercase;
}

/* Controls */
#controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 10px;
  background: var(--case-color);
  border-radius: 8px;
  margin-top: 8px;
  box-shadow: 
    inset 0 2px 0 rgba(255,255,255,0.3),
    inset 0 -2px 0 rgba(0,0,0,0.2);
}

.ctrl-btn {
  font-family: var(--text-pixel);
  font-size: 9px;
  padding: 8px 12px;
  border: 2px outset #DDD;
  background: #D0D0D0;
  color: #333;
  cursor: pointer;
  border-radius: 3px;
  user-select: none;
  transition: all 0.05s;
}
.ctrl-btn:active {
  border-style: inset;
  transform: translateY(1px);
}
.ctrl-btn:hover { background: #E0E0E0; }

.power-btn { background: #555; color: #CCC; border-color: #777; }
.power-btn:hover { background: #666; }
.power-btn.on { background: #2A5A2A; color: var(--green-accent); }

.led {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #333;
  margin-right: 4px;
  vertical-align: middle;
}
.power-btn.on .led {
  background: var(--green-accent);
  box-shadow: 0 0 6px var(--green-accent);
}

.reset-btn { background: #C0403A; color: white; border-color: #A03030; }
.reset-btn:hover { background: #D04A44; }

.cassette-btn { font-size: 11px; }

.speed-control {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--text-pixel);
  font-size: 8px;
  color: #555;
}
.speed-btn {
  font-family: var(--text-pixel);
  font-size: 8px;
  padding: 6px 8px;
  border: 2px outset #DDD;
  background: #D0D0D0;
  color: #555;
  cursor: pointer;
  border-radius: 3px;
}
.speed-btn.active {
  background: var(--green-accent);
  color: #000;
  border-style: inset;
}

/* Cassette Status */
#cassette-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: #1A1A2E;
  border: 1px solid #333;
  border-radius: 4px;
  margin-top: 6px;
  color: var(--amber);
  font-size: 16px;
}
#cassette-status.hidden { display: none; }

.cassette-animation {
  display: flex;
  gap: 16px;
}
.reel {
  width: 20px;
  height: 20px;
  border: 2px solid var(--amber);
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 0.5s linear infinite;
}
.right-reel { animation-direction: reverse; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Keyboard */
#keyboard {
  margin-top: 8px;
  background: var(--case-color);
  border-radius: 8px;
  padding: 10px;
  box-shadow: 
    inset 0 2px 0 rgba(255,255,255,0.3),
    inset 0 -2px 0 rgba(0,0,0,0.2);
}
.kb-row {
  display: flex;
  justify-content: center;
  gap: 3px;
  margin-bottom: 3px;
}
.kb-key {
  font-family: var(--text-pixel);
  font-size: 8px;
  min-width: 32px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #444;
  color: #DDD;
  border: 2px outset #666;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  transition: all 0.05s;
  padding: 0 4px;
}
.kb-key:active, .kb-key.pressed {
  border-style: inset;
  background: var(--green-accent);
  color: #000;
  transform: translateY(1px);
}
.kb-key.wide { min-width: 55px; }
.kb-key.space { min-width: 160px; }

/* Footer */
#footer {
  text-align: center;
  padding: 12px;
  font-size: 13px;
  color: #555;
  margin-top: 10px;
  border-top: 1px solid #222;
}
#footer a { color: var(--green-dim); text-decoration: none; margin-left: 12px; }
#footer a:hover { color: var(--green-accent); }

/* Drop overlay */
#drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
#drop-overlay.hidden { display: none; }
.drop-text {
  font-family: var(--text-pixel);
  font-size: 24px;
  color: var(--green-accent);
  text-shadow: 0 0 20px var(--green-accent);
  animation: pulse 1s ease-in-out infinite alternate;
}
@keyframes pulse { from { opacity: 0.6; } to { opacity: 1; } }

/* Scrollbar */
#debug-content::-webkit-scrollbar { width: 6px; }
#debug-content::-webkit-scrollbar-track { background: #111; }
#debug-content::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }

/* CRT Scanlines overlay */
.scanlines {
  pointer-events: none;
  position: absolute;
  inset: 8px;
  border-radius: 4px;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.15) 2px,
    rgba(0,0,0,0.15) 4px
  );
  z-index: 2;
}

/* Responsive */
@media (max-width: 768px) {
  #main-area { flex-direction: column; }
  #debug-panel { width: 100% !important; }
  #debug-panel.collapsed { width: 100% !important; height: 40px; }
  #toggle-debug { writing-mode: horizontal-tb; width: 100%; height: 40px; }
  #debug-content { margin-left: 0; margin-top: 40px; }
  .kb-key { min-width: 24px; height: 26px; font-size: 7px; }
  .kb-key.wide { min-width: 40px; }
  .kb-key.space { min-width: 100px; }
  .header-title { font-size: 14px; }
}