/* Tokens, page layout, masthead, buttons.
   Colour follows Paris itself: large surfaces stay in the low-chroma tones of Haussmann
   limestone, white bevelled métro tiles and the navy of the enamel station plaques;
   saturated colour (line colours, validator violet, Guimard-lamp amber) only covers small areas.
   Texture is the métro tile, laid in running bond, always drawn at screen size. */
:root {
  color-scheme: light;
  --ground: #efe8da;      /* pierre de Paris: limestone */
  --surface: #fbf9f3;     /* glazed tile white */
  --ink: #18223f;         /* plaque navy, as ink */
  --ink-soft: #565d70;
  --rule: #d5ccba;
  --grout: #d9d1c1;
  --rail-off: #c9c4b8;
  --enamel: #1c2b5a;      /* the station plaque */
  --enamel-edge: #f4f1e8;
  --guimard: #2c5a4c;     /* cast-iron verdigris of the 1900 entrances */
  --amber: #f0a73a;       /* the entrance lamps: keyboard focus only */
  --violet: #5b3b8c;      /* validator ink */
  --rouge: #b8323a;
  --ok: #1f6a47;
  --warn: #8a5800;
  --seine: #b9cad1;

  --font-body: "Fira Sans", "Zen Kaku Gothic New", "Hiragino Sans", system-ui, sans-serif;
  --font-sign: "Fira Sans", "Zen Kaku Gothic New", "Hiragino Sans", sans-serif;
  --font-sign-narrow: "Fira Sans Condensed", "Fira Sans", "Zen Kaku Gothic New", sans-serif;
  --font-display: "Bodoni Moda", "Didot", "Bodoni 72", "Shippori Mincho B1", Georgia, serif;
  --font-ja: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", sans-serif;
  --font-ja-display: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --font-ink: "Doto", "Courier New", monospace;

  /* Carreaux biseautés: white bevelled tiles in running bond, light from above. */
  --tiles: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%23ffffff'/%3E%3Cstop offset='.55' stop-color='%23f7f3ea'/%3E%3Cstop offset='1' stop-color='%23e3dccd'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='40' height='40' fill='%23d6cdbb'/%3E%3Cg fill='url(%23g)'%3E%3Crect x='.75' y='.75' width='38.5' height='18.5' rx='3.5'/%3E%3Crect x='-19.25' y='20.75' width='38.5' height='18.5' rx='3.5'/%3E%3Crect x='20.75' y='20.75' width='38.5' height='18.5' rx='3.5'/%3E%3C/g%3E%3C/svg%3E");

  --panel-w: 448px;
  --gutter: clamp(16px, 2.2vw, 28px);
  --ease-stamp: cubic-bezier(0.2, 0.9, 0.25, 1.25);
}

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

/* A class that sets display must never beat the hidden attribute. */
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  background: var(--ground);
  color: var(--ink);
  font: 400 1rem/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

:root:lang(ja) body { line-height: 1.7; }
[lang="ja"] { font-family: var(--font-ja); }

p, h1, h2, h3 { text-wrap: pretty; }
:lang(ja) p { word-break: auto-phrase; line-break: strict; }

a { color: inherit; text-underline-offset: 0.18em; }

.defs { position: absolute; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--amber);
}

/* ---------- layout: the plan on the left, everything you touch on the right ---------- */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  grid-template-rows: auto auto minmax(150px, 1fr) auto;
  grid-template-areas:
    "map head"
    "map console"
    "map lines"
    "map foot";
  min-height: 100dvh;
}

.masthead { grid-area: head; padding: 18px var(--gutter) 0; }
.console { grid-area: console; padding: 16px var(--gutter) 0; }
.mapwrap { grid-area: map; }
.lines { grid-area: lines; overflow-y: auto; padding: 18px var(--gutter) 8px; }
.foot { grid-area: foot; padding: 12px var(--gutter) 18px; }

@media (min-width: 901px) {
  .mapwrap, .lines { contain: size; }
  /* The panel is a column of its own: a thin cast-iron rule separates it from the plan. */
  .masthead, .console, .lines, .foot { border-left: 1px solid var(--rule); }
}

/* Phones: the plan sits right above the answer field, so it stays in view while typing. */
@media (max-width: 900px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas: "head" "map" "console" "lines" "foot";
  }
  .mapwrap { height: clamp(280px, 86vw, 48svh); margin-top: 12px; border-block: 1px solid var(--rule); }
  .lines { overflow: visible; }
  .console { display: flex; flex-direction: column; padding-top: 12px; }
  .console .answer { order: 1; margin-top: 0; }
  .console .scoreline { order: 2; }
  .console .board { order: 3; margin-top: 14px; }
  .lede { font-size: 0.88rem; }
}

