:root {
  --bg: #0b0c10;
  --panel: rgba(20, 20, 28, 0.85);
  --accent: #f4c45f;
  --accent2: #ff4d4d;
  --text: #f3f3f3;
  --muted: #9aa0a6;
  --green: #32d583;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Montserrat", "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #1b1f2b, #060608);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

#app { height: 100%; }

.screen { display: none; height: 100%; }
.screen.active { display: flex; }

#lobby {
  position: relative;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.lobby-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.lobby-bg .bg-img,
.lobby-bg .bg-grid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.9;
}


.lobby-bg .bg-grid {
  opacity: 0.35;
  animation: drift 30s linear infinite;
}

#lobbyCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

@keyframes drift {
  from { transform: translateX(0); }
  to { transform: translateX(-200px); }
}

.lobby-topbar {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  gap: 10px;
  z-index: 2;
}

.lobby-content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 40px;
  padding: 40px 60px;
  align-items: center;
  width: 100%;
  max-width: 1200px;
}

.lobby-left { max-width: 520px; }

.logo {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: 1px;
}

.tag {
  color: var(--muted);
  margin-top: 12px;
}

.lobby-actions { display: flex; gap: 12px; margin-top: 24px; }

.lobby-join {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.glass {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  padding: 24px;
}

.block { margin-bottom: 16px; }

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

input, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.35);
  color: var(--text);
}

.btn {
  border: none;
  padding: 12px 16px;
  border-radius: 12px;
  background: #2b2f3c;
  color: var(--text);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}

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

.btn.primary { background: linear-gradient(135deg, #f4c45f, #ffb347); color: #141414; font-weight: 700; }

.btn.danger { background: linear-gradient(135deg, #ff5f5f, #ff3b3b); }

.btn.ghost { background: transparent; border: 1px solid rgba(255,255,255,0.2); }

.hidden { display: none !important; }

.muted { color: var(--muted); font-size: 12px; }

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

.token {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  gap: 8px;
}

.token-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.token-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  margin-right: 6px;
}

.token.active { outline: 2px solid var(--accent); }

.players .player {
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 8px 10px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.players .player.active { outline: 2px solid var(--accent); }

.chat {
  margin-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 12px;
}

.chat-title { font-weight: 600; margin-bottom: 8px; }

.chat-list {
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 10px;
  height: 150px;
  overflow-y: auto;
  font-size: 12px;
}

.chat-item { margin-bottom: 6px; color: #d6d6d6; }

.chat-input {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

#game {
  width: 100%;
  display: grid;
  grid-template-columns: 72px 1fr 280px;
  grid-template-rows: 1fr 80px;
  grid-template-areas:
    "sidebar board right"
    "bottom bottom bottom";
  height: 100%;
}

.sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 12px;
}

.icon {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  width: 44px;
  height: 44px;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}

.board-wrap {
  grid-area: board;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#board {
  width: min(85vh, 85vw);
  height: min(85vh, 85vw);
  background: #101218;
  border-radius: 14px;
  border: 4px solid rgba(255,255,255,0.08);
  box-shadow: var(--shadow);
}

.dice3d, .roulette3d {
  position: absolute;
  width: 240px;
  height: 240px;
  pointer-events: none;
}

.roulette3d { width: 300px; height: 300px; }

.right-panel {
  grid-area: right;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.game-chat {
  margin-top: auto;
}

.turn {
  background: var(--panel);
  padding: 10px;
  border-radius: 12px;
  text-align: center;
  font-weight: 600;
}

.bottom {
  grid-area: bottom;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.35);
  border-top: 1px solid rgba(255,255,255,0.08);
}

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

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.modal-card {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  min-width: 320px;
  max-width: 520px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.modal-title { font-size: 18px; margin-bottom: 8px; }

.modal-body { color: var(--muted); margin-bottom: 12px; white-space: pre-line; }

.modal-art {
  width: 100%;
  max-height: 120px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 8px;
  border: 1px solid rgba(255,255,255,0.08);
}

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

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #12131a;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
}

@media (max-width: 1100px) {
  .lobby-content { grid-template-columns: 1fr; }
  #game { grid-template-columns: 60px 1fr 220px; }
}

@media (orientation: portrait) {
  #game { display: none; }
  #lobby::after {
    content: "Поверни телефон ↔️";
    display: block;
    margin-top: 12px;
    color: var(--muted);
  }
}
