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

body {
  background: #f7f7f5;
  color: #1a1a1a;
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 2rem 1rem 3rem;
}

#app {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ---------- HEADER ---------- */

header {
  border-bottom: 2px solid #1a1a1a;
  padding-bottom: 0.6rem;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: #1a1a1a;
}

.subtitle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.2rem;
  flex-wrap: wrap;
}

.subtitle {
  font-size: 0.85rem;
  color: #666;
}

/* ---------- MODE SWITCHER ---------- */

.mode-switcher {
  display: flex;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  overflow: hidden;
}

.mode-btn {
  padding: 6px 18px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: #fff;
  color: #888;
  transition: background 0.15s, color 0.15s;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.mode-btn + .mode-btn {
  border-left: 1px solid #d0d0d0;
}

.mode-btn:hover:not(.locked) {
  background: #f5f5f5;
  color: #444;
}

.mode-btn.active {
  background: #1a1a1a;
  color: #fff;
}

.mode-btn.locked {
  color: #bbb;
  cursor: not-allowed;
  background: #fafafa;
}

@keyframes flash-locked {
  0%   { background: #fafafa; }
  40%  { background: #fee2e2; color: #dc2626; }
  100% { background: #fafafa; color: #bbb; }
}

.mode-btn.locked-flash {
  animation: flash-locked 0.45s ease forwards;
}

/* ---------- PRACTICE BACK BUTTON ---------- */

#back-to-categories {
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #666;
  background: #fff;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}

#back-to-categories:hover {
  border-color: #1a1a1a;
  color: #1a1a1a;
}

/* ---------- PRACTICE CATEGORY GRID ---------- */

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.75rem;
}

.cat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 1.2rem 0.75rem;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  text-align: center;
}

.cat-card:hover {
  border-color: #1a1a1a;
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
  transform: translateY(-2px);
}

.cat-card:active {
  transform: translateY(0);
}

.cat-emoji {
  font-size: 1.9rem;
  line-height: 1;
}

.cat-label {
  font-size: 0.86rem;
  font-weight: 700;
  color: #1a1a1a;
}

.cat-desc {
  font-size: 0.7rem;
  color: #aaa;
}

/* ---------- LIVES ---------- */

#lives-container {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lives-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #999;
  margin-right: 4px;
}

.life {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #ddd;
  transition: background 0.3s;
}

.life.active {
  background: #2ecc71;
}

/* ---------- STAT BAR ---------- */

#stat-bar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 0.75rem 1.25rem;
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #999;
}

.stat-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: #1a1a1a;
}

.stat-world .stat-value {
  color: #888;
  font-weight: 400;
}

.stat-divider {
  width: 1px;
  height: 32px;
  background: #e8e8e8;
}

/* ---------- ENERGY FLOW BAR ---------- */

#flow-bar {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 0.75rem 1.25rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.flow-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #999;
}

.flow-track {
  display: flex;
  height: 28px;
  border-radius: 4px;
  overflow: hidden;
  width: 100%;
  background: #f5f5f5;
  cursor: default;
}

.flow-segment {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
  overflow: hidden;
  transition: width 0.5s ease, filter 0.15s;
  min-width: 0;
  cursor: pointer;
}

.flow-segment:hover { filter: brightness(1.1); }

.flow-segment span {
  padding: 0 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.flow-segment.generation { background: #4a90c4; }
.flow-segment.exports    { background: #2ab5a0; }
.flow-segment.imports    { background: #e8925a; }

.flow-legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.flow-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: #666;
}

.flow-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.flow-swatch.generation { background: #4a90c4; }
.flow-swatch.exports    { background: #2ab5a0; }
.flow-swatch.imports    { background: #e8925a; }

/* ---------- CHARTS SECTION ---------- */

#charts-section {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 1rem;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 1.25rem 1.25rem 1rem;
}

.chart-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #888;
  margin-bottom: 0.5rem;
}

#chart-left {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#line-wrapper {
  position: relative;
  width: 100%;
  height: 300px;
}

#chart-right {
  display: flex;
  flex-direction: column;
  border-left: 1px solid #e8e8e8;
  padding-left: 1rem;
}

#bar-wrapper {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 300px;
}

/* ---------- SHARED LEGEND ---------- */

#legend-shared {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px 16px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 0.65rem 1rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: #444;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ---------- GLOSSARY ---------- */

#glossary {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
}

#glossary-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.7rem 1rem;
  cursor: pointer;
  list-style: none;
  font-size: 0.82rem;
  font-weight: 600;
  color: #555;
  user-select: none;
  transition: background 0.15s;
}

#glossary-trigger::-webkit-details-marker { display: none; }
#glossary-trigger:hover { background: #f9f9f9; }

.glossary-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e8e8e8;
  color: #666;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.glossary-arrow {
  margin-left: auto;
  font-size: 1rem;
  color: #bbb;
  transition: transform 0.2s;
}

#glossary[open] .glossary-arrow { transform: rotate(90deg); }

#glossary-body {
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.glossary-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.glossary-heading {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-bottom: 4px;
  border-bottom: 1px solid #f0f0f0;
}

.glossary-heading.fossil     { color: #8a4a2a; }
.glossary-heading.low-carbon { color: #6a4a9a; }
.glossary-heading.renewables { color: #2a7a4a; }

.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.6rem 1.5rem;
}

.glossary-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.glossary-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
  margin-top: 3px;
}

.glossary-item strong {
  font-size: 0.82rem;
  color: #1a1a1a;
  display: block;
  margin-bottom: 2px;
}

.glossary-item p {
  font-size: 0.75rem;
  color: #666;
  line-height: 1.45;
}

.glossary-source {
  font-size: 0.72rem;
  color: #aaa;
  border-top: 1px solid #f0f0f0;
  padding-top: 0.75rem;
}

.glossary-source a { color: #888; text-decoration: none; }
.glossary-source a:hover { text-decoration: underline; }

/* ---------- TOOLTIP ---------- */

#tooltip {
  position: fixed;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 8px 11px;
  font-size: 0.78rem;
  color: #1a1a1a;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 999;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  line-height: 1.6;
  max-width: 270px;
  width: max-content;
  word-break: break-word;
}

/* ---------- GUESS HISTORY ---------- */

#guesses {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.guess-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-radius: 3px;
  font-size: 0.85rem;
  border: 1px solid #e0e0e0;
  background: #fff;
  flex-wrap: wrap;
  gap: 6px;
}

.guess-row.correct {
  border-color: #2ecc71;
  background: #f0fdf4;
}

.guess-name {
  font-weight: 600;
  min-width: 140px;
}

.guess-hint {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #888;
  font-size: 0.8rem;
  flex-wrap: wrap;
}

.guess-arrow {
  display: flex;
  align-items: center;
  color: #1a1a1a;
  line-height: 1;
}

.guess-direction {
  font-size: 0.75rem;
  font-weight: 700;
  color: #555;
  letter-spacing: 0.03em;
  min-width: 28px;
}

.hint-divider {
  color: #ccc;
  margin: 0 2px;
}

/* ---------- BANNER ---------- */

#banner .win {
  background: #f0fdf4;
  border: 1px solid #2ecc71;
  color: #166534;
  border-radius: 4px;
  padding: 0.9rem 1.1rem;
  font-weight: 600;
  font-size: 0.95rem;
}

#banner .lose {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
  border-radius: 4px;
  padding: 0.9rem 1.1rem;
  font-weight: 600;
  font-size: 0.95rem;
}

/* ---------- INPUT ---------- */

#input-area {
  display: flex;
  gap: 8px;
}

#autocomplete-wrapper {
  flex: 1;
  position: relative;
}

#guess-input {
  width: 100%;
  padding: 9px 13px;
  background: #fff;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  color: #1a1a1a;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.2s;
}

#guess-input:focus { border-color: #888; }

#autocomplete-list {
  display: none;
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.ac-item {
  padding: 8px 13px;
  font-size: 0.88rem;
  cursor: pointer;
  color: #333;
  transition: background 0.1s;
}

.ac-item:hover  { background: #f5f5f5; }
.ac-item.ac-active { background: #f0f0f0; font-weight: 600; }

#submit-btn {
  padding: 9px 22px;
  background: #1a1a1a;
  border: none;
  border-radius: 3px;
  color: #fff;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

#submit-btn:hover  { background: #333; }
#submit-btn:active { transform: scale(0.97); }

/* ---------- NEW GAME / COME BACK ---------- */

#new-game-btn {
  width: 100%;
  padding: 10px;
  background: #fff;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  color: #666;
  font-size: 0.92rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

#new-game-btn:hover {
  border-color: #1a1a1a;
  color: #1a1a1a;
}

/* ---------- ERROR ---------- */

#error {
  font-size: 0.8rem;
  color: #dc2626;
}

#error:empty {
  display: none;
}

/* ---------- LOADING ---------- */

#loading {
  text-align: center;
  padding: 3rem;
  color: #888;
  font-size: 0.9rem;
}

/* ---------- FOOTER ---------- */

footer {
  text-align: center;
  font-size: 0.72rem;
  color: #aaa;
  border-top: 1px solid #e8e8e8;
  padding-top: 0.75rem;
}

footer a { color: #888; text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ---------- CAT CARD WRAP (list button) ---------- */

.cat-card-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
}

.cat-list-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border: 1px solid #e0e0e0;
  border-radius: 3px;
  background: #fff;
  color: #aaa;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
  z-index: 1;
}

.cat-list-btn:hover {
  border-color: #1a1a1a;
  color: #1a1a1a;
}

/* ---------- COUNTRY LIST MODAL ---------- */

#cl-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cl-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
}

.cl-box {
  position: relative;
  background: #fff;
  border-radius: 6px;
  width: min(480px, 92vw);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  overflow: hidden;
}

.cl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  font-weight: 700;
  font-size: 0.9rem;
  border-bottom: 1px solid #e8e8e8;
}

.cl-count {
  font-weight: 400;
  color: #888;
  font-size: 0.8rem;
}

.cl-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #888;
  line-height: 1;
  padding: 2px 4px;
}
.cl-close:hover { color: #1a1a1a; }

.cl-body {
  overflow-y: auto;
  padding: 0.4rem 0;
}

.cl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  border-bottom: 1px solid #f5f5f5;
}

.cl-row:last-child { border-bottom: none; }

.cl-name { font-weight: 500; }

.cl-meta {
  font-size: 0.75rem;
  color: #aaa;
}

/* ---------- BROWSE BUTTON ---------- */

.browse-btn-wrap {
  display: flex;
  justify-content: center;
  padding: 0.25rem 0 0.5rem;
}

.browse-all-btn {
  padding: 8px 22px;
  background: #fff;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.browse-all-btn:hover {
  border-color: #1a1a1a;
  color: #1a1a1a;
}

/* ---------- BROWSE SCREEN ---------- */

.browse-search-wrap {
  position: sticky;
  top: 0;
  background: #f7f7f5;
  padding: 0.5rem 0;
  z-index: 10;
}

#browse-search {
  width: 100%;
  padding: 9px 13px;
  background: #fff;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.2s;
}

#browse-search:focus { border-color: #888; }

.browse-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.browse-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 3px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
  width: 100%;
}

.browse-row:hover {
  border-color: #1a1a1a;
  background: #fafafa;
}

.browse-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: #1a1a1a;
}

.browse-meta {
  font-size: 0.75rem;
  color: #aaa;
}

#back-to-browse, #back-to-cats {
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #666;
  background: #fff;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}

#back-to-browse:hover, #back-to-cats:hover {
  border-color: #1a1a1a;
  color: #1a1a1a;
}

/* ---------- STATS / LEADERBOARD MODAL ---------- */

#stats-modal, #lb-modal, #username-modal {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The name prompt must sit above every other modal */
#username-modal { z-index: 700; }

.st-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
}

.st-box {
  position: relative;
  background: #fff;
  border-radius: 8px;
  width: min(420px, 94vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0,0,0,0.18);
  overflow: hidden;
}

.st-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem 0.8rem;
  border-bottom: 1px solid #efefef;
}

.st-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #1a1a1a;
}

.st-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: #888;
  line-height: 1;
  padding: 2px 4px;
}
.st-close:hover { color: #1a1a1a; }

/* stat grid */
.st-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  padding: 1rem 1.2rem;
  text-align: center;
}

.st-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.st-num {
  font-size: 2rem;
  font-weight: 700;
  color: #1a1a1a;
  line-height: 1;
}

.st-lbl {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #999;
}

/* distribution */
.st-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #999;
  padding: 0 1.2rem 0.5rem;
}

.st-dist {
  padding: 0 1.2rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.st-dist-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.st-dist-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #555;
  width: 14px;
  text-align: right;
  flex-shrink: 0;
}

.st-dist-bar-wrap {
  flex: 1;
}

.st-dist-bar {
  background: #d0d0d0;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 2px;
  min-width: 24px;
  text-align: right;
  transition: width 0.4s ease;
}

.st-dist-bar--current {
  background: #2ecc71;
}

/* footer */
.st-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1.2rem;
  border-top: 1px solid #efefef;
  flex-wrap: wrap;
}

.st-countdown-wrap {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.st-countdown-lbl {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #999;
}

.st-countdown {
  font-size: 1.35rem;
  font-weight: 700;
  color: #1a1a1a;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.st-share-btn {
  padding: 8px 16px;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.st-share-btn:hover { background: #333; }

.st-practice-btn {
  padding: 8px 16px;
  background: #fff;
  color: #1a1a1a;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s;
}
.st-practice-btn:hover { border-color: #1a1a1a; }

/* leaderboard coming soon */
.lb-coming-soon {
  padding: 2.5rem 1.2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.lb-coming-soon p {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a1a1a;
}

.lb-sub {
  font-size: 0.82rem !important;
  font-weight: 400 !important;
  color: #888 !important;
}

/* mode-switcher 4-button layout */
.mode-switcher {
  flex-wrap: wrap;
}

/* ---------- LEADERBOARD MODAL ---------- */

.lb-tabs {
  display: flex;
  border-bottom: 1px solid #efefef;
}

.lb-tab {
  flex: 1;
  padding: 0.65rem;
  background: none;
  border: none;
  font-size: 0.82rem;
  font-weight: 600;
  color: #999;
  cursor: pointer;
  transition: color 0.15s;
}

.lb-tab:hover { color: #1a1a1a; }

.lb-tab--active {
  color: #1a1a1a;
  border-bottom: 2px solid #1a1a1a;
  margin-bottom: -1px;
}

.lb-body {
  overflow-y: auto;
  max-height: 340px;
  padding: 0.5rem 0;
}

.lb-loading, .lb-empty {
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.85rem;
  color: #888;
}

.lb-list { display: flex; flex-direction: column; }

.lb-header-row {
  display: flex;
  align-items: center;
  padding: 0.3rem 1rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #bbb;
  border-bottom: 1px solid #f0f0f0;
}

.lb-row {
  display: flex;
  align-items: center;
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
  border-bottom: 1px solid #f8f8f8;
  transition: background 0.1s;
}

.lb-row:last-child { border-bottom: none; }
.lb-row:hover { background: #fafafa; }
.lb-row--me { background: #f0fdf4; font-weight: 600; }
.lb-row--me:hover { background: #e8faf0; }

.lb-rank {
  width: 32px;
  flex-shrink: 0;
  font-size: 0.85rem;
  color: #888;
}

.lb-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #1a1a1a;
}

.lb-score {
  width: 72px;
  text-align: right;
  flex-shrink: 0;
  font-size: 0.82rem;
  color: #888;
  font-variant-numeric: tabular-nums;
}

.lb-score--won  { color: #16a34a; font-weight: 700; }
.lb-score--lost { color: #dc2626; }

/* ============================================================
   MOBILE — iPhone and small screens (max 600px)
   ============================================================ */

@media (max-width: 600px) {

  body {
    padding: 1rem 0.75rem 2rem;
  }

  h1 { font-size: 1.4rem; }

  /* Mode switcher — 2x2 grid on mobile */
  .mode-switcher {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-radius: 4px;
    overflow: hidden;
  }

  .mode-btn {
    padding: 6px 8px;
    font-size: 0.75rem;
  }

  .mode-btn:nth-child(1),
  .mode-btn:nth-child(2) {
    border-bottom: 1px solid #d0d0d0;
  }

  /* Stack charts vertically (minmax stops the canvas's default 300 px width from pushing the card wider than small phones) */
  #charts-section {
    grid-template-columns: minmax(0, 1fr);
    padding: 0.9rem 0.9rem 0.75rem;
  }

  #chart-right {
    border-left: none;
    border-top: 1px solid #e8e8e8;
    padding-left: 0;
    padding-top: 0.75rem;
  }

  #line-wrapper  { height: 220px; }
  #bar-wrapper   { min-height: 180px; }

  /* Stat bar — 2 columns */
  #stat-bar {
    gap: 0.75rem;
    padding: 0.6rem 0.9rem;
    flex-wrap: wrap;
  }

  .stat-divider { display: none; }

  .stat-value { font-size: 0.85rem; }

  /* Flow bar */
  #flow-bar { padding: 0.6rem 0.9rem 0.55rem; }

  /* Category grid — 2 columns */
  .cat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
  }

  .cat-card { padding: 0.9rem 0.5rem; }
  .cat-emoji { font-size: 1.5rem; }
  .cat-label { font-size: 0.78rem; }
  .cat-desc  { font-size: 0.65rem; }

  /* Guess rows — stack hint below name */
  .guess-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 8px 10px;
  }

  .guess-hint {
    font-size: 0.75rem;
    flex-wrap: wrap;
    gap: 3px;
  }

  /* Input area */
  #input-area { gap: 6px; }
  #guess-input { font-size: 0.85rem; padding: 8px 10px; }
  #submit-btn  { padding: 8px 14px; font-size: 0.85rem; }

  /* Stats modal */
  .st-box { width: 96vw; }
  .st-num  { font-size: 1.6rem; }

  .st-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }

  .st-share-btn,
  .st-practice-btn {
    width: 100%;
    text-align: center;
  }

  /* Country list modal */
  .cl-box { width: 96vw; max-height: 75vh; }

  /* Browse list */
  .browse-row { padding: 8px 10px; }
  .browse-name { font-size: 0.83rem; }
  .browse-meta { font-size: 0.7rem; }

  /* Leaderboard */
  .lb-body { max-height: 260px; }
  .lb-row  { padding: 0.45rem 0.75rem; font-size: 0.8rem; }
  .lb-score { width: 40px; font-size: 0.75rem; }

  /* Glossary */
  .glossary-grid { grid-template-columns: 1fr; }

  /* Legend */
  #legend-shared { gap: 4px 10px; }
  .legend-item   { font-size: 0.72rem; }

  /* Footer */
  footer { font-size: 0.65rem; }
}

/* ---------- STATS MODAL — today's result ---------- */

.st-today {
  margin: 0 1.2rem 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.4;
}

.st-today--won {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #166534;
}

.st-today--lost {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
}

.st-today strong { font-weight: 700; }

/* ---------- LEADERBOARD — all-time avg column header ---------- */

.lb-score--hdr {
  color: #999;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Give the all-time table a touch more room */
.lb-row--alltime { padding: 0.65rem 1rem; }

.lb-body { max-height: 380px; }

/* ---------- GLOSSARY BUTTON in legend + GLOSSARY MODAL ---------- */

#legend-shared {
  position: relative;
}

.glossary-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #666;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.glossary-btn:hover { border-color: #1a1a1a; color: #1a1a1a; }

.glossary-btn .glossary-icon {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #e8e8e8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: #555;
}

.gl-box { max-width: 520px; }

.gl-body {
  overflow-y: auto;
  max-height: 70vh;
  padding: 1rem 1.2rem;
}

/* ---------- AUTOCOMPLETE — scrollable full list ---------- */

#autocomplete-list {
  max-height: 260px;
  overflow-y: auto;
}

/* Mobile: glossary button wraps below legend items */
@media (max-width: 600px) {
  .glossary-btn { margin-left: 0; margin-top: 4px; }
  #autocomplete-list { max-height: 200px; }
  .gl-box { width: 96vw; }
}

/* ---------- GUESS NUMBER BADGE + TIGHTER SPACING (practice/daily) ---------- */

.guess-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  background: #f0f0f0;
  color: #888;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  white-space: nowrap;
}

.guess-row.correct .guess-num {
  background: #dcfce7;
  color: #16a34a;
}

.guess-name {
  display: flex;
  align-items: center;
}

/* Tighten the space between input, error line, and the first guess */
#error {
  margin: 0;
}

#error:not(:empty) {
  margin-top: 4px;
}

