:root {
  color-scheme: dark;
  --bg: #000000;
  --bg-soft: #04060a;
  --panel: #020406;
  --line: rgba(0, 229, 255, 0.55);
  --line-soft: rgba(0, 229, 255, 0.22);
  --text: #cdf6ff;
  --muted: #4f8a99;
  --phosphor: #00e5ff;
  --phosphor-2: #ff2e88;
  --phosphor-3: #ffae00;
  --phosphor-4: #39ff14;
  --danger: #ff2e88;
  --font-arcade: "Press Start 2P", monospace;
  --font-term: "VT323", "Share Tech Mono", ui-monospace, monospace;
  --glow: 0 0 6px var(--phosphor), 0 0 14px rgba(0, 229, 255, 0.55);
}

* {
  box-sizing: border-box;
}

html,
body {
  background: #000;
}

body {
  margin: 0;
  font-family: var(--font-term);
  font-size: 1.25rem;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(0, 229, 255, 0.08), transparent 55%),
    radial-gradient(ellipse at 50% 120%, rgba(255, 46, 136, 0.06), transparent 55%),
    #000;
  color: var(--text);
  min-height: 100vh;
  text-shadow: 0 0 4px rgba(0, 229, 255, 0.35);
}

.shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 40px;
  display: grid;
  gap: 18px;
  grid-template-columns: 330px 1fr;
  grid-template-areas:
    "intro arena"
    "controls arena";
}

.panel {
  position: relative;
  background:
    linear-gradient(180deg, rgba(0, 229, 255, 0.04), rgba(0, 0, 0, 0)),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.8) inset,
    0 0 18px rgba(0, 229, 255, 0.18),
    0 0 40px rgba(0, 229, 255, 0.08);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  pointer-events: none;
}

.intro {
  grid-area: intro;
  padding: 26px;
  align-self: start;
}

.controls {
  grid-area: controls;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

.arena-panel {
  grid-area: arena;
  padding: 20px;
}

.eyebrow {
  margin: 0 0 18px;
  font-family: var(--font-arcade);
  font-size: 0.55rem;
  letter-spacing: 0.18em;
  color: var(--phosphor-3);
  text-shadow: 0 0 6px rgba(255, 174, 0, 0.6);
  animation: flicker 4s infinite;
}

.label,
.hint,
.status,
.rules {
  color: var(--muted);
}

h1,
h2,
p,
ul {
  margin: 0;
}

h1 {
  font-family: var(--font-arcade);
  font-size: clamp(1.4rem, 4vw, 2.1rem);
  line-height: 1.25;
  margin-bottom: 18px;
  color: var(--phosphor);
  text-shadow:
    0 0 8px rgba(0, 229, 255, 0.8),
    0 0 22px rgba(0, 229, 255, 0.45),
    0 0 40px rgba(0, 229, 255, 0.25);
  letter-spacing: 0.02em;
}

h2 {
  font-family: var(--font-arcade);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  margin-bottom: 14px;
  color: var(--phosphor);
  text-shadow: 0 0 6px rgba(0, 229, 255, 0.55);
}

.lede {
  line-height: 1.3;
  font-size: 1.35rem;
  color: var(--text);
}

.rules {
  padding-left: 20px;
  margin-top: 18px;
  display: grid;
  gap: 8px;
  font-size: 1.2rem;
}

.card {
  padding: 16px;
  background: rgba(0, 229, 255, 0.03);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  display: grid;
  gap: 12px;
}

input,
button {
  font: inherit;
  border-radius: 4px;
  border: 1px solid var(--line);
}

input {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-term);
  font-size: 1.35rem;
  letter-spacing: 0.08em;
  background: #000;
  color: var(--phosphor);
  text-shadow: 0 0 6px rgba(0, 229, 255, 0.6);
  caret-color: var(--phosphor);
}

input::placeholder {
  color: var(--muted);
  text-shadow: none;
}

input:focus {
  outline: none;
  border-color: var(--phosphor);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.5), 0 0 0 1px var(--phosphor) inset;
}

button {
  padding: 12px 16px;
  cursor: pointer;
  font-family: var(--font-arcade);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  background: #000;
  color: var(--phosphor);
  text-shadow: 0 0 6px rgba(0, 229, 255, 0.6);
  box-shadow: 0 0 0 1px rgba(0, 229, 255, 0.4) inset, 0 0 10px rgba(0, 229, 255, 0.15);
  transition: box-shadow 0.12s ease, transform 0.05s ease, background 0.12s ease;
}

