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

body {
  background: #1a1a1a;
  background-image: radial-gradient(ellipse at 50% 30%, #2a2a2a 0%, #1a1a1a 70%);
  font-family: 'IBM Plex Mono', monospace;
  color: #c0c0c0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px;
  overflow-x: hidden;
}

#workspace {
  max-width: 860px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#coco-case {
  background: linear-gradient(180deg, #d0d0d0 0%, #b8b8b8 20%, #c8c8c8 50%, #a8a8a8 100%);
  border-radius: 16px;
  padding: 0;
  width: 100%;
  max-width: 840px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 2px 4px rgba(255,255,255,0.2) inset, 0 -2px 4px rgba(0,0,0,0.3) inset;
  overflow: hidden;
  border: 1px solid #999;
}

#rainbow-stripe {
  display: flex;
  height: 8px;
  width: 100%;
}
.stripe { flex: 1; }
.stripe.red { background: #cc3333; }
.stripe.orange { background: #e68a2e; }
.stripe.yellow { background: #cccc33; }
.stripe.green { background: #33aa33; }

#case-top {
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#logo-area {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.tandy-text {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: #cc3333;
  letter-spacing: 2px;
}

.coco-text {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  color: #333;
  letter-spacing: 1px;
}

#power-led {
  display: flex;
  align-items: center;
  gap: 6px;
}
.led-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #333;
  box-shadow: 0 0 2px #000;
  transition: all 0.3s;
}
.led-dot.on {
  background: #0f0;
  box-shadow: 0 0 6px #0f0, 0 0 12px rgba(0,255,0,0.4);
}
.led-label {
  font-size: 8px; color: #666; font-weight: 700; letter-spacing: 1px;
}

#screen-bezel {
  background: #222;
  margin: 0 20px;
  padding: 20px;
  border-radius: 8px;
  border: 3px solid #444;
  box-shadow: 0 4px 16px rgba(0,0,0,0.8) inset;
}

#crt-container {
  position: relative;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  aspect-ratio: 4/3;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 0 40px rgba(0, 200, 0, 0.15), 0 0 80px rgba(0, 200, 0, 0.05);
}

#canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  display: block;
  background: #000;
}

#scanline-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.12) 2px, rgba(0,0,0,0.12) 4px);
  pointer-events: none;
  z-index: 2;
}

#crt-curve {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.35) 100%);
  pointer-events: none;
  z-index: 3;
}

/* ========== CONTROLS AREA ========== */
#controls-area {
  padding: 12px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: linear-gradient(180deg, #b0b0b0, #a0a0a0);
  border-top: 1px solid #ccc;
  flex-wrap: wrap;
}

/* ========== CASSETTE DECK ========== */
#cassette-deck {
  flex: 1;
  min-width: 320px;
  background: linear-gradient(180deg, #3a3a3a, #2a2a2a);
  border-radius: 8px;
  padding: 8px 10px;
  border: 2px solid #555;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5) inset, 0 1px 0 rgba(255,255,255,0.1);
}

#cassette-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

#cassette-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #ffcc00;
  letter-spacing: 1px;
}

.motor-led {
  width: 8px; height: 8px;
  border-radius: 50%;
  border: 1px solid #666;
  transition: all 0.2s;
}
.motor-led.off { background: #440000; }
.motor-led.on { background: #ff3333; box-shadow: 0 0 6px #f33, 0 0 12px rgba(255,50,50,0.5); }

/* Tape Reels */
#tape-reel-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-bottom: 6px;
}

.reel-window {
  width: 60px; height: 60px;
  background: #111;
  border-radius: 6px;
  border: 1px solid #444;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.reel-svg {
  width: 56px; height: 56px;
}

#tape-path {
  flex: 1;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-width: 60px;
}

#tape-line {
  width: 100%;
  height: 2px;
  background: #5a3a1a;
}

#tape-head-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px; height: 14px;
  background: #666;
  border-radius: 2px;
  border: 1px solid #888;
  display: flex;
  align-items: center;
  justify-content: center;
}

