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

body {
  background: #0a0a14;
  background-image:
    radial-gradient(ellipse at 50% 30%, #12122a 0%, #0a0a14 70%);
  color: #6C5EB5;
  font-family: 'Press Start 2P', monospace;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

#header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: linear-gradient(180deg, #c4b59a 0%, #a89478 100%);
  width: 100%;
  max-width: 800px;
  border-radius: 8px 8px 0 0;
  margin-top: 20px;
}

.commodore-logo {
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo-stripes {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 24px;
}

.logo-stripes span {
  display: block;
  height: 4px;
  border-radius: 1px;
}

.s1 { background: #e74c3c; }
.s2 { background: #f1c40f; }
.s3 { background: #27ae60; }

.logo-text {
  font-size: 10px;
  color: #4a3c28;
  letter-spacing: 2px;
  text-transform: lowercase;
  font-family: 'Press Start 2P', monospace;
}

.header-title {
  font-size: 8px;
  color: #4a3c28;
  letter-spacing: 1px;
  margin-left: auto;
}

#monitor-bezel {
  background: linear-gradient(160deg, #2a2a3a 0%, #1a1a2a 40%, #0f0f1f 100%);
  padding: 20px;
  border-radius: 12px;
  box-shadow:
    0 0 0 3px #333,
    0 0 0 6px #1a1a1a,
    inset 0 0 40px rgba(0,0,0,0.5),
    0 8px 32px rgba(0,0,0,0.8);
  width: 100%;
  max-width: 800px;
}

#screen-container {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  box-shadow:
    inset 0 0 60px rgba(108, 108, 255, 0.05),
    0 0 20px rgba(108, 108, 255, 0.1);
}

#canvas {
  display: block;
  width: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border-radius: 4px;
}

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

#screen-glow {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    ellipse at center,
    transparent 60%,
    rgba(0,0,0,0.4) 100%
  );
  pointer-events: none;
  border-radius: 4px;
}

#status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #111122 0%, #0d0d1a 100%);
  border: 1px solid #222;
  border-top: none;
  max-width: 800px;
  width: 100%;
  font-size: 7px;
  align-items: center;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-item .label {
  color: #588D43;
  font-size: 6px;
}

.status-item .value {
  color: #9AD284;
  font-size: 7px;
}

#sid-viz {
  vertical-align: middle;
  border: 1px solid #333;
  border-radius: 2px;
}

.cycle-counter .value {
  font-variant-numeric: tabular-nums;
  min-width: 80px;
  text-align: right;
}

/* Datasette */
#datasette-panel {
  max-width: 800px;
  width: 100%;
  margin-top: 12px;
}

.datasette-body {
  background: linear-gradient(180deg, #d4c8a8 0%, #c4b490 50%, #b4a480 100%);
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow:
    0 2px 8px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.3);
}

.datasette-label {
  font-size: 7px;
  color: #4a3c28;
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: 2px;
}

.tape-window {
  background: #2a2018;
  border-radius: 4px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 20px;
  margin-bottom: 8px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.5);
}

.tape-reel {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid #555;
  background: radial-gradient(circle, #444 30%, #333 70%);
  transition: transform 0.1s;
}

.tape-reel.spinning {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.datasette-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
}

.play-btn, .stop-btn, .rew-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  padding: 6px 12px;
  border: 2px solid #8a7a5a;
  border-radius: 4px;
  background: linear-gradient(180deg, #e8dcc0 0%, #c8bc9a 100%);
  color: #4a3c28;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transition: all 0.1s;
}

.play-btn:hover, .stop-btn:hover, .rew-btn:hover {
  background: linear-gradient(180deg, #f0e4c8 0%, #d8cca8 100%);
}

.play-btn:active, .stop-btn:active, .rew-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.tape-counter {
  font-size: 10px;
  color: #eee;
  background: #111;
  display: inline-block;
  padding: 3px 8px;
  border-radius: 2px;
  float: right;
  margin-top: -28px;
  letter-spacing: 2px;
}

/* Memory Inspector */
#memory-panel {
  max-width: 800px;
  width: 100%;
  margin-top: 12px;
}

.mem-header {
  background: #1a1a2e;
  border: 1px solid #333;
  padding: 8px 12px;
  font-size: 7px;
  color: #6C5EB5;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
  user-select: none;
}

.mem-header:hover {
  background: #222244;
}

.mem-body {
  background: #0d0d1a;
  border: 1px solid #333;
  border-top: none;
  padding: 10px;
  max-height: 300px;
  overflow-y: auto;
  display: none;
  border-radius: 0 0 4px 4px;
}

.mem-body.open {
  display: block;
}

.mem-map {
  display: flex;
  gap: 2px;
  margin-bottom: 10px;
  font-size: 6px;
  flex-wrap: wrap;
}

.map-region {
  padding: 4px 6px;
  border-radius: 2px;
  color: #fff;
  opacity: 0.6;
}

.map-region.active {
  opacity: 1;
  box-shadow: 0 0 8px rgba(111,61,134,0.5);
}

.hex-dump {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  color: #6C5EB5;
  line-height: 1.8;
  white-space: pre;
  overflow-x: auto;
}

/* Virtual Keyboard */
#virtual-keyboard {
  max-width: 800px;
  width: 100%;
  margin-top: 12px;
  display: none;
}

@media (max-width: 768px) {
  #virtual-keyboard {
    display: block;
  }
}

.vk-row {
  display: flex;
  gap: 2px;
  margin-bottom: 2px;
  justify-content: center;
}

.vk-key {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  padding: 8px 4px;
  min-width: 28px;
  text-align: center;
  background: linear-gradient(180deg, #7a6a4a 0%, #5a4a2a 100%);
  color: #e8dcc0;
  border: 1px solid #4a3a1a;
  border-radius: 3px;
  cursor: pointer;
  box-shadow: 0 2px 0 #3a2a0a;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.vk-key:active {
  transform: translateY(2px);
  box-shadow: none;
}

.vk-key.special {
  background: linear-gradient(180deg, #5a5a6a 0%, #3a3a4a 100%);
  color: #b0b0c0;
}

.vk-key.wide {
  min-width: 60px;
}

.vk-key.space {
  min-width: 160px;
}

footer {
  margin-top: 20px;
  margin-bottom: 20px;
  font-size: 8px;
}

footer a {
  color: #588D43;
  text-decoration: none;
}

footer a:hover {
  color: #9AD284;
}

/* Scrollbar styling */
.mem-body::-webkit-scrollbar {
  width: 6px;
}
.mem-body::-webkit-scrollbar-track {
  background: #0a0a14;
}
.mem-body::-webkit-scrollbar-thumb {
  background: #352879;
  border-radius: 3px;
}

@media (max-width: 600px) {
  #header { margin-top: 8px; padding: 8px 12px; gap: 8px; }
  .header-title { display: none; }
  #monitor-bezel { padding: 10px; }
  #status-bar { font-size: 5px; padding: 6px 8px; }
  .status-item .label { font-size: 5px; }
  .status-item .value { font-size: 5px; }
  .datasette-controls { flex-wrap: wrap; }
  .hex-dump { font-size: 5px; }
}