button:hover:not(:disabled) {
  background: rgba(0, 229, 255, 0.12);
  box-shadow: 0 0 0 1px var(--phosphor) inset, 0 0 16px rgba(0, 229, 255, 0.45);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

.secondary-button,
.hud-action {
  border-color: var(--line-soft);
  color: var(--muted);
  text-shadow: none;
  box-shadow: 0 0 0 1px rgba(0, 229, 255, 0.2) inset;
}

.secondary-button:hover:not(:disabled),
.hud-action:hover:not(:disabled) {
  color: var(--phosphor);
  border-color: var(--phosphor);
}

button.is-active {
  background: rgba(57, 255, 20, 0.14);
  border-color: var(--phosphor-4);
  color: var(--phosphor-4);
  text-shadow: 0 0 8px rgba(57, 255, 20, 0.7);
  box-shadow: 0 0 0 1px var(--phosphor-4) inset, 0 0 16px rgba(57, 255, 20, 0.5);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.arena-actions {
  margin-bottom: 10px;
}

.join-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.join-row input {
  min-width: 0;
}

.difficulty-slider-wrap {
  display: grid;
  gap: 8px;
}

.difficulty-slider-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.difficulty-label {
  margin-bottom: 0;
  color: var(--phosphor);
  text-shadow: 0 0 6px rgba(0, 229, 255, 0.55);
}

.difficulty-value {
  color: var(--phosphor-4);
  font-size: 1.25rem;
  letter-spacing: 0.08em;
  text-shadow: 0 0 8px rgba(57, 255, 20, 0.45);
}

.difficulty-slider {
  width: 100%;
  padding: 0;
  appearance: none;
  background: transparent;
  border: 0;
  box-shadow: none;
  cursor: pointer;
}

.difficulty-slider::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.12), rgba(57, 255, 20, 0.2));
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.2);
}

.difficulty-slider::-moz-range-track {
  height: 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.12), rgba(57, 255, 20, 0.2));
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.2);
}

.difficulty-slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -5px;
  border-radius: 50%;
  border: 1px solid var(--phosphor-4);
  background: #000;
  box-shadow: 0 0 0 1px rgba(57, 255, 20, 0.5) inset, 0 0 14px rgba(57, 255, 20, 0.6);
}

.difficulty-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--phosphor-4);
  background: #000;
  box-shadow: 0 0 0 1px rgba(57, 255, 20, 0.5) inset, 0 0 14px rgba(57, 255, 20, 0.6);
}

.difficulty-slider:focus {
  outline: none;
}

.difficulty-slider:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.difficulty-scale {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.difficulty-scale span:nth-child(2) {
  text-align: center;
}

.difficulty-scale span:nth-child(3) {
  text-align: center;
}

.difficulty-scale span:last-child {
  text-align: right;
}

.icon-button,
.bot-remove,
.bot-badge {
  border-color: var(--phosphor-3);
  color: var(--phosphor-3);
  text-shadow: 0 0 6px rgba(255, 174, 0, 0.6);
  box-shadow: 0 0 0 1px rgba(255, 174, 0, 0.4) inset, 0 0 12px rgba(255, 174, 0, 0.2);
}

.icon-button:hover:not(:disabled),
.bot-remove:hover:not(:disabled) {
  background: rgba(255, 174, 0, 0.14);
  box-shadow: 0 0 0 1px var(--phosphor-3) inset, 0 0 16px rgba(255, 174, 0, 0.5);
}

.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.room-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.room-card-header h2 {
  margin-bottom: 0;
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 4px;
  font-size: 1.1rem;
  line-height: 1;
}

.add-bot-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  border-radius: 4px;
  font-family: var(--font-arcade);
  font-size: 0.52rem;
  letter-spacing: 0.08em;
  box-shadow: 0 0 0 1px var(--phosphor-3) inset, 0 0 14px rgba(255, 174, 0, 0.35);
}

.add-bot-plus {
  font-family: var(--font-term);
  font-size: 1.2rem;
  line-height: 1;
  color: var(--phosphor-4);
  text-shadow: 0 0 8px rgba(57, 255, 20, 0.8);
}

.add-bot-label {
  color: var(--phosphor-3);
  text-shadow: 0 0 6px rgba(255, 174, 0, 0.6);
}

.bot-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bot-icon rect,
.bot-icon line,
.bot-icon circle {
  fill: rgba(255, 174, 0, 0.12);
}

.lobby-list {
  display: grid;
  gap: 8px;
  align-content: start;
}

.lobby-card {
  flex: 1;
  min-height: 0;
}

.lobby-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 4px;
  background: rgba(0, 229, 255, 0.03);
  border: 1px solid var(--line-soft);
  color: var(--muted);
}

