:root {
  --app-bg: #1e1b4b;
  --app-bg-dark: #0f0e24;
  --app-color: #818cf8;
  --app-accent: #fbbf24;
  --app-gradient: linear-gradient(135deg, #312e81, #f59e0b);
  --text: #f8fafc;
  --muted: #c7d2fe;
  --surface: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.14);
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--app-bg);
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100dvh;
  min-height: -webkit-fill-available;
}

/* —— Splash —— */
.ofni-wow-splash {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  background: var(--app-bg);
  color: var(--text);
  transition: opacity 0.65s ease, visibility 0.65s ease;
}

.ofni-wow-splash.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.ofni-wow-splash__stage {
  grid-area: 1 / 1;
  position: relative;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.ofni-wow-splash__mesh {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 24%, rgba(129, 140, 248, 0.45), transparent 46%),
    radial-gradient(circle at 82% 78%, rgba(251, 191, 36, 0.32), transparent 42%),
    radial-gradient(circle at 52% 48%, rgba(99, 102, 241, 0.18), transparent 38%);
  animation: mesh 14s ease-in-out infinite alternate;
}

.ofni-wow-splash__orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(72px);
  opacity: 0.45;
  animation: orb 11s ease-in-out infinite alternate;
}

.ofni-wow-splash__orb--1 {
  width: min(58vw, 460px);
  height: min(58vw, 460px);
  background: rgba(129, 140, 248, 0.7);
  top: -10%;
  left: -12%;
}

.ofni-wow-splash__orb--2 {
  width: min(46vw, 340px);
  height: min(46vw, 340px);
  background: rgba(251, 191, 36, 0.55);
  bottom: -8%;
  right: -10%;
  animation-delay: -3s;
}

.ofni-wow-splash__orb--3 {
  width: min(30vw, 240px);
  height: min(30vw, 240px);
  background: rgba(56, 189, 248, 0.4);
  top: 42%;
  left: 58%;
  animation-delay: -6s;
}

.ofni-wow-splash__hero {
  grid-area: 1 / 1;
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  width: min(36rem, 100%);
}

.ofni-wow-splash__icon-wrap {
  width: 148px;
  height: 148px;
  display: grid;
  place-items: center;
}

.ofni-wow-splash__icon {
  width: 148px;
  height: 148px;
  border-radius: 36px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.ofni-wow-splash__wordmark {
  margin: 0;
  letter-spacing: 0.28em;
  text-transform: lowercase;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.ofni-wow-splash__app {
  margin: 0;
  font-size: clamp(1.4rem, 4vw, 1.85rem);
  font-weight: 800;
}

.ofni-wow-splash__pitch {
  min-height: 3.4em;
  width: min(34rem, 92vw);
  display: grid;
  place-items: center;
}

.ofni-wow-splash__pitch-line {
  margin: 0;
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.ofni-wow-splash__cursor {
  display: inline-block;
  width: 0.08em;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -0.12em;
  background: var(--app-accent);
  animation: blink 0.85s step-end infinite;
}

.ofni-wow-splash__status {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.ofni-wow-splash__footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(28px, env(safe-area-inset-bottom));
  z-index: 3;
  display: flex;
  justify-content: center;
  padding: 0 24px;
  pointer-events: none;
}

.ofni-wow-splash__track {
  width: min(320px, 78vw);
  height: 4px;
  border-radius: 999px;
  background: rgba(129, 140, 248, 0.22);
  overflow: hidden;
}

.ofni-wow-splash__bar {
  height: 100%;
  width: 4%;
  border-radius: inherit;
  background: var(--app-gradient);
  transition: width 0.45s ease;
}

@keyframes mesh {
  from { transform: scale(1) translate(0, 0); }
  to { transform: scale(1.08) translate(2%, -2%); }
}

@keyframes orb {
  from { transform: translate(0, 0); }
  to { transform: translate(4%, 6%); }
}

@keyframes blink {
  50% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .ofni-wow-splash__mesh,
  .ofni-wow-splash__orb,
  .ofni-wow-splash__cursor {
    animation: none;
  }
}

/* —— App shell —— */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  padding-top: max(12px, env(safe-area-inset-top));
  padding-left: max(14px, env(safe-area-inset-left));
  padding-right: max(14px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--border);
  background: rgba(15, 14, 36, 0.55);
  backdrop-filter: blur(10px);
}

.app-topbar h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  min-width: 0;
}

.app-topbar__version {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.9em;
}

.app-topbar__who {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: right;
  max-width: 48%;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-main {
  flex: 1;
  display: grid;
  place-items: start center;
  padding: 16px 14px max(28px, env(safe-area-inset-bottom));
  padding-left: max(14px, env(safe-area-inset-left));
  padding-right: max(14px, env(safe-area-inset-right));
  width: 100%;
}

.app-placeholder {
  width: min(40rem, 100%);
  text-align: center;
  padding: 28px 24px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
}

.app-placeholder h2 {
  margin: 0 0 8px;
  font-size: 1.35rem;
}

.app-placeholder p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.home {
  width: min(40rem, 100%);
  display: grid;
  gap: 14px;
}

.home__eyebrow {
  margin: 0;
  color: var(--app-accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.78rem;
  font-weight: 700;
}

.home h2 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2rem);
}

.home__when {
  margin: 0;
  color: #e2e8f0;
  font-size: 1.1rem;
  font-weight: 600;
}

.home__theme {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  min-height: 140px;
}

.home__theme-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  transform-origin: center center;
  will-change: transform, opacity;
}

