:root {
  --grey: #bdbdbd;
  --yellow: #f5d547;
  --red: #d84343;
  --sea: #a9d3e5;
  --stroke: #333333;
  --stroke-selected: #1a1a1a;
  --stroke-w: 3.2;
  --stroke-w-selected: 5;
  --focus: #1d6fd8;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
  padding: 16px 12px 48px;
  background: var(--sea);
  color: #17323f;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.page {
  width: 100%;
  max-width: 780px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* The map is capped to a comfortable share of the viewport height rather
   than trying to fit the whole page on one screen now that there's a
   scoreboard below it too - the page scrolls, the map just stays a
   sensible size while doing so. */
#map-wrap {
  position: relative;
  width: min(100%, calc(60vh * 1060 / 1200), 900px);
  aspect-ratio: 1060 / 1200;
  margin: 0 auto;
}

#japan-map {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.sea {
  fill: var(--sea);
}

.inset-frame {
  fill: none;
  stroke: #7f97a4;
  stroke-width: 1.5;
  stroke-dasharray: 6 5;
  pointer-events: none;
}

/* base prefecture styling - bold, slightly cartoony outlines rather than
   fine-line precision */
.prefecture {
  fill: var(--grey);
  stroke: var(--stroke);
  stroke-width: var(--stroke-w);
  stroke-linejoin: round;
  stroke-linecap: round;
  cursor: pointer;
  transform-box: fill-box;
  transform-origin: 50% 50%;
  transition: transform 380ms cubic-bezier(0.34, 1.56, 0.64, 1),
              fill 150ms ease,
              stroke-width 200ms ease,
              stroke 200ms ease;
}

.prefecture:focus-visible {
  outline: none;
  stroke: var(--focus);
  stroke-width: calc(var(--stroke-w) + 1.5);
}

.prefecture.state-1 { fill: var(--yellow); }
.prefecture.state-2 { fill: url(#stripe-pattern); }
.prefecture.state-3 { fill: var(--red); }

/* enlarged / selected prefecture - pops up with a little bounce, and
   settles back down the same way when deselected */
.pref-group.selected .prefecture {
  transform: scale(1.6);
  stroke-width: var(--stroke-w-selected);
  stroke: var(--stroke-selected);
}

/* floating name labels */
#labels-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.pref-label {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.9);
  color: #222;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  opacity: 0;
  visibility: hidden;
  transition: opacity 120ms ease;
  pointer-events: none;
}

.pref-label.visible {
  opacity: 1;
  visibility: visible;
}

@media (max-width: 480px) {
  .pref-label {
    font-size: 11px;
    padding: 1px 7px;
  }
}

/* ---------------------------------------------------------------------- */
/* Episode selector bar                                                    */
/* ---------------------------------------------------------------------- */

.episode-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ep-nav {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.75);
  color: #17323f;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: background 120ms ease, transform 120ms ease;
}

.ep-nav:hover:not(:disabled) {
  background: #fff;
  transform: translateY(-1px);
}

.ep-nav:disabled {
  opacity: 0.35;
  cursor: default;
}

.ep-info {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.ep-title-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ep-number {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.7);
  padding: 2px 8px;
  border-radius: 8px;
  white-space: nowrap;
}

#ep-title {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.25;
}

.ep-summary {
  margin: 5px 0 7px;
  font-size: 0.85rem;
  opacity: 0.8;
  max-width: 52ch;
  margin-left: auto;
  margin-right: auto;
}

.ep-dates {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.date-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.75);
}

.date-badge.nebula { box-shadow: inset 0 0 0 1.5px #6c4fd6; }
.date-badge.youtube { box-shadow: inset 0 0 0 1.5px #d13b3b; }
.date-badge.future { opacity: 0.55; font-style: italic; }

.load-error {
  background: #fdecea;
  color: #7a1f1f;
  border: 1px solid #f0b8b3;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.4;
}

/* ---------------------------------------------------------------------- */
/* Challenges "on the board"                                               */
/* ---------------------------------------------------------------------- */

.challenges h2,
.team-panels-heading {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
  margin: 0 0 10px;
  text-align: center;
}

.challenge-balls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  min-height: 20px;
}

.challenge-ball {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: repeating-conic-gradient(
    from 0deg,
    #1c1042 0deg 30deg,
    #946bd6 30deg 60deg
  );
  border: 3px solid #120a2c;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6px;
  gap: 3px;
}

.challenge-ball .cb-title {
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.15;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

.challenge-ball .cb-reward {
  font-size: 0.62rem;
  font-weight: 600;
  color: #fff;
  opacity: 0.92;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

.board-empty-note {
  font-size: 0.82rem;
  opacity: 0.65;
  text-align: center;
  font-style: italic;
}

/* ---------------------------------------------------------------------- */
/* Team panels + playing cards                                            */
/* ---------------------------------------------------------------------- */

.team-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 560px) {
  .team-panels {
    grid-template-columns: 1fr;
  }
}

.team-panel {
  background: rgba(255, 255, 255, 0.6);
  border-radius: 14px;
  padding: 14px 14px 16px;
  border-top: 6px solid var(--team-accent, #999);
}

.team-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.team-name {
  font-weight: 800;
  font-size: 1.05rem;
}

.team-members {
  font-size: 0.78rem;
  opacity: 0.75;
}

.team-stat {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-top: 3px;
}

.hand {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.card {
  width: 76px;
  height: 108px;
  border-radius: 9px;
  background: #fff;
  border: 2px solid #2a2a2a;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 6px 5px;
  text-align: center;
}

.card-title {
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1.1;
}

.card-emojis {
  font-size: 1.35rem;
  line-height: 1;
}

.card-blurb {
  font-size: 0.58rem;
  line-height: 1.15;
  opacity: 0.75;
}

.card.empty-slot {
  border-style: dashed;
  border-color: rgba(0, 0, 0, 0.25);
  box-shadow: none;
  background: rgba(255, 255, 255, 0.35);
}

@media (max-width: 420px) {
  .card {
    width: 66px;
    height: 96px;
  }
  .card-emojis {
    font-size: 1.15rem;
  }
}

/* ---------------------------------------------------------------------- */
/* Per-episode travel routes                                               */
/* ---------------------------------------------------------------------- */

#routes {
  pointer-events: none;
}

.route-casing {
  fill: none;
  stroke: #000;
  stroke-width: 7.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 1;
}

.route-line {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 13 9;
  opacity: 1;
}

.route-yellow { stroke: var(--yellow); }
.route-red { stroke: var(--red); }

.route-arrowhead-yellow { fill: var(--yellow); stroke: #000; stroke-width: 1; }
.route-arrowhead-red { fill: var(--red); stroke: #000; stroke-width: 1; }

.route-stop {
  stroke: #000;
  stroke-width: 2.5;
}

.route-stop-yellow { fill: var(--yellow); }
.route-stop-red { fill: var(--red); }

/* ---------------------------------------------------------------------- */
/* Footer                                                                   */
/* ---------------------------------------------------------------------- */
 
.site-footer {
  text-align: center;
  font-size: 0.78rem;
  opacity: 0.75;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.15);
}
 
.site-footer a {
  color: inherit;
  text-decoration: underline;
}
 
.site-footer a:hover {
  opacity: 0.8;
}
 
.footer-sep {
  margin: 0 6px;
}
