*,
*::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;
  min-height: 16px;
}

/* ---------- 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 {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.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 */
  #charts-section {
    grid-template-columns: 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; }