.home__theme-caption {
  position: absolute;
  left: 12px;
  bottom: 10px;
  margin: 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 14, 36, 0.72);
  color: #fde68a;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.home__facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.home__facts-wide {
  grid-column: 1 / -1;
}

.home__label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.home__notes {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.92rem;
  font-weight: 400;
}

.home__notes:empty {
  display: none;
}

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

.home__map iframe {
  width: 100%;
  min-height: 220px;
  border: 0;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #0b1020;
}

.home__map-link {
  color: #c7d2fe;
  font-size: 0.9rem;
}

.home__players {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.home__players-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 10px;
}

.home__players-head h3 {
  margin: 0;
  font-size: 1rem;
}

.home__players-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.home__players-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.poll-timer {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.poll-timer:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.poll-timer.is-refreshing {
  color: var(--app-accent);
  border-color: var(--app-accent);
}

.player-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.player-list__row,
.player-list li {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
}

.player-list__row.is-me {
  border-color: rgba(251, 191, 36, 0.45);
}

.player-list__main {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 4px;
}

.player-list__name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.player-list__name-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 4px 0;
  margin: -4px 0;
  text-align: left;
  font: inherit;
  min-width: 0;
  touch-action: manipulation;
}

.player-list__name-btn:disabled {
  pointer-events: none;
}

.player-list__name-btn:not(:disabled) {
  cursor: pointer;
}

.player-list__name {
  font-weight: 600;
}

.player-list__name em {
  font-style: normal;
  color: var(--app-accent);
  font-weight: 500;
  font-size: 0.85em;
}

.player-list__crown {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 2px;
  margin: 0;
  cursor: pointer;
  touch-action: manipulation;
  line-height: 0;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}

.player-list__crown img {
  display: block;
  width: 18px;
  height: 18px;
}

.player-list__bring {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
  text-align: left;
}

button.player-list__bring {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  font: inherit;
  color: #c7d2fe;
  cursor: pointer;
  touch-action: manipulation;
  text-decoration: underline;
  text-decoration-color: rgba(199, 210, 254, 0.35);
  text-underline-offset: 2px;
}

.player-list__bring--add {
  color: var(--app-accent);
  text-decoration-color: rgba(251, 191, 36, 0.4);
}

.player-list__bring--empty {
  font-style: italic;
  opacity: 0.75;
}

.player-list__status {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: capitalize;
  flex-shrink: 0;
  padding-top: 2px;
}

button.player-list__status {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  text-transform: capitalize;
  cursor: pointer;
  touch-action: manipulation;
  /* Expand tap target without changing visual size */
  padding: 6px 2px;
  margin: -6px -2px;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.2);
  text-underline-offset: 2px;
}

/* Keep old attribute selector working in case anything still renders a span */
.player-list__status[data-action="rsvp"] {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.2);
  text-underline-offset: 2px;
}

