/* ─── Reset & base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #050505;
  --card:        #101010;
  --elevated:    #151515;
  --border:      #1D1D1D;
  --primary:     #E6FF2E;
  --cacho:       #35F06D;
  --cricri:      #FF6262;
  --baraja:      #FF7A1A;
  --text:        #F5F5F0;
  --text2:       #8E8E86;
  --radius:      10px;
  --radius-lg:   16px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100dvh;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* ─── Layout helpers ────────────────────────────────────────────── */
.page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* Respeta safe-area en teléfonos con notch */
  padding:
    calc(env(safe-area-inset-top, 0px) + 24px)
    calc(env(safe-area-inset-right, 0px) + 20px)
    calc(env(safe-area-inset-bottom, 0px) + 32px)
    calc(env(safe-area-inset-left, 0px) + 20px);
}

.page--top {
  justify-content: flex-start;
}

.inner {
  width: 100%;
  max-width: 420px;
}

/* ─── Card ──────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  width: 100%;
}

.card--cacho  { border-color: rgba(53,240,109,.25); }
.card--cricri { border-color: rgba(255,98,98,.25); }

/* ─── Logo / brand ──────────────────────────────────────────────── */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}

.brand__hex {
  width: 36px;
  height: 36px;
  background: var(--primary);
  clip-path: polygon(50% 0%,93% 25%,93% 75%,50% 100%,7% 75%,7% 25%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 900;
  color: #050505;
  letter-spacing: -1px;
}

.brand__name {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.4px;
}

/* ─── Typography ────────────────────────────────────────────────── */
h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.3px; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; }

.mono {
  font-family: "SF Mono", "Fira Code", ui-monospace, monospace;
  letter-spacing: 6px;
  font-size: 42px;
  font-weight: 900;
}

.mono--sm {
  font-size: 22px;
  letter-spacing: 4px;
}

.text-secondary { color: var(--text2); }
.text-sm        { font-size: 13px; }
.text-center    { text-align: center; }

/* ─── Form elements ─────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.input {
  width: 100%;
  height: 52px;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  padding: 0 16px;
  outline: none;
  transition: border-color .15s;
}

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

.input--code {
  font-family: "SF Mono", ui-monospace, monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 6px;
  text-transform: uppercase;
  text-align: center;
}

/* ─── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  width: 100%;
  transition: opacity .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .45; pointer-events: none; }

.btn--primary  { background: var(--primary); color: #050505; }
.btn--cacho    { background: var(--cacho);   color: #050505; }
.btn--cricri   { background: var(--cricri);  color: #fff; }
.btn--ghost    { background: var(--elevated); color: var(--text); border: 1px solid var(--border); }
.btn--danger   { background: #2a0a0a; color: var(--cricri); border: 1px solid rgba(255,98,98,.3); }

/* ─── Apple Sign-In ─────────────────────────────────────────────── */
.btn--apple {
  background: #fff;
  color: #000;
  font-size: 15px;
}

.btn--apple svg { flex-shrink: 0; }

/* ─── Stack / spacing ───────────────────────────────────────────── */
.stack       { display: flex; flex-direction: column; gap: 16px; }
.stack--sm   { gap: 10px; }
.stack--lg   { gap: 24px; }

.row         { display: flex; align-items: center; gap: 10px; }
.row--spread { justify-content: space-between; }

/* ─── Divider ───────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  width: 100%;
  margin: 4px 0;
}

/* ─── Player list ───────────────────────────────────────────────── */
.player-list  { display: flex; flex-direction: column; gap: 8px; width: 100%; }

.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

.player-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.player-name { font-size: 15px; font-weight: 500; }
.player-me   { font-weight: 700; }

.lives {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.heart { font-size: 16px; line-height: 1; }
.heart--dead { opacity: .2; }

/* ─── Dado / cup ────────────────────────────────────────────────── */
.cup-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 32px 0;
}

.cup-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 72px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  transition: transform .15s;
  user-select: none;
}

.cup-btn:active { transform: scale(0.92); }

.dice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  min-height: 80px;
}

.die {
  width: 64px;
  height: 64px;
  background: var(--elevated);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  line-height: 1;
  transition: opacity .3s, transform .3s;
}

.die--hidden { opacity: 0; transform: scale(0.5); }

/* ─── Banner de acción pendiente ────────────────────────────────── */
.banner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5,5,5,.85);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 0 16px calc(env(safe-area-inset-bottom,0px) + 24px);
  backdrop-filter: blur(4px);
}

.banner {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid rgba(255,98,98,.4);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  animation: slideUp .25s ease-out;
}

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

/* ─── Status badge ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
}

.badge--waiting { background: rgba(142,142,134,.12); color: var(--text2); }
.badge--playing { background: rgba(53,240,109,.12);  color: var(--cacho); }
.badge--cricri  { background: rgba(255,98,98,.12);   color: var(--cricri); }

/* ─── Spinner ───────────────────────────────────────────────────── */
.spinner {
  width: 24px; height: 24px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Toast ─────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom,0px) + 20px);
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 10px 20px;
  font-size: 14px;
  white-space: nowrap;
  z-index: 200;
  opacity: 1;
  transition: opacity .3s, transform .3s;
}

.toast--hidden { opacity: 0; transform: translateX(-50%) translateY(10px); }

/* ─── Utilidades ────────────────────────────────────────────────── */
.hidden   { display: none !important; }
.w-full   { width: 100%; }
.mt-auto  { margin-top: auto; }
.mt-4     { margin-top: 16px; }
.mt-6     { margin-top: 24px; }
.mt-8     { margin-top: 32px; }