/* Once playing, the intro folds away so the sign, the plan and the line list get the room. */
.app.started .lede, .app.started .linestrip { display: none; }

/* ---------- masthead ---------- */
.masthead { position: relative; isolation: isolate; border-top: 5px solid var(--enamel); }

/* The tiled wall of a station, fading down into limestone. */
.masthead::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 200px;
  z-index: -1;
  background: var(--tiles) 0 0 / 40px 40px;
  opacity: 0.9;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, rgb(0 0 0 / 0.35) 55%, transparent);
  mask-image: linear-gradient(to bottom, #000 0%, rgb(0 0 0 / 0.35) 55%, transparent);
}

/* A miniature enamel plaque as the edition mark. */
.edition { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding-right: 150px; min-height: 36px; }
.edition-plaque {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 5px 10px 4px;
  border-radius: 4px;
  background: var(--enamel);
  box-shadow: inset 0 0 0 2px var(--enamel), inset 0 0 0 3.2px var(--enamel-edge), 0 2px 0 rgb(24 34 63 / 0.25);
  color: #fff;
  font: 600 0.82rem/1 var(--font-sign);
  letter-spacing: 0.14em;
}
.edition-plaque b { font-weight: 700; color: var(--amber); letter-spacing: 0.04em; }
.edition-text { font: 600 0.7rem/1.3 var(--font-sign); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }

