:root {
  --bg: #111827;
  --card: #1f2937;
  --text: #f9fafb;
  --muted: #9ca3af;
  --accent: #f59e0b;
  --danger: #ef4444;
  --success: #22c55e;
  --border: rgba(255,255,255,0.08);
  --app-height: 100vh;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

body {
  min-height: var(--app-height);
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  color: var(--text);
  font-family: Inter, Arial, sans-serif;
  touch-action: pan-y;
}

button, input, select { font: inherit; }

button {
  border: 0;
  border-radius: 14px;
  padding: 14px 18px;
  background: var(--accent);
  color: #111827;
  font-weight: 700;
  cursor: pointer;
}

button.secondary { background: #e5e7eb; }

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

button.danger {
  background: var(--danger);
  color: white;
}

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

input, select {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
}

label {
  display: grid;
  gap: 8px;
  font-size: 14px;
}

main {
  width: 100%;
  display: grid;
  gap: 14px;
}

.app-shell {
  width: 100%;
  max-width: 100%;
  min-height: var(--app-height);
  margin: 0;
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card {
  width: 100%;
  background: rgba(31, 41, 55, 0.94);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

.card-light {
  background: rgba(11, 18, 32, 0.7);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
}

.stack { display: grid; gap: 14px; }
.compact { gap: 8px; }

.grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.row { display: flex; gap: 12px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.between { justify-content: space-between; }
.center { align-items: center; }

.muted { color: var(--muted); }
.hidden { display: none !important; }

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

.tabs-two {
  grid-template-columns: repeat(2, 1fr);
}

.tab {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.tab.active {
  background: var(--accent);
  color: #111827;
}

.banner {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

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

.slot-btn {
  min-height: 90px;
  border-radius: 18px;
}

.player-list {
  display: grid;
  gap: 12px;
}

.player-card {
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.alive-highlight {
  border-color: rgba(34, 197, 94, 0.55);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.2) inset;
}

.kicked-highlight {
  border-color: rgba(239, 68, 68, 0.55);
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.2) inset;
}

.player-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.player-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #0b1220;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
}

.character-grid {
  display: grid;
  gap: 10px;
}

.character-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #0b1220;
  border: 1px solid var(--border);
}

.character-row strong {
  color: var(--accent);
}

.reveal-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  align-items: stretch;
}

.reveal-row button {
  min-height: 72px;
  width: 100%;
  justify-self: stretch;
}

.profile-box {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  background: #0b1220;
}

.profile-avatar.medium {
  width: 72px;
  height: 72px;
}

.avatar-uploader {
  display: flex;
  gap: 14px;
  align-items: center;
}

.xp-card {
  padding: 14px;
  border-radius: 18px;
  background: rgba(11, 18, 32, 0.7);
  border: 1px solid var(--border);
}

.xp-bar {
  width: 100%;
  height: 14px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  overflow: hidden;
}

.xp-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #16a34a 0%, #22c55e 100%);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.bottom-nav,
.room-nav {
  position: sticky;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: rgba(17, 24, 39, 0.96);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 10px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.bottom-nav {
  bottom: 0;
  z-index: 30;
  margin-top: 8px;
}

.room-nav {
  top: 0;
  z-index: 25;
}

.nav-btn {
  background: #0b1220;
  color: var(--text);
  border: 1px solid var(--border);
  position: relative;
}

.nav-btn.active {
  background: var(--accent);
  color: #111827;
}

.chat-badge {
  display: inline-flex;
  min-width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: white;
  color: #111827;
  font-size: 12px;
  font-weight: 700;
  margin-left: 8px;
}

.social-list {
  display: grid;
  gap: 10px;
}

.social-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #0b1220;
}

.social-user {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.social-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #111827;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  font-size: 13px;
}

.presence-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online { background: #22c55e; }
.status-dot.ingame { background: #16a34a; }
.status-dot.offline { background: #94a3b8; }

.chat-messages {
  display: grid;
  gap: 10px;
  max-height: min(44vh, 360px);
  overflow-y: auto;
  padding-right: 4px;
}

.chat-message {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.chat-message.mine {
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #111827;
}

.chat-bubble {
  max-width: 80%;
  padding: 10px 12px;
  border-radius: 16px;
  background: #0b1220;
  border: 1px solid var(--border);
}

.chat-message.mine .chat-bubble {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.22);
}

.chat-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  margin-bottom: 6px;
  color: var(--muted);
}

.chat-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-send-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.select-like { appearance: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #0b1220;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 16px;
  min-width: 220px;
  text-align: center;
  z-index: 50;
}

button,
.nav-btn,
.tab,
.slot-btn {
  transition:
    transform .18s ease,
    box-shadow .22s ease,
    background-color .22s ease,
    border-color .22s ease,
    opacity .22s ease;
  -webkit-tap-highlight-color: transparent;
}

button:active,
.nav-btn:active,
.tab:active,
.slot-btn:active {
  transform: scale(.98);
}

button:hover,
.nav-btn:hover,
.tab:hover,
.slot-btn:hover {
  box-shadow: 0 6px 16px rgba(0,0,0,.18);
}

main section { width: 100%; }

@media (max-width: 700px) {
  .app-shell {
    padding:
      max(10px, env(safe-area-inset-top))
      10px
      calc(18px + env(safe-area-inset-bottom))
      10px;
  }

  .grid-two { grid-template-columns: 1fr; }

  .player-head,
  .row.between.center,
  .profile-box,
  .avatar-uploader,
  .social-card {
    flex-direction: column;
    align-items: stretch;
  }

  .player-main,
  .social-user {
    align-items: center;
  }

  .chat-send-row { grid-template-columns: 1fr; }

  .card {
    border-radius: 18px;
    padding: 14px;
  }

  .bottom-nav,
  .room-nav {
    border-radius: 16px;
  }

  h1 {
    font-size: 28px;
    margin: 0;
  }

  h2 { margin: 0; }

  .reveal-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 520px) {
  .reveal-row {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 14px;
    border-radius: 18px;
  }

  button {
    padding: 13px 15px;
  }
}