﻿:root {
  --bg: #0f1b24;
  --panel: #172733;
  --panel-edge: #2c495d;
  --text: #f0f6ff;
  --muted: #9cb4c7;
  --accent: #5bd6ff;
  --danger: #ff7a7a;
  --ok: #94ff93;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 20% 10%, #21394a 0%, var(--bg) 55%, #0b141a 100%);
  color: var(--text);
  font-family: "Lucida Console", Monaco, monospace;
}

#gameCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: linear-gradient(180deg, rgba(7, 12, 16, 0.56), rgba(7, 12, 16, 0.78));
}

#joinOverlay {
  overflow: hidden;
  isolation: isolate;
  background: transparent;
}

#joinOverlay::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(80vw, 1240px);
  height: min(80vh, 820px);
  transform: translate(-50%, -50%);
  background: url("/assets/menu/menu.png") center center / contain no-repeat;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  opacity: 1;
  z-index: -2;
}

#joinOverlay::after {
  content: "";
  position: absolute;
  inset: 0;
  background: transparent;
  z-index: -1;
}

.panel {
  width: min(560px, 100%);
  border: 3px solid var(--panel-edge);
  background: linear-gradient(180deg, rgba(23, 39, 51, 0.95), rgba(13, 23, 31, 0.96));
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.45);
  padding: 18px;
}

#joinPanel {
  transform: translateY(14vh);
  border-color: rgba(182, 214, 234, 0.88);
  background: linear-gradient(180deg, rgba(18, 31, 41, 0.92), rgba(11, 20, 26, 0.94));
  box-shadow:
    0 18px 36px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(120, 186, 225, 0.28);
}

#joinPanel.join-panel-centered {
  transform: translateY(0);
}

h1 {
  margin: 0;
  font-size: clamp(20px, 4.2vw, 32px);
  letter-spacing: 1px;
}

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

.step {
  display: none;
  margin-top: 14px;
  padding-top: 8px;
  border-top: 1px solid rgba(146, 174, 194, 0.24);
}

.step.active {
  display: block;
}

h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
}

input[type="text"],
input:not([type]) {
  width: 100%;
  border: 2px solid #325266;
  background: #0c1a24;
  color: var(--text);
  font: inherit;
  padding: 10px;
}

input[type="color"] {
  width: 54px;
  height: 32px;
  border: none;
  background: transparent;
  padding: 0;
}

button {
  border: 2px solid #3f7794;
  background: #1f5a76;
  color: var(--text);
  font: inherit;
  padding: 9px 12px;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.12);
}

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

button.secondary {
  background: #2d3f4a;
  border-color: #4b6270;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}

.color-swatch {
  border: 2px solid rgba(240, 246, 255, 0.3);
  height: 30px;
  cursor: pointer;
}

.color-swatch.selected {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px rgba(91, 214, 255, 0.75);
}

.custom-color-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.buttons-row {
  margin-top: 12px;
  display: flex;
  gap: 10px;
}

#toColorBtn {
  margin-top: 0;
}

.profile-hint {
  min-height: 16px;
  margin-top: 8px;
  color: #b9cfde;
  font-size: 12px;
}

.profile-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 132px;
  overflow-y: auto;
  margin-top: 6px;
  padding-right: 2px;
}

.profile-list.hidden {
  display: none;
}

.profile-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  align-items: center;
  border: 1px solid rgba(98, 137, 160, 0.45);
  background: rgba(10, 20, 28, 0.56);
  padding: 4px 6px;
}

.profile-row.active {
  border-color: rgba(175, 222, 255, 0.72);
  background: rgba(18, 34, 46, 0.78);
}

.profile-row-name {
  font-size: 12px;
  color: #eaf5ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-row button {
  padding: 4px 8px;
  font-size: 11px;
}

.crime-board-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  min-height: 264px;
}

.crime-board-row {
  display: grid;
  grid-template-columns: 34px 30px 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(98, 137, 160, 0.45);
  background: rgba(10, 20, 28, 0.6);
  padding: 4px 6px;
}

.crime-board-rank {
  color: #93bbd6;
  font-size: 11px;
}

.crime-board-avatar {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 1px solid rgba(118, 167, 196, 0.56);
  background: rgba(7, 14, 20, 0.78);
}

.crime-board-main {
  min-width: 0;
}

.crime-board-name {
  color: #ecf7ff;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crime-board-sub {
  margin-top: 1px;
  color: #a8c3d6;
  font-size: 10px;
}

.crime-board-score {
  text-align: right;
}

.crime-board-score-value {
  color: #ffcf77;
  font-size: 12px;
}