.player-list__status.is-in { color: #86efac; }
.player-list__status.is-out { color: #fda4af; }
.player-list__status.is-pending { color: #fde68a; }

/* —— Modals —— */
body.has-modal {
  overflow: hidden;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: grid;
  place-items: end center;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: rgba(8, 7, 20, 0.72);
  backdrop-filter: blur(6px);
}

.modal-root[hidden] {
  display: none !important;
}

.modal {
  width: min(26rem, 100%);
  padding: 20px 18px 16px;
  border-radius: 18px 18px 14px 14px;
  border: 1px solid var(--border);
  background: #1a1740;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

.modal h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.modal__lede {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.45;
}

.modal__winner {
  margin: 0 0 8px;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fde68a;
}

.modal__crown {
  display: block;
  margin: 0 auto 10px;
  width: 48px;
  height: 48px;
}

.modal--crown {
  text-align: center;
}

.modal__label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.modal__input {
  width: 100%;
  margin-bottom: 14px;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}

.modal__input:focus {
  outline: 2px solid rgba(251, 191, 36, 0.55);
  outline-offset: 1px;
}

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

.btn {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.btn--game {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(134, 239, 172, 0.35);
  color: #bbf7d0;
}

.btn--out {
  background: rgba(244, 63, 94, 0.14);
  border-color: rgba(253, 164, 175, 0.35);
  color: #fecdd3;
}

.btn--secondary {
  background: rgba(129, 140, 248, 0.14);
  border-color: rgba(199, 210, 254, 0.28);
  color: #e0e7ff;
}

.modal__close {
  appearance: none;
  display: block;
  width: 100%;
  margin-top: 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  padding: 10px;
}

/* —— Phone-first tweaks —— */
@media (max-width: 480px) {
  .ofni-wow-splash__icon-wrap,
  .ofni-wow-splash__icon {
    width: 112px;
    height: 112px;
  }

  .ofni-wow-splash__icon {
    border-radius: 28px;
  }

  .ofni-wow-splash__pitch-line {
    font-size: clamp(1.25rem, 6.5vw, 1.7rem);
  }

  .ofni-wow-splash__hero {
    gap: 10px;
    width: min(100%, 92vw);
  }

  .app-topbar {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .app-topbar__who {
    max-width: 100%;
    flex: 1 1 100%;
    text-align: left;
    white-space: normal;
  }

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

  .home__players-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .home__map iframe {
    min-height: 180px;
  }

  .player-list__row,
  .player-list li {
    min-height: 44px;
    align-items: center;
  }

  .home__when {
    font-size: 1rem;
  }
}

@media (min-width: 720px) {
  .app-main {
    padding-top: 28px;
  }

  .home__map iframe {
    min-height: 260px;
  }
}

/* —— Couple group rows —— */

/* Full-width column: person row 1, person row 2, bring item */
.player-list__row--couple {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  background: var(--couple-tint, rgba(99,102,241,0.10));
  overflow: hidden;
}

.player-list__couple-names {
  display: flex;
  flex-direction: column;
  align-self: stretch;
}

/* Each person row: name left, status right — full width */
.player-list__person {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  align-self: stretch;
  gap: 8px;
  padding: 9px 12px;
  width: 100%;
  box-sizing: border-box;
}

.player-list__person + .player-list__person {
  border-top: 1px solid var(--border);
}

/* Name takes all available space, truncates if too long */
.player-list__person .player-list__name-btn {
  flex: 1 1 0;
  min-width: 0;
  text-align: left;
}

.player-list__person .player-list__name-btn .player-list__name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* Status stays right, never wraps */
.player-list__person .player-list__status {
  flex-shrink: 0;
  white-space: nowrap;
}

.player-list__person.is-me .player-list__name {
  color: var(--app-accent);
}

/* Bring item: full width below both names */
.player-list__couple-bring {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 7px 12px 10px;
  border-top: 1px solid var(--border);
}

/* —— Editable notes (host / superadmin) —— */

/* When the notes paragraph is editable, show a subtle pencil hint */
.home__notes--editable {
  cursor: pointer;
  border-radius: 8px;
  padding: 5px 8px;
  margin-left: -8px;
  transition: background 0.15s;
  position: relative;
}

.home__notes--editable:hover,
.home__notes--editable:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

.home__notes--editable::after {
  content: ' ✎';
  font-size: 0.8em;
  opacity: 0.45;
  white-space: nowrap;
}

/* Empty-state placeholder when editable but no notes yet */
.home__notes--editable:empty::before {
  content: 'Add parking & access notes…';
  color: var(--muted);
  opacity: 0.6;
  font-style: italic;
}

/* Override the :empty hiding rule for admins who can add notes */
.home__notes--editable:empty {
  display: block;
}

/* Textarea in the notes modal */
.modal__textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
}

/* Char counter below textarea */
.modal__char-count {
  margin: -8px 0 14px;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: right;
}

.modal__char-count.is-near-limit {
  color: #fde68a;
}

.modal__error {
  margin: 0 0 14px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(253, 164, 175, 0.3);
  color: #fecdd3;
  font-size: 0.88rem;
  line-height: 1.4;
}

.modal__error[hidden] {
  display: none;
}

/* —— Dev environment badge —— */
.app-topbar__env-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.18);
  border: 1px solid rgba(251, 191, 36, 0.5);
  color: #fbbf24;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  vertical-align: middle;
}

.app-topbar__env-badge[hidden] {
  display: none;
}
