/*
 * Shared mobile-first design system for the platform and every game.
 * Games link this file and add their own stylesheet on top.
 */
:root {
  --bg: #0b0b14;
  --bg-2: #12121f;
  --surface: #1a1a2b;
  --surface-2: #232338;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f4f4f8;
  --text-2: #a9a9c0;
  --text-3: #6e6e88;
  --primary: #8b5cf6;
  --primary-2: #a78bfa;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;

  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 26px;
  --gutter: 16px;
  --tap: 52px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;

  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(120% 60% at 100% 0%, rgba(139, 92, 246, 0.16), transparent 60%),
    radial-gradient(90% 50% at 0% 100%, rgba(236, 72, 153, 0.08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

/* ---------- Layout ---------- */

.app {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(var(--safe-top) + 12px) var(--gutter) calc(var(--safe-bottom) + 24px);
  display: flex;
  flex-direction: column;
}

@media (min-width: 900px) {
  .app--wide {
    max-width: 1080px;
  }
}

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

.topbar__title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.spacer {
  flex: 1;
}

/* ---------- Typography ---------- */

.h1 {
  font-size: 1.75rem;
  line-height: 1.3;
  font-weight: 700;
  margin: 0;
}

.h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
}

.muted {
  color: var(--text-2);
}

.small {
  font-size: 0.85rem;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 22px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface-2);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  user-select: none;
  transition: transform 0.12s ease, opacity 0.2s ease, background 0.2s ease;
}

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

.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.btn--primary {
  background: linear-gradient(135deg, var(--primary), #6d28d9);
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.35);
}

.btn--danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

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

.btn--block {
  width: 100%;
}

.btn--sm {
  min-height: 40px;
  padding: 0 14px;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
}

.icon-btn:active {
  transform: scale(0.94);
}

/* ---------- Forms ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field__label {
  font-size: 0.9rem;
  color: var(--text-2);
}

.input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 16px; /* 16px stops iOS from zooming in on focus */
  outline: none;
  transition: border-color 0.2s ease;
}

.input:focus {
  border-color: var(--primary);
}

.input--code {
  text-align: center;
  letter-spacing: 0.5em;
  font-size: 1.5rem;
  font-weight: 700;
  direction: ltr;
}

/* ---------- Surfaces ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}

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

.list__item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.avatar {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
}

.badge--live {
  background: rgba(34, 197, 94, 0.14);
  color: #86efac;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  inset-inline: var(--gutter);
  bottom: calc(var(--safe-bottom) + 20px);
  max-width: 520px;
  margin: 0 auto;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: center;
  font-weight: 600;
  transform: translateY(150%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
  z-index: 100;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.toast--error {
  border-color: rgba(239, 68, 68, 0.4);
}

[hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
