/* SPDX-License-Identifier: AGPL-3.0-or-later */
/* Maniobres 2.0 · estètica clara i alegre: cel, gespa i vagons de colors. */
:root {
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  --ink: #1d2b38;
  --muted: #5b6b7a;
  --line: #d8e3ec;
  --panel: #ffffff;
  --sky: #e6f3fc;
  --green: #1f9d6b;
  --green-dark: #157a52;
  --orange: #ff8a3d;
  --red: #e5533d;
  --gold: #f5b82e;
  color: var(--ink);
  background: var(--sky);
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: 56px;
  background:
    radial-gradient(circle at 12% -10%, #ffffffcc 0 22%, transparent 40%),
    linear-gradient(180deg, #d9eefc 0%, #eef7fd 45%, #f6fbf3 100%);
  background-attachment: fixed;
}
h1,
h2,
h3 {
  margin: 0 0 8px;
  letter-spacing: -0.4px;
  line-height: 1.15;
}
h1 {
  font-size: 30px;
}
h2 {
  font-size: 25px;
}
h3 {
  font-size: 18px;
}
p {
  margin: 0 0 10px;
  line-height: 1.55;
}
a {
  color: var(--green-dark);
}
button,
input {
  font: inherit;
  touch-action: manipulation;
}
button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 9px 15px;
  font-weight: 600;
  box-shadow: 0 1px 0 #1d2b380d;
  transition:
    background 0.15s,
    transform 0.15s;
}
button:hover {
  background: #f2f8fc;
}
button:active {
  transform: translateY(1px);
}
button:focus-visible,
input:focus-visible {
  outline: 3px solid #ff8a3d88;
  outline-offset: 2px;
}
button:disabled {
  opacity: 0.4;
  cursor: default;
}
button.primary {
  background: var(--green);
  border-color: var(--green-dark);
  color: #fff;
  box-shadow: 0 3px 0 var(--green-dark);
}
button.primary:hover {
  background: #22ad76;
}
button.ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--green-dark);
  padding: 5px 8px;
}
button.ghost:hover {
  background: #1f9d6b14;
}
input {
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  max-width: 100%;
}
.icon {
  width: 19px;
  height: 19px;
  flex: none;
  vertical-align: middle;
}
.eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--green-dark);
  margin-bottom: 6px;
}
.muted {
  color: var(--muted);
  font-weight: 400;
}
.badge {
  display: inline-block;
  border-radius: 99px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 800;
  background: var(--orange);
  color: #fff;
  vertical-align: middle;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 8px 24px #1d4b6b12;
}
.loading {
  padding: 50px;
}
.warning {
  color: var(--red) !important;
}

