:root {
  --bg0: #081018;
  --bg1: #132431;
  --accent: #f9b233;
  --danger: #ff4a57;
  --ok: #58d68d;
  --text: #e8f0f4;
  --muted: #9fb2bf;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 8% 0%, #1a3a4f 0%, transparent 70%),
    radial-gradient(900px 500px at 90% 100%, #3a1d2e 0%, transparent 70%),
    linear-gradient(145deg, var(--bg0), var(--bg1));
}

body {
  display: grid;
  place-items: center;
  padding: 14px;
}

.shell {
  width: min(1500px, 100%);
}

.topbar {
  margin-bottom: 10px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.3rem, 2.4vw, 2rem);
  letter-spacing: 0.04em;
}

.hint {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.game-wrap {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  background: rgba(4, 9, 15, 0.9);
}

.hud {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.38);
  display: grid;
  gap: 5px;
  min-width: 170px;
  backdrop-filter: blur(2px);
}

.hud div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.hud span {
  color: var(--muted);
}

.minimap {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 180px;
  height: 180px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.14);
  overflow: hidden;
  backdrop-filter: blur(2px);
}

.mini-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 25%, rgba(126, 213, 255, 0.12), transparent 45%),
    linear-gradient(160deg, rgba(12, 30, 44, 0.95), rgba(8, 18, 30, 0.95));
}

.mini-view {
  position: absolute;
  border: 1px solid rgba(255, 243, 176, 0.85);
  background: rgba(255, 243, 176, 0.08);
}

.mini-dot {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
}

.mini-dot.enemy {
  background: rgba(255, 90, 112, 0.9);
}

.mini-dot.boss {
  width: 6px;
  height: 6px;
  background: rgba(255, 205, 102, 1);
}

.mini-dot.player {
  width: 6px;
  height: 6px;
  background: rgba(119, 255, 189, 1);
}

.mini-dot.tree {
  width: 3px;
  height: 3px;
  background: rgba(96, 171, 88, 0.75);
}

.mini-dot.rock {
  width: 3px;
  height: 3px;
  background: rgba(162, 170, 175, 0.72);
}

.mini-dot.gem {
  width: 4px;
  height: 4px;
  background: rgba(147, 255, 232, 0.95);
}

.mini-dot.pickup {
  width: 5px;
  height: 5px;
  background: rgba(255, 211, 124, 0.95);
  box-shadow: 0 0 6px rgba(255, 211, 124, 0.65);
}

.weapon-stats-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 0 12px;
  pointer-events: none;
}

.wstat {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(8, 18, 28, 0.82);
  border: 1px solid rgba(120, 210, 255, 0.22);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.78rem;
  color: #cce8f8;
  backdrop-filter: blur(3px);
  transition: opacity 0.3s;
}

.wstat.locked {
  opacity: 0.35;
  border-color: rgba(255,255,255,0.1);
}

.wstat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #79ffc8;
  box-shadow: 0 0 6px rgba(121,255,200,0.7);
  flex-shrink: 0;
}

.wstat.locked .wstat-dot {
  background: #606e78;
  box-shadow: none;
}

.weapon-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.87rem;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(182, 222, 245, 0.18);
  background: linear-gradient(100deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03));
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.weapon-row:not(.off) {
  box-shadow: inset 0 0 12px rgba(125, 219, 255, 0.08);
}

.weapon-row:not(.off):hover {
  transform: translateY(-1px);
  border-color: rgba(184, 233, 255, 0.35);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.26), inset 0 0 14px rgba(125, 219, 255, 0.14);
}

.weapon-row span:last-child {
  color: #d2e3ee;
}

.weapon-row.off {
  opacity: 0.48;
}

.weapon-row .left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.weapon-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #79ffc8;
  box-shadow: 0 0 8px rgba(121, 255, 200, 0.75);
}

.weapon-row.off .weapon-dot {
  background: #808d99;
  box-shadow: none;
}

.weapon-icon {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.03));
  flex: 0 0 auto;
}

.weapon-icon::before,
.weapon-icon::after {
  content: "";
  position: absolute;
}

.weapon-icon.blade {
  border-color: rgba(255, 226, 154, 0.7);
  box-shadow: inset 0 0 8px rgba(255, 220, 138, 0.3);
}

