/* Theme colours and shared values */
:root {
  --bg: #0b1020;
  --bg2: #111831;
  --card: #151d38;
  --card-2: #1b2547;
  --line: #26325c;
  --text: #e9edf8;
  --muted: #8e9bc4;
  --accent: #ff7a1a;
  --accent-2: #ffb066;
  --blue: #3d7bff;
  --green: #22c55e;
  --yellow: #f5b82e;
  --red: #ef4444;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}

/* Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: Inter, system-ui, sans-serif;
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(255,122,26,.16), transparent 60%),
    radial-gradient(900px 500px at -10% 20%, rgba(61,123,255,.16), transparent 60%),
    var(--bg);
  background: var(--bg);
}

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
}

.wrap {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 24px 40px;
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

h1 {
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 800;
  font-size: 40px;
  letter-spacing: .5px;
  line-height: 1;
}

h1 span {
  color: var(--accent);
}

.tagline {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.seg {
  display: flex;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}

.seg button {
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  transition: .2s;
}

.seg button.on {
  background: var(--accent);
  color: #1a0b00;
  cursor: default;
}

.pill-btn {
  color: var(--muted);
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  gap: 8px;
  align-items: center;
  transition: .2s;
}

.pill-btn:hover {
  border-color: var(--accent);
  color: var(--accent-2);
}

/* Layout */
.grid {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 22px;
  align-items: start;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.card-h {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.card-h h2 {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: .3px;
}

.ico {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(255,122,26,.14);
  color: var(--accent);
}

.ico svg {
  width: 18px;
  height: 18px;
}

.card-h .spacer {
  flex: 1;
}

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

@media (min-width: 720px) {
  .card {
    background: linear-gradient(180deg,var(--card),var(--bg2));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
  }
}

/* Hints */
.xp-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.xp-box {
  flex: 1;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.xp-box small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .8px;
}

.xp-box b {
  font-family: "Barlow Condensed";
  font-size: 26px;
}

.xp-bar {
  height: 6px;
  background: var(--card-2);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 16px;
}

.xp-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg,var(--accent),var(--accent-2));
  transition: width .4s;
}

.hint {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  margin-bottom: 8px;
  border-radius: 12px;
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  transition: .2s;
  text-align: left;
}

.hint .lock {
  font-size: 12px;
  opacity: .8;
}

.hint.can {
  border-style: solid;
  border-color: rgba(255,122,26,.5);
  color: var(--text);
}

.hint.can:hover {
  background: rgba(255,122,26,.08);
}

.hint.open {
  border-style: solid;
  border-color: rgba(34,197,94,.45);
  background: rgba(34,197,94,.08);
  color: var(--text);
  cursor: default;
}

.hint.open .lock {
  color: var(--green);
  font-weight: 700;
  font-size: 14px;
  opacity: 1;
}

/* History */
.hist-stats {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.hist-stats div {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
}

.hist-stats b {
  display: block;
  font-family: "Barlow Condensed";
  font-size: 24px;
}

.hist-stats small {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
}

.hist-list {
  max-height: 180px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hist-item {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--card-2);
}

.hist-item .w {
  color: var(--green);
  font-weight: 600;
}

.hist-item .l {
  color: var(--red);
  font-weight: 600;
}

.empty {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 10px;
}

/* Main play card */
.play {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 26px;
}

.play p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 16px;
}

.search {
  position: relative;
}

.input-row {
  display: flex;
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  transition: .2s;
}

.input-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255,122,26,.15);
}

.input-row input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font: 500 16px Inter;
  padding: 16px;
  width: 100px;
}

.input-row button {
  background: var(--accent);
  color: #1a0b00;
  font-weight: 700;
  letter-spacing: .6px;
  padding: 0 24px;
  transition: .2s;
}

.input-row button:disabled {
  background: var(--card-2);
  color: var(--muted);
  cursor: not-allowed;
}

.suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 10;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: none;
}

.suggest button {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 11px 14px;
  font-size: 14px;
  text-align: left;
}

.suggest button span {
  color: var(--muted);
  font-size: 12px;
}

.suggest button:hover,
.suggest button.act {
  background: rgba(255,122,26,.12);
}

.progress {
  display: flex;
  gap: 6px;
  margin-top: 18px;
  align-items: center;
}

.progress i {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--card-2);
  transition: .3s;
}

.progress i.used {
  background: var(--accent);
}

.progress i.win {
  background: var(--green);
}

.replay {
  display: none;
  margin-top: 16px;
}

.replay.show {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

/* Player Info stat cards */
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  padding: 14px 16px;
  background: linear-gradient(145deg,#2453d6,#13307f);
  border: 1px solid rgba(255,255,255,.08);
}

.stat small {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #c7d6ff;
  font-weight: 600;
}

.stat b {
  display: block;
  font-family: "Barlow Condensed";
  font-size: 44px;
  font-weight: 700;
  line-height: 1.05;
  margin-top: 2px;
}

.stat em {
  font-style: normal;
  font-size: 12px;
  color: #a9bdf5;
}

/* Guess table */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
}

