:root {
  --bg1: #fff1b8;
  --bg2: #b8f3ff;
  --card: #ffffff;
  --ink: #1f2544;
  --primary: #ff7a59;
  --secondary: #34c5b5;
  --danger: #ff4f73;
  --accent: #ffd93d;
  --border: #1f2544;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, #fff, transparent 25%),
    radial-gradient(circle at 85% 15%, #ffc6b9, transparent 20%),
    linear-gradient(140deg, var(--bg1), var(--bg2));
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
}

body.alien-font {
  font-family: 'Orbitron', 'Nunito', system-ui, sans-serif;
}

h1,
h2 {
  font-family: 'Baloo 2', cursive;
  margin: 0 0 2px;
  letter-spacing: 0.5px;
}

.app-logo {
  display: block;
  width: 100%;
  max-width: 280px;
  height: auto;
  margin: 0 auto 8px;
}

.logo-fallback {
  display: none;
}

.subtitle {
  margin: 0 0 16px;
  opacity: 0.85;
}

.app-shell {
  width: 100%;
  max-width: 480px;
  margin: 0;
}

.top-meta {
  width: 100%;
  max-width: 480px;
  display: grid;
  grid-template-columns: 140px 1fr;
  align-items: start;
  gap: 8px 10px;
  margin: 0 0 10px;
}

.card {
  background: var(--card);
  border: 3px solid var(--border);
  border-radius: 24px;
  box-shadow: 8px 8px 0 #00000024;
  padding: 20px;
  animation: pop-in 220ms ease-out;
}

.hidden {
  display: none;
}

.btn {
  width: 100%;
  border: 3px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 1rem;
  font-weight: 700;
  margin-top: 10px;
  cursor: pointer;
  transition: transform 80ms ease, filter 120ms ease;
}

.btn:active {
  transform: translateY(2px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.2);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-secondary {
  background: var(--secondary);
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

label,
.label {
  font-weight: 700;
  display: block;
  margin-top: 8px;
  margin-bottom: 4px;
}

input {
  width: 100%;
  border: 3px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 1rem;
  text-transform: uppercase;
}

#username {
  text-transform: none;
}

.join-wrap {
  margin-top: 16px;
  padding: 12px;
  border-radius: 14px;
  background: #ffe9b8;
}

.otp-wrap {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.otp-cell {
  text-align: center;
  border: 3px solid var(--border);
  border-radius: 12px;
  padding: 10px 0;
  font-size: 1.2rem;
  font-weight: 800;
  text-transform: uppercase;
  background: #fff;
}

.otp-cell:focus {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}

.help-text {
  margin: 6px 0 0;
  font-size: 0.85rem;
  opacity: 0.8;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 12px;
}

.toggle-label {
  font-weight: 800;
}

.switch {
  position: relative;
  width: 56px;
  height: 32px;
  display: inline-block;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.slider {
  position: absolute;
  inset: 0;
  background: #d7d7d7;
  border: 3px solid var(--border);
  border-radius: 999px;
  transition: background-color 160ms ease;
}

.slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 4px;
  top: 4px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--border);
  transition: transform 160ms ease;
}

.switch input:checked + .slider {
  background: var(--secondary);
}

.switch input:checked + .slider::before {
  transform: translateX(22px);
}

.switch input:focus + .slider {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}

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

.avatar-btn {
  border: 3px solid var(--border);
  border-radius: 12px;
  background: #fff;
  font-size: 1.3rem;
  padding: 6px;
  cursor: pointer;
}

.avatar-btn.active {
  background: var(--accent);
  transform: translateY(-2px);
}

.players-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
}

.players-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 3px solid var(--border);
  border-radius: 14px;
  background: #fff;
  padding: 10px 12px;
  margin: 8px 0;
}

.status-chips {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-self: end;
  grid-column: 2;
  gap: 6px;
  max-width: 65%;
}

.effect-chip {
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.78rem;
  font-weight: 800;
  color: #fff;
  border: 2px solid var(--border);
}

.effect-chip-jammed {
  background: #c62828;
}

.effect-chip-forced {
  background: #6a1b9a;
}

.effect-chip-double {
  background: #1565c0;
}

.effect-chip-life-link {
  background: #2e7d32;
}

.player-eliminated {
  opacity: 0.45;
}

.badge {
  background: var(--accent);
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.8rem;
  font-weight: 700;
}

.host-controls {
  margin-top: 14px;
}

.round-prompt {
  margin: 4px 0 0;
  text-align: center;
  font-size: 2rem;
  font-weight: 900;
}

.round-category {
  margin: 6px 0 12px;
  text-align: center;
  font-size: 1rem;
  font-weight: 800;
  opacity: 0.8;
}

#gadget-slot {
  margin-top: 12px;
  border-style: dashed;
}

#gadget-inbox-list {
  margin-top: 10px;
}

select {
  width: 100%;
  border: 3px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 1rem;
  background: #fff;
}

.me-chip {
  background: #fff;
  border: 3px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 800;
  justify-self: end;
  grid-column: 2;
  text-align: right;
}

.corner-logo {
  width: 140px;
  max-width: 32vw;
  height: auto;
  grid-column: 1;
  grid-row: 1 / span 2;
  align-self: start;
}

@media (max-width: 560px) {
  .top-meta {
    grid-template-columns: 1fr;
  }

  .corner-logo {
    grid-column: 1;
    grid-row: auto;
  }

  .me-chip,
  .status-chips {
    grid-column: 1;
    justify-self: end;
  }
}

.boot-loader {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #00000066;
  padding: 16px;
}

.boot-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 3px solid var(--border);
  border-radius: 16px;
  padding: 16px;
}

.boot-bar {
  width: 100%;
  height: 14px;
  border: 2px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: #f3f3f3;
}

.boot-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--secondary), var(--primary));
  transition: width 180ms ease;
}

.modal {
  position: fixed;
  inset: 0;
  background: #00000066;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 60;
}

.modal.hidden {
  display: none !important;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 3px solid var(--border);
  border-radius: 16px;
  padding: 16px;
}

.vote-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.vote-option.selected {
  outline: 4px solid var(--accent);
  transform: translateY(-1px);
}

.vote-line {
  opacity: 0;
  transform: translateY(6px);
  animation: vote-line-in 220ms ease-out forwards;
}

@keyframes vote-line-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg-word {
  color: #2b6cff;
  font-weight: 900;
  text-transform: uppercase;
}

.gadget-sender-note {
  font-size: 0.82rem;
  opacity: 0.8;
}

.toast {
  display: none !important;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes gadget-blink {
  0% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.08); filter: brightness(1.35); }
  100% { transform: scale(1); filter: brightness(1); }
}

@media (min-width: 700px) {
  body {
    padding: 24px;
  }

  .card {
    padding: 24px;
  }
}
