* {
  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: 820px;
  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: 800px;
  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;
}

#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;
}

#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 {
  padding: 12px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  background: linear-gradient(180deg, #b0b0b0, #a0a0a0);
  border-top: 1px solid #ccc;
}

#cassette-deck {
  flex: 1;
  min-width: 240px;
  background: #333;
  border-radius: 6px;
  padding: 8px 12px;
  border: 2px solid #555;
}

#cassette-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #ffcc00;
  margin-bottom: 6px;
}

#cassette-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

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

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

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

.ctrl-button {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  padding: 8px 14px;
  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);
  border-color: #444;
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.5) inset;
}

.big-button {
  font-size: 14px;
  padding: 10px 24px;
  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);
  border-color: #cc3333;
}

.big-button:active {
  background: linear-gradient(180deg, #881111, #660000);
}

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

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

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

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

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

#keyboard-decoration {
  padding: 12px 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  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: 9px;
  font-weight: 700;
  padding: 5px 4px;
  border-radius: 3px;
  border: 1px solid #666;
  text-align: center;
  min-width: 28px;
  box-shadow: 0 2px 3px rgba(0,0,0,0.4);
}

.deco-key.wide { min-width: 32px; }
.deco-key.extra-wide { min-width: 60px; }

#status-bar {
  width: 100%;
  max-width: 800px;
  background: #111;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 8px 12px;
  overflow-x: auto;
}

#registers {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 11px;
}

.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-toggle {
  width: 100%;
  max-width: 800px;
}

#memory-viewer {
  width: 100%;
  max-width: 800px;
  background: #111;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 10px;
  transition: max-height 0.3s;
  overflow: hidden;
}

#memory-viewer.collapsed {
  display: none;
}

#mem-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

#mem-controls label {
  font-size: 11px;
  color: #888;
}

#mem-controls input[type="text"],
#mem-controls input[type="number"] {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  background: #222;
  color: #0f0;
  border: 1px solid #444;
  padding: 4px 6px;
  width: 60px;
  border-radius: 3px;
}

#mem-dump {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: #0a0;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
  text-shadow: 0 0 3px rgba(0,255,0,0.2);
}

#about-section {
  width: 100%;
  max-width: 800px;
  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: 480px;
  color: #ccc;
  font-size: 13px;
  line-height: 1.6;
}

#about-content h3 {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  color: #ffcc00;
  margin-bottom: 12px;
}

#about-content p {
  margin-bottom: 10px;
}

#about-content button {
  margin-top: 10px;
}

#app-footer {
  width: 100%;
  max-width: 800px;
  text-align: center;
  padding: 16px 0 8px;
}

#app-footer a {
  color: #666;
  font-size: 11px;
  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);
}

@media (max-width: 600px) {
  body { padding: 8px; }
  #screen-bezel { margin: 0 8px; padding: 10px; }
  #controls-area { padding: 8px; }
  #keyboard-decoration { display: none; }
  .coco-text { font-size: 11px; }
  #registers { font-size: 9px; gap: 6px; }
  .deco-key { min-width: 22px; font-size: 7px; padding: 3px 2px; }
}