/* Estructura */
.shell {
  max-width: 1500px;
  margin: 0 auto;
  min-height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  padding: 12px 22px 10px;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 0;
  box-shadow: none;
  padding: 0;
  text-align: left;
  flex: none;
}
.brand:hover {
  background: none;
}
.brand img {
  width: 48px;
}
.brand strong {
  display: block;
  font-size: 26.5px;
  letter-spacing: -0.6px;
}
.brand small {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 1.8px;
  text-transform: uppercase;
}
.tabs-top {
  display: flex;
  gap: 4px;
  margin-left: 18px;
  margin-right: auto;
  background: #ffffffb3;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 4px;
}
.tabs-top button {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 15px;
  border: 0;
  box-shadow: none;
  background: transparent;
  color: var(--muted);
  padding: 8px 16px;
}
.tabs-top button.active {
  background: var(--green);
  color: #fff;
  box-shadow: 0 2px 0 var(--green-dark);
}
.top-actions {
  display: flex;
  gap: 8px;
}
.top-actions button {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 8px 12px;
}
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Joc */
.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stage-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.goal-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 18px;
  font-weight: 650;
}
.goal-line b {
  color: var(--green-dark);
}
.target-train {
  display: flex;
  gap: 5px;
}
.target-train {
  align-items: center;
  gap: 0;
  padding: 2px 8px;
  border-radius: 12px;
  background: linear-gradient(#ffffff00 46%, #c9bfa7 46%, #c9bfa7 54%, #ffffff00 54%);
}
.mini-wagon {
  width: 52px;
  height: 38px;
  margin: 0 -2px;
  filter: drop-shadow(0 2px 1px #1d3a2230);
}
.stage-stats {
  display: flex;
  gap: 8px;
}
.stage-stats > div {
  min-width: 86px;
  padding: 6px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 4px 12px #1d4b6b0f;
}
.stage-stats b {
  display: block;
  font-size: 22px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.stage-stats > div:first-child b {
  color: var(--orange);
}
.stage-stats small {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.board-wrap {
  position: relative;
  flex: 1;
  min-height: 260px;
  border-radius: 22px;
  border: 3px solid #fff;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 15%, #ffffff55 0 10%, transparent 30%),
    linear-gradient(160deg, #d4efc0 0%, #c3e6ab 55%, #b5dd9c 100%);
  box-shadow: 0 12px 30px #2c6b3a26;
}
.board-wrap .board {
  position: absolute;
  inset: 6px 10px 42px;
  width: calc(100% - 20px);
  height: calc(100% - 48px);
}
.board {
  display: block;
}
.board-wrap.complete {
  border-color: var(--gold);
  box-shadow:
    0 0 0 4px #f5b82e66,
    0 12px 30px #2c6b3a26;
}
.board-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 9px 16px;
  background: #ffffffd9;
  backdrop-filter: blur(4px);
  font-size: 14px;
  font-weight: 550;
  color: var(--ink);
}
.board-caption b {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  font-size: 12px;
}
.board-caption b.ok {
  background: var(--green);
}
.board-caption .solution {
  font-family: ui-monospace, monospace;
  font-weight: 800;
  color: var(--green-dark);
}
.board-caption .hint-line {
  margin-left: 10px;
  font-weight: 800;
  color: #c2410c;
}
.track-label {
  font-weight: 800;
  fill: #2d4a32;
}
.board .scenery,
.board .hint-route {
  pointer-events: none;
}
.board .hint-dash {
  animation: hint-flow 0.9s linear infinite;
}
.board .hint-wagon > g {
  animation: hint-glow 1.1s ease-in-out infinite;
}
@keyframes hint-flow {
  to {
    stroke-dashoffset: -18;
  }
}
@keyframes hint-glow {
  0%,
  100% {
    filter: drop-shadow(0 0 2px #ff8a3d) drop-shadow(0 4px 2px #1d3a2240);
  }
  50% {
    filter: drop-shadow(0 0 9px #ff8a3d) drop-shadow(0 0 4px #ff8a3d);
  }
}
.board .siding {
  cursor: pointer;
  pointer-events: bounding-box;
}
.board .siding:focus {
  outline: none;
}
.track-halo {
  opacity: 0;
  transition: opacity 0.2s;
}
.board .siding:hover .track-halo,
.board .siding:focus-visible .track-halo,
.board .siding.selected .track-halo {
  opacity: 1;
}
.wagon {
  filter: drop-shadow(0 4px 2px #1d3a2240);
}
.board .cut-target {
  cursor: pointer;
}
.board .cut-target > g {
  filter: drop-shadow(0 0 5px #ff8a3d);
}
#main .board {
  touch-action: none;
  user-select: none;
}
#main .board [data-src] {
  cursor: grab;
}
#main .board.dragging,
#main .board.dragging * {
  cursor: grabbing;
}
.board .lifted {
  filter: drop-shadow(0 12px 8px #1d3a2255);
  pointer-events: none;
}
.board .maniobra-halo {
  opacity: 0;
}
#main .board.dragging .track-halo,
#main .board.dragging .maniobra-halo {
  transition: none;
}
#main .board.dragging .siding .track-halo {
  opacity: 0;
}
#main .board.dragging .siding.drop-ok .track-halo,
#main .board.dragging .siding.drop-bad .track-halo,
.board .maniobra-halo.drop-ok,
.board .maniobra-halo.drop-bad {
  opacity: 1;
}
.board .drop-ok .track-halo,
.board .maniobra-halo.drop-ok {
  stroke: #ffffffaa;
}
.board .drop-bad .track-halo,
.board .maniobra-halo.drop-bad {
  stroke: #e5533d88;
}
.stage-controls {
  display: flex;
  align-items: center;
  gap: 8px 14px;
  flex-wrap: wrap;
}
.choice-row,
.tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.choice-row:empty {
  display: none;
}
.choice-row {
  align-items: center;
}
.choice-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-right: 2px;
}
.choice-row .chip {
  padding: 5px 12px;
  border-radius: 99px;
  font-size: 13px;
  background: #fff8f0;
  border-color: #ffd2ad;
  box-shadow: none;
}
.choice-row .chip:disabled {
  background: transparent;
  border-color: var(--line);
}
.choice-row .chip.ghost {
  background: transparent;
  border-color: transparent;
}
.choice-row button .icon {
  width: 16px;
  height: 16px;
}
.choice-row > button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tool-row {
  margin-left: auto;
}
.tool-row button {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 8px 12px;
}
.tool-row .icon {
  width: 16px;
  height: 16px;
}

/* Diàlegs */
dialog {
  background: #fff;
  color: var(--ink);
  border: 0;
  border-radius: 24px;
  max-width: 600px;
  width: calc(100% - 32px);
  padding: 28px;
  box-shadow: 0 30px 80px #1d4b6b40;
}
dialog::backdrop {
  background: #1d3a5266;
  backdrop-filter: blur(3px);
}
dialog .close {
  float: right;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
}
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.result {
  text-align: center;
}
dialog:has(.result) .close {
  position: absolute;
  top: 30px;
  right: 30px;
  z-index: 2;
  width: 32px;
  height: 32px;
  font-size: 18px;
  background: #ffffffcc;
}
.result-art {
  position: relative;
  margin: -6px -6px 14px;
  padding: 50px 14px 10px;
  border-radius: 18px;
  border: 3px solid #fff;
  background:
    radial-gradient(circle at 50% 0%, #fff6d6 0 22%, transparent 55%),
    linear-gradient(160deg, #d4efc0 0%, #c3e6ab 55%, #b5dd9c 100%);
  box-shadow: 0 8px 20px #2c6b3a22;
  overflow: hidden;
}
.result-train {
  display: block;
  width: 100%;
  height: auto;
  animation: result-roll 1.1s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.result-stars {
  position: absolute;
  top: 8px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
}
.result-stars span {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
}
.result-stars .icon {
  width: 36px;
  height: 36px;
  fill: #ffffffaa;
  stroke: #9fc98a;
  stroke-width: 1.2;
}
.result-stars span:nth-child(2) .icon {
  width: 44px;
  height: 44px;
  transform: translateY(-4px);
}
.result-stars .on .icon {
  fill: var(--gold);
  stroke: #d99a12;
  filter: drop-shadow(0 3px 4px #b7860f55);
}
.result-stars .on {
  animation: star-pop 0.55s cubic-bezier(0.3, 1.6, 0.5, 1) var(--d) both;
}
@keyframes star-pop {
  from {
    transform: scale(0) rotate(-40deg);
    opacity: 0;
  }
}
@keyframes result-roll {
  from {
    transform: translateX(-60%);
  }
}
.result h2 {
  margin-bottom: 4px;
}
.result-msg {
  margin: 0 0 12px;
  color: var(--muted);
}
.result-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.result-tiles div {
  padding: 8px 4px;
  border-radius: 14px;
  background: #f1f8fd;
}
.result-tiles b {
  display: block;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}
.result-tiles small {
  font-size: 12px;
  color: var(--muted);
}
.result-tiles .pts {
  background: #eaf6f0;
}
.result-tiles .pts b {
  color: var(--green-dark);
}
.result .your-solution {
  margin: 10px 0 4px;
  color: var(--muted);
}
.result .rank-note {
  text-align: left;
}
.result .dialog-actions {
  justify-content: center;
}
.dialog-actions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.dialog-actions .icon {
  width: 16px;
  height: 16px;
}
.your-solution {
  font-size: 14px;
}
.your-solution b {
  font-family: ui-monospace, monospace;
  color: var(--green-dark);
}
.rank-note {
  background: #fff7ec;
  border: 1px solid #ffd9b3;
  border-radius: 14px;
  padding: 12px 14px;
  margin: 6px 0 4px;
  font-size: 14px;
  line-height: 1.5;
}
.rank-note:empty {
  display: none;
}
.rank-note small,
.me-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.name-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0 6px;
}
.name-form input {
  flex: 1;
  min-width: 180px;
  font-size: 15px;
}
.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 16px 0 4px;
}
.level-card {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 14px 6px 12px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fff;
  border-top: 5px solid var(--l);
}
.level-card:hover {
  border-color: var(--l);
}
.level-card.on {
  border-color: var(--l);
  background: color-mix(in srgb, var(--l) 10%, #fff);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--l) 30%, transparent);
}
.level-card .bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 20px;
  margin-bottom: 4px;
}
.level-card .bars i {
  width: 6px;
  border-radius: 2px;
  background: var(--line);
}
.level-card .bars i.f {
  background: var(--l);
}
.level-card b {
  font-size: 17px;
  color: var(--ink);
}
.level-card small {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
}
.level-card .pts {
  margin-top: 4px;
  padding: 2px 9px;
  border-radius: 99px;
  background: var(--l);
  color: #fff;
  font-size: 11.5px;
  font-weight: 800;
}
/* Com s'hi juga */
.guide {
  text-align: center;
}
.guide-art {
  margin: -6px -6px 14px;
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 15%, #ffffff66 0 12%, transparent 35%),
    linear-gradient(160deg, #d4efc0 0%, #c3e6ab 55%, #b5dd9c 100%);
  border: 3px solid #fff;
  box-shadow: 0 8px 20px #2c6b3a22;
}
.guide-art.tools {
  background: linear-gradient(160deg, #eef7fd, #f6fbf3);
}
.scene {
  display: block;
  width: 100%;
  height: auto;
}
.scene .scene-label {
  font: 800 15px system-ui;
  fill: #2d4a32;
}
.scene .scene-tag {
  font: 800 11.5px system-ui;
  fill: #fff;
}
.scene .slide {
  animation: guide-slide 3.4s ease-in-out infinite;
}
.scene .finger {
  animation: guide-press 3.4s ease-in-out infinite;
}
.scene .pop {
  animation: guide-pop 2.6s ease-in-out infinite;
  transform-origin: center;
}
@keyframes guide-slide {
  0%,
  22% {
    transform: translateX(0);
    opacity: 1;
  }
  62%,
  84% {
    transform: translateX(var(--dx));
    opacity: 1;
  }
  94% {
    transform: translateX(var(--dx));
    opacity: 0;
  }
  100% {
    transform: translateX(0);
    opacity: 0;
  }
}
@keyframes guide-press {
  0%,
  12% {
    opacity: 0;
  }
  20%,
  66% {
    opacity: 1;
  }
  76%,
  100% {
    opacity: 0;
  }
}
@keyframes guide-pop {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}
.guide-tools {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 18px 14px;
}
.guide-tools div {
  display: grid;
  justify-items: center;
  gap: 3px;
}
.guide-tools span {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 16px;
  background: var(--c);
  color: #fff;
  box-shadow: 0 6px 14px #1d2b3826;
  margin-bottom: 4px;
}
.guide-tools .icon {
  width: 24px;
  height: 24px;
}
.guide-tools b {
  font-size: 14px;
}
.guide-tools small {
  font-size: 12px;
  color: var(--muted);
}
.guide-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 12px;
}
.guide-dots i {
  width: 8px;
  height: 8px;
  border-radius: 9px;
  background: var(--line);
  transition: width 0.2s;
}
.guide-dots i.done {
  background: #9fd8bf;
}
.guide-dots i.on {
  width: 24px;
  background: var(--green);
}
.guide h2 {
  font-size: 24px;
}
.guide p {
  color: #3c4c5a;
  font-size: 16px;
  max-width: 420px;
  margin: 0 auto;
  min-height: 3.1em;
}
.guide-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}
.guide-actions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 130px;
  justify-content: center;
}
.guide-actions .icon {
  width: 17px;
  height: 17px;
}
dialog:has(.guide) {
  max-width: 560px;
}
dialog:has(.guide) .close {
  display: none;
}
.pref-list {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}
.pref-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #f4f9fc;
  cursor: pointer;
}
.install-row {
  cursor: default;
  background: #eef5fd;
}
.pref-ic {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--c);
  color: #fff;
}
.pref-ic .icon {
  width: 20px;
  height: 20px;
}
.pref-txt {
  flex: 1;
  min-width: 0;
}
.pref-txt b {
  display: block;
  font-size: 15px;
}
.pref-txt small {
  font-size: 12.5px;
  color: var(--muted);
}
.switch {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  flex: none;
  position: relative;
  display: block;
  width: 50px;
  height: 30px;
  min-width: 50px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 99px;
  background: #c9d5df;
  box-shadow: inset 0 1px 3px #1d2b3826;
  cursor: pointer;
  transition: background-color 0.25s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px #1d2b3840;
  transition: transform 0.25s cubic-bezier(0.3, 0.7, 0.4, 1);
}
.switch:checked {
  background: var(--green);
}
.switch:checked::after {
  transform: translateX(20px);
}
.switch:focus-visible {
  outline: 3px solid #1f9d6b55;
  outline-offset: 2px;
}
.keys h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin: 0 0 8px;
  color: var(--muted);
}
.keys h3 .icon {
  width: 18px;
  height: 18px;
}
.keys-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
  font-size: 13px;
  color: #3c4c5a;
}
kbd {
  display: inline-block;
  min-width: 22px;
  margin-right: 3px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 3px;
  border-radius: 6px;
  background: #fff;
  font: 700 12px system-ui;
  text-align: center;
  color: var(--ink);
}
@media (hover: none) {
  .keys {
    display: none;
  }
}
.pref-note {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
}
.install-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
#toast {
  position: fixed;
  left: 50%;
  bottom: 74px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 11px 18px;
  border-radius: 14px;
  box-shadow: 0 10px 30px #1d2b3844;
  z-index: 40;
  max-width: 90%;
  font-size: 14px;
  display: none;
}