#fsk-led {
  width: 6px; height: 6px;
  border-radius: 50%;
  transition: all 0.1s;
}
.fsk-off { background: #333; }
.fsk-on-0 { background: #00aaff; box-shadow: 0 0 4px #0af; }
.fsk-on-1 { background: #ff6600; box-shadow: 0 0 4px #f60; }

/* Tape Counter */
#tape-counter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

#tape-counter {
  display: flex;
  gap: 1px;
  background: #111;
  padding: 2px 4px;
  border-radius: 3px;
  border: 1px solid #444;
}

.counter-digit {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  color: #ddd;
  background: #1a1a1a;
  width: 14px;
  text-align: center;
  border: 1px solid #333;
  border-radius: 2px;
}

#tape-status-readout {
  background: #111;
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid #444;
}

#tape-status-text {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  color: #0f0;
  text-shadow: 0 0 4px rgba(0,255,0,0.5);
}

#tape-position-readout {
  font-size: 9px;
  color: #888;
  font-family: 'IBM Plex Mono', monospace;
}

/* Transport Buttons */
#transport-buttons {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
  justify-content: center;
}

.transport-btn {
  font-size: 14px;
  padding: 6px 12px;
  border: 2px solid #555;
  border-radius: 4px;
  background: linear-gradient(180deg, #555, #333);
  color: #ccc;
  cursor: pointer;
  transition: all 0.1s;
  min-width: 40px;
  text-align: center;
}
.transport-btn:hover { background: linear-gradient(180deg, #666, #444); border-color: #777; }
.transport-btn:active { background: linear-gradient(180deg, #222, #111); transform: translateY(1px); }
.transport-btn.active { background: linear-gradient(180deg, #444, #222); border-color: #0f0; color: #0f0; }

.play-btn.active { border-color: #0f0; color: #0f0; text-shadow: 0 0 6px rgba(0,255,0,0.5); }
.rec-btn { color: #ff4444; }
.rec-btn.active { border-color: #f44; color: #f44; text-shadow: 0 0 6px rgba(255,50,50,0.5); }

/* Load Buttons Row */
#cassette-load-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.load-mode-section {
  display: flex;
  gap: 4px;
}

.cas-btn {
  background: linear-gradient(180deg, #2a6a2a, #1a4a1a) !important;
  border-color: #3a8a3a !important;
}
.cas-btn:hover { background: linear-gradient(180deg, #3a8a3a, #2a6a2a) !important; }

#file-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

#filename-display {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: #0f0;
  background: #111;
  padding: 3px 6px;
  border-radius: 3px;
  border: 1px solid #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 0 4px rgba(0,255,0,0.5);
}

#filesize-display {
  font-size: 8px;
  color: #888;
}

/* VU Meter */
#vu-meter-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.vu-label {
  font-size: 8px;
  color: #888;
  font-weight: 700;
  letter-spacing: 1px;
  min-width: 20px;
}

#vu-meter {
  display: flex;
  gap: 2px;
  flex: 1;
}

.vu-bar {
  flex: 1;
  height: 8px;
  background: #222;
  border-radius: 1px;
  border: 1px solid #333;
  transition: background 0.05s;
}
.vu-bar.active-0 { background: #00aaff; box-shadow: 0 0 3px #0af; }
.vu-bar.active-1 { background: #ff6600; box-shadow: 0 0 3px #f60; }

#fsk-bit-display {
  font-size: 14px;
  font-weight: 700;
  min-width: 12px;
  text-align: center;
}

#fsk-bps-display {
  min-width: 48px;
  text-align: right;
}

/* ========== RIGHT PANEL ========== */
#right-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 200px;
}

#action-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

#mode-select {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #333;
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid #555;
}

.mode-label {
  font-size: 10px;
  color: #ccc;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mode-label input[type="radio"] {
  accent-color: #0f0;
}

#indicators {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.ind-label {
  font-size: 7px;
  color: #555;
  font-weight: 700;
  letter-spacing: 1px;
}

.ind-value {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: #0f0;
  background: #111;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid #333;
  min-width: 40px;
  text-align: center;
  text-shadow: 0 0 4px rgba(0,255,0,0.5);
}

/* ========== GENERAL BUTTONS ========== */
.ctrl-button {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 6px 10px;
  border: 2px solid #666;
  border-radius: 4px;
  background: linear-gradient(180deg, #666, #444);
  color: #eee;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.1s;
  user-select: none;
  white-space: nowrap;
}
.ctrl-button:hover { background: linear-gradient(180deg, #777, #555); border-color: #888; }
.ctrl-button:active { background: linear-gradient(180deg, #333, #222); transform: translateY(1px); }

.big-button {
  font-size: 13px;
  padding: 8px 20px;
  background: linear-gradient(180deg, #cc3333, #991111);
  border-color: #aa2222;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.big-button:hover { background: linear-gradient(180deg, #dd4444, #aa2222); }
.big-button:active { background: linear-gradient(180deg, #881111, #660000); }

/* ========== KEYBOARD ========== */
#keyboard-decoration {
  padding: 10px 24px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: linear-gradient(180deg, #a0a0a0, #909090);
}
.key-row { display: flex; gap: 3px; }
.deco-key {
  background: linear-gradient(180deg, #555, #333);
  color: #ccc;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 8px;
  font-weight: 700;
  padding: 4px 3px;
  border-radius: 3px;
  border: 1px solid #666;
  text-align: center;
  min-width: 26px;
  box-shadow: 0 2px 3px rgba(0,0,0,0.4);
}
.deco-key.wide { min-width: 30px; }
.deco-key.extra-wide { min-width: 56px; }

/* ========== STATUS BAR ========== */
#status-bar {
  width: 100%;
  max-width: 840px;
  background: #111;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 6px 10px;
  overflow-x: auto;
}
#registers, #cassette-status-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 10px;
}
#cassette-status-bar { margin-top: 4px; padding-top: 4px; border-top: 1px solid #222; }
.reg { color: #888; white-space: nowrap; }
.reg span { color: #0f0; font-weight: 700; text-shadow: 0 0 4px rgba(0,255,0,0.3); }

/* ========== MEMORY VIEWER ========== */
#memory-viewer-toggle { width: 100%; max-width: 840px; }
#memory-viewer {
  width: 100%;
  max-width: 840px;
  background: #111;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 10px;
  overflow: hidden;
}
#memory-viewer.collapsed { display: none; }
#mem-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
#mem-controls label { font-size: 10px; color: #888; }
#mem-controls input[type="text"],
#mem-controls input[type="number"] {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  background: #222;
  color: #0f0;
  border: 1px solid #444;
  padding: 3px 5px;
  width: 55px;
  border-radius: 3px;
}
#mem-dump {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: #0a0;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
  text-shadow: 0 0 3px rgba(0,255,0,0.2);
}

/* ========== ABOUT ========== */
#about-section { width: 100%; max-width: 840px; display: flex; justify-content: flex-end; }
#about-modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}
#about-modal.hidden { display: none; }
#about-content {
  background: #222;
  border: 2px solid #555;
  border-radius: 12px;
  padding: 24px;
  max-width: 520px;
  color: #ccc;
  font-size: 12px;
  line-height: 1.6;
}
#about-content h3 { font-family: 'Press Start 2P', monospace; font-size: 11px; color: #ffcc00; margin-bottom: 10px; }
#about-content h4 { font-size: 11px; color: #ffcc00; margin: 10px 0 6px; }
#about-content p { margin-bottom: 8px; }
#about-content button { margin-top: 8px; }

/* ========== FOOTER ========== */
#app-footer { width: 100%; max-width: 840px; text-align: center; padding: 14px 0 8px; }
#app-footer a {
  color: #666;
  font-size: 10px;
  text-decoration: none;
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 1px;
  transition: color 0.2s;
}
#app-footer a:hover { color: #0f0; text-shadow: 0 0 8px rgba(0,255,0,0.4); }

/* ========== REEL ANIMATION ========== */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.reel-svg.spinning {
  animation: spin 0.8s linear infinite;
}
.reel-svg.spinning-fast {
  animation: spin 0.2s linear infinite;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 700px) {
  body { padding: 8px; }
  #screen-bezel { margin: 0 8px; padding: 10px; }
  #controls-area { padding: 8px; flex-direction: column; }
  #cassette-deck { min-width: 100%; }
  #keyboard-decoration { display: none; }
  .coco-text { font-size: 11px; }
  #registers, #cassette-status-bar { font-size: 8px; gap: 4px; }
}