:root {
  --bg: #06131a;
  --bg-accent: #0c2a39;
  --card: #102d3d;
  --line: #3ec3c8;
  --line-soft: #2b8f98;
  --text: #d7f2f3;
  --muted: #8bc5c8;
  --button: #1a5d73;
  --button-alt: #42495f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at 20% 10%, #14506a, var(--bg) 60%);
  color: var(--text);
  font-family: "Fira Sans", "Segoe UI", Tahoma, sans-serif;
}

body {
  position: relative;
  overflow-x: hidden;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  background-image: radial-gradient(circle, #fff 1px, transparent 1px);
  background-size: 3px 3px;
}

.layout {
  width: min(98vw, 1920px);
  margin: 0 auto;
  padding: 24px clamp(14px, 2vw, 30px);
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) minmax(760px, 2.5fr) minmax(300px, 0.95fr);
  gap: clamp(14px, 1.3vw, 26px);
  align-items: start;
}

.panel {
  background: linear-gradient(170deg, rgba(16, 45, 61, 0.95), rgba(8, 26, 35, 0.95));
  border: 1px solid rgba(62, 195, 200, 0.5);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

h1 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: 0.04em;
}

h2 {
  margin-top: 0;
}

.subtitle {
  margin-top: 8px;
  color: var(--muted);
}

.lobby {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.join-group {
  display: flex;
  gap: 8px;
}

input,
button {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.95rem;
}

input {
  width: 100%;
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
}

.btn {
  background: var(--button);
  color: #d6fcff;
  cursor: pointer;
  font-weight: 700;
}

.btn.alt {
  background: var(--button-alt);
}

.btn:hover {
  filter: brightness(1.07);
}

.status {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(62, 195, 200, 0.3);
  border-radius: 8px;
  margin-bottom: 14px;
  color: var(--muted);
}

.rom-section {
  margin-bottom: 12px;
}

#rom-name {
  margin: 6px 0 0;
  color: var(--muted);
}

.drop-zone {
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
  padding: 16px;
  color: var(--muted);
  margin-bottom: 12px;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.drop-zone.active {
  transform: scale(1.01);
  background: rgba(62, 195, 200, 0.08);
}

.drop-zone.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.host-note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.controls-help p {
  margin: 4px 0;
  color: var(--muted);
}

.controls-config {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.controls-config label {
  color: var(--muted);
  font-size: 0.92rem;
}

.controls-config select {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.95rem;
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
}

.quick-keys {
  margin-top: 12px;
}

.quick-keys p {
  margin: 0 0 8px;
  color: var(--muted);
}

.center {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel.center {
  padding: clamp(10px, 1vw, 16px);
}

#c64-canvas {
  width: 100%;
  max-width: min(100%, 1440px);
  aspect-ratio: 403 / 284;
  image-rendering: pixelated;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #041219;
}

.c64-frame {
  width: 100%;
  max-width: min(100%, 1440px);
  aspect-ratio: 403 / 284;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #041219;
}

.c64-video {
  width: 100%;
  max-width: min(100%, 1440px);
  aspect-ratio: 403 / 284;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #041219;
}

.chat-log {
  min-height: 340px;
  max-height: 460px;
  overflow: auto;
  border: 1px solid rgba(62, 195, 200, 0.3);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 10px;
  background: rgba(0, 0, 0, 0.2);
}

.chat-item {
  margin-bottom: 8px;
  line-height: 1.3;
}

.chat-item strong {
  color: #75eff4;
}

.chat-form {
  display: flex;
  gap: 8px;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .chat-log {
    min-height: 180px;
  }
}
