:root {
  --bg: #070911;
  --bg-day: #0f172a;
  --card: rgba(19, 24, 39, 0.78);
  --card-border: rgba(255, 255, 255, 0.09);
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #e11d48;
  --primary-2: #be123c;
  --secondary: #3b82f6;
  --success: #10b981;
  --warning: #f59e0b;
  --radius: 20px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  transition: background 0.6s ease;
}

body.theme-day {
  background: var(--bg-day);
}

/* Ambient Orbs */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  transition: background 0.6s ease;
}

.orb-1 {
  width: 280px;
  height: 280px;
  background: #e11d48;
  top: -80px;
  right: -60px;
}

.orb-2 {
  width: 260px;
  height: 260px;
  background: #4f46e5;
  bottom: -60px;
  left: -80px;
}

body.theme-day .orb-1 {
  background: #f59e0b;
  opacity: 0.25;
}

body.theme-day .orb-2 {
  background: #0ea5e9;
  opacity: 0.25;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 14px 32px;
}

.view {
  display: none;
  flex-direction: column;
  gap: 14px;
  animation: fadeUp 0.25s ease;
}

.view.active {
  display: flex;
}

.hidden {
  display: none !important;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Glass Card */
.glass-card {
  background: var(--card);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
}

/* Hero */
.hero {
  text-align: center;
  padding: 14px 8px 4px;
}

.logo-ring {
  width: 82px;
  height: 82px;
  margin: 0 auto 12px;
  border-radius: 26px;
  padding: 3px;
  background: linear-gradient(135deg, #fb7185, #e11d48, #6366f1);
  box-shadow: 0 14px 36px rgba(225, 29, 72, 0.4);
  animation: float 3.5s ease-in-out infinite;
}

.logo-badge {
  width: 100%;
  height: 100%;
  border-radius: 23px;
  background: #0d101c;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-5px); }
}

.brand-tag {
  font-size: 11px;
  letter-spacing: 3px;
  font-weight: 800;
  color: #fb7185;
  margin-bottom: 4px;
}

.brand-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 36px;
  letter-spacing: 3px;
  font-weight: 800;
  background: linear-gradient(180deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-top: 6px;
  line-height: 1.45;
}

/* Inputs */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

input[type="text"],
input[type="tel"],
select {
  width: 100%;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(9, 12, 22, 0.85);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

select {
  width: auto;
  padding: 8px 12px;
  font-size: 13px;
}

/* Avatar Picker */
.avatar-picker {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.avatar-opt {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  height: 44px;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}

.avatar-opt.selected {
  border-color: var(--primary);
  background: rgba(225, 29, 72, 0.22);
  transform: scale(1.06);
}

/* Buttons */
.btn {
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  color: #fff;
  transition: transform 0.1s ease, opacity 0.2s ease, box-shadow 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.btn:active {
  transform: scale(0.96);
}

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

.btn-lg {
  padding: 15px 18px;
  font-size: 16px;
  width: 100%;
}

.btn-sm {
  padding: 9px 13px;
  font-size: 13px;
  border-radius: 11px;
}

.btn-primary {
  background: linear-gradient(135deg, #f43f5e, #e11d48);
}

.glow-btn {
  box-shadow: 0 8px 24px rgba(225, 29, 72, 0.35);
}

.btn-secondary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 11px;
  width: 36px;
  height: 36px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.or-sep {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  position: relative;
}

.join-row {
  display: flex;
  gap: 10px;
}

.join-row input {
  flex: 1;
  text-align: center;
  letter-spacing: 5px;
  font-weight: 800;
  font-family: 'Space Grotesk', sans-serif;
}

/* Roles Showcase */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pill-tag {
  font-size: 11px;
  font-weight: 700;
  background: rgba(225, 29, 72, 0.18);
  color: #fda4af;
  padding: 4px 10px;
  border-radius: 999px;
}

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

.role-mini {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}

.role-mini span {
  font-size: 22px;
}

/* Lobby */
.lobby-banner {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.muted-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 1px;
}

.room-code-big {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--warning);
}

.lobby-share-btns {
  display: flex;
  gap: 8px;
}

.lan-hint {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 13px;
  color: #bfdbfe;
  word-break: break-all;
}

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

.badge {
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.player-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(9, 12, 22, 0.7);
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.player-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
}

.p-avatar {
  font-size: 20px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.dot.offline {
  background: var(--muted);
}

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

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
}

.setting-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 14px;
  font-weight: 600;
}

.setting-info small {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}

.toggle {
  width: 22px;
  height: 22px;
  accent-color: var(--primary);
  cursor: pointer;
}

.waiting-text {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 8px;
}

/* Game Shell & Bottom Nav */
.game-shell {
  padding-bottom: 76px;
}

.game-bar {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  position: sticky;
  top: 8px;
  z-index: 25;
}

.phase-pill {
  display: flex;
  flex-direction: column;
  font-weight: 800;
  font-size: 15px;
}

.round-tag {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.timer-pill {
  background: rgba(245, 158, 11, 0.16);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 6px 10px;
  border-radius: 11px;
  font-weight: 800;
  font-size: 14px;
  min-width: 46px;
  text-align: center;
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 14px;
}

.tab-panel.active {
  display: flex;
}

.bottom-nav {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 28px);
  max-width: 452px;
  flex-direction: row;
  padding: 6px;
  gap: 6px;
  z-index: 30;
  border-radius: 18px;
}

.nav-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 8px 6px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  position: relative;
}

.nav-btn.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-ico {
  font-size: 18px;
}

.unread-dot {
  position: absolute;
  top: 6px;
  right: 28%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

/* 3D Role Flip Card */
.flip-wrap {
  perspective: 1000px;
  cursor: pointer;
}

.flip-card {
  position: relative;
  width: 100%;
  min-height: 230px;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  transform-style: preserve-3d;
}

.flip-card.flipped {
  transform: rotateY(180deg);
}

.flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 18px;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.flip-front {
  background: linear-gradient(145deg, #1e2438, #0f1320);
}

.flip-back {
  background: linear-gradient(145deg, #251324, #101422);
  transform: rotateY(180deg);
}

/* Phase Cards */
.phase-card {
  text-align: center;
}

.phase-card.night-card {
  border-color: rgba(99, 102, 241, 0.35);
}

.phase-card.danger-card {
  border-color: rgba(225, 29, 72, 0.5);
}

.role-emoji-big {
  font-size: 54px;
}

.role-desc {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.target-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.target-btn {
  background: rgba(9, 12, 22, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  padding: 12px 10px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.target-btn.selected {
  border-color: var(--primary);
  background: rgba(225, 29, 72, 0.22);
  box-shadow: 0 0 0 2px rgba(225, 29, 72, 0.25);
}

.target-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.target-sub {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

/* Players Grid */
.players-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.player-chip {
  background: rgba(9, 12, 22, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 10px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
}

.player-chip.dead {
  opacity: 0.45;
  text-decoration: line-through;
}

.player-chip.is-you {
  border-color: var(--secondary);
}

/* Chat */
.chat-messages {
  height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.chat-msg {
  font-size: 13px;
  line-height: 1.45;
  background: rgba(9, 12, 22, 0.75);
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-msg.system {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 12px;
  padding: 3px 6px;
  text-align: center;
}

.chat-msg.mafia-secret {
  border-color: rgba(225, 29, 72, 0.4);
  background: rgba(225, 29, 72, 0.12);
}

.chat-sender {
  font-weight: 700;
  color: var(--warning);
  margin-right: 6px;
}

.chat-form {
  display: flex;
  gap: 8px;
}

.chat-form input {
  padding: 11px 13px;
  font-size: 14px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 60;
}

.modal-card {
  max-width: 360px;
  width: 100%;
  text-align: center;
}

.mafia-team {
  background: rgba(225, 29, 72, 0.16);
  border: 1px solid rgba(225, 29, 72, 0.4);
  border-radius: 12px;
  padding: 10px;
  font-size: 13px;
}

.history-box {
  background: rgba(9, 12, 22, 0.75);
  border-radius: 12px;
  padding: 10px 12px;
  text-align: left;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Toast */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  padding: 11px 18px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  z-index: 100;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
  max-width: 92%;
  text-align: center;
}