.langs { position: absolute; top: 20px; right: var(--gutter); display: flex; font-size: 0.76rem; }
.langs a {
  padding: 3px 9px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink-soft);
  font-weight: 600;
  text-decoration: none;
}
.langs a + a { border-left: 0; }
.langs a:first-child { border-radius: 3px 0 0 3px; }
.langs a:last-child { border-radius: 0 3px 3px 0; }
.langs a:hover { color: var(--ink); }
.langs a[aria-current] { background: var(--enamel); border-color: var(--enamel); color: #fff; }

/* City switcher: Paris now, the rest of France's métros to come. */
.cities { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 16px; }
.cities-label { margin-right: 4px; font: 700 0.68rem/1 var(--font-sign); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.city {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 30px;
  padding: 3px 12px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: 600 0.82rem/1.2 var(--font-sign);
  text-decoration: none;
}
.city[aria-current] { background: var(--enamel); border-color: var(--enamel); color: #fff; }
.city.soon { border-style: dashed; border-color: var(--rail-off); background: transparent; color: var(--ink-soft); cursor: default; }
.city.soon small { font-size: 0.64rem; font-weight: 500; font-style: italic; }

@media (max-width: 900px) {
  .cities {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-inline: calc(-1 * var(--gutter));
    padding: 2px var(--gutter);
    scrollbar-width: none;
    mask-image: linear-gradient(90deg, transparent 0, #000 var(--gutter), #000 calc(100% - 28px), transparent);
  }
  .cities::-webkit-scrollbar { display: none; }
  .city, .cities-label { flex: none; }
}

/* The title: a Didone, the typeface family Firmin Didot cut in Paris, with an engraved
   shadow of fine hatching in Guimard green, like the plates of an old Plan de Paris. */
.title {
  position: relative;
  isolation: isolate;
  margin: 0;
  font: italic 500 clamp(2rem, 1.3rem + 1.9vw, 2.9rem)/1.04 var(--font-display);
  font-optical-sizing: auto;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
:lang(ja) .title { font: 700 clamp(1.6rem, 1.15rem + 1.1vw, 2.15rem)/1.2 var(--font-ja-display); letter-spacing: 0.02em; word-break: auto-phrase; }

.title::before {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  z-index: -1;
  transform: translate(0.045em, 0.055em);
  background: repeating-linear-gradient(-45deg, var(--guimard) 0 0.8px, transparent 0.8px 2.6px);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lede { margin: 10px 0 0; max-width: 34em; color: var(--ink-soft); font-size: 0.95rem; }

/* All sixteen line colours, end to end. */
.linestrip { display: flex; gap: 2px; height: 5px; margin-top: 16px; }
.linestrip span { flex: 1; background: var(--c); }
.linestrip span:first-child { border-radius: 3px 0 0 3px; }
.linestrip span:last-child { border-radius: 0 3px 3px 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4em;
  min-height: 44px;
  padding: 0.5rem 1.05rem;
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font: 600 0.95rem/1.15 var(--font-body);
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: transform 0.08s ease, background-color 0.15s ease;
}
.btn:hover { background: #fff; }
.btn:active { transform: translateY(1px); }
.btn-ink { border-color: var(--enamel); background: var(--enamel); color: #fff; box-shadow: inset 0 0 0 2px var(--enamel), inset 0 0 0 3px rgb(255 255 255 / 0.55); }
.btn-ink:hover { background: #253872; }
.btn-quiet { border-color: var(--rule); font-weight: 500; min-height: 36px; padding: 0.35rem 0.8rem; }

/* ---------- footer ---------- */
.foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; border-top: 1px dashed var(--ink-soft); background: var(--surface); }
.maker { margin: 0; font-size: 0.8rem; font-weight: 500; }
.support-author { margin-left: auto; font-size: 0.8rem; font-weight: 600; color: var(--violet); text-underline-offset: 0.2em; }
.support-author:hover { color: var(--rouge); }
.credit { flex: 1 1 100%; margin: 0; font-size: 0.72rem; line-height: 1.5; color: var(--ink-soft); }

.other-game {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 100%;
  min-height: 52px;
  padding: 8px 12px;
  border: 1.5px solid #7b2d26;
  border-radius: 3px;
  background: #fbf4ec;
  color: #4b1c18;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.other-game:hover { transform: translateY(-2px); box-shadow: 3px 3px 0 #e2c9bf; }
.other-game-seal {
  display: grid; place-items: center; flex: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #c53d43;
  color: #fff9ed;
  font: 700 1rem/1 var(--font-ja);
}
.other-game-copy { display: grid; gap: 1px; }
.other-game-copy small { font: 500 0.68rem/1.2 var(--font-body); letter-spacing: 0.03em; }
.other-game-copy strong { font: 700 0.9rem/1.2 var(--font-body); }
.other-game-arrow { margin-left: auto; font-size: 1.2rem; }
.other-game-jinja { border-color: #3b594c; background: #f5f1e8; color: #254236; }
.other-game-jinja:hover { box-shadow: 3px 3px 0 #b7c6b1; }
.other-game-jinja .other-game-seal { background: #aa473a; }

@media (max-width: 480px) { .edition-text { display: none; } }
@media (max-width: 380px) {
  .langs a { padding-inline: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Streamers for a completed line or a full clear (motion.js confetti()). */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i { position: absolute; width: 8px; height: 4px; border-radius: 1px; }

/* ---------- network switch ---------- */
/* Each chip carries its network's pictogram language: Métro a disc, RER a ring, Tram two bars. */
.nets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 14px; }
.nets-label { margin-right: 2px; font: 700 0.68rem/1 var(--font-sign); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.net {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 34px;
  padding: 4px 10px 4px 8px;
  border: 1.5px dashed var(--ink-soft);
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font: 600 0.84rem/1 var(--font-sign);
  text-decoration: none;
  transition: background-color 0.15s ease, transform 0.08s ease;
}
.net:hover { background: var(--surface); }
.net:active { transform: translateY(1px); }
.net small { font-weight: 500; font-size: 0.72rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.net[aria-pressed="true"] { border-style: solid; border-color: var(--enamel); background: var(--enamel); color: #fff; box-shadow: inset 0 0 0 2px var(--enamel), inset 0 0 0 3px rgb(255 255 255 / 0.5); }
.net[aria-pressed="true"] small { color: rgb(255 255 255 / 0.75); }
.net[aria-pressed="false"]::before { content: "+"; margin-right: -3px; font-weight: 700; color: var(--ink-soft); }
.net[aria-disabled="true"] { cursor: default; }
.net-mark { flex: none; width: 13px; height: 13px; }
.net-metro .net-mark { border-radius: 50%; background: var(--amber); }
.net-rer .net-mark { border-radius: 50%; box-shadow: inset 0 0 0 3px #e3051c; background: #fff; }
.net-tram .net-mark { height: 11px; border-block: 3px solid #216eb4; background: #fff; }
.nets-hint { flex: 1 1 100%; font-size: 0.72rem; color: var(--ink-soft); }
.app.started .nets-hint { display: none; }

/* A friend's score from a shared link: the one number to beat. */
.challenge {
  margin: 12px 0 0;
  padding: 8px 12px;
  border: 1.5px solid var(--violet);
  border-radius: 4px;
  background: #f5f0fb;
  color: var(--violet);
  font-weight: 600;
  font-size: 0.92rem;
}

.lang-suggest { display: inline-block; margin: -6px 0 12px; font-size: 0.8rem; font-weight: 600; color: var(--enamel); }
