/* GameFundas player pages: home (live games), join form and lobby.
   Loaded after style.css on the player page only. In-game controller views keep
   the base game styles. */

body.controller {
  --brand-1: #ff8a3d;
  --brand-2: #e8466f;
  --brand-grad: linear-gradient(135deg, #ffb547 0%, var(--brand-1) 45%, var(--brand-2) 100%);
  --ok: #34d399;
  --live: #fbbf24;
  background:
    radial-gradient(700px 380px at 50% -120px, color-mix(in srgb, var(--brand-1) 22%, transparent), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}

/* The home page is allowed to be wider on laptops. Game views stay phone-width. */
body.controller #app.wide { max-width: 1040px; }

.p-logo { display: block; border-radius: 22%; }
.p-brand { font-weight: 500; letter-spacing: -0.01em; }
.p-brand b { font-weight: 800; background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ------------------------------------------------ home */

.p-home { display: grid; gap: 22px; padding-top: 8px; }
.p-hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 0 4px; }
.p-hero .p-logo { width: 64px; height: 64px; box-shadow: 0 10px 30px color-mix(in srgb, var(--brand-2) 35%, transparent); }
.p-hero h1 { font-size: 2.2rem; margin: 6px 0 0; }
.p-tagline { margin: 0; color: var(--muted); font-size: 1.02rem; max-width: 26em; }
.p-steps { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; width: 100%; text-align: left; }
.p-steps li { display: flex; align-items: center; gap: 12px; background: color-mix(in srgb, var(--surface) 70%, transparent); border: 1px solid var(--surface-2); border-radius: 12px; padding: 10px 14px; font-size: 0.95rem; }
.p-steps li span { font-size: 1.3rem; width: 1.6em; text-align: center; }

.p-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.p-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 4px 0 10px; }
.p-section-head h2, .p-section-head h3 { margin: 0; font-size: 1.15rem; }
.p-live { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.82rem; }
.p-live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); animation: p-pulse 1.8s ease-in-out infinite; }
@keyframes p-pulse { 50% { opacity: 0.35; } }

.p-games { display: flex; flex-direction: column; gap: 10px; }
button.p-game, button.p-resume {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--surface-2); border-radius: 16px; padding: 14px 16px; color: var(--text);
  transition: transform 0.08s ease, border-color 0.15s ease;
}
button.p-game:hover, button.p-resume:hover { border-color: color-mix(in srgb, var(--brand-1) 60%, var(--surface-2)); }
button.p-game:active, button.p-resume:active { transform: scale(0.99); }
.p-game-icon, .p-resume-icon {
  flex: none; width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 1.6rem;
  background: color-mix(in srgb, var(--brand-1) 16%, var(--surface-2));
}
.p-game-text, .p-resume-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.p-game-text strong { font-size: 1.12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-game-text small, .p-resume-text small { color: var(--muted); font-size: 0.86rem; }
.p-chevron { flex: none; font-size: 1.3rem; color: var(--muted); }
button.p-resume { background: linear-gradient(135deg, color-mix(in srgb, var(--brand-1) 22%, var(--surface)), color-mix(in srgb, var(--brand-2) 18%, var(--surface))); border-color: color-mix(in srgb, var(--brand-1) 50%, transparent); }
.p-resume-text strong { font-size: 1.1rem; }
button.p-resume .p-chevron { color: var(--text); }

.p-pill { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 1px 10px; font-size: 0.76rem; font-weight: 700; margin-top: 2px; }
.p-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.p-pill.open { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.p-pill.live { color: var(--live); background: color-mix(in srgb, var(--live) 14%, transparent); }

.p-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; color: var(--muted); padding: 30px 18px; border: 1px dashed var(--surface-2); border-radius: 16px; }
.p-empty strong { color: var(--text); font-size: 1.05rem; }
.p-empty-icon { font-size: 2.4rem; }
.p-spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--surface-2); border-top-color: var(--brand-1); animation: p-spin 0.8s linear infinite; }
@keyframes p-spin { to { transform: rotate(360deg); } }

.p-notice { margin: 0; background: color-mix(in srgb, var(--live) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--live) 30%, transparent); border-radius: 12px; padding: 10px 14px; font-size: 0.95rem; }
.p-foot { text-align: center; color: var(--muted); font-size: 0.88rem; padding: 6px 0 12px; }
.p-foot a { color: var(--text); font-weight: 600; text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--brand-1) 60%, transparent); }

