body {
  margin: 0;
  background: #0a0a0a;
  color: #eaeaea;
  font-family: Arial, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  overflow: hidden;
}

.container {
  width: 100%;
  max-width: 686px;
  height: 898px;
  background: #141414;
  border-radius: 16px;
  box-shadow: 0 0 40px rgba(255, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.form-progress-wrap {
  height: 3px;
  background: #1a1a1a;
  flex-shrink: 0;
}
.form-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #8b0000, #ff3333);
  box-shadow: 0 0 8px rgba(255, 0, 0, 0.55);
  transition: width 0.45s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.pages-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.form-banner {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.form-banner img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 0;
  margin: 0;
}

.page {
  position: absolute;
  top: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  transition: transform 0.6s ease, opacity 0.6s ease;
  display: flex;
  flex-direction: column;
}

.page.hidden { transform: translateX(-100%); opacity: 0; }
.page.next { transform: translateX(100%); }

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 28px 0;
  box-sizing: border-box;
}

.page-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #141414;
  border-top: 1px solid #222;
  flex-shrink: 0;
}

.page-footer.single {
  justify-content: flex-end;
}

h1, h2 { margin: 0 0 12px; }
h3 { margin: 16px 0 6px; font-size: 14px; color: #eaeaea; }
p { line-height: 1.55; margin: 8px 0; font-size: 14px; }

label { display: block; font-size: 14px; margin-top: 4px; }

input, select, textarea {
  width: 100%;
  padding: 12px;
  margin: 6px 0 14px;
  border-radius: 8px;
  border: 1px solid #333;
  background: #262626;
  color: white;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 14px;
}

textarea { resize: vertical; line-height: 1.5; }
input[readonly] { cursor: default; color: #fff; opacity: 0.85; }

input:focus, select:focus, textarea:focus { outline: none; border-color: #ff1a1a; }

/* Time range grid */
.time-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}
.time-grid label {
  font-size: 13px;
  color: #bdbdbd;
  margin: 0 0 4px;
}

.btn {
  padding: 10px 18px;
  border-radius: 25px;
  border: none;
  font-weight: bold;
  cursor: pointer;
}

.next-btn {
  background: linear-gradient(135deg, #ff1a1a, #8b0000);
  color: white;
  box-shadow: 0 0 15px rgba(255, 0, 0, 0.6);
}

.back-btn {
  background: #333;
  color: white;
}

img {
  width: 40%;
  display: block;
  margin: 10px auto 12px;
  border-radius: 10px;
}

/* Multi-select chips */
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; padding-bottom: 16px; }
.chip {
  border: 1px solid #333;
  background: #262626;
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  text-align: center;
  font-size: 14px;
  color: white;
  transition: all 0.2s ease;
}
.chip:hover { border-color: #ff1a1a; }
.chip.active {
  border-color: #ff1a1a;
  background: rgba(255, 0, 0, 0.12);
  box-shadow: 0 0 14px rgba(255, 0, 0, 0.8);
}

.helper { font-size: 13px; color: #bdbdbd; }

/* Tables */
.table { margin-top: 10px; padding-bottom: 16px; }
.row {
  display: grid;
  grid-template-columns: 120px repeat(7, 1fr);
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
  font-size: 12px;
}
.row.header { font-weight: bold; color: #aaa; }
.row.header div:first-child { visibility: hidden; }

.cell {
  height: 28px;
  border-radius: 6px;
  border: 1px solid #333;
  background: #1f1f1f;
  cursor: pointer;
  transition: all 0.2s ease;
}
.cell.active {
  background: rgba(255,0,0,0.2);
  border-color: #ff1a1a;
  box-shadow: 0 0 10px rgba(255,0,0,0.8);
}

/* Radio groups */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 16px;
}
.radio {
  border: 1px solid #333;
  background: #1f1f1f;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s ease;
}
.radio:hover { border-color: #ff1a1a; }
.radio.active {
  border-color: #ff1a1a;
  background: rgba(255, 0, 0, 0.12);
  box-shadow: 0 0 10px rgba(255, 0, 0, 0.6);
}

/* Clear button */
.clear-btn {
  background: transparent;
  border: 1px solid #555;
  color: #aaa;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  margin-bottom: 12px;
  transition: all 0.2s ease;
}
.clear-btn:hover { border-color: #ff1a1a; color: #ff1a1a; }

/* Player Card */
.player-card {
  background: linear-gradient(135deg, #1a1a1a, #0f0f0f);
  border: 1px solid #333;
  border-radius: 12px;
  padding: 16px;
  margin: 4px 0 16px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.player-card.loaded {
  border-color: #ff1a1a;
  box-shadow: 0 0 20px rgba(255, 0, 0, 0.15);
}
.player-loading {
  font-size: 13px;
  color: #888;
  text-align: center;
  padding: 4px 0;
}
.player-card-inner {
  display: flex;
  gap: 16px;
  align-items: center;
}
.player-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}
.player-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid #ff1a1a;
  object-fit: cover;
  background: #222;
  display: block;
}
.player-level-badge {
  position: absolute;
  bottom: -6px;
  right: -6px;
  background: #111;
  border: 1px solid #444;
  border-radius: 20px;
  padding: 2px 7px;
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: bold;
  color: #ffd700;
  white-space: nowrap;
}
.player-level-badge img {
  width: 14px;
  height: 14px;
  object-fit: contain;
}
.player-info {
  flex: 1;
  min-width: 0;
}
.player-name {
  font-size: 15px;
  font-weight: bold;
  color: #fff;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.player-meta-item {
  font-size: 12px;
  color: #aaa;
}
.player-meta-item span {
  color: #ddd;
}

/* ── Hero Cards (pages 6 & 7) ─────────────────────── */
.hero-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding-bottom: 16px;
}

.hero-card {
  background: linear-gradient(180deg, #120a08 0%, #0e0806 100%);
  border: 1px solid #2a1614;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.hero-card:focus-within { border-color: #8b0000; box-shadow: 0 0 16px rgba(160,0,0,.22); }

.hero-portrait {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: block;
  object-fit: cover;
  background: #1a0d0b;
  border-bottom: 1px solid #321810;
}

.hero-card-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hero-card-name {
  font-weight: bold;
  font-size: 13px;
  color: #e8d0cc;
  text-align: center;
  text-shadow: 0 0 12px rgba(220,80,60,.2);
}

/* Star picker — 5 stars, each with 6 selectable SVG facets */
.stp-picker { display: flex; flex-direction: column; gap: 6px; }

.stp-stars {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.stp-star-svg {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  cursor: pointer;
  overflow: visible;
  transition: transform 0.15s ease;
}
.stp-star-svg:hover { transform: scale(1.1); }
.stp-star-svg.star-active {}

.stp-facet {
  cursor: pointer;
  transition: fill 0.1s ease;
}

.stp-label { display: none; }

.hero-dont-have {
  background: rgba(8,0,0,.55);
  border: 1px solid #3d0000;
  color: #664444;
  border-radius: 4px;
  padding: 5px 14px;
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
  align-self: center;
  transition: all 0.2s ease;
}
.hero-dont-have:hover {
  background: rgba(80,0,0,.35);
  border-color: #aa0000;
  color: #ff5555;
  box-shadow: 0 0 10px rgba(160,0,0,.35);
}

/* ── Slider wrappers ─────────────────────────────────── */
.weapon-slider-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0;
}
.skill-slider-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0;
}
.weapon-label, .skill-label {
  font-size: 11px;
  color: #b03030;
  text-align: center;
  letter-spacing: 0.04em;
}

/* ── Heartbeat glow (double-beat like a real pulse) ─── */
@keyframes blood-pulse {
  0%   { box-shadow: 0 0 7px rgba(255,0,0,.55),  0 0 14px rgba(180,0,0,.25), 0 2px 5px rgba(0,0,0,.9); }
  10%  { box-shadow: 0 0 22px rgba(255,0,0,1),    0 0 44px rgba(220,0,0,.85), 0 0 70px rgba(160,0,0,.45), 0 2px 5px rgba(0,0,0,.9); }
  22%  { box-shadow: 0 0 10px rgba(255,0,0,.65),  0 0 20px rgba(200,0,0,.35), 0 2px 5px rgba(0,0,0,.9); }
  32%  { box-shadow: 0 0 17px rgba(255,0,0,.9),   0 0 36px rgba(210,0,0,.65), 0 0 55px rgba(140,0,0,.35), 0 2px 5px rgba(0,0,0,.9); }
  46%  { box-shadow: 0 0 7px rgba(255,0,0,.55),   0 0 14px rgba(180,0,0,.25), 0 2px 5px rgba(0,0,0,.9); }
  100% { box-shadow: 0 0 7px rgba(255,0,0,.55),   0 0 14px rgba(180,0,0,.25), 0 2px 5px rgba(0,0,0,.9); }
}

/* ── Track ───────────────────────────────────────────── */
input[type="range"].weapon-range,
input[type="range"].skill-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  outline: none;
  cursor: pointer;
  transition: opacity 0.3s ease, filter 0.3s ease;
}
input[type="range"].weapon-range::-webkit-slider-runnable-track,
input[type="range"].skill-range::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 1px;
  background: linear-gradient(
    to right,
    #cc2200 0%,
    #cc2200 var(--pct, 0%),
    #333 var(--pct, 0%),
    #333 100%
  );
}
input[type="range"].weapon-range::-moz-range-track,
input[type="range"].skill-range::-moz-range-track {
  height: 2px;
  border-radius: 1px;
  background: #333;
}
input[type="range"].weapon-range::-moz-range-progress,
input[type="range"].skill-range::-moz-range-progress {
  height: 2px;
  border-radius: 1px;
  background: #cc2200;
}

/* ── Thumb — webkit (Chrome, Edge, Safari) ───────────── */
input[type="range"].weapon-range::-webkit-slider-thumb,
input[type="range"].skill-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -6px;
  border-radius: 50%;
  background: radial-gradient(circle at 33% 28%, #ff9999 0%, #ee0000 38%, #6a0000 72%, #250000 100%);
  border: 1px solid rgba(255,80,50,.4);
  box-shadow: 0 0 6px rgba(255,0,0,.6), 0 0 12px rgba(180,0,0,.3);
  cursor: pointer;
  animation: blood-pulse 2.2s ease-in-out infinite;
  transition: transform 0.12s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.12s ease;
}
input[type="range"].weapon-range:hover::-webkit-slider-thumb,
input[type="range"].skill-range:not(.skill-inactive):hover::-webkit-slider-thumb {
  transform: scale(1.35);
  animation-play-state: paused;
  box-shadow: 0 0 18px rgba(255,0,0,1), 0 0 38px rgba(220,0,0,.75), 0 0 60px rgba(160,0,0,.4), 0 2px 8px rgba(0,0,0,.95);
}
input[type="range"].weapon-range:active::-webkit-slider-thumb,
input[type="range"].skill-range:active::-webkit-slider-thumb {
  transform: scale(0.88);
  animation-play-state: paused;
  box-shadow: 0 0 28px rgba(255,0,0,.95), 0 0 55px rgba(200,0,0,.8), 0 0 80px rgba(150,0,0,.5), 0 1px 4px rgba(0,0,0,.95);
}

/* ── Thumb — Firefox ─────────────────────────────────── */
input[type="range"].weapon-range::-moz-range-thumb,
input[type="range"].skill-range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 33% 28%, #ff9999 0%, #ee0000 38%, #6a0000 72%, #250000 100%);
  border: 1px solid rgba(255,80,50,.4);
  box-shadow: 0 0 6px rgba(255,0,0,.6), 0 0 12px rgba(180,0,0,.3);
  cursor: pointer;
  animation: blood-pulse 2.2s ease-in-out infinite;
  transition: transform 0.12s ease;
}

/* ── Inactive — dimmed but interactive (pointer-events stays on) */
input[type="range"].skill-inactive {
  opacity: 0.18;
  filter: grayscale(85%);
}
input[type="range"].skill-inactive::-webkit-slider-thumb { animation: none; }
input[type="range"].skill-inactive::-moz-range-thumb    { animation: none; }

/* ── Mobile ───────────────────────────────────────── */
@media (max-width: 560px) {
  body {
    align-items: flex-start;
    height: auto;
    min-height: 100dvh;
    overflow: auto;
  }

  .container {
    height: 100dvh;
    max-width: 100%;
    border-radius: 0;
    box-shadow: none;
  }

  /* Hero tables: scroll horizontally instead of overflowing */
  .table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .row {
    min-width: 480px;
  }

  /* Bigger tap targets */
  .chip {
    padding: 13px 12px;
  }

  .radio {
    padding: 13px 14px;
  }

  .btn {
    padding: 12px 22px;
    font-size: 15px;
  }

  /* Hero cards — 1 col, full width */
  .hero-cards {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .hero-portrait {
    object-fit: contain;
    height: 160px;
    width: 100%;
  }
  /* Fat-finger stars */
  .stp-star-svg {
    width: 52px;
    height: 52px;
  }
  .stp-stars { gap: 6px; }
  /* Fat-finger slider thumbs */
  input[type="range"].weapon-range::-webkit-slider-thumb,
  input[type="range"].skill-range::-webkit-slider-thumb {
    width: 22px;
    height: 22px;
    margin-top: -10px;
  }
  input[type="range"].weapon-range::-moz-range-thumb,
  input[type="range"].skill-range::-moz-range-thumb {
    width: 22px;
    height: 22px;
  }
}

/* ── Custom popover (replaces native alert) ─────────────────────────── */
.popover-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: popover-fade 140ms ease-out;
}
.popover-backdrop[hidden] { display: none; }

.popover-card {
  background: #1a0e0e;
  border: 1px solid rgba(255, 60, 60, 0.35);
  border-radius: 14px;
  padding: 28px 32px 22px;
  min-width: 280px;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 0 40px rgba(255, 0, 0, 0.25), 0 8px 30px rgba(0, 0, 0, 0.6);
  animation: popover-pop 160ms ease-out;
}

.popover-msg {
  color: #f4f4f4;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 18px;
  white-space: pre-line;   /* render \n in multi-line messages (e.g. the required-fields list) as line breaks */
}

.popover-ok {
  background: rgba(255, 60, 60, 0.18);
  border: 1px solid rgba(255, 60, 60, 0.55);
  color: #ffb8b8;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 28px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms, transform 120ms;
}
.popover-ok:hover  { background: rgba(255, 60, 60, 0.30); }
.popover-ok:active { transform: scale(0.97); }
.popover-ok:focus-visible {
  outline: 2px solid rgba(255, 60, 60, 0.6);
  outline-offset: 2px;
}

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

/* ── Player login (page 2) — mobile-first: stacked, full-width, 44px targets ── */
.auth-box[hidden],
.auth-signed-in[hidden],
.auth-error[hidden] { display: none; }

.auth-show {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin: -8px 0 6px;
  font-size: 13px;
  color: #bdbdbd;
  cursor: pointer;
}
/* The global input rule is full-width with padding — undo it for the checkbox. */
.auth-show input {
  width: 20px;
  height: 20px;
  margin: 0;
  padding: 0;
  accent-color: #ff1a1a;
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}
.auth-actions .btn { min-height: 44px; width: 100%; }
.auth-actions .btn:disabled { opacity: 0.6; cursor: wait; }

.auth-error {
  margin: 0 0 10px;
  padding: 8px 12px;
  border: 1px solid #ff1a1a;
  border-radius: 8px;
  background: rgba(255, 26, 26, 0.1);
  color: #ff6b6b;
  font-size: 13px;
}

.auth-signed-in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 14px;
  padding: 8px 12px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #1c1c1c;
  font-size: 13px;
}
.auth-logout {
  min-height: 44px;
  padding: 0 6px;
  border: none;
  background: none;
  color: #ff6b6b;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* The player's own rally seat. pre-line so the lines set via textContent break. */
.assignment-banner[hidden] { display: none; }
.assignment-banner {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid #ff1a1a;
  border-radius: 8px;
  background: rgba(255, 26, 26, 0.1);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-line;
}

@media (min-width: 561px) {
  .auth-actions { flex-direction: row; }
}