.weapon-icon.blade::before {
  width: 3px;
  height: 11px;
  left: 8px;
  top: 2px;
  background: linear-gradient(180deg, #fff3c2, #ffd88c 70%, #d69f41);
  border-radius: 1px;
}

.weapon-icon.blade::after {
  width: 9px;
  height: 2px;
  left: 4px;
  top: 12px;
  background: #e8ab47;
  border-radius: 1px;
}

.weapon-icon.whip {
  border-color: rgba(255, 190, 134, 0.7);
  box-shadow: inset 0 0 8px rgba(255, 177, 124, 0.28);
}

.weapon-icon.whip::before {
  width: 11px;
  height: 11px;
  border: 2px solid #ffbf8a;
  border-left-color: transparent;
  border-bottom-color: transparent;
  border-radius: 10px;
  left: 3px;
  top: 3px;
  transform: rotate(20deg);
}

.weapon-icon.whip::after {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #ffdfa8;
  left: 11px;
  top: 1px;
}

.weapon-icon.orbit {
  border-color: rgba(212, 185, 255, 0.72);
  box-shadow: inset 0 0 8px rgba(204, 173, 255, 0.28);
}

.weapon-icon.orbit::before {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #f3e9ff;
  left: 6px;
  top: 6px;
}

.weapon-icon.orbit::after {
  width: 12px;
  height: 12px;
  border: 1px solid rgba(214, 186, 255, 0.9);
  border-radius: 50%;
  left: 2px;
  top: 2px;
}

.weapon-icon.aura {
  border-color: rgba(144, 220, 255, 0.76);
  box-shadow: inset 0 0 8px rgba(117, 208, 255, 0.32);
}

.weapon-icon.aura::before {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #a8ecff;
  left: 7px;
  top: 7px;
}

.weapon-icon.aura::after {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(124, 220, 255, 0.9);
  left: 1px;
  top: 1px;
}

.weapon-row.off .weapon-icon {
  filter: grayscale(0.9);
}

.xp-outer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 10px;
  background: rgba(255, 255, 255, 0.11);
}

.xp-inner {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #78ffd6, #5bc0ff);
  transition: width 0.1s linear;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.56);
}

.overlay.hidden {
  display: none;
}

.card {
  width: min(680px, calc(100% - 24px));
  background: #101f2b;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 16px;
}

.card h2 {
  margin: 0 0 8px;
}

.card p {
  margin: 0 0 12px;
  color: var(--muted);
}

.card .meta {
  margin-bottom: 10px;
  color: #c8d9e3;
}

.meta-grid {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.meta-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.03);
}

.meta-item span {
  color: #dce8ee;
}