@media (min-width: 900px) {
  .p-home { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); column-gap: 48px; align-items: start; padding-top: 48px; }
  .p-hero { text-align: left; align-items: flex-start; position: sticky; top: 48px; }
  .p-hero h1 { font-size: 3rem; }
  .p-tagline { font-size: 1.15rem; }
  .p-foot { grid-column: 1 / -1; }
}

/* ------------------------------------------------ join */

.p-join { display: flex; flex-direction: column; gap: 14px; }
.p-topbar { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; }
.p-back { background: var(--surface); border: 1px solid var(--surface-2); color: var(--text); width: 40px; height: 40px; border-radius: 12px; font-size: 1.1rem; }
.p-card { background: var(--surface); border: 1px solid var(--surface-2); border-radius: 20px; padding: 22px 18px; display: flex; flex-direction: column; gap: 14px; }
.p-card-icon { width: 60px; height: 60px; border-radius: 16px; display: grid; place-items: center; font-size: 1.9rem; background: color-mix(in srgb, var(--brand-1) 16%, var(--surface-2)); align-self: center; }
.p-card h1 { margin: 0; text-align: center; font-size: 1.6rem; }
.p-sub { margin: -8px 0 0; text-align: center; color: var(--muted); }
.p-field { display: flex; flex-direction: column; gap: 6px; }
.p-field > span { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.p-field small { color: var(--muted); font-size: 0.82rem; }
.p-field input { background: var(--bg); border: 1px solid var(--surface-2); min-height: 54px; }
.p-field input:focus { border-color: var(--brand-1); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-1) 25%, transparent); }
input.p-pin { text-align: center; font-size: 2rem; font-weight: 800; letter-spacing: 0.5em; padding-left: 0.5em; font-variant-numeric: tabular-nums; min-height: 64px; }
.p-error { margin: 0; color: var(--bad); font-weight: 600; }
button.p-cta { border: 0; border-radius: 14px; min-height: 56px; font-size: 1.15rem; font-weight: 800; color: #fff; background: var(--brand-grad); box-shadow: 0 8px 24px color-mix(in srgb, var(--brand-2) 35%, transparent); }
button.p-cta:active { transform: scale(0.99); }

/* ------------------------------------------------ in a game: top bar + lobby */

.p-gamebar { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.p-gamebar-name { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-me { flex: none; background: var(--surface); border: 1px solid var(--surface-2); border-radius: 999px; padding: 4px 12px; font-size: 0.88rem; font-weight: 600; }

.p-lobby { display: flex; flex-direction: column; gap: 12px; }
.p-lobby-hero { text-align: center; background: var(--surface); border: 1px solid var(--surface-2); border-radius: 20px; padding: 24px 18px 20px; }
.p-check { width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 50%; display: grid; place-items: center; font-size: 1.8rem; font-weight: 900; color: #fff; background: var(--brand-grad); }
.p-lobby-hero h2 { margin: 0 0 4px; font-size: 1.5rem; }
.p-lobby-hero p { margin: 0; color: var(--muted); }
.p-dots { display: flex; justify-content: center; gap: 6px; margin-top: 14px; }
.p-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-1); animation: p-bounce 1.2s ease-in-out infinite; }
.p-dots i:nth-child(2) { animation-delay: 0.15s; }
.p-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes p-bounce { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-5px); } }
.p-players { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.p-players li { background: var(--surface); border: 1px solid var(--surface-2); border-radius: 999px; padding: 6px 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.p-players li.me { border-color: color-mix(in srgb, var(--brand-1) 60%, transparent); }
.p-players li small { color: var(--muted); font-weight: 500; font-size: 0.78rem; }
.p-players li.offline { opacity: 0.45; }
details.p-rules { background: var(--surface); border: 1px solid var(--surface-2); border-radius: 14px; padding: 12px 16px; }
details.p-rules summary { font-weight: 700; cursor: pointer; }
details.p-rules ul { padding-left: 1.2rem; margin: 10px 0 0; display: flex; flex-direction: column; gap: 6px; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .p-live::before, .p-dots i, .p-spinner { animation: none; }
}