/* Pàgines de contingut */
.page {
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding-bottom: 20px;
}

/* Rànquing */
.rank-main {
  display: grid;
  gap: 10px;
  align-content: start;
  min-width: 0;
}
.level-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.level-tabs:empty {
  display: none;
}
.level-tabs button {
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 700;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  box-shadow: none;
}
.level-tabs button::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--l);
}
.level-tabs button.on {
  background: var(--l);
  border-color: var(--l);
  color: #fff;
}
.level-tabs button.on::before {
  background: #fff;
}
.rank-page {
  max-width: 1100px;
}
.rank-top {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.rank-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, #ffb347, #ff8a3d);
  color: #fff;
  box-shadow: 0 6px 14px #ff8a3d44;
}
.rank-icon .icon {
  width: 24px;
  height: 24px;
}
.rank-title {
  flex: 1;
  min-width: 0;
}
.rank-title h1 {
  font-size: 26px;
  margin: 0;
}
.rank-title p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.rank-chips {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
.rank-chips span {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--muted);
}
.rank-chips b {
  color: var(--ink);
  font-size: 15px;
}
.rank-layout {
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 16px;
  align-items: start;
}
.rank-side {
  display: grid;
  gap: 14px;
}
.me-card {
  padding: 16px;
  font-size: 14px;
}
.me-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.me-head .avatar {
  width: 48px;
  height: 48px;
  font-size: 20px;
}
.me-head small {
  display: block;
  font-size: 12px;
  color: var(--muted);
}
.me-head strong {
  font-size: 18px;
  overflow-wrap: anywhere;
}
.me-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 12px 0 6px;
}
.me-stats div {
  background: #fff7ec;
  border-radius: 12px;
  padding: 7px 4px;
  text-align: center;
}
.me-stats b {
  display: block;
  font-size: 19px;
  color: #c2410c;
}
.me-stats small {
  font-size: 11px;
  color: var(--muted);
}
.me-actions {
  display: flex;
  justify-content: space-between;
}
.how-card {
  padding: 16px;
}
.how-card h3 {
  font-size: 15px;
}
.how-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
}
.how-card b {
  display: inline-block;
  min-width: 46px;
  color: var(--green-dark);
  font-size: 14px;
}
.avatar {
  --a: #1f9d6b;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--a);
  color: #fff;
  font-weight: 900;
  font-size: 16px;
  border: 3px solid #fff;
  box-shadow: 0 3px 8px #1d2b3826;
}
.rank-table {
  overflow: hidden;
  padding: 6px;
}
.rank-table ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}
.rank-head,
.ranking-row {
  display: grid;
  grid-template-columns: 44px 40px minmax(0, 1fr) 70px 86px 82px;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
}
.rank-head {
  padding: 8px 14px 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}