.crime-board-color {
  margin-top: 1px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #a8c3d6;
  font-size: 10px;
}

.crime-board-color-swatch {
  width: 9px;
  height: 9px;
  border: 1px solid rgba(220, 238, 251, 0.55);
}

.crime-board-pagination {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#crimeBoardPage {
  color: #d7edf9;
  font-size: 11px;
}

.error {
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.hud {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 5;
  border: 2px solid rgba(230, 244, 255, 0.45);
  background: rgba(10, 19, 24, 0.72);
  padding: 8px 10px;
  min-width: 220px;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.hud-world-stats-row {
  margin-top: 2px;
  justify-content: flex-start;
  gap: 0;
  font-size: 11px;
  color: #b5cad8;
}

.hud-help {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.chat-bar {
  position: fixed;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  gap: 6px;
  align-items: center;
  border: 2px solid rgba(230, 244, 255, 0.45);
  background: rgba(10, 19, 24, 0.78);
  padding: 6px;
  touch-action: manipulation;
}

.chat-bar input[type="text"] {
  width: min(58vw, 420px);
  padding: 7px 8px;
  border: 2px solid #325266;
  background: #0c1a24;
  color: #f0f6ff;
  font: inherit;
}

.chat-bar button {
  padding: 7px 10px;
}

.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 10, 14, 0.66);
  padding: 12px;
}

.mobile-rotate-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(6, 10, 14, 0.92);
}

.mobile-rotate-card {
  border: 2px solid rgba(230, 244, 255, 0.52);
  background: rgba(11, 21, 29, 0.96);
  padding: 16px 14px;
  text-align: center;
  max-width: 280px;
}

.mobile-rotate-title {
  font-size: 14px;
  color: #f2f7ff;
}

.mobile-rotate-subtitle {
  margin-top: 8px;
  font-size: 11px;
  color: #bad0df;
}

.mobile-controls {
  position: fixed;
  inset: 0;
  z-index: 7;
  pointer-events: none;
}

.mobile-stick-base {
  position: absolute;
  left: calc(12px + env(safe-area-inset-left));
  bottom: calc(12px + env(safe-area-inset-bottom));
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 2px solid rgba(230, 244, 255, 0.46);
  background: rgba(14, 26, 35, 0.6);
  pointer-events: auto;
  touch-action: none;
}

.mobile-stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(221, 239, 255, 0.65);
  background: rgba(101, 195, 232, 0.45);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.mobile-action-stack {
  position: absolute;
  right: calc(12px + env(safe-area-inset-right));
  bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}

.mobile-action-stack button {
  min-width: 42px;
  min-height: 38px;
  padding: 6px 10px;
  border: 2px solid rgba(209, 232, 246, 0.62);
  background: rgba(16, 35, 47, 0.72);
  color: #f2f7ff;
  touch-action: manipulation;
}

body.mobile-ui .hud {
  top: calc(6px + env(safe-area-inset-top));
  left: calc(6px + env(safe-area-inset-left));
  min-width: 158px;
  padding: 6px 8px;
}

body.mobile-ui .hud-row {
  gap: 8px;
  font-size: 11px;
}

body.mobile-ui .hud-help {
  display: none;
}

body.mobile-ui .chat-bar {
  left: 50%;
  right: auto;
  width: min(68vw, 280px);
  bottom: calc(4px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 4px;
  gap: 4px;
}

body.mobile-ui .chat-bar input[type="text"] {
  width: 100%;
  padding: 4px 6px;
  font-size: 11px;
}

.settings-panel {
  width: min(420px, 100%);
  border: 2px solid rgba(230, 244, 255, 0.45);
  background: linear-gradient(180deg, rgba(23, 39, 51, 0.98), rgba(13, 23, 31, 0.98));
  padding: 12px;
}

.settings-panel h2 {
  margin: 0 0 10px;
  font-size: 14px;
}

.settings-row {
  display: grid;
  grid-template-columns: 44px 1fr 40px;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 12px;
  color: var(--muted);
}

.settings-row input[type="range"] {
  width: 100%;
  height: 14px;
  margin: 0;
  accent-color: #5bd6ff;
}

.settings-buttons {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.hidden {
  display: none;
}

@media (max-width: 640px) {
  .panel {
    padding: 14px;
  }

  .color-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .hud {
    top: 8px;
    left: 8px;
    min-width: 170px;
  }

  .chat-bar {
    left: 8px;
    right: 8px;
    transform: none;
  }

  .chat-bar input[type="text"] {
    width: 100%;
    min-width: 0;
  }
}