th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
  padding: 0 6px 4px;
}

th:first-child {
  text-align: left;
}

td {
  background: var(--card-2);
  padding: 10px 6px;
  text-align: center;
  font-size: 14px;
}

td:first-child {
  border-radius: 12px 0 0 12px;
  text-align: left;
  padding-left: 14px;
  font-weight: 600;
}

td:last-child {
  border-radius: 0 12px 12px 0;
  padding-right: 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  min-width: 60px;
  justify-content: center;
}

/* Old chip styles with background colours (unused, kept for reference):
   .c-hit{background:rgba(34,197,94,.18);color:#6ee7a0}
   .c-hot{background:rgba(245,184,46,.38);color:var(--accent)}
   .c-warm{background:rgba(245,184,46,.38);color:#ffd36b}
   .c-cold{background:rgba(255,255,255,.04);color:var(--muted)} */

/* Hot/cold colours for guess chips */
.c-hit {
  color: #6ee7a0;
}

.c-hot {
  color: var(--accent);
}

.c-warm {
  color: #ffd36b;
}

.c-cold {
  color: var(--muted);
}

.xp-tag {
  color: var(--accent-2);
  font-weight: 700;
}

tr.correct td {
  background: rgba(34,197,94,.14);
}

tr.new td {
  animation: pop .45s ease;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.legend {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  flex-wrap: wrap;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

/* Share */
.share-grid {
  display: grid;
  grid-template-columns: repeat(5,1fr);
  gap: 8px;
}

.share-grid a {
  aspect-ratio: 1;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  transition: .2s;
}

.share-grid a:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  color: var(--accent);
}

.share-grid svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.share-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.share-label {
  font-size: 13px;
  color: var(--muted);
  margin-right: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.share-label svg {
  width: 16px;
  height: 16px;
  fill: var(--accent);
  color: var(--accent);
  flex: none;
}

.share-row a {
  width: 20px;
  height: 20px;
  aspect-ratio: auto;
  border: none;
  background: none;
}

/* Footer */
footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-top: 36px;
}

footer a {
  color: var(--accent);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(5,8,18,.7);
  backdrop-filter: blur(6px);
  display: none;
  place-items: center;
  z-index: 50;
  padding: 20px;
}

.modal.show {
  display: grid;
}

.modal-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px;
  max-width: 460px;
  width: 100%;
  box-shadow: var(--shadow);
  animation: pop .3s;
}

.modal-box h3 {
  font-family: "Barlow Condensed";
  font-size: 30px;
  margin-bottom: 10px;
}

.modal-box p,
.modal-box li {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.modal-box ul {
  padding-left: 18px;
  margin: 8px 0 18px;
}

.modal-box .big {
  font-family: "Barlow Condensed";
  font-size: 34px;
  color: var(--text);
  margin: 6px 0 14px;
}

.btn {
  background: var(--accent);
  color: #1a0b00;
  font-weight: 700;
  padding: 12px 20px;
  border-radius: 12px;
  width: 100%;
}

.modal-box.rules-box {
  max-width: 780px;
  max-height: calc(100vh - 40px);
  overflow: auto;
}

.modal-box h4 {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .3px;
  margin: 4px 0 8px;
}

/* Rules scoring table */
.table-scroll {
  overflow-x: auto;
  margin: 0 0 18px;
  border-radius: 12px;
}

.table-scroll:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.rules-table {
  border-spacing: 0 6px;
  min-width: 620px;
}

.modal-box .scoring-note {
  font-size: 13px;
  margin: 0 0 6px;
}

.rules-table th,
.rules-table td {
  font-size: 13px;
  line-height: 1.4;
  padding: 9px 10px;
  text-align: left;
  vertical-align: middle;
}

.rules-table thead th {
  background: none;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 600;
  padding-bottom: 2px;
}

.rules-table tbody td,
.rules-table tbody th {
  background: var(--card-2);
  color: var(--text);
  font-weight: 400;
}

.rules-table tbody td:first-child {
  border-radius: 12px 0 0 12px;
  padding-left: 14px;
  font-size: 15px;
  width: 36px;
}

.rules-table tbody td:last-child {
  border-radius: 0 12px 12px 0;
  padding-right: 14px;
}

.rules-table tbody th {
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
}

.rules-table .text-center {
  text-align: center;
}

.rules-table .xp-val {
  color: var(--accent-2);
  font-weight: 700;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 18px;
}

.rules-table .exact-match,
.rules-table .r-hit {
  color: #6ee7a0;
}

.rules-table .hot,
.rules-table .r-hot {
  color: var(--accent);
}

.rules-table .warm,
.rules-table .r-warm {
  color: #ffd36b;
}

.rules-table .cold,
.rules-table .r-cold {
  color: var(--muted);
}

/* Screen-reader-only text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Toast message */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--card-2);
  border: 1px solid var(--line);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  transition: .3s;
  z-index: 60;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ---------- Responsive: tablets and narrow windows ---------- */