.rank-head span:first-child,
.rank-head span:nth-child(n + 3) {
  text-align: center;
}
.rank-head span:nth-child(2) {
  grid-column: span 2;
}
.rank-head span:last-child {
  text-align: right;
}
.ranking-row {
  width: 100%;
  padding-block: 8px;
  border: 0;
  border-radius: 14px;
  box-shadow: none;
  background: transparent;
  text-align: left;
  font-size: 15px;
  font-weight: 400;
  transition:
    background 0.15s,
    transform 0.15s;
}
.rank-table li:nth-child(even) .ranking-row {
  background: #f6fafd;
}
.rank-table li .ranking-row:hover {
  background: #e8f4fc;
}
.ranking-row:active {
  transform: scale(0.995);
}
.rank-table li .ranking-row.top {
  background: linear-gradient(90deg, var(--tint) 0%, #ffffff00 70%);
}
.ranking-row.t1 {
  --tint: #fff1c7;
  --medal: linear-gradient(135deg, #ffd34d, #e09b0b);
}
.ranking-row.t2 {
  --tint: #eaf0f5;
  --medal: linear-gradient(135deg, #c9d6e0, #8299ab);
}
.ranking-row.t3 {
  --tint: #fbe7da;
  --medal: linear-gradient(135deg, #f0b48a, #c7743f);
}
.rank-table li .ranking-row.me {
  background: #fff3e6;
  box-shadow: inset 4px 0 0 var(--orange);
}
.ranking-row .pos {
  justify-self: center;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-weight: 900;
  font-size: 15px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.ranking-row.top .pos {
  background: var(--medal);
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 3px 8px #1d2b3826;
  text-shadow: 0 1px 1px #0003;
}
.ranking-row .who {
  min-width: 0;
}
.ranking-row .who strong {
  display: block;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ranking-row .who .bar {
  margin-top: 6px;
  height: 6px;
}
.ranking-row .mini {
  display: none;
}
.ranking-row .num {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.ranking-row .perfect .icon,
.how-card .star .icon {
  width: 17px;
  height: 17px;
  color: var(--gold);
  fill: var(--gold);
}
.bar {
  height: 10px;
  border-radius: 9px;
  background: #e6eef4;
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  border-radius: 9px;
  background: linear-gradient(90deg, var(--green), #6fd3a3);
}
.ranking-row.t1 .bar i {
  background: linear-gradient(90deg, #f5b82e, #ffd34d);
}
.ranking-row .score {
  text-align: right;
  font-weight: 900;
  font-size: 20px;
  color: var(--green-dark);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.ranking-row .score small {
  display: none;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
/* Fitxa d'un jugador */
.player-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.player-head .avatar {
  width: 58px;
  height: 58px;
  font-size: 24px;
}
.player-head small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.player-head h2 {
  margin: 0;
  overflow-wrap: anywhere;
}
.player-stats {
  margin: 0 0 8px;
}
.player-sub {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 12px;
}
.player-card h3 {
  font-size: 15px;
  margin: 0 0 6px;
}
.game-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  max-height: min(46vh, 420px);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.game-row {
  display: grid;
  grid-template-columns: 74px 1fr 112px 64px 44px 36px;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 14px;
  border-bottom: 1px solid #edf2f6;
}
.game-row:last-child {
  border-bottom: 0;
}
.game-row:nth-child(even) {
  background: #f8fbfd;
}
.game-row .lvl {
  justify-self: start;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  background: var(--l);
}
.game-row .when {
  color: var(--muted);
}
.game-row .moves {
  display: flex;
  align-items: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}
.game-row .moves small {
  color: var(--muted);
}
.game-row .icon {
  width: 16px;
  height: 16px;
}
.game-row .moves .icon {
  color: var(--gold);
  fill: var(--gold);
}
.game-row .secs {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.game-row .pts {
  font-weight: 900;
  color: var(--green-dark);
  text-align: right;
}
.game-row .play-again {
  padding: 6px;
  justify-self: end;
}
.player-note {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.player-note .icon {
  width: 13px;
  height: 13px;
}

.empty {
  text-align: center;
  padding: 34px 20px;
}
.empty .icon {
  width: 44px;
  height: 44px;
  color: var(--gold);
}
.empty p {
  color: var(--muted);
}
.rank-rules {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}
.rank-rules div {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--muted);
}
.rank-rules b {
  display: block;
  color: var(--ink);
  font-size: 15px;
}

/* Benvinguda */
.welcome {
  text-align: center;
  padding: 6px 6px 0;
}
.welcome-logo {
  width: 96px;
  height: 96px;
  margin: -4px auto 10px;
  display: block;
  filter: drop-shadow(0 10px 18px #16915f55);
}
.welcome h2 {
  font-size: 34px;
  letter-spacing: -1px;
}
.welcome p {
  color: var(--muted);
  max-width: 420px;
  margin: 0 auto 6px;
}
.welcome .name-form input {
  text-align: center;
  font-size: 17px;
}
.welcome .name-form button {
  font-size: 16px;
}
.name-error {
  min-height: 1.4em;
  color: var(--red) !important;
  font-weight: 650;
  font-size: 14px;
}
.claim-box {
  margin: 10px 0 4px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff6e8;
  border: 1px solid #ffd29e;
  text-align: left;
}
.claim-box p {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--ink) !important;
  max-width: none !important;
}
.claim-box p.muted {
  color: var(--muted) !important;
}
.welcome .claim-actions {
  justify-content: center;
}
.claim-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* Sobre el joc */
.about-page {
  display: grid;
  gap: 12px;
}
.about-top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 4px 4px 0;
}
.about-top img {
  width: 52px;
  height: 52px;
  flex: none;
  filter: drop-shadow(0 6px 12px #16915f44);
}
.about-top .eyebrow {
  margin-bottom: 2px;
}
.about-top h1 {
  font-size: 26px;
  margin: 0;
}
.about-top p {
  margin: 2px 0 0;
  color: var(--muted);
}
.about-page h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  margin-bottom: 10px;
}
.about-page h3 .icon {
  color: var(--green-dark);
}
.about-rules {
  padding: 16px 18px;
}
.rule-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.rule-tiles div {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 2px;
  padding: 11px 8px 10px;
  border-radius: 16px;
  background: #f4f9fc;
}
.rule-tiles span {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--c);
  color: #fff;
  margin-bottom: 6px;
  box-shadow: 0 6px 12px #1d2b3820;
}
.rule-tiles .icon {
  width: 23px;
  height: 23px;
}
.rule-tiles b {
  font-size: 15px;
}
.rule-tiles small {
  font-size: 12.5px;
  color: var(--muted);
}
.about-trio {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.about-card {
  padding: 16px 18px;
}
.about-card > small {
  display: block;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
.score-pills {
  display: grid;
  gap: 7px;
}
.score-pills span {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #3c4c5a;
}
.score-pills b {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  height: 28px;
  border-radius: 9px;
  font-size: 15px;
  color: #fff;
}
.score-pills .plus b {
  background: var(--green);
}
.score-pills .minus b {
  background: var(--red);
}
.score-pills .gold b {
  background: var(--gold);
}
.score-pills .gold .icon {
  width: 17px;
  height: 17px;
  fill: #fff;
}
.skill-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.skill-chips span {
  padding: 6px 12px;
  border-radius: 99px;
  background: #eaf6f0;
  color: var(--green-dark);
  font-size: 13.5px;
  font-weight: 650;
}
.skill-chips span:nth-child(3n + 2) {
  background: #fff1e6;
  color: #c2410c;
}
.skill-chips span:nth-child(3n) {
  background: #eaf2fd;
  color: #2f6fb5;
}
.origin {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 0;
  font-size: 14px;
  color: #3c4c5a;
}
.origin > b {
  flex: none;
  padding: 6px 10px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
}
.about-facts {
  padding: 12px;
}
.facts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.facts div {
  border-radius: 14px;
  padding: 10px;
  text-align: center;
  background: #f1f8fd;
}
.facts strong {
  display: block;
  font-size: 24px;
  color: var(--green-dark);
}
.facts small {
  font-size: 12px;
  color: var(--muted);
}
.credits {
  margin: 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* Peu */
.felip-app-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 22px;
  background: #ffffffeb;
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.5;
}
.felip-app-footer img {
  width: 67px;
  display: block;
}
.felip-app-footer a {
  color: inherit;
  font-weight: 700;
  text-decoration: none;
}
.felip-app-footer a:hover {
  color: var(--green-dark);
}
.felip-app-footer p {
  margin: 0;
  line-height: 1.5;
}

/* Pantalles baixes (escalat del 125 % i 150 %) */
@media (max-height: 700px) and (min-width: 651px) {
  .shell {
    padding-top: 8px;
  }
  .topbar {
    margin-bottom: 8px;
  }
  .brand small {
    display: none;
  }
  .stage {
    gap: 7px;
  }
  .stage-head .eyebrow {
    display: none;
  }
  .stage-stats b {
    font-size: 18px;
  }
  .board-wrap {
    min-height: 200px;
  }
  .board-caption {
    padding: 6px 12px;
    font-size: 13px;
  }
  .tool-row button {
    padding: 6px 10px;
  }
}
@media (max-width: 1150px) and (min-width: 651px) {
  .stage-stats > div {
    min-width: 66px;
    padding: 5px 8px;
  }
  .top-actions button {
    font-size: 0;
    gap: 0;
  }
}

/* Mòbil */
@media (max-width: 650px) {
  body {
    padding-bottom: 48px;
  }
  .shell {
    padding: max(18px, env(safe-area-inset-top)) 16px 16px;
    min-height: calc(100vh - 48px);
    min-height: calc(100dvh - 48px);
  }
  /* Capçalera en dues files: marca i botons rodons; a sota, les pestanyes a tota l’amplada. */
  .topbar {
    flex-wrap: wrap;
    gap: 12px 8px;
    margin-bottom: 20px;
  }
  .brand {
    order: 1;
  }
  .top-actions {
    order: 2;
    margin-left: auto;
  }
  .tabs-top {
    order: 3;
    flex: 1 1 100%;
    min-width: 0;
    padding: 4px;
    border-radius: 16px;
    box-shadow: 0 4px 14px #1d4b6b12;
  }
  .tabs-top button {
    flex: 1 1 0;
    justify-content: center;
    white-space: nowrap;
  }
  /* Jugar: el tauler creix i reparteix l’alçada; els botons queden a baix. */
  .stage {
    gap: 16px;
    justify-content: space-between;
  }
  .stage-head {
    gap: 16px;
  }
  .stage-head .eyebrow {
    margin-bottom: 8px;
  }
  .goal-line {
    gap: 10px 12px;
  }
  .stage-stats > div {
    padding: 9px 8px;
  }
  .board-wrap {
    display: flex;
    flex-direction: column;
    max-height: calc(50vw + 230px);
  }
  .stage-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .tool-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }
  .tool-row button {
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 9px 4px;
    font-size: 12.5px;
    min-height: 58px;
  }
  .tool-row .icon {
    width: 19px;
    height: 19px;
  }
  .choice-row {
    justify-content: center;
    gap: 6px;
  }
  .choice-row button {
    font-size: 13px;
    padding: 8px 11px;
  }
  .brand img {
    width: 44px;
  }
  .brand strong {
    font-size: 23px;
  }
  .brand small {
    font-size: 9px;
    letter-spacing: 1.5px;
  }
  .tabs-top {
    margin-left: 0;
  }
  .tabs-top button {
    gap: 6px;
    font-size: 14px;
    padding: 9px 6px;
    border-radius: 12px;
  }
  .tabs-top .icon {
    width: 17px;
    height: 17px;
  }
  .top-actions button {
    font-size: 0;
    gap: 0;
    width: 42px;
    height: 42px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
  }
  .top-actions .icon {
    width: 21px;
    height: 21px;
  }
  .goal-line {
    font-size: 15px;
  }
  .mini-wagon {
    width: 44px;
    height: 32px;
  }
  .target-train {
    padding: 0 4px;
  }
  .stage-stats {
    width: 100%;
  }
  .stage-stats > div {
    flex: 1;
    min-width: 0;
  }
  .board-wrap {
    flex: 1;
    min-height: 0;
  }
  .board-wrap .board {
    position: static;
    width: 100%;
    height: auto;
    flex: none;
    margin: auto 0;
  }
  .board-caption {
    position: static;
    font-size: 13px;
  }
  .tool-row {
    margin-left: 0;
  }
  .rank-layout {
    grid-template-columns: 1fr;
  }
  .rank-top {
    gap: 10px;
  }
  .rank-icon {
    width: 40px;
    height: 40px;
  }
  .rank-chips {
    margin-left: 0;
    flex-basis: 100%;
  }
  .result-tiles {
    grid-template-columns: 1fr 1fr;
  }
  .result-art {
    padding-top: 44px;
  }
  .choice-label {
    flex-basis: 100%;
    text-align: center;
  }
  .choice-row .chip {
    padding: 5px 10px;
  }
  .choice-row .amb {
    display: none;
  }
  .level-tabs {
    flex-wrap: nowrap;
    gap: 5px;
  }
  .level-tabs button {
    flex: 1 1 auto;
    padding: 6px 8px;
    font-size: 12.5px;
  }
  .level-tabs button::before {
    margin-right: 4px;
  }
  .install-btn {
    display: none;
  }
  .top-actions:has(.install-btn) [data-action="settings"] {
    position: relative;
  }
  .top-actions:has(.install-btn) [data-action="settings"]::after {
    content: "";
    position: absolute;
    top: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--orange);
    border: 2px solid #fff;
  }
  .difficulty-grid,
  .facts,
  .rank-rules {
    grid-template-columns: 1fr 1fr;
  }
  .guide-tools {
    grid-template-columns: 1fr 1fr;
    row-gap: 16px;
  }
  .rule-tiles {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .rule-tiles div {
    grid-template-columns: auto 1fr;
    justify-items: start;
    text-align: left;
    column-gap: 12px;
    row-gap: 0;
    padding: 9px 12px;
  }
  .rule-tiles span {
    grid-row: span 2;
    width: 40px;
    height: 40px;
    margin: 0;
  }
  .about-trio {
    grid-template-columns: 1fr;
  }
  .about-top img {
    width: 46px;
    height: 46px;
  }
  .about-top h1 {
    font-size: 21px;
  }
  .guide h2 {
    font-size: 21px;
  }
  .guide p {
    font-size: 15px;
  }
  .guide-actions button {
    min-width: 0;
    flex: 1;
  }
  .rank-table {
    padding: 4px;
  }
  .rank-head {
    display: none;
  }
  .ranking-row {
    grid-template-columns: 30px 34px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 10px;
  }
  .ranking-row .pos {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }
  .ranking-row .num {
    display: none;
  }
  .ranking-row .mini {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
  }
  .ranking-row .who .bar {
    margin-top: 5px;
  }
  .ranking-row .score {
    font-size: 18px;
  }
  .ranking-row .score small {
    display: block;
  }
  .game-row {
    grid-template-columns: auto 1fr auto 36px;
    grid-template-areas:
      "lvl when pts go"
      "moves moves secs go";
    row-gap: 4px;
    padding: 9px 10px;
  }
  .game-row .lvl {
    grid-area: lvl;
  }
  .game-row .when {
    grid-area: when;
    font-size: 13px;
  }
  .game-row .moves {
    grid-area: moves;
  }
  .game-row .secs {
    grid-area: secs;
  }
  .game-row .pts {
    grid-area: pts;
  }
  .game-row .play-again {
    grid-area: go;
  }
  .avatar {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
  .welcome .name-form {
    flex-direction: column;
    align-items: center;
    gap: 16px;
  }
  .welcome .name-form input {
    width: 100%;
  }
  .felip-app-footer {
    padding: 7px 12px;
    font-size: 9px;
  }
  .felip-app-footer img {
    width: 55px;
  }
}
/* Mòbils molt estrets: pestanyes sense icona perquè el text hi càpiga. */
@media (max-width: 359px) {
  .tabs-top .icon {
    display: none;
  }
}
/* Botó i finestra de menú (el botó només es veu al mòbil horitzontal). */
.menu-btn {
  display: none;
}
.menu-sheet h2 {
  margin: 0 0 14px;
  font-size: 20px;
}
.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 10px;
}
.menu-grid button {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 14px 6px;
  border-radius: 16px;
  font-size: 13.5px;
  background: #f4f9fc;
  border-color: transparent;
}
.menu-grid button.on {
  background: var(--green);
  color: #fff;
  box-shadow: 0 3px 0 var(--green-dark);
}
.menu-grid .icon {
  width: 24px;
  height: 24px;
}
/* Avís de girar el mòbil (només al mòbil vertical). */
.rotate-tip {
  display: none;
}
@media (orientation: portrait) and (max-width: 650px) and (pointer: coarse) {
  .rotate-tip {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 99px;
    border: 0;
    background: #ffffffd9;
    color: var(--green-dark);
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 2px 8px #1d3a2222;
  }
  .rotate-tip .icon {
    width: 16px;
    height: 16px;
  }
}
/* Mòbil horitzontal: el tauler ocupa tota la pantalla i els controls van als racons buits. */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  body:has(.stage) {
    overflow: hidden;
  }
  body:has(.stage) .felip-app-footer,
  .shell:has(.stage) .topbar,
  .stage .goal,
  .board-caption {
    display: none;
  }
  .shell:has(.stage) {
    padding: 0;
    min-height: 0;
  }
  .board-wrap {
    position: fixed;
    inset: 0;
    z-index: 1;
    min-height: 0;
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .board-wrap.complete {
    box-shadow: inset 0 0 0 4px var(--gold);
  }
  .board-wrap .board {
    position: absolute;
    inset: max(4px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 4px max(8px, env(safe-area-inset-left));
    width: auto;
    height: auto;
  }
  .board-caption.warning {
    display: block;
    position: fixed;
    z-index: 3;
    left: 50%;
    right: auto;
    bottom: 8px;
    transform: translateX(-50%);
    border-radius: 12px;
    font-size: 12px;
  }
  .stage-head {
    position: fixed;
    z-index: 3;
    top: 8px;
    left: max(8px, env(safe-area-inset-left));
    flex-wrap: nowrap;
    gap: 6px;
  }
  .menu-btn {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border-radius: 12px;
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
    box-shadow: 0 2px 6px #1d3a2230;
  }
  .menu-btn .icon {
    width: 22px;
    height: 22px;
  }
  .stage-stats {
    gap: 5px;
  }
  .stage-stats > div {
    min-width: 0;
    padding: 3px 9px;
    border-radius: 10px;
    background: #ffffffd9;
    box-shadow: 0 2px 6px #1d3a2218;
  }
  .stage-stats b {
    font-size: 15px;
  }
  .stage-stats small {
    font-size: 9.5px;
  }
  .stage-controls {
    position: fixed;
    z-index: 3;
    left: max(8px, env(safe-area-inset-left));
    bottom: 8px;
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 6px;
    max-width: 44vw;
  }
  .tool-row {
    margin: 0;
    gap: 6px;
  }
  .tool-row button {
    font-size: 0;
    gap: 0;
    padding: 9px;
    border-radius: 12px;
    background: #ffffffe6;
  }
  .tool-row button.primary {
    background: var(--green);
  }
  .tool-row .icon {
    width: 19px;
    height: 19px;
  }
  .choice-row {
    gap: 5px;
  }
  .choice-label {
    flex-basis: 100%;
    font-size: 11.5px;
  }
  .choice-row .chip {
    padding: 4px 9px;
    font-size: 12px;
    background: #fffffff0;
  }
  .choice-row .amb {
    display: none;
  }
  .choice-row > button:not(.chip) {
    font-size: 12.5px;
    padding: 6px 11px;
  }
  dialog {
    padding: 18px 22px;
  }
  .result-art {
    padding: 34px 10px 6px;
  }
  .result-train {
    width: auto;
    max-width: 100%;
    height: 54px;
    margin: 0 auto;
  }
  .result-stars .icon {
    width: 26px;
    height: 26px;
  }
  .result-stars span:nth-child(2) .icon {
    width: 32px;
    height: 32px;
  }
  .result-art {
    margin-bottom: 8px;
  }
  .result .eyebrow,
  .result-msg,
  .result .your-solution {
    display: none;
  }
  .result h2 {
    font-size: 20px;
    margin-bottom: 8px;
  }
  .result-tiles div {
    padding: 4px;
  }
  .result-tiles b {
    font-size: 17px;
  }
  .result .rank-note {
    padding: 7px 12px;
    font-size: 13px;
  }
  .result .dialog-actions {
    margin-top: 10px;
  }
}
.reduced *:not(.switch) {
  animation: none !important;
  transition: none !important;
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
