* {
  box-sizing: border-box;
}

:root {
  --bg: #0b0f14;
  --panel: rgba(10, 14, 20, 0.82);
  --panel-strong: rgba(12, 17, 24, 0.95);
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-border-strong: rgba(255, 255, 255, 0.12);
  --text: #e8edf2;
  --muted: #9aa7b4;
  --accent: #6dd3ff;
  --accent-2: #8b7dff;
  --danger: #ff6b6b;
  --shadow-lg: 0 24px 80px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.28);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Arial, sans-serif;
}

body {
  position: relative;
}

button,
input,
select {
  font: inherit;
}

#gameCanvas {
  display: block;
  width: 100vw;
  height: 100vh;
  background:
    radial-gradient(circle at top, rgba(70, 90, 120, 0.18), transparent 35%),
    linear-gradient(to bottom, #131a22 0%, #0b0f14 100%);
}

.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 6, 10, 0.55);
  backdrop-filter: blur(6px);
}

.screen.active {
  display: flex;
}

.auth-card,
.creator-card {
  background: var(--panel-strong);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-lg);
}

.auth-card {
  width: min(440px, calc(100vw - 32px));
  padding: 30px;
  border-radius: var(--radius-lg);
}

.creator-card {
  width: min(1040px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 24px;
  border-radius: var(--radius-lg);
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(340px, 420px);
  gap: 28px;
  align-items: start;
}

.brand,
.creator-header {
  margin-bottom: 18px;
}

.brand-kicker {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.brand h1,
.creator-header h2 {
  margin: 0 0 8px;
  line-height: 1.05;
}

.brand h1 {
  font-size: 38px;
}

.creator-header h2 {
  font-size: 30px;
}

.brand p,
.creator-subtitle {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.creator-left {
  min-width: 0;
}

.creator-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-full {
  grid-column: 1 / -1;
}

label {
  font-size: 14px;
  color: var(--muted);
}

input,
select,
button {
  width: 100%;
  min-height: 46px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 12px 14px;
}

input[type="color"] {
  padding: 6px;
  cursor: pointer;
}

input:focus,
select:focus,
button:focus {
  outline: none;
  border-color: rgba(109, 211, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(109, 211, 255, 0.12);
}

button {
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.12s ease;
}

button:hover {
  transform: translateY(-1px);
}

.auth-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

#loginBtn {
  background: linear-gradient(135deg, var(--accent), #4dafff);
  color: #041018;
  font-weight: 700;
}

#registerBtn,
#createCharacterBtn {
  background: linear-gradient(135deg, var(--accent-2), #6f63ff);
  color: #fff;
  font-weight: 700;
}

#randomizeBtn {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

#logoutBtn {
  width: auto;
  min-width: 120px;
  background: rgba(255, 107, 107, 0.14);
  color: #ffd6d6;
  border-color: rgba(255, 107, 107, 0.25);
}

.status-text {
  min-height: 20px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.creator-right {
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: start;
}

.preview-shell {
  width: 100%;
  max-width: 400px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.03);
}

.preview-title {
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
}

#creatorPreview,
#minimapCanvas {
  display: block;
  border-radius: 12px;
  border: 1px solid var(--panel-border-strong);
  background: rgba(255, 255, 255, 0.04);
}

#creatorPreview {
  width: 100%;
  height: auto;
  aspect-ratio: 320 / 420;
}

#minimapCanvas {
  width: 180px;
  height: 180px;
}

#hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

#hud.hidden {
  display: none;
}

.panel {
  position: absolute;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(6px);
}

.hud-top-left {
  top: 16px;
  left: 16px;
  min-width: 230px;
}

.hud-top-right {
  top: 16px;
  right: 16px;
  pointer-events: auto;
}

.hud-bottom-left {
  bottom: 16px;
  left: 16px;
  min-width: 230px;
}

.hud-bottom-right {
  right: 16px;
  bottom: 16px;
  width: 280px;
  min-height: 120px;
}

.hud-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}

.hud-section-title,
.minimap-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
}

.hud-line,
.chat-muted {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
}

.minimap-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.chat-placeholder {
  pointer-events: none;
}

@media (max-width: 960px) {
  .creator-card {
    grid-template-columns: 1fr;
    width: min(620px, calc(100vw - 24px));
  }

  .creator-right {
    order: -1;
  }

  .preview-shell {
    max-width: 340px;
  }
}

@media (max-width: 700px) {
  .screen {
    padding: 12px;
  }

  .auth-card,
  .creator-card {
    border-radius: 16px;
  }

  .creator-form-grid,
  .auth-buttons {
    grid-template-columns: 1fr;
  }

  .hud-top-left,
  .hud-top-right,
  .hud-bottom-left,
  .hud-bottom-right {
    transform: scale(0.95);
  }

  .hud-top-left,
  .hud-bottom-left {
    transform-origin: left top;
  }

  .hud-top-right,
  .hud-bottom-right {
    transform-origin: right top;
  }
}