/* Guesses container takes no space until it has at least one guess */
#guesses {
  margin: 0;
}

#guesses:not(:empty) {
  margin-top: 8px;
}

/* Banner collapses entirely when empty, spaced only when shown */
#banner {
  margin: 0;
}

#banner:not(:empty) {
  margin-top: 10px;
}

/* Next-game button only exists in the layout when visible (display toggled in JS) */
#new-game-btn {
  margin-top: 10px;
}

/* ── Leaderboard modal: larger than the shared .st-box, but not full screen ── */
#lb-modal .st-box.lb-box {
  width: min(760px, 92vw);     /* ~2x the current width on a monitor, near full width on phones */
  max-width: none;
  height: min(820px, 85vh);    /* fixed tall box; the list scrolls inside it */
  max-height: none;
  display: flex;
  flex-direction: column;
}
#lb-modal .lb-body {
  flex: 1 1 auto;              /* list fills the space under the header and tabs */
  min-height: 0;               /* lets the flex child scroll instead of overflowing */
  max-height: none;            /* removes the old short cap that caused the early scrollbar */
  overflow-y: auto;
}

/* ── Header right: podium + Leaderboard button ── */
.header-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.header-right { display: flex; align-items: center; gap: 18px; }
.header-right .mode-switcher { margin: 0; }

.podium {
  display: flex; align-items: flex-end; gap: 6px;
  background: none; border: 0; padding: 4px 6px; margin: 0;
  border-radius: 6px; cursor: pointer; font: inherit; color: inherit;
}
.podium:hover { background: rgba(0, 0, 0, 0.04); }
.podium-slot { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 72px; }
.podium-medal { font-size: 1.35rem; line-height: 1; }
.podium-name {
  max-width: 100%; font-size: 0.72rem; font-weight: 600; color: #444;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Row under the header line: lives left, mode buttons right ── */
.nav-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
  margin: 0;                   /* #app's 1.25rem gap already spaces this row, as it did the old lives row */
}
.nav-row #lives-container { margin: 0; }
.nav-row .mode-switcher { margin: 0 0 0 auto; flex-shrink: 0; }

/* ============================================================
   PHONES ONLY (max 600px) — compact header
   Desktop is unaffected by everything in this block.
   ============================================================ */
@media (max-width: 600px) {

  /* The older mobile rule made .mode-switcher a 2x2 grid for 4 buttons.
     The groups now hold 3 (Daily/Practice/Stats) and 1 (Leaderboard), so use a single row. */
  .mode-switcher { display: flex; flex-wrap: nowrap; }
  .mode-btn:nth-child(1),
  .mode-btn:nth-child(2) { border-bottom: none; }

  /* Row 1: larger title left; medals with the Leaderboard button stacked under them, right */
  .header-top { flex-wrap: nowrap; gap: 10px; align-items: center; }
  h1 { font-size: 1.9rem; white-space: nowrap; }
  .header-right {
    flex-direction: column; align-items: stretch; gap: 5px;
    flex-shrink: 1; min-width: 0;
  }
  .podium { gap: 0; padding: 2px; justify-content: space-between; }
  .podium-slot { width: 50px; }
  .podium-medal { font-size: 1.05rem; }
  .podium-name { font-size: 0.62rem; }
  .lb-switcher { width: 100%; }                       /* button spans the width of the medals */
  .lb-switcher .mode-btn { flex: 1; padding: 5px 8px; font-size: 0.72rem; }

  /* Row 2: subtitle kept to a single line */
  .subtitle {
    font-size: 0.72rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    min-width: 0; flex: 1;
  }
  .subtitle-row { flex-wrap: nowrap; }

  /* Row 3: Daily / Practice / Stats as a full-width row,
     Row 4: "Guesses left" as its own full row underneath */
  .nav-row { flex-direction: column-reverse; align-items: stretch; flex-wrap: nowrap; gap: 0.9rem; }
  .nav-row > div:empty { display: none; }              /* Practice/Browse screens have no dots */
  .nav-row .mode-switcher { width: 100%; margin: 0; }
  .nav-row .mode-btn { flex: 1; padding: 7px 8px; font-size: 0.78rem; }
  .nav-row #lives-container { justify-content: center; }
  .lives-label { white-space: nowrap; }

  /* Stat bar: 2x2 grid, centred — generation + its world average on top,
     demand per capita + its world average below */
  #stat-bar {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 0.7rem 0.75rem; text-align: center;
  }
  .stat-item { align-items: center; }
}

/* Very narrow phones (≤ 380px, e.g. many Androids at 360px): tighten one more step */
@media (max-width: 380px) {
  h1 { font-size: 1.65rem; }
  .podium-slot { width: 46px; }
  .podium-name { font-size: 0.58rem; }
  .subtitle { font-size: 0.68rem; }
  .stat-value { font-size: 0.8rem; }
}
/* ---------- LEADERBOARD — Weighted Score + optional explanation ---------- */