@media (max-width: 1100px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .main-col {
    order: -1;
  }
}

/* ---------- Responsive: phones ---------- */
@media (max-width: 720px) {
  .grid {
    grid-template-columns: 1fr;
  }

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

  h1 {
    font-size: 32px;
  }

  /* Player Info stat cards: one row of 4, smaller text */
  .stats {
    grid-template-columns: repeat(4,minmax(0,1fr));
    gap: 6px;
  }

  .stat {
    padding: 10px 4px;
    border-radius: 10px;
    text-align: center;
  }

  .stat small {
    display: block;
    font-size: 9px;
    letter-spacing: .3px;
  }

  .stat b {
    font-size: 26px;
    margin-top: 2px;
  }

  .stat em {
    display: block;
    font-size: 9px;
  }

  /* Fit the page inside narrow phones (down to 320px) */
  .wrap {
    padding: 20px 16px 32px;
  }

  .card {
    border-bottom: 1px solid var(--card-2);
    padding-bottom: 22px;
  }

  .header-actions {
    flex-wrap: wrap;
  }

  /* Guesses table: each guess becomes a card with the player name on top
     and the seven values in equal columns underneath */
  .guess-table,
  .guess-table thead,
  .guess-table tbody {
    display: block;
  }

  .guess-table tr {
    display: grid;
    grid-template-columns: repeat(7,minmax(0,1fr));
  }

  .guess-table tbody tr {
    margin-top: 8px;
  }

  .guess-table th {
    font-size: 10px;
    letter-spacing: .5px;
    padding: 0 2px 2px;
  }

  .guess-table th:first-child {
    display: none;
  }

  .guess-table td {
    padding: 6px 2px 10px;
    font-size: 13px;
    border-radius: 0;
  }

  .guess-table td:first-child {
    grid-column: 1/-1;
    text-align: center;
    padding: 10px 12px 4px;
    border-radius: 12px 12px 0 0;
    overflow-wrap: anywhere;
  }

  .guess-table td:nth-child(2) {
    border-bottom-left-radius: 12px;
  }

  .guess-table td:last-child {
    border-bottom-right-radius: 12px;
    padding-right: 2px;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .guess-table .chip {
    min-width: 0;
    padding: 4px 3px;
    font-size: 13px;
    gap: 3px;
  }

  .guess-table .chip i {
    font-size: 11px;
  }
}

/* Phones in portrait: stack each hot/cold icon under its value so 7 columns fit;
   on the narrowest phones, also tighten the column headings */
@media (max-width: 480px) {
  .guess-table .chip {
    flex-direction: column;
    gap: 1px;
    line-height: 2em;
  }
}

@media (max-width: 380px) {
  .guess-table th {
    font-size: 9px;
    letter-spacing: 0;
  }
}

/* Win confetti (canvas sits behind the end-of-game modal box) */
.confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.modal .modal-box {
  position: relative;
}

/* Two-button row in the "Start a new game?" modal */
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

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

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent-2);
}

/* "Stats last updated" line under the Player Info cards */
.stats-updated {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

/* Close (×) button in the top-right corner of every modal. Sticky + float keeps it
   visible at the top while the Rules modal's content scrolls underneath. */
.modal-close {
  position: sticky;
  top: 0;
  float: right;
  z-index: 1;
  margin: -14px -14px 0 8px;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--card-2);
  border: 1px solid var(--line);
  font-size: 16px;
  transition: .2s;
}

/* Let clicks on the × icon pass through to the button itself */
.modal-close i {
  pointer-events: none;
}

.modal-close:hover {
  color: var(--accent-2);
  border-color: var(--accent);
}

.modal-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Season dropdown in the header */
/* Hidden when SEASON_PICKER_ENABLED is false in script.js */
.season-pick[hidden] {
  display: none;
}

.season-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px 0 16px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  transition: .2s;
}

.season-pick:hover,
.season-pick:focus-within {
  border-color: var(--accent);
}

.season-pick select {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  outline: 0;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  padding: 6px 26px 6px 4px;
  border-radius: 999px;
  /* Small chevron so it still reads as a dropdown */
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238e9bc4' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center;
}

.season-pick select:disabled {
  opacity: .6;
  cursor: progress;
}

/* The open list uses the browser's own menu; keep it dark to match */
.season-pick select option {
  background: var(--card-2);
  color: var(--text);
}

/* Season tag on Game History entries from past seasons */
.hist-season {
  color: var(--muted);
  font-size: 11px;
  margin-left: 4px;
}