.lobby-row-name {
  min-width: 0;
  color: var(--text);
  font-size: 1.3rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lobby-row.self {
  color: var(--phosphor);
  border-color: var(--phosphor);
  box-shadow: 0 0 0 1px rgba(0, 229, 255, 0.25) inset, 0 0 10px rgba(0, 229, 255, 0.18);
}

.lobby-row.is-ready {
  border-color: var(--phosphor-4);
  box-shadow: 0 0 0 1px rgba(57, 255, 20, 0.25) inset, 0 0 14px rgba(57, 255, 20, 0.18);
}

.lobby-row.self.is-ready {
  border-color: var(--phosphor);
  box-shadow:
    0 0 0 1px rgba(0, 229, 255, 0.25) inset,
    0 0 0 3px rgba(57, 255, 20, 0.35) inset,
    0 0 14px rgba(57, 255, 20, 0.22);
}

.lobby-row.self .lobby-row-name {
  color: var(--phosphor);
  text-shadow: 0 0 6px rgba(0, 229, 255, 0.45);
}

.lobby-row.is-ready .lobby-row-name {
  color: var(--phosphor-4);
  text-shadow: 0 0 6px rgba(57, 255, 20, 0.5);
}

.lobby-row.self.is-ready .lobby-row-name {
  color: var(--phosphor-4);
  text-shadow: 0 0 6px rgba(57, 255, 20, 0.5);
}

.bot-badge {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--phosphor-3);
  border-radius: 4px;
  background: rgba(255, 174, 0, 0.08);
  flex: 0 0 auto;
}

.chat-card {
  min-height: 220px;
}

.chat-log {
  height: 180px;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
}

.chat-empty {
  color: var(--muted);
  font-size: 1.1rem;
  letter-spacing: 0.04em;
}

.chat-message {
  padding: 8px 10px;
  border-radius: 4px;
  background: rgba(0, 229, 255, 0.04);
  border: 1px solid rgba(0, 229, 255, 0.16);
}

.chat-message.self {
  border-color: rgba(57, 255, 20, 0.45);
  background: rgba(57, 255, 20, 0.05);
}

.chat-meta {
  color: var(--phosphor-3);
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}

.chat-text {
  color: var(--text);
  font-size: 1.15rem;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.chat-form input {
  min-width: 0;
  letter-spacing: 0.04em;
}

.bot-remove {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 4px;
  font-size: 1rem;
  flex: 0 0 auto;
}

.status {
  min-height: 0;
  padding: 0;
  font-size: 1.15rem;
  line-height: 1.25;
  letter-spacing: 0.04em;
  overflow: hidden;
  white-space: nowrap;
}

.status-centered {
  width: min(420px, 100%);
  margin: 6px auto 0;
  text-align: center;
}

.status-text {
  display: inline-block;
  max-width: 100%;
}

.status.is-scrolling {
  text-align: left;
}

.status.is-scrolling .status-text {
  padding-inline: 24px;
  animation: status-marquee var(--status-scroll-duration, 8s) ease-in-out infinite alternate;
}

.hud {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 1.25rem;
}

.hud div {
  min-width: 0;
}

.status-column {
  flex: 1 1 auto;
  text-align: center;
}

.status-column #phase-label {
  display: block;
}

.self-label-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
}

.self-label-row .label {
  margin-bottom: 0;
}

.room-row,
.self-row {
  min-height: 1.4em;
}

.self-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.hud-action {
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.55rem;
}

.label {
  display: block;
  font-family: var(--font-arcade);
  font-size: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 6px;
  color: var(--muted);
}

#arena {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  border-radius: 4px;
  background: #000;
  border: 1px solid var(--line);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.9) inset,
    0 0 22px rgba(0, 229, 255, 0.25),
    0 0 60px rgba(0, 229, 255, 0.1);
}

.hint {
  margin-top: 12px;
  font-size: 1.1rem;
  letter-spacing: 0.03em;
}

.modal {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  box-shadow: 0 0 30px rgba(0, 229, 255, 0.3);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.modal-card {
  margin: 0;
  padding: 22px;
  display: grid;
  gap: 16px;
  background: #000;
  border: 1px solid var(--line-soft);
}

.crt-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.18) 0px,
      rgba(0, 0, 0, 0.18) 1px,
      transparent 1px,
      transparent 3px
    );
  mix-blend-mode: multiply;
}

.crt-overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(0, 0, 0, 0.55) 100%);
}

@keyframes flicker {
  0%, 92%, 100% { opacity: 1; }
  93% { opacity: 0.4; }
  94% { opacity: 1; }
  95% { opacity: 0.6; }
  96% { opacity: 1; }
}

@keyframes status-marquee {
  from { transform: translateX(0); }
  to { transform: translateX(calc(-1 * var(--status-scroll-distance, 0px))); }
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "intro"
      "controls"
      "arena";
  }

  .hud {
    flex-direction: column;
  }

  .self-label-row,
  .self-row {
    justify-content: flex-start;
  }

  .status-column {
    text-align: left;
  }

  .status-centered {
    margin-inline: 0;
  }
}