/* "Weighted Score ⓘ" header: a button that opens the explanation */
.lb-info-btn {
  background: none; border: none; padding: 0; margin: 0; cursor: pointer;
  font: inherit; text-transform: inherit; letter-spacing: inherit;
  display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px;
  text-align: right;
}
.lb-info-btn:hover, .lb-info-btn[aria-expanded="true"] { color: #4a90c4; }
.lb-info-icon {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid currentColor;
  font-size: 0.6rem; font-weight: 700; font-style: italic; font-family: Georgia, serif;
  text-transform: none; line-height: 1;
}

/* The explanation itself — only shown after a tap */
.lb-info-panel {
  margin: 0.4rem 1rem 0.6rem;
  padding: 0.7rem 0.9rem 0.8rem;
  background: #f4f8fc;
  border: 1px solid #d6e5f2;
  border-radius: 6px;
  font-size: 0.8rem; line-height: 1.5; color: #444;
}
.lb-info-head {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; color: #1a1a1a; margin-bottom: 0.35rem;
}
.lb-info-close {
  background: none; border: none; cursor: pointer;
  font-size: 1.1rem; line-height: 1; color: #888; padding: 0 2px;
}
.lb-info-close:hover { color: #1a1a1a; }
.lb-info-panel ul { padding-left: 1.1rem; display: flex; flex-direction: column; gap: 0.25rem; }
.lb-info-panel strong { color: #1a1a1a; }

/* Weighted Score column: the ranking key, so it stands out */
.lb-score--main { color: #1a1a1a; font-weight: 700; font-size: 0.88rem; }
.lb-score--main-hdr { color: #1a1a1a; width: 120px; }
.lb-row--alltime .lb-score--main { width: 120px; }

/* Reference line where scores pass the typical result */
.lb-avg-divider {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.35rem 1rem;
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: #4a90c4;
}
.lb-avg-divider::before, .lb-avg-divider::after {
  content: ''; flex: 1; border-top: 1px dashed #b9d3e8;
}

@media (max-width: 600px) {
  .lb-info-panel { margin: 0.4rem 0.75rem 0.6rem; font-size: 0.76rem; }
  .lb-score--main-hdr, .lb-row--alltime .lb-score--main { width: 70px; }
  .lb-info-btn { white-space: normal; line-height: 1.15; }
  .lb-avg-divider { padding: 0.3rem 0.75rem; }
  /* Narrow numeric columns: keep Win %, Avg and Played headers apart */
  #lb-modal .lb-score { width: 44px; flex-shrink: 0; }
  #lb-modal .lb-header-row .lb-score { font-size: 0.6rem; letter-spacing: 0.02em; }
  /* Weighted Score (far right) needs room for its two-line header and the info icon */
  #lb-modal .lb-score.lb-score--main-hdr,
  #lb-modal .lb-row--alltime .lb-score.lb-score--main { width: 70px; margin-left: 6px; }
}
.lb-info-sub {
  margin: 0.55rem 0 0.25rem; padding-top: 0.5rem; border-top: 1px solid #d6e5f2;
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #4a90c4;
}

/* ============================================================
   MOTION — load animations + ambient pulses
   ============================================================ */
header { position: relative; }

.logo-bolt { display: inline-block; transform-origin: 50% 60%; }
header.intro-play .logo-bolt { animation: boltFlicker .55s steps(1, end) .1s both; }
@keyframes boltFlicker {
  0% { opacity: 0 } 15% { opacity: 1 } 25% { opacity: .15 } 40% { opacity: 1 }
  55% { opacity: .35 } 70%, 100% { opacity: 1 }
}

/* a short charge every 7–20 s (timed in game.js) */
.logo-bolt.bolt-pulse { animation: boltPulse .9s ease-out; }
@keyframes boltPulse {
  0%   { transform: scale(1); filter: none; }
  18%  { transform: scale(1.22) rotate(-6deg); filter: drop-shadow(0 0 6px rgba(255, 196, 0, .95)) brightness(1.15); }
  34%  { transform: scale(.96); filter: drop-shadow(0 0 2px rgba(255, 196, 0, .5)); }
  48%  { transform: scale(1.07); filter: drop-shadow(0 0 4px rgba(255, 196, 0, .7)); }
  100% { transform: scale(1); filter: none; }
}

/* a current runs along the header line on first load */
.header-current {
  position: absolute; left: 0; right: 0; bottom: -2px; height: 2px;
  overflow: hidden; pointer-events: none;
}
.header-current::before {
  content: ''; position: absolute; top: 0; left: -18%; width: 16%; height: 100%;
  background: linear-gradient(90deg, rgba(245, 200, 66, 0), #f5c842 40%, #fff6cf 50%, #f5c842 60%, rgba(245, 200, 66, 0));
  box-shadow: 0 0 8px 1px rgba(245, 200, 66, .6);
  animation: headerCurrent 1.1s cubic-bezier(.5, 0, .4, 1) .45s forwards;
}
@keyframes headerCurrent { to { left: 102%; } }
/* the same current, fired with every ambient pulse (no start delay, slightly softer) */
.header-current.is-pulse::before { animation-delay: 0s; animation-duration: 1.2s; opacity: .85; }

/* legend: hover or tap a source to bring its line forward */
#legend-shared .legend-item { cursor: pointer; padding: 2px 6px; border-radius: 4px; transition: opacity .2s, background .2s; }
#legend-shared .legend-item:hover,
#legend-shared .legend-item.is-on { background: #f3f3f1; }
#legend-shared .legend-item.is-on { font-weight: 600; color: #1a1a1a; }
#legend-shared .legend-item.is-dim { opacity: .4; }
#legend-shared .legend-item:focus-visible { outline: 2px solid #f5c842; outline-offset: 1px; }

/* energy balance fills in: generation first, then imports / exports */
.flow-segment { transform-origin: left center; animation: flowGrow .7s cubic-bezier(.3, .7, .3, 1) .6s both; }
.flow-segment.imports,
.flow-segment.exports { position: relative; animation-delay: 1.25s; animation-duration: .35s; }
.flow-segment.imports::after,
.flow-segment.exports::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .4), rgba(255, 255, 255, 0));
  background-size: 200% 100%;
  animation: flowShimmer 2.2s linear 1.7s infinite;
}
@keyframes flowGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes flowShimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* overlay for the spark that runs along a chart line */
canvas.line-pulse { position: absolute; left: 0; top: 0; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  header.intro-play .logo-bolt, .logo-bolt.bolt-pulse, .flow-segment,
  .flow-segment.imports::after, .flow-segment.exports::after, .header-current::before { animation: none !important; }
  .header-current, canvas.line-pulse { display: none; }
}

/* ============================================================
   BALANCE CARD — headline stats (left) + energy balance flow chart (right)
   ============================================================ */
#balance-card {
  display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px;
}
.bc-stats, .bc-flow { background: #fff; border: 1px solid #e0e0e0; border-radius: 4px; box-sizing: border-box; }
.bc-stats {
  display: flex; flex-direction: column; justify-content: space-evenly; align-items: center; text-align: center;
  gap: 18px; padding: 22px 16px;
}
.bc-stat { display: flex; flex-direction: column; align-items: center; gap: 6px; }
#balance-card .stat-value { font-size: 1.75rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.15; }
.bc-world {
  margin-top: 2px; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.bc-world--gen { background: rgba(100, 116, 139, .12); color: #475569; }   /* generation colour, very light */
.bc-world--dem { background: rgba(31, 41, 55, .07);   color: #374151; }   /* demand colour, very light */
.bc-flow { padding: 14px 20px 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }

#flow-chart { position: relative; width: 100%; }
#flow-chart svg { position: absolute; left: 0; top: 0; overflow: visible; }
.fc-box {
  position: absolute; box-sizing: border-box; background: #fff; border: 1px solid #e2e4e8; border-radius: 6px;
  display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 1px; padding: 0 8px;
}
.fc-accent { position: absolute; width: 4px; }
.fc-accent--L { right: -1px; }
.fc-accent--R { left: -1px; }
.fc-name { font-size: 11px; font-weight: 700; letter-spacing: .06em; }
.fc-val  { font-size: 17px; font-weight: 600; color: #111827; font-variant-numeric: tabular-nums; line-height: 1.2; white-space: nowrap; }
.fc-tag  { position: absolute; transform: translateY(-50%); line-height: 1; font-size: 13px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* load animation: boxes appear, flows grow left to right, then the shares */
.fc-animate .fc-box { opacity: 0; animation: fcIn .35s ease-out .15s forwards; }
.fc-animate .fc-link { transform-box: fill-box; transform-origin: left center; transform: scaleX(0); animation: fcGrow .8s cubic-bezier(.3,.7,.3,1) .4s forwards; }
.fc-animate .fc-link--trade { animation-delay: .6s; }
.fc-animate .fc-tag { opacity: 0; animation: fcIn .35s ease-out 1.25s forwards; }
@keyframes fcGrow { to { transform: scaleX(1); } }
@keyframes fcIn { to { opacity: 1; } }

@media (max-width: 600px) {
  #balance-card { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .bc-stats { flex-direction: row; justify-content: space-around; align-items: flex-start; gap: 12px; padding: 16px 10px; }
  .bc-stat { flex: 1; min-width: 0; gap: 3px; }
  #balance-card .stat-value { font-size: 1.25rem; }
  .bc-world { font-size: 0.68rem; padding: 2px 8px; }
  .bc-flow { padding: 12px 12px 14px; gap: 10px; }
  .fc-name { font-size: 9.5px; }
  .fc-val  { font-size: 13.5px; }
  .fc-tag  { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .fc-animate .fc-box, .fc-animate .fc-link, .fc-animate .fc-tag { animation: none !important; opacity: 1; transform: none; }
}

/* ---------- flow chart polish ---------- */
.fc-box { box-shadow: 0 1px 2px rgba(17, 24, 39, .05); }
.fc-accent--L { border-radius: 0 2px 2px 0; }
.fc-accent--R { border-radius: 2px 0 0 2px; }
.fc-tag { text-shadow: 0 0 3px rgba(255, 255, 255, .9), 0 0 1px rgba(255, 255, 255, .9); }
#flow-chart .fc-link { transition: opacity .2s ease; cursor: default; }
#flow-chart .fc-links:hover .fc-link { opacity: .45; }          /* hovering one flow quiets the other */
#flow-chart .fc-links .fc-link:hover { opacity: 1; }

/* ---------- stats: whose stats these are ---------- */
.st-player {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 12px; padding: 8px 12px; background: #f6f6f4; border-radius: 6px;
  font-size: .85rem; color: #333; line-height: 1.3;
}
.st-player strong { font-weight: 700; color: #1a1a1a; }
.st-player-note { display: block; font-size: .72rem; color: #888; }
.st-player-avatar {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: #1a1a1a; color: #fff; font-size: .8rem; font-weight: 700;
}
.st-player-avatar--empty { background: #d4d4d4; color: #fff; }

/* ============================================================
   STATS MODAL (refreshed): personal header, today, tiles, distribution
   ============================================================ */
.sx-box {
  position: relative; background: #fff; border-radius: 14px;
  width: min(500px, 94vw); max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .22);
  display: flex; flex-direction: column;
}
.sx-head { display: flex; align-items: center; gap: 16px; padding: 26px 28px 18px; }
.sx-avatar {
  width: 54px; height: 54px; flex-shrink: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 22px; font-weight: 700;
}
.sx-who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.sx-name { font-size: 1.35rem; font-weight: 700; color: #1a1a1a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sx-sub { font-size: .85rem; color: #6b7280; }
.sx-close {
  width: 40px; height: 40px; flex-shrink: 0; border: 0; border-radius: 50%;
  background: #f3f3f1; color: #555; font-size: 20px; cursor: pointer;
}
.sx-close:hover { background: #e8e8e5; }

.sx-today { margin: 0 28px 18px; padding: 14px 16px; border-radius: 12px; display: flex; align-items: center; gap: 14px; }
.sx-today--won  { background: #ecf7f0; }
.sx-today--lost { background: #fdeceb; }
.sx-today-badge {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 17px;
}
.sx-today--won .sx-today-badge  { background: #22a04b; }
.sx-today--lost .sx-today-badge { background: #c0392b; }
.sx-today-title { display: block; font-size: 1rem; font-weight: 700; }
.sx-today--won .sx-today-title  { color: #14532d; }
.sx-today--lost .sx-today-title { color: #7f1d1d; }
.sx-today-sub { display: block; font-size: .8rem; margin-top: 2px; }
.sx-today--won .sx-today-sub  { color: #2f6b45; }
.sx-today--lost .sx-today-sub { color: #9b3a32; }

.sx-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0 28px; border: 1px solid #ececec; border-radius: 12px; }
.sx-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px 4px; }
.sx-tile + .sx-tile { border-left: 1px solid #ececec; }
.sx-tile-num { font-size: 1.7rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sx-tile-lbl { font-size: .75rem; color: #6b7280; text-align: center; }

.sx-dist-head {
  display: flex; justify-content: space-between; align-items: baseline; padding: 24px 28px 10px;
  font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #888;
}
.sx-dist-head span:last-child { text-transform: none; letter-spacing: 0; font-weight: 500; font-variant-numeric: tabular-nums; }
.sx-dist { display: flex; flex-direction: column; gap: 9px; padding: 0 28px 24px; }
.sx-row { display: grid; grid-template-columns: 18px minmax(0, 1fr) 64px; gap: 12px; align-items: center; }
.sx-key { font-size: .85rem; font-weight: 700; color: #444; text-align: center; font-variant-numeric: tabular-nums; }
.sx-track { height: 20px; border-radius: 6px; background: #f1f1ef; overflow: hidden; display: block; }
.sx-fill {
  display: block; height: 100%; border-radius: 6px; background: #9aa3ad;
  transform-origin: left center; transform: scaleX(0); animation: sxGrow .6s cubic-bezier(.3, .7, .3, 1) forwards;
}
.sx-fill--today { background: #22a04b; }
.sx-fill--x     { background: #c0654a; }
.sx-fill--lost  { background: #c0392b; }
@keyframes sxGrow { to { transform: scaleX(1); } }
.sx-count { font-size: .8rem; text-align: right; color: #1a1a1a; font-variant-numeric: tabular-nums; }
.sx-count--zero  { color: #bbb; }
.sx-count--today { font-weight: 700; }

.sx-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 18px 28px 22px; border-top: 1px solid #ececec; background: #fafaf8;
}
.sx-next { display: flex; flex-direction: column; }
.sx-next-lbl { font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #888; }
.sx-next-time { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.sx-actions { display: flex; gap: 8px; }
.sx-btn {
  min-height: 44px; padding: 0 18px; border-radius: 8px; border: 1px solid #d4d4d4; background: #fff;
  font-family: inherit; font-size: .9rem; font-weight: 600; color: #1a1a1a; cursor: pointer;
}
.sx-btn:hover { border-color: #1a1a1a; }
.sx-btn--dark { background: #1a1a1a; color: #fff; border-color: #1a1a1a; }
.sx-btn--dark:hover { background: #333; }

@media (max-width: 520px) {
  .sx-head { padding: 20px 18px 14px; gap: 12px; }
  .sx-avatar { width: 44px; height: 44px; font-size: 18px; }
  .sx-today, .sx-tiles { margin-left: 18px; margin-right: 18px; }
  .sx-tile-num { font-size: 1.35rem; }
  .sx-dist-head { padding: 20px 18px 8px; }
  .sx-dist { padding: 0 18px 20px; }
  .sx-foot { padding: 16px 18px 18px; }
}
@media (prefers-reduced-motion: reduce) { .sx-fill { animation: none; transform: none; } }

/* ============================================================
   GUESSES LEFT — six-cell battery
   ============================================================ */
#lives-container { gap: 10px; }
.lives-label { margin-right: 0; }
.battery { display: inline-flex; align-items: center; }
.battery-body { display: inline-flex; gap: 2px; padding: 2px; border: 2px solid #1a1a1a; border-radius: 5px; }
.battery-cap { width: 3px; height: 8px; background: #1a1a1a; border-radius: 0 2px 2px 0; }
.battery-cell { width: 13px; height: 16px; border-radius: 2px; background: #ececea; transition: background .3s; }
.battery-cell.is-high { background: #58b07a; }
.battery-cell.is-mid  { background: #e0b25a; }
.battery-cell.is-low  { background: #c97064; }
.battery-cell.is-drain { animation: batDrain .8s steps(1, end) forwards; }
@keyframes batDrain { 0% { background: #c97064; } 15% { background: #ececea; } 30% { background: #c97064; } 45% { background: #ececea; } 60% { background: #c97064; } 75%, 100% { background: #ececea; } }
.battery-cell.is-glow { animation: batGlow .5s ease-out both; }
@keyframes batGlow { 0% { filter: brightness(1); } 50% { filter: brightness(1.35); box-shadow: 0 0 8px rgba(46, 204, 113, .8); } 100% { filter: brightness(1); } }
.battery-count { font-size: .8rem; font-weight: 700; color: #444; font-variant-numeric: tabular-nums; }

/* ============================================================
   FLAGS
   ============================================================ */
.flag, .ac-flag {
  width: 20px; height: 15px; flex-shrink: 0; display: block; object-fit: cover;
  border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .1); background: #f0f0ee;
}
.flag--none { background: #ececea; }
.ac-item { display: flex; align-items: center; gap: 10px; }
#guess-flag { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); pointer-events: none; z-index: 1; }
#guess-flag:empty { display: none; }
#autocomplete-wrapper.has-flag #guess-input { padding-left: 42px; }

/* ============================================================
   GUESS ROWS — slim rows with a closeness ring, hint pill and live wire
   ============================================================ */
#guesses { gap: 5px; }
.gr-row {
  --cl: 196, 112, 96;
  position: relative; padding: 5px 10px 5px 6px; border-radius: 6px;
  background: #fff; border: 1px solid #e6e5e1;
}
.gr-main { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; }

.gr-num {
  position: relative; width: 30px; height: 30px; padding: 0; border: 0; background: none; border-radius: 50%;
  cursor: help; font: inherit; display: inline-flex; align-items: center; justify-content: center;
}
.gr-num svg { position: absolute; inset: 0; }
.gr-ring-bg { fill: rgba(var(--cl), .08); stroke: #ecebe8; stroke-width: 2.5; }
.gr-ring { fill: none; stroke: rgb(var(--cl)); stroke-width: 2.5; stroke-linecap: round; }
.gr-n { position: relative; font-size: 12px; font-weight: 700; color: #333; font-variant-numeric: tabular-nums; }

.gr-who { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.gr-name { display: inline-flex; align-items: center; gap: 8px; min-width: 0; align-self: center; font-size: .95rem; font-weight: 600; }
.gr-name > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gr-facts { font-size: .82rem; color: #888; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.gr-dot { color: #ccc; margin: 0 6px; }

.gr-hint { position: relative; padding: 0; border: 0; background: none; font: inherit; color: inherit; cursor: help; border-radius: 999px; flex-shrink: 0; }
.gr-pill {
  display: inline-flex; align-items: center; gap: 7px; width: 158px; box-sizing: border-box;
  padding: 2px 11px 2px 3px; border-radius: 999px;
  background: rgba(var(--cl), .10); border: 1px solid rgba(var(--cl), .25);
}
.gr-compass { position: relative; width: 26px; height: 26px; flex-shrink: 0; }
.gr-compass > svg { position: absolute; inset: 0; }
.gr-needle { position: absolute; inset: 0; display: block; transform: rotate(var(--deg)); }
.gr-dir { font-size: 13px; font-weight: 700; color: #1a1a1a; }
.gr-km { margin-left: auto; font-size: 13px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }

.gr-num:focus-visible, .gr-hint:focus-visible { outline: 2px solid #1a1a1a; outline-offset: 2px; }
.gr-tip, .gr-htip {
  position: absolute; z-index: 20; padding: 8px 10px; border-radius: 8px; background: #1a1a1a; color: #fff;
  font-size: 12px; line-height: 1.4; text-align: left; font-weight: 400; white-space: normal;
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s;
}
.gr-tip { left: calc(100% + 10px); top: 50%; width: 200px; transform: translate(-4px, -50%); }
@media (hover: hover) { .gr-num:hover .gr-tip { opacity: 1; transform: translate(0, -50%); } }
.gr-num:focus-visible .gr-tip { opacity: 1; transform: translate(0, -50%); }
.gr-htip { right: 0; bottom: calc(100% + 8px); width: 230px; transform: translateY(4px); }
@media (hover: hover) { .gr-hint:hover .gr-htip { opacity: 1; transform: none; } }
.gr-hint:focus-visible .gr-htip { opacity: 1; transform: none; }

/* live wire under each row, energised up to the closeness level */
.gr-wire { position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: #efeeea; overflow: hidden; pointer-events: none; }
.gr-wire-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; background: rgba(var(--cl), .75); overflow: hidden; transform-origin: left center; }
.gr-wire-fill::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 60px; left: -60px;
  background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.95), rgba(255,255,255,0));
}
.gr-wire-fill.is-pulse::after { animation: grWirePulse 1.1s ease-in-out; }
@keyframes grWirePulse { from { left: -60px; } to { left: 100%; } }

/* the solved row */
.gr-row--win { overflow: hidden; border: 0; background: #3f9a63; color: #fff; }
.gr-sweep { position: absolute; inset: 0; background: linear-gradient(90deg, #3f9a63, #58b07a); transform-origin: left center; }
.gr-current { position: absolute; top: 0; bottom: 0; width: 22%; left: -25%; background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.45), rgba(255,255,255,0)); }
.gr-winline { position: relative; display: flex; align-items: center; gap: 10px; }
.gr-badge {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%; background: rgba(255,255,255,.2);
  font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums;
}
.gr-row--win .gr-name { flex: 1; font-weight: 700; color: #fff; }
.gr-wintxt { font-size: .82rem; font-weight: 600; white-space: nowrap; }
.gr-check { width: 24px; height: 24px; flex-shrink: 0; border-radius: 50%; background: #fff; color: #3f9a63; display: inline-flex; align-items: center; justify-content: center; }

/* entry animation for a new guess (rows restored on reload appear without it) */
.gr-anim { animation: grIn .42s cubic-bezier(.2, .8, .3, 1) both; }
@keyframes grIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.gr-anim .gr-ring { stroke-dashoffset: var(--c); animation: grRing 1s cubic-bezier(.3, .7, .3, 1) .25s forwards; }
@keyframes grRing { to { stroke-dashoffset: 0; } }
.gr-anim .gr-needle { animation: grSpin .9s cubic-bezier(.3, .7, .3, 1) .15s both; }
@keyframes grSpin { 0% { transform: rotate(calc(var(--deg) - 300deg)); } 70% { transform: rotate(calc(var(--deg) + 14deg)); } 85% { transform: rotate(calc(var(--deg) - 5deg)); } 100% { transform: rotate(var(--deg)); } }
.gr-anim .gr-wire-fill { animation: grGrow .9s cubic-bezier(.3, .7, .3, 1) .3s both; }
.gr-anim .gr-facts { animation: grFade .35s ease-out .5s both; }
@keyframes grGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes grFade { from { opacity: 0; } to { opacity: 1; } }
.gr-anim.gr-row--win .gr-sweep { animation: grGrow .55s cubic-bezier(.5, 0, .3, 1) both; }
.gr-anim .gr-current { animation: grCurrent 1s cubic-bezier(.5, 0, .4, 1) .45s forwards; }
@keyframes grCurrent { to { left: 105%; } }
.gr-anim .gr-check { animation: grPop .35s cubic-bezier(.3, 1.6, .5, 1) .3s both; }
@keyframes grPop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

@media (max-width: 600px) {
  .gr-who { display: contents; }
  .gr-num { grid-row: 1 / span 2; }
  .gr-hint { grid-row: 1; grid-column: 3; }
  .gr-facts { grid-row: 2; grid-column: 2 / -1; font-size: .75rem; margin-top: -2px; }
  .gr-pill { width: auto; gap: 5px; }
  .gr-km { margin-left: 2px; }
  .gr-wintxt { font-size: .75rem; }
  .gr-tip { left: calc(100% + 6px); width: 180px; }
}

/* ============================================================
   RESULT CARD — the guess path, replacing the old emoji banner
   ============================================================ */
.go-card {
  position: relative; padding: 14px 16px; border-radius: 10px; background: #fff;
  border: 1px solid rgba(63, 154, 99, .35); box-shadow: inset 3px 0 0 #3f9a63;
}
.go-card--lost { border-color: rgba(196, 112, 96, .35); box-shadow: inset 3px 0 0 #c47060; }
.go-card.go-anim { animation: grIn .42s cubic-bezier(.2, .8, .3, 1) both; }
.go-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.go-title { font-size: .95rem; font-weight: 700; }
.go-tag { font-size: .75rem; color: #888; white-space: nowrap; font-variant-numeric: tabular-nums; }
.go-summary { margin: 12px 0 0; font-size: .82rem; color: #555; }
.go-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid #efeeea; }
.go-next { font-size: .82rem; color: #666; }
.go-next strong { color: #1a1a1a; font-variant-numeric: tabular-nums; }
.go-actions { display: flex; gap: 8px; }
.go-btn {
  min-height: 38px; padding: 0 16px; border-radius: 6px; border: 1px solid #d4d4d4; background: #fff;
  font-family: inherit; font-size: .88rem; font-weight: 600; color: #1a1a1a; cursor: pointer;
}
.go-btn:hover { border-color: #1a1a1a; }
.go-btn--dark { background: #1a1a1a; border-color: #1a1a1a; color: #fff; }
.go-btn--dark:hover { background: #333; }

.go-path { margin: 16px 18px 0; }
.go-track { position: relative; height: 34px; }
.go-linebox { position: absolute; left: 13px; right: 15px; top: 0; bottom: 0; }
.go-line { position: absolute; left: 0; top: 50%; height: 2px; margin-top: -1px; border-radius: 2px; transform-origin: left center; }
.go-gap { position: absolute; right: 0; top: 50%; margin-top: -1px; border-top: 2px dashed #d6d3cd; }
.go-spark { position: absolute; top: 50%; width: 46px; height: 6px; margin: -3px 0 0 -23px; border-radius: 6px; opacity: 0; background: radial-gradient(closest-side, #fff, rgba(255,255,255,0)); }
.go-nodes { position: relative; height: 100%; display: flex; justify-content: space-between; align-items: center; }
.go-path--one .go-nodes { justify-content: center; }
.go-node { position: relative; width: 26px; height: 26px; flex-shrink: 0; }
.go-node--answer { width: 30px; height: 30px; }
.go-ring {
  display: block; width: 100%; height: 100%; box-sizing: border-box; border-radius: 50%; padding: 2px;
  background: #fff; border: 2px solid rgb(var(--cl));
}
.go-node--miss .go-ring { border-style: dashed; }
.go-flag { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; background: #f0f0ee; }
.go-node--miss .go-flag { filter: grayscale(.6); opacity: .8; }
.go-badge {
  position: absolute; right: -4px; bottom: -3px; width: 14px; height: 14px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 800; color: #fff;
  background: rgb(var(--cl)); box-shadow: 0 0 0 2px #fff;
}
.go-burst { position: absolute; inset: -3px; border-radius: 50%; border: 2px solid #58b07a; opacity: 0; pointer-events: none; }
.go-labels { display: flex; justify-content: space-between; margin-top: 4px; }
.go-path--one .go-labels { justify-content: center; }
.go-label { width: 52px; margin: 0 -13px; text-align: center; font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.go-label--answer { width: 64px; margin: 0 -17px; font-weight: 700; }

/* the current runs from the first guess to the answer */
.go-anim .go-line { animation: grGrow var(--dur) linear var(--at) both; }
.go-anim .go-gap  { opacity: 0; animation: grFade .3s ease-out var(--at) forwards; }
.go-anim .go-spark { animation: goSpark var(--dur) linear var(--at) forwards; }
@keyframes goSpark { 0% { left: 0; opacity: 1; } 92% { opacity: 1; } 100% { left: var(--to); opacity: 0; } }
.go-anim .go-node { opacity: .25; transform: scale(.7); animation: goNode .35s cubic-bezier(.3, 1.5, .5, 1) var(--at) forwards; }
.go-anim .go-node--miss { transform: none; animation: grFade .35s ease-out var(--at) forwards; }
@keyframes goNode { to { opacity: 1; transform: scale(1); } }
.go-anim .go-label { opacity: 0; animation: grFade .35s ease-out var(--at) forwards; }
.go-anim .go-burst { animation: goBurst .7s ease-out var(--at) forwards; }
@keyframes goBurst { 0% { opacity: .9; transform: scale(.9); } 100% { opacity: 0; transform: scale(2); } }

/* miniature version in the stats screen */
.go-path--mini { margin: 10px 0 0; }
.go-path--mini .go-track { height: 24px; }
.go-path--mini .go-linebox { left: 9px; right: 11px; }
.go-path--mini .go-node { width: 18px; height: 18px; }
.go-path--mini .go-node--answer { width: 22px; height: 22px; }
.go-path--mini .go-ring { padding: 1.5px; border-width: 1.5px; }

@media (max-width: 600px) {
  .go-card { padding: 12px 12px; }
  .go-path { margin: 14px 10px 0; }
  .go-node { width: 24px; height: 24px; }
  .go-linebox { left: 12px; right: 14px; }
  .go-label:not(.go-label--answer) { visibility: hidden; }     /* too tight for every distance; hover/long-press a flag for it */
  .go-foot { flex-wrap: wrap; }
  .go-btn { min-height: 36px; padding: 0 12px; }
}

/* ============================================================
   STATS SCREEN — live wire touches
   ============================================================ */
.sx-today { display: block; padding: 12px 14px; }
.sx-today--won  { background: #f0f7f2; }
.sx-today--lost { background: #faf2f0; }
.sx-today-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sx-today-title { display: inline; font-size: .9rem; }
.sx-today--won .sx-today-title  { color: #1f5c38; }
.sx-today--lost .sx-today-title { color: #7a3b2f; }
.sx-today-sub { display: inline; margin: 0; font-size: .75rem; color: #6b7280 !important; }
.sx-tiles { border: 0; border-radius: 0; margin-top: 2px; }
.sx-tile { padding: 8px 4px; }
.sx-tile + .sx-tile { border-left: 0; }
.sx-track { position: relative; height: 6px; border-radius: 6px; background: #efeeea; }
.sx-fill { position: relative; overflow: hidden; border-radius: 6px; background: #a3abb5; }
.sx-fill--today { background: #4fa671; }
.sx-fill--x     { background: rgba(196, 112, 96, .55); }
.sx-fill--lost  { background: #c47060; }
.sx-pulse { position: absolute; top: 0; bottom: 0; width: 50px; left: -50px; background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.9), rgba(255,255,255,0)); animation: sxPulse 6s ease-in-out 1.2s infinite; }
@keyframes sxPulse { 0% { left: -50px; } 20% { left: 100%; } 100% { left: 100%; } }
.sx-dist { gap: 11px; }
.sx-share { padding: 10px 28px 16px; background: #fafaf8; border-top: 1px dashed #e6e5e1; }
.sx-share-lbl { font-size: .68rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #aaa; }
.sx-share-txt { margin: 4px 0 0; font-family: inherit; font-size: .82rem; line-height: 1.5; color: #444; white-space: pre-wrap; }
@media (max-width: 520px) { .sx-share { padding: 10px 18px 14px; } }

@media (prefers-reduced-motion: reduce) {
  .gr-anim, .gr-anim .gr-ring, .gr-anim .gr-needle, .gr-anim .gr-wire-fill, .gr-anim .gr-facts, .gr-anim .gr-sweep,
  .gr-anim .gr-check, .battery-cell.is-drain, .battery-cell.is-glow, .sx-pulse, .gr-wire-fill.is-pulse::after { animation: none !important; }
  .gr-current, .go-spark, .go-burst { display: none; }
}

/* Smallest phones (≤ 380 px): tighten the guess rows so country names keep their room */
@media (max-width: 380px) {
  .gr-row { padding: 5px 8px 5px 5px; }
  .gr-main { gap: 3px 8px; }
  .gr-name { gap: 6px; font-size: .88rem; }
  .gr-pill { gap: 4px; padding: 2px 8px 2px 2px; }
  .gr-compass, .gr-compass > svg, .gr-needle svg { width: 22px; height: 22px; }
  .gr-dir, .gr-km { font-size: 12px; }
  .gr-facts { font-size: .7rem; }
  .gr-dot { margin: 0 4px; }
  .gr-htip { width: 210px; }
}

/* Empty result slot takes no room (it sits between the input and the guesses) */
#banner:empty { display: none; }

/* Touch screens: a tap opens a guess row's tooltip and a tap elsewhere closes it */
@media (hover: none) {
  .gr-num.is-open .gr-tip { opacity: 1; transform: translate(0, -50%); }
  .gr-hint.is-open .gr-htip { opacity: 1; transform: none; }
}

/* ============================================================
   PHONE FIXES + REFRESH (legend, sources sheet, guesses header)
   ============================================================ */

/* Section titles share the chart-label look */
.section-title { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #888; }

/* "Guesses" header right above the input: title left, battery right */
#guess-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: -0.55rem; }
#guess-head #lives-container { display: flex; align-items: center; gap: 8px; margin: 0; }
#guess-head .lives-label { font-size: .8rem; font-weight: 500; text-transform: none; letter-spacing: 0; color: #888; }
.battery-body { gap: 3px; }
.battery-cell { width: 15px; height: 16px; }

/* Legend card: title + link on top, then the sources */
#legend-shared { display: block; padding: .75rem 1rem .85rem; }
.lg-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: .55rem; }
.lg-items { display: flex; flex-wrap: wrap; gap: 4px 6px; }
#legend-shared .legend-item { gap: 7px; padding: 4px 9px 4px 7px; border-radius: 999px; border: 1px solid #ecebe8; font-size: .8rem; color: #333; background: #fff; }
#legend-shared .legend-item:hover, #legend-shared .legend-item.is-on { background: #f3f3f1; border-color: #dcdad5; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; }
.glossary-btn { margin: 0; padding: 0; border: 0; background: none; font-size: .78rem; font-weight: 600; color: #666; gap: 6px; }
.glossary-btn:hover { color: #1a1a1a; border: 0; text-decoration: underline; text-underline-offset: 2px; }
.glossary-btn .glossary-icon { width: 16px; height: 16px; font-size: .7rem; font-style: italic; font-family: Georgia, serif; background: #ececea; color: #555; }

/* Sources explanation: centred window on desktop, a sheet sliding up from the bottom on phones */
#glossary-modal { position: fixed; inset: 0; z-index: 600; display: flex; align-items: center; justify-content: center; }
#glossary-modal .gl-box {
  position: relative; width: min(560px, 94vw); max-height: 86vh; max-width: none; display: flex; flex-direction: column;
  background: #fff; border-radius: 14px; box-shadow: 0 24px 60px rgba(0,0,0,.18); overflow: hidden;
  animation: glIn .22s ease-out;
}
@keyframes glIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.gl-grab { display: none; }
.gl-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 22px 12px; }
.gl-heading { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.gl-title { font-size: 1.15rem; font-weight: 700; color: #1a1a1a; }
.gl-sub { font-size: .8rem; color: #6b7280; }
#glossary-modal .gl-body { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto; padding: 4px 22px 8px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.gl-group + .gl-group { margin-top: 16px; }
.gl-group-title { margin: 0 0 6px; font-size: .7rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.gl-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gl-item { display: flex; gap: 10px; padding: 10px 12px; border-radius: 10px; background: #f7f7f5; min-width: 0; }
.gl-item.is-absent { opacity: .6; }
.gl-sw { width: 4px; align-self: stretch; border-radius: 4px; flex-shrink: 0; }
.gl-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.gl-name { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: .88rem; font-weight: 700; color: #1a1a1a; }
.gl-here { font-size: .65rem; font-weight: 600; color: #2f7a4d; background: #e9f4ed; padding: 1px 7px; border-radius: 999px; }
.gl-desc { font-size: .78rem; line-height: 1.4; color: #555; }
.gl-foot { margin: 0; padding: 10px 22px 16px; border-top: 1px solid #efeeea; font-size: .72rem; color: #888; }
.gl-foot a { color: #888; }

@media (max-width: 600px) {
  #glossary-modal { align-items: flex-end; }
  #glossary-modal .gl-box { width: 100%; max-height: 85vh; border-radius: 16px 16px 0 0; animation: glUp .25s cubic-bezier(.2,.8,.3,1); }
  @keyframes glUp { from { transform: translateY(100%); } to { transform: none; } }
  .gl-grab { display: block; width: 36px; height: 4px; border-radius: 4px; background: #d6d4cf; margin: 8px auto 0; }
  .gl-head { padding: 12px 16px 10px; }
  #glossary-modal .gl-body { padding: 2px 16px 8px; }
  .gl-list { grid-template-columns: 1fr; gap: 6px; }
  .gl-foot { padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); }

  #legend-shared { padding: .7rem .75rem .8rem; }
  .lg-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 5px; }
  #legend-shared .legend-item { font-size: .74rem; padding: 4px 8px 4px 7px; min-width: 0; }
  .legend-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .glossary-btn { font-size: .74rem; }

  /* Phones zoom into any text field under 16 px when it is focused; 16 px keeps the whole page in view */
  input[type="text"], input[type="search"], input:not([type]), select, textarea { font-size: 16px !important; }
}
@media (prefers-reduced-motion: reduce) { #glossary-modal .gl-box { animation: none; } }

/* Result path: a long answer name ("Dominican Republic (the)") stays inside the card */
.go-labels { position: relative; }
.go-label--answer { width: auto; max-width: 76px; margin: 0 -2px 0 0; text-align: right; white-space: normal; line-height: 1.25; overflow-wrap: anywhere; }
.go-path--one .go-label--answer { max-width: 100%; margin: 0; text-align: center; }
@media (max-width: 600px) { .go-label--answer { max-width: 46%; } }   /* distances are hidden on phones, so the name has room */
.go-head { align-items: flex-start; }
.go-title { min-width: 0; overflow-wrap: anywhere; }

/* ============================================================
   GUESS SECTION v2 — battery over the Guess button, stacked hint, two-arc compass
   ============================================================ */
:root { --gbtn: 96px; }
#submit-btn { width: var(--gbtn); padding-left: 0; padding-right: 0; flex-shrink: 0; }
#guess-head { display: grid; grid-template-columns: minmax(0, 1fr) auto var(--gbtn); column-gap: 8px; align-items: center; }
#lives-count { font-size: .8rem; font-weight: 700; color: #444; font-variant-numeric: tabular-nums; }
#guess-head #lives-container { display: flex; }
#guess-head .battery { display: flex; width: 100%; }
#guess-head .battery-body { flex: 1; }
#guess-head .battery-cell { flex: 1; width: auto; height: 14px; }

.gr-hintbox { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 76px; padding: 0 6px 0 16px; }
.gr-hintdir { display: inline-flex; align-items: center; gap: 5px; }
.gr-compass, .gr-compass > svg, .gr-needle svg { width: 22px; height: 22px; }
.gr-dir { font-size: 12px; }
.gr-km { margin: 0; font-size: 12px; line-height: 1.25; }
.u-short { display: none; }

@media (max-width: 600px) {
  :root { --gbtn: 84px; }
  .gr-row { padding: 7px 8px 8px 7px; }
  .gr-main { grid-template-columns: 28px minmax(0, 1fr) auto; column-gap: 9px; }
  .gr-num { grid-row: auto; width: 28px; height: 28px; }
  .gr-num svg { width: 28px; height: 28px; }
  .gr-who { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
  .gr-name { align-self: flex-start; align-items: flex-start; font-size: .94rem; line-height: 1.3; }
  .gr-name .flag { margin-top: 3px; }
  .gr-name > span { white-space: normal; overflow: visible; }
  .gr-facts { grid-row: auto; grid-column: auto; margin-top: 0; font-size: .75rem; max-width: 100%; }
  .gr-hint { grid-row: auto; grid-column: auto; align-self: center; }
  .u-long { display: none; }
  .u-short { display: inline; }
}

@media (max-width: 600px) { .gr-row--win .gr-name { align-self: center; align-items: center; } .gr-row--win .gr-name .flag { margin-top: 0; } }

/* ============================================================
   PAGE HEADER v2 — fixed parts above the line, today's puzzle below it
   ============================================================ */
.hd-grid {
  display: grid; align-items: center; column-gap: 10px; row-gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-areas: "title podium lb" "title modes modes";
}
.hd-grid h1 { grid-area: title; font-size: 2.7rem; line-height: 1; letter-spacing: .5px; white-space: nowrap; }
.hd-grid .podium { grid-area: podium; justify-self: end; }
.hd-grid #mode-nav { grid-area: modes; margin: 0; }
.hd-grid .lb-switcher { grid-area: lb; margin: 0; }
header { padding-bottom: .85rem; }
.subtitle-row { margin-top: -0.55rem; }       /* sits just under the line; #app's gap is 1.25rem */
.subtitle { font-size: .9rem; color: #555; }

@media (max-width: 600px) {
  .hd-grid {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "title podium" "title lb" "modes modes";
    row-gap: 6px;
  }
  .hd-grid h1 { font-size: 2.2rem; }
  .hd-grid .lb-switcher { width: 100%; }
  .hd-grid #mode-nav { width: 100%; margin-top: 6px; }
  .hd-grid #mode-nav .mode-btn { flex: 1; padding: 7px 8px; font-size: 0.78rem; }
  .subtitle-row { margin-top: -0.6rem; }
  .subtitle { font-size: .76rem; }
}

/* ============================================================
   CHARTS SPLIT — the latest mix (narrow, left, under the headline stats)
   and the time series (wide, right, under the energy balance) as two cards
   ============================================================ */
#charts-section {
  grid-template-columns: 220px minmax(0, 1fr); gap: 20px;
  background: none; border: 0; border-radius: 0; padding: 0;
}
#chart-left, #chart-right {
  background: #fff; border: 1px solid #e0e0e0; border-radius: 4px; box-sizing: border-box;
  padding: 1.1rem 1.1rem .9rem; min-width: 0;
}
#chart-right { order: -1; border-left: 1px solid #e0e0e0; padding-left: 1.1rem; }
#bar-wrapper { min-height: 0; }
@media (max-width: 600px) {
  #charts-section { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 0; }
  #chart-left, #chart-right { padding: .9rem .9rem .75rem; }
  #chart-right { order: 0; border-top: 1px solid #e0e0e0; padding-top: .9rem; }
  #bar-wrapper { min-height: 200px; }
}
@media (max-width: 600px) {
  .subtitle { white-space: normal; overflow: visible; line-height: 1.35; }
  #bar-wrapper { min-height: 170px; }
}

/* ============================================================
   LAYOUT v3 — header buttons, fitted subtitle, spacing rhythm, bar on the right
   ============================================================ */
.hd-grid .lb-switcher { align-self: center; }
.hd-grid #mode-nav { width: 100%; }
.hd-grid #mode-nav .mode-btn { flex: 1; text-align: center; }

/* subtitle: the puzzle (bold) then the task, scaled in game.js to fill the line */
.subtitle-row { margin: 2px 0 6px; align-items: center; }
.subtitle { white-space: nowrap; color: #666; font-size: 20px; line-height: 1.25; margin: 0; }
.sub-lead { font-weight: 700; color: #1a1a1a; }
.sub-sep { color: #bbb; }

/* one rhythm for the game's information, a bigger break before the guesses */
#app { gap: 12px; }
#balance-card, #charts-section { gap: 12px; }
#guess-head { margin-top: 18px; margin-bottom: -4px; }

/* charts: the time series wide on the left, the latest mix narrow on the right */
#charts-section { grid-template-columns: minmax(0, 1fr) 220px; }
#chart-right { order: 0; }

@media (max-width: 600px) {
  .subtitle-row { margin: 0 0 4px; }
  .subtitle { white-space: normal; font-size: 15px; }
  .sub-lead { display: block; font-size: 15px; }
  .sub-sep { display: none; }
  .sub-rest { display: block; white-space: nowrap; color: #555; }
  #app { gap: 10px; }
  #balance-card, #charts-section { gap: 10px; }
  #guess-head { margin-top: 16px; }
  #charts-section { grid-template-columns: minmax(0, 1fr); }
}

/* ============================================================
   HEADER — calmer title; under the line: the puzzle and task on one quiet line, today's date on the right
   ============================================================ */
.hd-grid h1 { font-size: 2.2rem; font-weight: 600; letter-spacing: -.01em; }
.hd-grid h1 .logo-bolt { font-size: .85em; }
.subtitle-row { margin: 4px 0 8px; gap: 16px; }
.subtitle { white-space: normal; font-size: 17px; }
.sub-lead { font-weight: 600; color: #1a1a1a; }
.sub-rest { color: #666; }
.sub-date { font-size: 13px; color: #888; white-space: nowrap; }

/* footer: credit and data source on one small line */
footer p { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 10px; margin: 0; }
.ft-credit { color: #999; }
.ft-sep { color: #ccc; }

@media (max-width: 600px) {
  .hd-grid h1 { font-size: 1.9rem; }
  .subtitle { font-size: 15px; }
  .sub-lead, .sub-sep, .sub-rest { display: inline; white-space: normal; }
  .sub-date { display: none; }
  .ft-sep { display: none; }
  footer p { flex-direction: column; align-items: center; }
}

/* ============================================================
   CHART VIEW TOGGLE — by source / by category
   ============================================================ */
.view-toggle { display: inline-flex; padding: 2px; border: 1px solid #e0dfdb; border-radius: 999px; background: #f7f7f5; }
.vt-btn { padding: 4px 12px; border: 0; border-radius: 999px; background: none; font-family: inherit; font-size: .76rem; font-weight: 600; color: #777; cursor: pointer; transition: background .15s, color .15s; }
.vt-btn:hover { color: #1a1a1a; }
.vt-btn.is-on { background: #1a1a1a; color: #fff; }
.vt-btn:focus-visible { outline: 2px solid #1a1a1a; outline-offset: 2px; }
.lg-head { flex-wrap: wrap; }
.legend-members { font-size: .72rem; font-weight: 400; color: #999; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.lg-items--cat .legend-item { gap: 7px; }
@media (max-width: 600px) {
  .lg-items.lg-items--cat { display: flex; flex-direction: column; align-items: stretch; }
  .lg-items--cat .legend-item { justify-content: flex-start; }
  .vt-btn { padding: 4px 10px; font-size: .72rem; }
}

.gb-short { display: none; }
.lg-items--cat .legend-item { min-width: 0; max-width: 100%; box-sizing: border-box; }
.lg-items--cat .legend-name { flex-shrink: 0; }
.lg-items--cat .legend-members { flex: 1 1 auto; }
@media (max-width: 600px) {
  .lg-head { flex-wrap: nowrap; }
  .gb-long { display: none; }
  .gb-short { display: inline; }
}

/* Smallest phones (≤ 380 px): a slightly narrower hint block so the country's figures fit */
@media (max-width: 380px) {
  .gr-hintbox { min-width: 62px; padding: 0 2px 0 10px; }
  .gr-hintdir { gap: 3px; }
  .gr-facts { font-size: .7rem; }
  .gr-main { column-gap: 7px; }
}

/* ============================================================
   DISTANCE CHART — result card and stats screen
   ============================================================ */
.dc { position: relative; height: 158px; margin: 16px 0 4px; }
.dc-plot { position: absolute; left: 66px; right: 26px; top: 26px; bottom: 22px; }
.dc-grid { position: absolute; left: 0; right: 0; height: 0; border-top: 1px dashed #ecebe7; }
.dc-grid--base { border-top: 1px solid #dedcd7; }
.dc-yl { position: absolute; right: calc(100% + 10px); top: -7px; font-size: 10.5px; color: #9a9a96; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dc-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.dc-reveal { position: absolute; inset: 0; }
.dc-line { fill: none; stroke-width: 2.2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.dc-gap { stroke: #cfcac2; stroke-width: 2; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.dc-node { position: absolute; width: 0; height: 0; }
.dc-node .go-node { position: absolute; left: 0; top: 0; translate: -50% -50%; }
.dc-lbl { position: absolute; font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; translate: -50% calc(-100% - 15px); }
.dc-lbl--l { translate: -13px calc(-100% - 15px); }
.dc-lbl--a { translate: calc(-100% - 22px) -50%; font-weight: 700; }
.dc-x { position: absolute; left: 66px; right: 26px; bottom: 0; height: 14px; }
.dc-x span { position: absolute; translate: -50% 0; font-size: 10.5px; color: #aaa; font-variant-numeric: tabular-nums; }
.dc--one .dc-lbl--a { translate: -50% calc(-100% - 18px); }
/* animation: the line is revealed left to right while the flags pop in turn */
.go-anim .dc-reveal { clip-path: inset(-10px 100% -10px -10px); animation: dcReveal var(--dur) linear var(--at) forwards; }
@keyframes dcReveal { to { clip-path: inset(-10px calc(100% - var(--end)) -10px -10px); } }
.go-anim .dc-gapsvg { opacity: 0; animation: grFade .3s ease-out var(--at) forwards; }
.go-anim .dc-lbl { opacity: 0; animation: grFade .35s ease-out var(--at) forwards; }
/* small version in the stats screen */
.dc--mini { height: 62px; margin: 10px 0 0; }
.dc--mini .dc-plot { left: 10px; right: 12px; top: 10px; bottom: 10px; }
.dc--mini .go-node { width: 18px; height: 18px; }
.dc--mini .go-node--answer { width: 22px; height: 22px; }
.dc--mini .go-ring { padding: 1.5px; border-width: 1.5px; }
.dc--mini .dc-grid:not(.dc-grid--base) { display: none; }
@media (max-width: 600px) {
  .dc { height: 140px; }
  .dc-plot, .dc-x { left: 52px; right: 18px; }
  .dc-yl { font-size: 10px; right: calc(100% + 6px); }
  .dc-lbl { font-size: 10.5px; }
  .dc .go-node { width: 22px; height: 22px; }
  .dc .go-node--answer { width: 26px; height: 26px; }
  .dc--mini .go-node { width: 16px; height: 16px; }
  .dc--mini .go-node--answer { width: 20px; height: 20px; }
  .go-label:not(.go-label--answer) { visibility: visible; }
}
@media (prefers-reduced-motion: reduce) { .go-anim .dc-reveal, .go-anim .dc-gapsvg, .go-anim .dc-lbl { animation: none !important; clip-path: none; opacity: 1; } }

/* ============================================================
   CHART TOOLTIP — lighter card, aligned columns
   ============================================================ */
#tooltip { border: 0; border-radius: 10px; padding: 10px 12px; font-size: 12px; line-height: 1.35;
  box-shadow: 0 10px 30px rgba(0,0,0,.14), 0 0 0 1px rgba(0,0,0,.05); }
.tt-h { font-weight: 700; font-size: 12.5px; margin-bottom: 6px; color: #1a1a1a; }
.tt-row { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto 38px; column-gap: 8px; align-items: center; padding: 1.5px 0; }
.tt-sw { width: 8px; height: 8px; border-radius: 2px; }
.tt-l { color: #444; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tt-row--b .tt-l { font-weight: 600; color: #1a1a1a; }
.tt-v { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.tt-p { color: #9a9a96; font-size: 11px; text-align: right; font-variant-numeric: tabular-nums; }
.tt-sep { height: 1px; background: #efeeea; margin: 6px 0; }
@media (max-width: 600px) {
  #tooltip { font-size: 11px; padding: 8px 10px; }
  .tt-h { font-size: 11.5px; margin-bottom: 4px; }
  .tt-row { column-gap: 6px; grid-template-columns: 7px minmax(0, 1fr) auto 34px; padding: 1px 0; }
  .tt-sw { width: 7px; height: 7px; }
}

/* distance chart: points inset from the plot edges; the answer's name in the axis row */
.dc-in { position: absolute; top: 0; bottom: 0; left: 16px; right: 16px; }
.dc-x { left: 82px; right: 42px; height: 16px; }
.dc-x .dc-x-ans { font-weight: 700; font-size: 11px; white-space: nowrap; }
.dc-x span:last-child.dc-x-ans { translate: calc(-100% + 16px) 0; text-align: right; }
.dc--one .dc-x .dc-x-ans { translate: -50% 0; }
@media (max-width: 600px) {
  .dc-in { left: 14px; right: 14px; }
  .dc-x { left: 66px; right: 32px; }
}
.dc--mini .dc-in { left: 8px; right: 8px; }
.dc { height: 172px; margin: 8px 0 4px; }
.dc-plot { bottom: 36px; }
@media (max-width: 600px) { .dc { height: 152px; } .dc-plot { bottom: 34px; } }
.dc.dc--mini { height: 62px; margin: 10px 0 0; }
.dc.dc--mini .dc-plot { left: 10px; right: 12px; top: 10px; bottom: 10px; }

/* distance chart: no km axis (the scale is fitted to the guesses; each point carries its distance) */
.dc-plot { left: 44px; }
.dc-x { left: 60px; }
@media (max-width: 600px) { .dc-plot { left: 38px; } .dc-x { left: 52px; } }

/* distance chart: neutral line, green answer line, today's average for comparison */
.dc-line { stroke: #4a4a48; stroke-width: 2; }
.dc-grid--base { border-top: 2px solid #58b07a; }
.dc-yl { color: #3f9a63; font-weight: 600; }
.dc-avg { position: absolute; inset: 0; animation: grFade .5s ease-out both; pointer-events: none; }
.dc-avgline { fill: none; stroke: #a9a7a1; stroke-width: 1.6; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.dc-avgdot { position: absolute; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: #fff; border: 1.5px solid #a9a7a1; pointer-events: auto; }
.dc-legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 2px 0 0; font-size: 11.5px; color: #888; }
.dc-key { display: inline-block; width: 18px; height: 0; border-top: 2px solid #4a4a48; }
.dc-key--avg { border-top: 2px dashed #a9a7a1; margin-left: 10px; }
/* distance chart: plain round flags (no closeness rings), a white edge separates them from the line */
.dc .go-ring { padding: 0; border: 0; background: none; box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(0,0,0,.12); }
.dc .go-node--miss .go-ring { box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(196,112,96,.45); }
.dc .go-node { width: 22px; height: 22px; }
.dc .go-node--answer { width: 26px; height: 26px; }
.dc.dc--mini .go-node { width: 16px; height: 16px; }
.dc.dc--mini .go-node--answer { width: 19px; height: 19px; }
.dc.dc--mini .go-ring { box-shadow: 0 0 0 1.5px #fff, 0 0 0 2.5px rgba(0,0,0,.12); }

/* most common guess at each step, under the guess numbers */
.dc.dc--common { height: 200px; }
.dc-common { position: absolute; left: 60px; right: 42px; bottom: 0; height: 18px; }
.dc-common-item { position: absolute; translate: -50% 0; display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; color: #8a8a86; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dc-common-flag { width: 14px; height: 10.5px; border-radius: 1.5px; box-shadow: 0 0 0 1px rgba(0,0,0,.1); display: block; object-fit: cover; }
.dc--common .dc-plot { bottom: 60px; }
.dc--common .dc-x { bottom: 24px; }
.dc-key-flag { display: inline-block; width: 14px; height: 10px; margin-left: 10px; border-radius: 1.5px; background: linear-gradient(90deg, #c9d3e6 33%, #fff 33% 66%, #e6c9c9 66%); box-shadow: 0 0 0 1px rgba(0,0,0,.12); }
@media (max-width: 600px) {
  .dc.dc--common { height: 180px; }
  .dc-common { left: 52px; right: 32px; }
  .dc-common-item span { display: none; }       /* phones: just the flag (tap/hover for the share) */
}

@media (max-width: 600px) {
  .dc .go-node { width: 19px; height: 19px; }
  .dc .go-node--answer { width: 23px; height: 23px; }
  .dc-legend { font-size: 11px; gap: 5px; }
}

/* touch: a tapped guess-row tooltip, and the small bubble for distance-chart points */
.gr-num.is-open .gr-tip { opacity: 1; transform: translate(0, -50%); }
.gr-hint.is-open .gr-htip { opacity: 1; transform: none; }
#dot-tip { position: fixed; z-index: 999; max-width: 220px; padding: 6px 9px; border-radius: 8px; background: #1a1a1a; color: #fff;
  font-size: 11.5px; line-height: 1.35; pointer-events: none; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
@media (hover: none) { .dc [title], .dc [data-tip] { cursor: pointer; } }

/* header: a small byline under the title */
.hd-brand { grid-area: title; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.hd-by { font-size: .8rem; color: #888; letter-spacing: .01em; white-space: nowrap; }
.hd-by a { color: #555; text-decoration: none; }
.hd-by a:hover { text-decoration: underline; text-underline-offset: 2px; }
@media (max-width: 600px) { .hd-brand { gap: 4px; } .hd-by { font-size: .72rem; } }

/* distance chart: y-axis with km ticks */
.dc-yl { color: #9a9a96; font-weight: 400; }
.dc-grid--base .dc-yl { color: #3f9a63; font-weight: 600; }
.dc-yt { position: absolute; right: calc(100% + 10px); top: -22px; font-size: 10.5px; font-weight: 600; color: #9a9a96; }
@media (max-width: 600px) { .dc-yt { right: calc(100% + 6px); font-size: 10px; } }

/* header: the byline sits on the title's line, much smaller */
.hd-brand { flex-direction: row; align-items: baseline; flex-wrap: wrap; column-gap: 10px; row-gap: 2px; }
.hd-by { font-size: .78rem; }

/* lost game: a straight drop from the final guess to the 0 km line, its distance beside it in bold */
.dc-drop { stroke: #c47060; stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.dc-droplbl { position: absolute; translate: calc(-100% - 6px) -50%; padding: 1px 4px; border-radius: 4px; background: #fff; font-size: 11.5px; line-height: 1.2; font-weight: 700; color: #a85a4a; white-space: nowrap; font-variant-numeric: tabular-nums; z-index: 2; }
.go-anim .dc-dropsvg, .go-anim .dc-droplbl { opacity: 0; animation: grFade .35s ease-out var(--at) forwards; }

/* most guessed: a label in the axis column, like a y-axis label for the flag row */
.dc-common-lbl { position: absolute; right: calc(100% + 26px); top: 50%; translate: 0 -50%; font-size: 9.5px; line-height: 1.1; font-weight: 600; color: #9a9a96; text-align: right; white-space: nowrap; }
.dc-legend { margin-top: 4px; }
@media (max-width: 600px) { .dc-common-lbl { right: calc(100% + 20px); font-size: 9px; } .dc-droplbl { font-size: 11px; } }

/* path section: key and closing line centred, with air between them and the most-guessed row */
.dc-legend { justify-content: center; margin-top: 16px; }
.dc-legend .dc-key--avg:first-child { margin-left: 0; }
.dc + .dc-legend + .go-summary, .dc + .go-summary { text-align: center; margin-top: 10px; }
@media (max-width: 600px) {
  /* phones: the share sits under each flag, centred */
  .dc.dc--common { height: 194px; }
  .dc--common .dc-plot { bottom: 74px; }
  .dc--common .dc-x { bottom: 38px; }
  .dc-common { height: 28px; }
  .dc-common-item { flex-direction: column; gap: 3px; line-height: 1; }
  .dc-common-item span { display: block; font-size: 10px; }
  .dc-legend { margin-top: 14px; }
}

/* distances are always black */
.dc-lbl { color: #1a1a1a; }
.dc-droplbl { color: #1a1a1a; }
/* key: a sample of the average line itself (dashed, with its hollow dot), and room before the closing line */
.dc-legend { color: #555; font-size: 12px; gap: 8px; }
.dc-key-avg { position: relative; display: inline-block; width: 32px; height: 0; border-top: 2px dashed #a9a7a1; }
.dc-key-avgdot { position: absolute; left: 50%; top: -1px; width: 7px; height: 7px; translate: -50% -50%; border-radius: 50%; background: #fff; border: 1.5px solid #a9a7a1; box-sizing: border-box; }
.dc + .dc-legend + .go-summary { margin-top: 16px; }
@media (max-width: 600px) { .dc-legend { font-size: 11.5px; } }

/* most guessed: the share sits centred under its flag, and the flag is centred on its guess number (all screen sizes) */
.dc-common-item { flex-direction: column; align-items: center; gap: 3px; line-height: 1; }
.dc-common-item span { display: block; font-size: 10px; text-align: center; }
.dc-common { height: 28px; }
.dc.dc--common { height: 212px; }
.dc--common .dc-plot { bottom: 74px; }
.dc--common .dc-x { bottom: 38px; }
@media (max-width: 600px) { .dc.dc--common { height: 194px; } }

/* distance labels stay readable where the average line passes, and move under the flag when it runs through them */
.dc-lbl { text-shadow: 0 0 2px #fff, 0 0 3px #fff, 0 0 4px #fff; z-index: 1; }
.dc-lbl.dc-lbl--below { translate: -50% 15px; }
.dc-lbl.dc-lbl--l.dc-lbl--below { translate: -13px 15px; }
.dc-lbl.dc-lbl--right { translate: 16px -50%; }
.dc-lbl.dc-lbl--left { translate: calc(-100% - 16px) -50%; }
/* lifted label (clears the average line): --lift is set by the script */
.dc-lbl { translate: -50% calc(-100% - 15px - var(--lift, 0px)); }
.dc-lbl.dc-lbl--l { translate: -13px calc(-100% - 15px - var(--lift, 0px)); }
.dc-lbl.dc-lbl--below { translate: -50% 15px; }
.dc-lbl.dc-lbl--l.dc-lbl--below { translate: -13px 15px; }
.dc-lbl.dc-lbl--right { translate: 16px -50%; }
.dc-lbl.dc-lbl--left { translate: calc(-100% - 16px) -50%; }

/* footer link that reopens the What's new notice */
.ft-link { padding: 0; border: 0; background: none; font: inherit; color: #888; cursor: pointer; }
.ft-link:hover { text-decoration: underline; }

/* What's new notice */
#notice-modal, #feedback-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; }
#notice-modal .st-backdrop, #feedback-modal .st-backdrop { position: absolute; inset: 0; }
.nt-box { position: relative; width: 100%; max-width: 440px; background: #fff; border-radius: 14px; box-shadow: 0 24px 60px rgba(0,0,0,.18); padding: 22px 24px 20px; display: flex; flex-direction: column; gap: 10px; color: #1a1a1a; }
.nt-eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #b98a12; }
.nt-title { margin: 0; font-size: 1.25rem; font-weight: 700; }
.nt-box p { margin: 0; font-size: .92rem; line-height: 1.5; color: #333; }
.nt-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; font-size: .92rem; line-height: 1.45; color: #333; }
.nt-keep { color: #666 !important; font-size: .85rem !important; }
.nt-btn { align-self: flex-end; min-height: 42px; padding: 0 22px; margin-top: 4px; border: 0; border-radius: 6px; background: #1a1a1a; color: #fff; font: inherit; font-size: .95rem; font-weight: 600; cursor: pointer; }
.nt-btn:focus-visible { outline: 2px solid #f5c842; outline-offset: 2px; }
@media (max-width: 600px) { .nt-box { padding: 18px 18px 16px; } }


/* ============================================================
   PRACTICE (2026-10): grouped picker with mix bars, country atlas, practice header
   ============================================================ */
.cr-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.mixbar { display: flex; height: 8px; border-radius: 3px; overflow: hidden; background: #ecebe8; gap: 1px; }
.mixbar span { min-width: 2px; }

.pc-section { display: flex; flex-direction: column; gap: 10px; }
.pc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 16px; flex-wrap: wrap; }
.pc-h { font-size: .75rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: #888; }
.pc-sub { font-size: 12px; color: #999; }
.pc-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.pc-card { display: flex; flex-direction: column; background: #fff; border: 1px solid #e0e0e0; border-radius: 4px; overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.pc-card:hover { border-color: #1a1a1a; box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.pc-main { flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 13px 14px 12px; border: 0; background: none; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.pc-main:focus-visible, .pc-list:focus-visible, .pc-atlas:focus-visible, .at-chip:focus-visible, .at-row:focus-visible { outline: 2px solid #f5c842; outline-offset: -2px; }
.pc-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pc-name { font-size: .95rem; font-weight: 700; line-height: 1.2; }
.pc-count { font-size: .8rem; font-weight: 600; color: #888; font-variant-numeric: tabular-nums; }
.pc-rule { font-size: .76rem; color: #777; line-height: 1.3; margin-top: -4px; }
.pc-mix { margin-top: auto; }
.pc-flags { display: flex; align-items: center; gap: 4px; }
.pc-flag { width: 20px; height: 15px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.1); object-fit: cover; display: block; }
.pc-more { font-size: .72rem; color: #999; margin-left: 2px; font-variant-numeric: tabular-nums; }
.pc-list { padding: 8px 14px; border: 0; border-top: 1px solid #f0efeb; background: #fafaf8; color: #777; font: inherit; font-size: .76rem; font-weight: 600; text-align: left; cursor: pointer; }
.pc-list:hover { color: #1a1a1a; background: #f3f3f1; }
.pc-atlas { display: flex; justify-content: space-between; align-items: center; gap: 12px 20px; flex-wrap: wrap; padding: 16px 18px; background: #fff; border: 1px solid #e0e0e0; border-radius: 4px; font: inherit; color: inherit; text-align: left; cursor: pointer; transition: border-color .15s; }
.pc-atlas:hover { border-color: #1a1a1a; }
.pc-atlas-txt { display: flex; flex-direction: column; gap: 2px; }
.pc-atlas-title { font-size: 1rem; font-weight: 700; }
.pc-atlas-sub { font-size: .82rem; color: #777; }
.pc-atlas-cta { font-size: .85rem; font-weight: 600; padding: 8px 14px; border-radius: 4px; background: #1a1a1a; color: #fff; white-space: nowrap; }

/* practice header: session tally + change group */
.pr-extra { display: inline-flex; align-items: center; gap: 12px; flex-shrink: 0; }
.pr-session { font-size: .8rem; color: #888; white-space: nowrap; font-variant-numeric: tabular-nums; }
#back-to-categories, #back-to-cats, #back-to-browse, #back-to-archive { padding: 5px 12px; font-size: .78rem; font-weight: 600; color: #555; background: #fff; border: 1px solid #d0d0d0; border-radius: 4px; cursor: pointer; white-space: nowrap; }
#back-to-categories:hover, #back-to-cats:hover, #back-to-browse:hover, #back-to-archive:hover { border-color: #1a1a1a; color: #1a1a1a; }

/* country list modal */
.cl-box { width: min(520px, 94vw); max-height: 78vh; border-radius: 12px; }
.cl-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 18px 12px; border-bottom: 1px solid #eee; }
.cl-titles { display: flex; flex-direction: column; gap: 2px; }
.cl-title { font-size: 1.05rem; font-weight: 700; }
.cl-count { font-size: .8rem; color: #888; font-weight: 400; }
.cl-body { overflow-y: auto; padding: 4px 18px; }
.cl-row { display: grid; grid-template-columns: 22px minmax(0, 1fr) 90px 64px; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid #f3f2ee; }
.cl-flag { width: 22px; height: 16px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.1); object-fit: cover; display: block; }
.cl-name { font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-mix { height: 6px; }
.cl-meta { font-size: .76rem; color: #888; text-align: right; font-variant-numeric: tabular-nums; }
.cl-foot { padding: 12px 18px 16px; border-top: 1px solid #eee; display: flex; justify-content: flex-end; }
.cl-play { min-height: 40px; padding: 0 18px; border: 0; border-radius: 6px; background: #1a1a1a; color: #fff; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; }

/* country atlas */
.at-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
#browse-search { flex: 1 1 220px; min-width: 0; min-height: 40px; padding: 0 12px; font: inherit; font-size: 16px; border: 1px solid #d4d4d4; border-radius: 4px; background: #fff; }
.at-chips { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; border: 1px solid #ecebe8; border-radius: 999px; background: #fff; }
.at-chip { min-height: 32px; padding: 0 12px; border: 0; border-radius: 999px; background: none; color: #777; font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; }
.at-chip[aria-pressed="true"] { background: #1a1a1a; color: #fff; }
.at-sort { display: inline-flex; align-items: center; gap: 8px; font-size: .8rem; color: #888; }
.at-sort select { min-height: 34px; padding: 0 8px; border: 1px solid #d4d4d4; border-radius: 4px; background: #fff; font: inherit; font-size: .82rem; color: #1a1a1a; }
.at-head, .at-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 92px 82px; align-items: center; gap: 16px; }
.at-head { padding: 0 14px; font-size: .7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #aaa; }
.at-head span:nth-child(n+3) { text-align: right; }
.at-list { display: flex; flex-direction: column; gap: 4px; }
.browse-row.at-row { width: 100%; padding: 9px 14px; background: #fff; border: 1px solid #ecebe8; border-radius: 4px; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.browse-row.at-row:hover { border-color: #1a1a1a; }
.at-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.at-flag { width: 24px; height: 18px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.1); object-fit: cover; flex-shrink: 0; display: block; }
.at-names { display: flex; flex-direction: column; min-width: 0; }
.at-names .browse-name { font-size: .9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.at-region { font-size: .72rem; color: #999; }
.at-num { font-size: .82rem; text-align: right; font-variant-numeric: tabular-nums; color: #333; }
.at-dpc { color: #777; }
.at-row[hidden] { display: none; }
.pc-key { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 11.5px; color: #777; margin-bottom: 2px; }
.pc-key-lbl { color: #999; margin-right: 4px; }
.pc-key-i { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.pc-key-sw { width: 9px; height: 9px; border-radius: 2px; }
.at-empty { text-align: center; color: #888; font-size: .85rem; padding: 18px; }

@media (max-width: 860px) { .pc-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px) {
  .pc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .pc-main { padding: 11px 11px 10px; gap: 7px; }
  .pc-list { padding: 8px 11px; }
  .pc-card:last-child:nth-child(odd) { grid-column: 1 / 3; }
  .pc-key-lbl { flex-basis: 100%; }
  .pc-key { gap: 3px 10px; font-size: 11px; }
  .at-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; order: 3; flex: 1 1 100%; }
  .at-chip { white-space: nowrap; flex-shrink: 0; }
  .at-sort { order: 2; margin-left: 0; }
  .at-sort > span { display: none; }
  #browse-search { flex-basis: 0; }
  .pc-atlas-cta { width: 100%; text-align: center; }
  .pr-session { display: none; }
  .at-head { display: none; }
  .at-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 6px; column-gap: 10px; }
  .at-row .at-mix { grid-column: 1 / 3; grid-row: 2; }
  .at-row .at-num:not(.at-dpc) { grid-column: 2; grid-row: 1; }
  .at-dpc { display: none; }
  .cl-row { grid-template-columns: 22px minmax(0, 1fr) 70px 56px; }
}


/* ============================================================
   PAST PUZZLES (archive): picker card, strip of recent days, date navigator
   ============================================================ */
.ar-row { align-items: center; }
.ar-nav { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.ar-arrow { width: 34px; height: 34px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; padding: 0; border: 1px solid #d0d0d0; border-radius: 50%; background: #fff; color: #1a1a1a; cursor: pointer; }
.ar-arrow:hover:not(:disabled) { border-color: #1a1a1a; }
.ar-arrow:disabled { color: #ccc; border-color: #ecebe8; cursor: default; }
.ar-title { display: inline-flex; align-items: baseline; gap: 10px; padding: 0 10px; min-width: 0; flex-wrap: wrap; }
.ar-num { font-size: 17px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ar-date { font-size: 15px; color: #666; white-space: nowrap; }
.ar-status { font-size: .8rem; font-weight: 600; white-space: nowrap; padding: 3px 10px; border-radius: 999px; background: #f0f0ee; color: #666; }
.ar-status--solved { background: #1a1a1a; color: #fff; }
.ar-note { margin: 0; padding: 12px 14px; border: 1px dashed #d4d2cc; border-radius: 6px; font-size: 13.5px; line-height: 1.45; color: #555; background: #fff; }
.go-btn:disabled { opacity: .35; cursor: default; }
.at-keyhead { display: inline-flex; gap: 10px; text-transform: none; letter-spacing: 0; font-weight: 400; color: #888; font-size: 11px; }

@media (max-width: 600px) {
  .ar-row { flex-wrap: wrap; gap: 8px; }
  .ar-nav { flex: 1 1 100%; justify-content: space-between; }
  .ar-title { flex-direction: column; align-items: center; gap: 0; padding: 0 6px; text-align: center; }
  .ar-num { font-size: 16px; } .ar-date { font-size: 13px; }
  .ar-row .pr-extra { flex: 1 1 100%; justify-content: space-between; }
}

/* archive list: one row per puzzle, newest first, by month. Shaded = solved on the day, in the daily game */
.ax-sum { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; font-size: .85rem; color: #666; font-variant-numeric: tabular-nums; }
.ax-sum strong { color: #1a1a1a; }
.ax-key { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; color: #888; }
.ax-sw { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.ax-sw--solved { background: #1a1a1a; }
.ax-month { display: flex; flex-direction: column; gap: 8px; }
.ax-mhead { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 16px; flex-wrap: wrap; }
.ax-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.ax-row { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; min-height: 76px; padding: 10px 12px 9px; border: 1px solid #e6e5e1; border-radius: 6px; background: #fff; color: #1a1a1a; font: inherit; text-align: left; cursor: pointer; transition: border-color .12s, transform .12s; }
.ax-row:hover { border-color: #1a1a1a; transform: translateY(-1px); }
.ax-row:focus-visible { outline: 2px solid #f5c842; outline-offset: 1px; }
.ax-num { font-weight: 700; font-size: .95rem; font-variant-numeric: tabular-nums; }
.ax-date { font-size: .8rem; color: #666; white-space: nowrap; }
.ax-status { margin-top: auto; padding-top: 6px; font-size: .76rem; color: #777; line-height: 1.25; font-variant-numeric: tabular-nums; }
.ax-chev { position: absolute; top: 11px; right: 9px; color: #bbb; }
.ax-row--solved { background: #1a1a1a; border-color: #1a1a1a; color: #fff; }
.ax-row--solved .ax-date, .ax-row--solved .ax-status { color: rgba(255,255,255,.75); }
.ax-row--solved .ax-chev { color: rgba(255,255,255,.45); }
.ax-row--solved:hover { border-color: #000; }
.ax-row--missed { background: #efeeea; border-color: #e3e2dd; }
.ax-row--missed .ax-status { color: #555; }
.ax-row--new { border-style: dashed; border-color: #d4d2cc; }
.ax-row--new .ax-status { color: #aaa; }
.ax-row--started .ax-status, .ax-row--replayed .ax-status { color: #333; }
.ax-row--today { box-shadow: inset 0 0 0 1px #f5c842; border-color: #f5c842; border-style: solid; }
.ax-row--today .ax-date { color: #8a6a1a; font-weight: 600; }
.ax-row--today.ax-row--solved .ax-date { color: #f5c842; }

/* one window for your stats, today's ranking and the all-time ranking */
#stats-modal .sx-box.hub-box, #lb-modal .st-box.lb-box.hub-box {
  width: min(620px, 94vw); height: min(780px, 88vh); max-width: none; max-height: none;
  border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; padding: 0;
}
.hub-bar { position: relative; display: flex; justify-content: center; padding: 14px 52px 0; border-bottom: 1px solid #efefef; flex-shrink: 0; }
.hub-tabs { display: flex; gap: 28px; }
.hub-tab { padding: 8px 2px 12px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; font: inherit; font-size: .95rem; font-weight: 700; color: #aaa; cursor: pointer; white-space: nowrap; }
.hub-tab:hover { color: #1a1a1a; }
.hub-tab.is-on { color: #1a1a1a; border-bottom-color: #1a1a1a; }
.hub-tab:focus-visible, .hub-close:focus-visible, .hub-sub-btn:focus-visible { outline: 2px solid #f5c842; outline-offset: -2px; }
.hub-close { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: none; font-size: 1.4rem; line-height: 1; color: #999; cursor: pointer; }
.hub-close:hover { background: #f3f3f1; color: #1a1a1a; }
.hub-subbar { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 16px 10px; border-bottom: 1px solid #efefef; flex-shrink: 0; }
.hub-sub { display: inline-flex; padding: 3px; border-radius: 999px; background: #f1f1ef; }
.hub-sub-btn { min-width: 96px; padding: 6px 16px; border: 0; border-radius: 999px; background: none; font: inherit; font-size: .8rem; font-weight: 600; color: #777; cursor: pointer; }
.hub-sub-btn.is-on { background: #fff; color: #1a1a1a; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.hub-cap { font-size: .75rem; color: #999; text-align: center; }
.hub-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.lb-switcher .mode-btn { white-space: nowrap; }
@media (max-width: 860px) { .ax-list { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 600px) {
  .ax-key { margin-left: 0; flex-basis: 100%; }
  .ax-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .ax-row { min-height: 70px; padding: 9px 11px 8px; }
  .hub-bar { padding: 10px 44px 0; }
  .hub-tabs { gap: 22px; }
  .hub-tab { font-size: .9rem; padding: 6px 2px 10px; }
  .hub-close { top: 6px; right: 6px; }
}
#stats-modal .hub-scroll { display: flex; flex-direction: column; }
#stats-modal .hub-scroll .sx-foot { margin-top: auto; }

/* mix bars: half-transparent segments with an outline, like the bar chart */
.mixbar { gap: 2px; background: none; border-radius: 0; height: 10px; }
.mixbar span { border-radius: 2px; min-width: 3px; }
.cl-mix { height: 8px; }
.pc-main { gap: 10px; padding-bottom: 14px; }
.pc-mix { margin-top: auto; }

/* phone: "by Oscar Viguié" starts exactly under the E of Energle (the bolt gets a fixed width) */
@media (max-width: 600px) {
  .hd-grid h1 .logo-bolt { width: 1.1em; text-align: center; }
  .hd-grid h1 .logo-gap { display: none; }
  .hd-grid h1 .logo-word { margin-left: .08em; }
  .hd-brand .hd-by { padding-left: calc(2.2rem * .85 * 1.1 + 2.2rem * .08 - .2rem); }
}

/* puzzle server unreachable, or today's puzzle not out yet */
.un-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 20px; background: #fff; border: 1px solid #e0e0e0; border-radius: 4px; text-align: center; }
.un-title { margin: 0; font-size: 1.05rem; font-weight: 700; color: #1a1a1a; }
.un-text { margin: 0; font-size: .9rem; color: #666; }
.un-btn { margin-top: 8px; min-height: 40px; padding: 0 20px; border: 0; border-radius: 4px; background: #1a1a1a; color: #fff; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; }
.un-btn:disabled { opacity: .6; cursor: default; }

/* ============================================================
   CARBON SMOKE — soft puffs rising from the latest-mix bar. They stay inside the card
   (the worst ones just brush the card above). The CO2 figure sits under the chart.
   ============================================================ */
#bar-wrapper, #chart-right { overflow: visible; }
.co2-smoke { position: absolute; width: 0; height: 0; pointer-events: none; z-index: 2; }
/* soft cloud shapes: rounded and readable as "smoke", but with a soft edge rather than a cartoon outline */
.co2-puff { position: absolute; left: -15px; top: -20px; width: 30px; height: 22px;
  opacity: 0; animation: co2Rise 3.4s linear infinite; filter: blur(.5px); }
.co2-puff svg { display: block; width: 100%; height: 100%; overflow: visible; }
.co2-puff path { fill: rgb(var(--c)); fill-opacity: var(--a); stroke: rgb(var(--l)); stroke-opacity: .35; stroke-width: 1.4; stroke-linejoin: round; }
@keyframes co2Rise {
  0%   { transform: translate(0, 0) scale(.45); opacity: 0; }
  12%  { opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--rise) * -1)) scale(var(--s)); opacity: 0; }
}
/* this grid | world average: two equal columns split by a hairline, label above value */
.co2-note { display: grid; grid-template-columns: 1fr 1fr; margin: 10px 0 0; padding-top: 10px; border-top: 1px solid rgba(31, 41, 55, .08); }
.co2-col { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.co2-col + .co2-col { border-left: 1px solid rgba(31, 41, 55, .1); }
.co2-lbl { display: inline-flex; align-items: center; gap: 4px; font-size: .6rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #8a919c; white-space: nowrap; }
.co2-lbl svg path { fill: #9aa1ab; }
.co2-val { font-size: .7rem; color: #6b7280; white-space: nowrap; font-variant-numeric: tabular-nums; }
.co2-val strong { font-size: 1rem; font-weight: 700; color: #1a1a1a; }
.co2-world .co2-val strong { color: #6b7280; font-weight: 600; }
@media (prefers-reduced-motion: reduce) {
  .co2-puff { animation: none; opacity: 1; }
  .co2-puff:nth-child(2) { transform: translate(-4px, -18px) scale(1.3); }
  .co2-puff:nth-child(3) { transform: translate(6px, -36px) scale(1.7); }
  .co2-puff:nth-child(n+4) { display: none; }
}

/* ============================================================
   TOP CARDS, COMPACT — headline stats and energy balance a bit shorter
   ============================================================ */
.bc-stats { gap: 10px; padding: 12px 14px; }
.bc-stat { gap: 3px; }
#balance-card .stat-value { font-size: 1.4rem; line-height: 1.1; }
.bc-world { margin-top: 1px; padding: 2px 9px; font-size: .7rem; }
.bc-flow { padding: 10px 16px 12px; gap: 8px; }
.fc-name { font-size: 10px; }
.fc-val { font-size: 15px; }
.fc-tag { font-size: 12px; }
@media (max-width: 600px) {
  .bc-stats { padding: 10px 8px; gap: 8px; }
  #balance-card .stat-value { font-size: 1.1rem; }
  .bc-world { font-size: .64rem; padding: 2px 7px; }
  .bc-flow { padding: 9px 10px 10px; gap: 6px; }
  .fc-name { font-size: 9px; }
  .fc-val { font-size: 12.5px; }
  .fc-tag { font-size: 11px; }
}

/* ============================================================
   CHART HEIGHTS WITH THE CO2 STRIP — the bar keeps its full 300px on laptop:
   the cards grow instead, and the time series grows with them so both stay level
   ============================================================ */
@media (min-width: 601px) {
  #bar-wrapper { flex: 1 0 300px; min-height: 300px; }
  #line-wrapper { flex: 1 0 300px; height: auto; min-height: 300px; }
}


/* ============================================================
   OCT 2026 REFRESH: header (mode pill, split Stats & Leaderboard), practice pictures,
   locked-button bubble, Clue Shop teaser
   ============================================================ */
/* Stats & Leaderboard: one button, each half opens its own page */
.lb-split { align-items: stretch; background: #fff; }
.lb-split .mode-btn + .mode-btn { border-left: 0; }
.lb-split .mode-btn:first-child { padding-right: 4px; }
.lb-split .mode-btn:last-child { padding-left: 4px; }
.lb-split .lb-amp { display: grid; place-items: center; font-size: .82rem; font-weight: 600; color: #888; pointer-events: none; }
.lb-split .mode-btn:hover { background: #f5f5f5; color: #1a1a1a; }
.hd-grid .lb-split { justify-self: end; }
@media (max-width: 600px) {
  .lb-split .mode-btn { flex: 1 1 auto; }
  .lb-split .mode-btn:first-child { text-align: right; }
  .lb-split .mode-btn:last-child { text-align: left; }
}

/* Daily / Archive / Practice pill */
header .hd-modes { display: inline-flex; gap: 0; padding: 3px; border: 1px solid #e0dfdb; border-radius: 999px; background: #f7f7f5; overflow: visible; }
header .hd-modes .mode-btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 6px 16px; border: 0; border-radius: 999px; background: none; color: #777; font: inherit; font-size: .82rem; font-weight: 600; letter-spacing: 0; cursor: pointer; transition: background .15s, color .15s; }
header .hd-modes .mode-btn + .mode-btn { border-left: 0; }
header .hd-modes .mode-btn:hover:not(.locked):not(.active) { background: #ecebe7; color: #1a1a1a; }
header .hd-modes .mode-btn.active { background: #1a1a1a; color: #fff; }
header .hd-modes .mode-btn.locked { color: #b5b4b0; background: none; cursor: pointer; }
header .hd-modes .mode-btn.is-denied { animation: shopDeny .38s ease-in-out; }
header .hd-modes .mode-btn:focus-visible { outline: 2px solid #f5c842; outline-offset: 2px; }
/* the bubble under a button near the top of the page */
#lock-tip.is-below::after { bottom: auto; top: -5px; border-radius: 2px 0 0 0; }

/* layout: modes under the title (left), Stats & Leaderboard under the medals (right) */
.hd-grid { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title podium" "modes lb"; row-gap: 12px; }
.hd-grid #mode-nav.hd-modes { justify-self: start; width: auto; margin: 0; }
.hd-grid .lb-split { justify-self: end; align-self: center; width: auto; }
/* smaller pill */
header .hd-modes { padding: 2px; }
header .hd-modes .mode-btn, .hd-grid #mode-nav.hd-modes .mode-btn { flex: none; gap: 5px; padding: 4px 11px; font-size: .75rem; border-bottom: 0; }
.hd-ico { display: block; flex-shrink: 0; }
header .hd-modes .mode-btn .hd-ico { opacity: .85; }
header .hd-modes .mode-btn.active .hd-ico { opacity: 1; }
.hd-lockemo { font-size: .7rem; margin-left: 1px; }
/* Stats & Leaderboard with icons */
.lb-split .mode-btn { display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 600px) {
  .hd-grid { grid-template-areas: "title podium" "title lb" "modes modes"; row-gap: 8px; }
  .hd-grid #mode-nav.hd-modes { margin-top: 2px; }
  header .hd-modes .mode-btn, .hd-grid #mode-nav.hd-modes .mode-btn { padding: 4px 10px; font-size: .72rem; }
  .hd-grid .lb-split { width: 100%; }
  .lb-split .mode-btn { gap: 4px; justify-content: center; }
  .lb-split .mode-btn .hd-ico { width: 12px; height: 12px; }
}
.lb-split .lb-amp { align-self: center; }

/* right column: medals level with the title, Stats & Leaderboard centred under them */
.hd-grid .podium { justify-self: center; align-self: center; }
.hd-grid .lb-split { justify-self: center; }
.lb-split .mode-btn { gap: 7px; padding: 8px 16px; font-size: .86rem; }
.lb-split .mode-btn:first-child { padding-right: 5px; }
.lb-split .mode-btn:last-child { padding-left: 5px; }
.lb-split .lb-amp { font-size: .86rem; }
.lb-split .hd-ico { width: 16px; height: 16px; }
.lb-split .ico-stats { color: #4a90c4; }
.lb-split .ico-trophy { color: #c9971c; }
.lb-split .ico-trophy path:first-child { fill: #f5c842; }
@media (max-width: 600px) {
  .lb-split .mode-btn { padding: 7px 10px; font-size: .78rem; }
  .lb-split .lb-amp { font-size: .78rem; }
  .lb-split .hd-ico { width: 14px; height: 14px; }
}
.hd-grid .podium { position: relative; top: 7px; }
@media (max-width: 600px) { .hd-grid .hd-brand { align-self: start; } }
/* the & and the two labels: same font and line box, so they sit on one line */
.lb-split .mode-btn, .lb-split .lb-amp { font-family: inherit; line-height: 1.2; }

/* Stats & Leaderboard: icon · Stats · & · Leaderboard · icon, evenly spaced */
.lb-split .mode-btn { gap: 7px; }
.lb-split .mode-btn:first-child { padding: 8px 6px 8px 14px; }
.lb-split .mode-btn:last-child { padding: 8px 14px 8px 6px; }
@media (max-width: 600px) {
  .lb-split .mode-btn:first-child { padding: 7px 5px 7px 10px; }
  .lb-split .mode-btn:last-child { padding: 7px 10px 7px 5px; }
}
/* the bolt sits as close to "Energle" as "Energle" sits to "by Oscar Viguié" (measured on the drawn ink) */
@media (min-width: 601px) { .hd-grid h1 .logo-bolt { margin-right: -5px; } }


/* ============================================================
   PRACTICE PICKER: picture + name, no mix bar (the mix is in "See the N countries")
   ============================================================ */
.pc-card--art .pc-main { position: relative; flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px 14px 13px; }
.pc-art { --pa: #777; flex-shrink: 0; display: grid; place-items: center; width: 60px; height: 60px; border-radius: 14px;
  background: color-mix(in srgb, var(--pa) 11%, #fff); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pa) 26%, #fff); transition: transform .15s; }
.pc-art-svg { display: block; width: 46px; height: 46px; }
.pc-card--art:hover .pc-art { transform: scale(1.05) rotate(-2deg); }
.pc-txt { display: flex; flex-direction: column; gap: 4px; min-width: 0; width: 100%; }
.pc-card--art .pc-top { display: block; }
.pc-card--art .pc-count { position: absolute; top: 13px; right: 14px; }
.pc-card--art .pc-rule { margin-top: 0; }
@media (prefers-reduced-motion: reduce) { .pc-card--art:hover .pc-art { transform: none; } }
@media (max-width: 600px) {
  .pc-card--art .pc-main { gap: 9px; padding: 12px 11px 11px; }
  .pc-card--art .pc-count { top: 11px; right: 11px; }
  .pc-art { width: 52px; height: 52px; border-radius: 12px; }
  .pc-art-svg { width: 40px; height: 40px; }
}

/* country list: the group's picture and combined mix on top */
.pc-art--sm { width: 40px; height: 40px; border-radius: 10px; margin-right: 10px; }
.pc-art--sm .pc-art-svg { width: 30px; height: 30px; }
#cl-modal .cl-header { align-items: center; }
#cl-modal .cl-header .cl-titles { flex: 1; min-width: 0; }
.cl-group { display: flex; flex-direction: column; gap: 6px; padding: 10px 18px 12px; border-bottom: 1px solid #f0efeb; }
.cl-group-lbl { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #9a9a96; }
.cl-gmix { display: flex; height: 12px; gap: 2px; }
.cl-gkey { margin: 0; }
.cl-gkey strong { color: #1a1a1a; font-weight: 700; margin-left: 2px; }

/* ============================================================
   LOCKED BUTTONS: "no" wiggle + bubble saying why (Practice, Clue Shop teaser)
   ============================================================ */
@keyframes shopDeny { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-4px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
#lock-tip { position: fixed; z-index: 260; max-width: 260px; display: flex; gap: 8px; align-items: flex-start; padding: 9px 11px; border-radius: 8px; background: #1a1a1a; color: #e9e8e4; font-size: 12.5px; line-height: 1.4; box-shadow: 0 6px 18px rgba(0,0,0,.18); animation: tipIn .18s ease-out; }
#lock-tip strong { color: #fff; font-weight: 700; }
#lock-tip::after { content: ""; position: absolute; bottom: -5px; right: var(--arrow, 20px); width: 10px; height: 10px; background: #1a1a1a; transform: rotate(45deg); border-radius: 0 0 2px 0; }
.lt-lock { flex-shrink: 0; width: 14px; height: 14px; margin-top: 1px; background: #f5c842;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 7V5a3.5 3.5 0 0 1 7 0v2h.5a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1zm1.8 0h3.4V5a1.7 1.7 0 0 0-3.4 0z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 7V5a3.5 3.5 0 0 1 7 0v2h.5a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1zm1.8 0h3.4V5a1.7 1.7 0 0 0-3.4 0z'/%3E%3C/svg%3E") center / contain no-repeat; }
@keyframes tipIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ============================================================
   CLUE SHOP TEASER: shop-sign button left of Guess, "Soon" tag
   ============================================================ */
#input-area { align-items: stretch; }
#input-area > #autocomplete-wrapper, #input-area > #submit-btn, #input-area > .shop-btn { height: 44px; }
#guess-input { height: 100%; box-sizing: border-box; }
.shop-btn { --awn: #f5c842; position: relative; flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px 0 10px; border: 1.5px solid #1a1a1a; border-radius: 6px; background: #fff; color: #1a1a1a; font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; transition: background .15s, transform .1s; }
.shop-btn:hover { background: #fff8df; }
.shop-btn:active { transform: scale(.97); }
.shop-btn:focus-visible { outline: 2px solid #f5c842; outline-offset: 2px; }
.shop-ico { display: block; }
.shop-lbl { white-space: nowrap; }
.shop-soon { position: absolute; top: -8px; right: -8px; padding: 1px 6px; border-radius: 999px; background: #f5c842; color: #1a1a1a; box-shadow: 0 0 0 2px #f7f7f5, inset 0 0 0 1px #1a1a1a; font-size: 9.5px; font-weight: 800; letter-spacing: .04em; line-height: 15px; text-transform: uppercase; }
.shop-btn.is-denied { animation: shopDeny .38s ease-in-out; }
/* after the first guess, until the teaser has been opened once: a slow shimmer and the little shop jolts, twice */
.shop-btn.is-calling::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(105deg, transparent 38%, rgba(245, 200, 66, .55) 50%, transparent 62%) no-repeat;
  background-size: 260% 100%; background-position: 130% 0; animation: shopShimmer 5.5s ease-in-out .8s 2; }
.shop-btn.is-calling > * { position: relative; }
.shop-btn.is-calling .shop-soon { position: absolute; }
.shop-btn.is-calling .shop-ico { transform-origin: 50% 100%; animation: shopJolt 5.5s ease-in-out .8s 2; }
@keyframes shopShimmer { 0%, 52% { background-position: 130% 0; } 72%, 100% { background-position: -30% 0; } }
@keyframes shopJolt {
  0%, 70%, 100% { transform: none; }
  72% { transform: translateY(0) scale(1.1, .86); }
  75% { transform: translateY(-8px) scale(.92, 1.1) rotate(-7deg); }
  78% { transform: translateY(0) scale(1.08, .9); }
  80.5% { transform: translateY(-4px) scale(.97, 1.04) rotate(5deg); }
  83% { transform: translateY(0) scale(1.03, .97); }
  85% { transform: none; }
}
@media (max-width: 600px) {
  #input-area > #autocomplete-wrapper, #input-area > #submit-btn, #input-area > .shop-btn { height: 40px; }
  .shop-btn { height: 40px; padding: 0 8px; }
  .shop-lbl { display: none; }
  .shop-btn .shop-ico { width: 24px; height: 24px; }
}
@media (prefers-reduced-motion: reduce) { .shop-btn.is-calling::before, .shop-btn.is-calling .shop-ico, .shop-btn.is-denied, header .hd-modes .mode-btn.is-denied, #lock-tip { animation: none; } }

/* Ember credit inside the legend card */
.og-src--in { margin: 2px 0 0; font-size: 10.5px; color: #aaa7a0; text-align: right; }
#legend-shared { padding-bottom: 8px; }

/* ============================================================
   TOP CARDS: the flow chart sits in the middle of its card (also when there is no trade),
   headline stats a size smaller and centred
   ============================================================ */
.bc-flow { display: flex; flex-direction: column; }
#flow-chart { margin-block: auto; }
.bc-stats { justify-content: center; gap: 14px; }
.bc-stats .stat-label { font-size: .64rem; }
#balance-card .stat-value { font-size: 1.2rem; }
.bc-world { font-size: .66rem; }
@media (max-width: 600px) {
  .bc-stats { gap: 8px; }
  .bc-stats .stat-label { font-size: .6rem; }
  #balance-card .stat-value { font-size: 1rem; }
  .bc-world { font-size: .62rem; }
}
/* phone: the two stats side by side share three rows (label, value, world average),
   so labels, values and pills each sit on one line even when a label wraps */
@media (max-width: 600px) {
  .bc-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto auto auto; align-items: center; column-gap: 12px; row-gap: 3px; }
  .bc-stat { display: grid; grid-row: 1 / 4; grid-template-rows: subgrid; justify-items: center; gap: 0; min-width: 0; }
  .bc-stat .stat-label { line-height: 1.2; align-self: center; }
}

/* ============================================================
   PHONE HEADER, SCALED DOWN: title, medals with names and the Stats & Leaderboard button
   fit side by side without crowding (down to 320 px)
   ============================================================ */
@media (max-width: 600px) {
  .hd-grid h1 { font-size: 1.85rem; }
  .hd-grid .hd-by { font-size: .66rem; }
  .hd-grid .podium-slot { width: 44px; }
  .hd-grid .podium-medal { font-size: .95rem; }
  .hd-grid .podium-name { font-size: .58rem; }
  .lb-split .mode-btn { font-size: .7rem; gap: 4px; }
  .lb-split .lb-amp { font-size: .7rem; }
  .lb-split .hd-ico { width: 12px; height: 12px; }
  .lb-split .mode-btn:first-child { padding: 6px 4px 6px 9px; }
  .lb-split .mode-btn:last-child { padding: 6px 9px 6px 4px; }
  .hd-grid .lb-split { width: auto; }
}
@media (max-width: 360px) {
  .hd-grid h1 { font-size: 1.6rem; }
  .hd-grid .podium-slot { width: 40px; }
  .lb-split .mode-btn { font-size: .66rem; }
  .lb-split .lb-amp { font-size: .66rem; }
}

/* ---- result reminder: a small pill at the bottom once the game is over (script.js updateDonePill) ---- */
#done-pill {
  position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); z-index: 30;
  display: inline-flex; align-items: center; gap: 8px; max-width: calc(100vw - 32px);
  padding: 6px 10px 6px 12px; border: 1px solid #e3e1dc; border-radius: 999px; background: rgba(255,255,255,.96);
  box-shadow: 0 6px 18px rgba(0,0,0,.08); font-family: inherit; font-size: 13px; color: #1a1a1a; cursor: pointer;
  transform: translateX(-50%); transition: opacity .25s ease, transform .35s ease; backdrop-filter: blur(6px);
}
#done-pill.is-merged { opacity: 0; transform: translate(-50%, 22px) scale(.92); pointer-events: none; }
#done-pill:hover { border-color: #cfccc4; }
#done-pill .dp-tag { color: #8a8780; font-weight: 600; font-variant-numeric: tabular-nums; }
#done-pill .dp-flag { width: 18px; height: 13px; border-radius: 2px; object-fit: cover; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }
#done-pill .dp-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#done-pill .dp-score { font-weight: 750; font-variant-numeric: tabular-nums; padding: 1px 8px; border-radius: 999px; }
#done-pill .dp-score--won { color: #2f7a4d; background: #eaf5ee; }
#done-pill .dp-score--lost { color: #b0574a; background: #fbeeeb; }
#done-pill .dp-arrow { color: #9a978f; flex-shrink: 0; }
@media (prefers-reduced-motion: reduce) { #done-pill { transition: opacity .2s; } #done-pill.is-merged { transform: translateX(-50%); } }


/* ---- What's new: the last few updates, newest first ---- */
.nt-box--log { max-height: calc(100vh - 48px); overflow-y: auto; }
.nt-log { list-style: none; margin: 2px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.nt-log li { display: grid; grid-template-columns: 60px 1fr; gap: 10px; font-size: .9rem; line-height: 1.45; color: #444; }
.nt-date { font-size: .78rem; font-weight: 600; color: #9a978f; padding-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nt-item strong { display: block; color: #1a1a1a; font-weight: 650; }
footer .ft-more { color: #ccc; }          /* the card sources: one group that wraps as a line */
footer .ft-dot { color: #ccc; }

/* What's new: coming soon (the first item is the big one) */
.nt-soon { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; padding-top: 12px; border-top: 1px solid #eeede9; }
.nt-soon-item { display: flex; flex-direction: column; gap: 1px; font-size: .88rem; line-height: 1.45; color: #555; }
.nt-soon-item strong { color: #1a1a1a; font-weight: 650; }
.nt-soon-item.is-big { padding: 10px 12px; border-radius: 10px; background: #fbf3df; box-shadow: inset 0 0 0 1px #efd99c; color: #444; }
.nt-soon-item.is-big strong { font-size: .98rem; }

/* the date on the puzzle line opens What's new; an unread dot in front of it while an update is unread */
.sub-date--btn { position: relative; display: inline-flex; align-items: center; padding: 2px 0; border: 0; background: none; font: inherit; font-size: 13px; color: #888; cursor: pointer; }
.sub-date--btn:hover .sd-txt, .sub-date--btn:hover .sd-short, .sub-date--btn:focus-visible .sd-txt { text-decoration: underline; text-underline-offset: 3px; color: #1a1a1a; }
.sub-date--btn .sd-short { display: none; }
.sub-date--btn.has-news { padding-right: 9px; }         /* room for the badge, so it never hangs past the page edge */
.sub-date--btn .sd-ico { position: absolute; top: -2px; right: 0; width: 8px; height: 8px; border-radius: 50%; background: #ff3b30; box-shadow: 0 0 0 2px #f7f7f5; }   /* badge with a ring in the page colour */
@media (max-width: 600px) {   /* phones: a short date, shown only when there is news */
  .sub-date--btn { display: none; }
  .sub-date--btn.has-news { display: inline-flex; flex-shrink: 0; margin-right: 6px; }
  .sub-date--btn.has-news .sd-txt { display: none; }
  .sub-date--btn.has-news .sd-short { display: inline; font-size: 12px; }
}

/* phones: Daily / Archive / Practice and Stats & Leaderboard side by side on one row, both scaled down */
@media (max-width: 600px) {
  .hd-grid { grid-template-areas: "title podium" "modes lb"; row-gap: 10px; column-gap: 6px; }
  .hd-grid #mode-nav.hd-modes { justify-self: start; align-self: center; margin: 0; }
  header .hd-modes .mode-btn, .hd-grid #mode-nav.hd-modes .mode-btn { gap: 3px; padding: 4px clamp(4px, 1.4vw, 8px); font-size: clamp(.6rem, 2.6vw, .72rem); }
  header .hd-modes .mode-btn .hd-ico { width: 11px; height: 11px; }
  .hd-grid .lb-split { width: auto; justify-self: end; align-self: center; }
  .lb-split .mode-btn { gap: 3px; padding: 5px clamp(4px, 1.4vw, 9px); font-size: clamp(.6rem, 2.6vw, .72rem); }
  .lb-split .mode-btn:first-child { padding-right: 3px; }
  .lb-split .mode-btn:last-child { padding-left: 3px; }
  .lb-split .lb-amp { font-size: clamp(.6rem, 2.6vw, .72rem); }
  .lb-split .hd-ico { width: 11px; height: 11px; }
  .hd-lockemo { font-size: .55rem; margin-left: 0; }
}
@media (max-width: 345px) { header .hd-modes .mode-btn .hd-ico, .lb-split .hd-ico { display: none; } }   /* the smallest phones: words only */
/* phones whose font runs wider than expected: back to stacked rows (script.js fitHeader) */
@media (max-width: 600px) { .hd-grid.hd-stack { grid-template-areas: "title podium" "title lb" "modes modes"; } }

/* ── Streak flames: daily puzzles solved in a row (5+), count inside ── */
.lb-name { display: flex; align-items: center; gap: 6px; overflow: visible; }
.lb-nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sx-name { display: flex; align-items: center; gap: 8px; }
.sx-name { overflow: visible; }
.sx-nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#sx-flame:empty { display: none; }
#sx-flame { display: inline-flex; flex-shrink: 0; }

.flame {
  --f-out: #f26a1b; --f-in: #ff9d3a; --f-glow: rgba(242, 106, 27, .35); --f-txt: #fff;
  position: relative; flex-shrink: 0; display: inline-flex; align-items: flex-end; justify-content: center;
  width: 22px; height: 27px; margin: -7px 0 -6px; line-height: 1; vertical-align: middle; cursor: default;
}
.flame--t2 { --f-out: #e8461a; --f-in: #fb8a2e; --f-glow: rgba(232, 70, 26, .4); }
.flame--t3 { --f-out: #d42a3c; --f-in: #f47a35; --f-glow: rgba(212, 42, 60, .42); }
.flame-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 1px 2px var(--f-glow)); }
.flame-out, .flame-in { transform-box: fill-box; transform-origin: 50% 100%; }
.flame-out { fill: var(--f-out); animation: flameOut 1.6s ease-in-out var(--fd, 0s) infinite; }
.flame-in  { fill: var(--f-in); opacity: .95; animation: flameIn 1.1s ease-in-out var(--fd, 0s) infinite; }
.flame-n {
  position: relative; z-index: 1; margin-bottom: 4px;
  font-size: 11px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums;
  color: var(--f-txt); text-shadow: 0 0 1.5px rgba(100, 20, 0, .8), 0 1px 1px rgba(100, 20, 0, .5);
}
.flame--3d .flame-n { font-size: 8.5px; letter-spacing: -.05em; margin-bottom: 5px; }
@keyframes flameOut {
  0%, 100% { transform: scale(1, 1) skewX(0deg); }
  25%      { transform: scale(.97, 1.05) skewX(-2.5deg); }
  50%      { transform: scale(1.02, .97) skewX(1.5deg); }
  75%      { transform: scale(.98, 1.04) skewX(2.5deg); }
}
@keyframes flameIn {
  0%, 100% { transform: scale(1, 1) translateX(0); }
  33%      { transform: scale(.92, 1.1) translateX(-.4px); }
  66%      { transform: scale(1.04, .94) translateX(.4px); }
}

/* Personal stats: the Streak tile turns into a big flame */
.flame--big { width: 36px; height: 44px; margin: -9px 0 -5px; }
.flame--big .flame-n { font-size: 17px; margin-bottom: 6px; }
.flame--big.flame--3d .flame-n { font-size: 13px; }
/* Every tile's number box has the same height, flame or not, so the labels line up */
.sx-tile-num { height: 1.1em; display: flex; align-items: center; justify-content: center; overflow: visible; }
.sx-tile-num { align-items: flex-end; }
.sx-tile-num .flame--big { margin: 0 0 -2px; }          /* grows upward from the number line, never into the label */

/* Phone: more room for names in the leaderboard (tighter rank, number columns and padding; smaller flame) */
@media (max-width: 600px) {
  #lb-modal .lb-row, #lb-modal .lb-header-row { padding-left: 0.6rem; padding-right: 0.6rem; }
  #lb-modal .lb-rank { width: 26px; }
  #lb-modal .lb-row--alltime .lb-score, #lb-modal .lb-header-row .lb-score { width: 40px; }
  #lb-modal .lb-header-row .lb-score { letter-spacing: 0; }
  #lb-modal .lb-score.lb-score--main-hdr,
  #lb-modal .lb-row--alltime .lb-score.lb-score--main { width: 64px; margin-left: 7px; }
  .lb-name { gap: 4px; }
  .lb-name .flame { width: 20px; height: 25px; }
  .lb-name .flame-n { font-size: 10px; }
  .flame--big { width: 30px; height: 37px; }
  .flame--big .flame-n { font-size: 14px; margin-bottom: 5px; }
  .flame--big.flame--3d .flame-n { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) { .flame-out, .flame-in { animation: none; } }

/* ── Feedback ── */
.go-btn--fb { color: #555; }
.fb-lead { margin: 0; font-size: .92rem; line-height: 1.5; color: #555; }
.fb-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.fb-text { width: 100%; box-sizing: border-box; min-height: 110px; resize: vertical; padding: 10px 12px; border: 1px solid #d4d4d4; border-radius: 8px;
  font: inherit; font-size: .95rem; line-height: 1.45; color: #1a1a1a; background: #fff; }
.fb-text:focus { outline: none; border-color: #1a1a1a; }
.fb-row { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.fb-row .nt-btn { margin-top: 0; }
.fb-close { order: -1; padding: 0; border: 0; background: none; font: inherit; font-size: .9rem; color: #888; cursor: pointer; }
.fb-close:hover { color: #1a1a1a; }
.fb-alt { margin: 2px 0 0; padding-top: 10px; border-top: 1px solid #eeede9; font-size: .85rem; color: #777; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.fb-addr { color: #1a1a1a; font-weight: 600; user-select: all; }
.fb-copy { padding: 2px 9px; border: 1px solid #d4d4d4; border-radius: 999px; background: #fff; font: inherit; font-size: .78rem; font-weight: 600; color: #555; cursor: pointer; }
.fb-copy:hover { border-color: #1a1a1a; color: #1a1a1a; }
.fb-msg { margin: 0; font-size: .82rem; line-height: 1.45; color: #777; }
.fb-msg:empty { display: none; }
.nt-fb { margin: 2px 0 0; font-size: .85rem; color: #777; }
.nt-fb-link { color: #1a1a1a; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.ft-nav { white-space: nowrap; }