.meta-item small {
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.char-grid {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.char-btn {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.char-btn.active {
  border-color: rgba(88, 214, 141, 0.8);
  background: rgba(88, 214, 141, 0.14);
}

.char-btn small {
  color: var(--muted);
}

.btn {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
}

.btn.primary {
  border-color: rgba(88, 214, 141, 0.6);
  background: rgba(88, 214, 141, 0.16);
}

.btn:hover,
.btn:focus-visible {
  outline: none;
  border-color: var(--accent);
}

.options {
  display: grid;
  gap: 8px;
}

.option {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  text-align: left;
  padding: 10px;
  cursor: pointer;
}

.option:hover,
.option:focus-visible {
  outline: none;
  border-color: var(--accent);
  background: rgba(249, 178, 51, 0.15);
}

/* SCREEN MANAGEMENT */
.screen {
  display: none;
  width: 100%;
  min-height: 100vh;
}

.screen.active {
  display: block;
}

/* LOBBY SCREEN */
.lobby-content {
  padding: 20px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.lobby-section {
  margin-bottom: 20px;
}

.lobby-section h2 {
  margin: 0 0 16px;
  font-size: 1.5rem;
  text-align: center;
  color: var(--accent);
}

.lobby-section h3 {
  margin: 0 0 14px;
  font-size: 1.2rem;
  color: var(--text);
}

.mode-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 28px 20px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  transition: all 0.25s ease;
}

.mode-btn:hover {
  border-color: var(--accent);
  background: rgba(249, 178, 51, 0.12);
  transform: translateY(-4px);
}

.mode-btn .icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.mode-btn .label {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.mode-btn .desc {
  font-size: 0.85rem;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  color: #d4e1eb;
  font-size: 0.95rem;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font-size: 1rem;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(249, 178, 51, 0.2);
}

.character-select {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.char-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: all 0.2s ease;
}

.char-option input[type="radio"] {
  cursor: pointer;
}

.char-option input[type="radio"]:checked + span {
  color: var(--ok);
  font-weight: 600;
}

.char-option:has(input[type="radio"]:checked) {
  border-color: var(--ok);
  background: rgba(88, 214, 141, 0.15);
}

.char-option span {
  flex: 1;
  font-size: 0.95rem;
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.action-btn {
  flex: 1;
  min-width: 140px;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.action-btn.primary {
  border-color: var(--ok);
  background: rgba(88, 214, 141, 0.18);
  color: var(--ok);
  font-weight: 600;
}

.action-btn.primary:hover:not(:disabled) {
  background: rgba(88, 214, 141, 0.28);
  box-shadow: 0 0 12px rgba(88, 214, 141, 0.3);
}

.action-btn.secondary {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.05);
}

.action-btn.secondary:hover:not(:disabled) {
  border-color: var(--muted);
  background: rgba(255, 255, 255, 0.1);
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.session-info {
  padding: 14px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 14px;
}

.session-info h4 {
  margin: 0 0 8px;
  color: var(--accent);
}

.session-id {
  margin: 0 0 12px;
  font-size: 0.9rem;
}

  .code-display {
    padding: 16px;
    border-radius: 10px;
    background: rgba(88, 214, 141, 0.08);
    border: 2px solid var(--ok);
    margin-bottom: 14px;
    text-align: center;
  }

  .big-code {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--ok);
    letter-spacing: 4px;
    font-family: 'Courier New', monospace;
    margin: 14px 0;
    background: rgba(0, 0, 0, 0.3);
    padding: 16px;
    border-radius: 8px;
    user-select: all;
    cursor: pointer;
  }

  .big-code:hover {
    background: rgba(88, 214, 141, 0.15);
  }

  .join-code-container {
    padding: 20px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.12);
  }

  .join-code-container h4 {
    margin: 0 0 10px;
    color: var(--accent);
    font-size: 1.3rem;
  }
.session-id code {
  background: rgba(249, 178, 51, 0.2);
  padding: 3px 8px;
  border-radius: 4px;
  font-family: monospace;
  color: var(--accent);
}

.player-list {
  margin-top: 10px;
}

.player-list h5 {
  margin: 0 0 8px;
  color: #d4e1eb;
  font-size: 0.9rem;
}

.player-list ul {
  margin: 0;
  padding-left: 20px;
  list-style: none;
}

.player-list li {
  padding: 6px 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.info-text {
  padding: 12px;
  border-radius: 8px;
  background: rgba(88, 214, 141, 0.1);
  border-left: 3px solid var(--ok);
  color: #b8e6c8;
  font-size: 0.9rem;
  margin: 0;
}

.sessions-list {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.session-card {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: all 0.2s ease;
}

.session-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent);
}

.session-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.session-card-header strong {
  color: var(--accent);
}

.session-card-header small {
  color: var(--muted);
  font-size: 0.85rem;
}

.connection-status {
  margin-top: 20px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(88, 214, 141, 0.4);
  background: rgba(88, 214, 141, 0.08);
  text-align: center;
  color: var(--ok);
  font-size: 0.9rem;
}

.connection-status.error {
  border-color: rgba(255, 74, 87, 0.4);
  background: rgba(255, 74, 87, 0.08);
  color: var(--danger);
}

/* GAME SCREEN */
#gameScreen {
  display: grid;
  place-items: center;
  padding: 14px;
}

#mpInfo {
  color: var(--accent);
}

#mpInfo.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .hud {
    min-width: 130px;
    font-size: 0.9rem;
  }

  .minimap {
    width: 128px;
    height: 128px;
    top: 8px;
    right: 8px;
  }

  .weapons-hud {
    left: 8px;
    transform: none;
    bottom: 14px;
    width: calc(100% - 16px);
  }

  .mode-buttons {
    grid-template-columns: 1fr;
  }

  .character-select {
    grid-template-columns: 1fr;
  }
}
