/* OM TOUK. Colours come from the festival: night river, palace gold, boat lacquer, krama cloth. */

@font-face {
  font-family: 'Touk Pixel';
  src: url('../fonts/toukpixel.woff2') format('woff2');
  font-display: block;
}
/* The race word in English. Touk Pixel's thin strokes and look-alike M, N and H were hard to read
   at speed; Jersey 15 is still a pixel face, with thick strokes and distinct letters. */
@font-face {
  font-family: 'Jersey 15';
  src: url('../fonts/jersey15-latin-400.woff2') format('woff2');
  font-display: block;
}
/* Khmer letters read small next to pixel capitals, so they are drawn a little larger. */
@font-face {
  font-family: 'Nokora';
  font-weight: 400;
  src: url('../fonts/nokora-khmer-400.woff2') format('woff2');
  unicode-range: U+1780-17FF, U+19E0-19FF, U+200C-200D, U+25CC;
  size-adjust: 118%;
  font-display: swap;
}
@font-face {
  font-family: 'Nokora';
  font-weight: 700;
  src: url('../fonts/nokora-khmer-700.woff2') format('woff2');
  unicode-range: U+1780-17FF, U+19E0-19FF, U+200C-200D, U+25CC;
  size-adjust: 118%;
  font-display: swap;
}
@font-face {
  font-family: 'Riel Sign';
  src: url('../fonts/nokora-khmer-700.woff2') format('woff2');
  unicode-range: U+17DB;
  size-adjust: 150%;
  font-display: swap;
}
@font-face {
  font-family: 'Moul';
  src: url('../fonts/moul-khmer-400.woff2') format('woff2');
  unicode-range: U+1780-17FF, U+19E0-19FF, U+200C-200D, U+25CC;
  font-display: swap;
}

:root {
  --ink: #14122a;
  --indigo: #1c1b3a;
  --indigo-2: #2a2858;
  --indigo-3: #45417f;
  --cream: #f6ecd0;
  --dim: #b5aecb;
  --gold: #f2c14a;
  --red: #c8322b;
  --red-dark: #8f1f22;
  --teal: #1b7a8c;
  --jade: #58c98a;
  --pink: #f08fa8;
  --px: 2px; /* one "pixel" of the interface */
  --stage-w: 100vw;
  --font: 'Touk Pixel', 'Riel Sign', 'Nokora', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  /* a faint krama check fills the sides on wide screens */
  background: var(--ink) var(--krama-dim, none) 0 0 / 16px auto;
  image-rendering: pixelated;
  color: var(--cream);
  overscroll-behavior: none;
}

body {
  font: 16px/1.5 var(--font);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}

button,
input {
  font: inherit;
  color: inherit;
}

canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

[hidden] {
  display: none !important;
}

#app {
  height: var(--vvh, 100dvh);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

/* ---------- the river ---------- */

#stage {
  position: relative;
  flex: none;
  width: var(--stage-w);
  aspect-ratio: 16 / 9;
  container-type: inline-size;
  background: #2a2358;
  overflow: hidden;
}

/* --g is one pixel of the 320 x 180 scene, so overlays scale with it */
#stage > * {
  --g: 0.3125cqw;
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
}

/* Phone, portrait, game's own keys: a tall river. The 16:9 picture is anchored left and cropped on the right. */
#app.phone-race #stage {
  height: var(--stage-h);
  aspect-ratio: auto;
}

#app.phone-race #scene {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--scene-w);
  height: var(--stage-h);
  max-width: none;
}

/* Sponsor line and cheers, along the bottom of the river. `left` moves the text.
   A quiet veil, not a banner: the river still shows through. 16px is 2× the pixel
   font, the next crisp step up from the old 10px, and the band is just tall enough
   for Khmer vowels. */
#ticker {
  position: absolute;
  z-index: 1;
  left: 0;
  right: 0;
  bottom: 0;
  height: 32px;
  overflow: hidden;
  background: rgba(20, 18, 42, 0.72);
  pointer-events: none;
}

#ticker .ticker-line {
  position: absolute;
  top: 0;
  left: 100%;
  height: 32px;
  display: flex;
  align-items: center;
  white-space: nowrap;
  color: #f3ead4;
  font-size: 16px;
  line-height: 32px;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  text-shadow:
    -1px 0 0 #14122a,
    1px 0 0 #14122a,
    0 -1px 0 #14122a,
    0 1px 0 #14122a;
}

html[lang='km'] #ticker .ticker-line {
  line-height: 32px;
}

#bar,
#logo,
#hud,
#banner,
#rivalTag {
  z-index: 2;
}

#app.phone-race #ticker {
  left: 0;
  right: 0;
  bottom: 0;
}

#krama {
  flex: none;
  width: var(--stage-w);
  height: calc(var(--px) * 4);
  background: var(--red) var(--krama, none) 0 0 / calc(var(--px) * 8) auto;
  image-rendering: pixelated;
}

#bar {
  position: absolute;
  inset: calc(var(--g) * 3) calc(var(--g) * 3) auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
  font-size: max(12px, calc(var(--g) * 6));
  line-height: 1.35;
  pointer-events: none;
}

#bar > *,
.bar-right > * {
  pointer-events: auto;
}

.bar-right {
  display: flex;
  align-items: center;
  gap: max(4px, calc(var(--g) * 2));
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  min-height: max(28px, calc(var(--g) * 12));
  padding: 0 0.6em;
  border: 0;
  background: rgba(20, 18, 42, 0.86);
  color: var(--cream);
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--ink),
    0 var(--px) 0 0 var(--ink),
    calc(var(--px) * -1) 0 0 0 var(--ink),
    var(--px) 0 0 0 var(--ink);
  white-space: nowrap;
}

button.chip {
  cursor: pointer;
}

button.chip:hover {
  background: var(--indigo-2);
}

.chip canvas {
  width: max(20px, calc(var(--g) * 9));
  height: max(20px, calc(var(--g) * 9));
  margin-left: -0.3em;
}

.chip.riel {
  color: var(--gold);
}

/* Menu pictures. 32 source pixels; --px * 16 is 32 CSS px, and #panel zoom grows the big ones. */
canvas.ico {
  width: calc(var(--px) * 16);
  height: calc(var(--px) * 16);
  image-rendering: pixelated;
  flex: none;
}

.btn:not(.big) canvas.ico,
.chip.riel canvas.ico {
  width: calc(var(--px) * 8);
  height: calc(var(--px) * 8);
}

.chip.riel canvas.ico {
  margin-left: 0;
}

.chip.icon {
  min-width: max(28px, calc(var(--g) * 12));
  justify-content: center;
  padding: 0 0.4em;
}

.chip.icon.off {
  color: var(--dim);
  text-decoration: line-through;
}

#logo {
  position: absolute;
  inset: 12% 0 auto;
  display: none;
  text-align: center;
  pointer-events: none;
}

#app[data-screen='title'] #logo {
  display: block;
}

.logo-km {
  font: calc(var(--g) * 30) / 1.3 'Moul', var(--font);
  color: var(--gold);
  text-shadow:
    calc(var(--g) * -1) 0 0 var(--ink),
    calc(var(--g) * 1) 0 0 var(--ink),
    0 calc(var(--g) * -1) 0 var(--ink),
    0 calc(var(--g) * 1) 0 var(--ink),
    calc(var(--g) * 2) calc(var(--g) * 2) 0 var(--red-dark);
}

.logo-en {
  margin-top: calc(var(--g) * 1);
  font-size: calc(var(--g) * 16);
  line-height: 1.1;
  letter-spacing: calc(var(--g) * 1);
  color: var(--cream);
  text-shadow:
    calc(var(--g) * -1) 0 0 var(--ink),
    calc(var(--g) * 1) 0 0 var(--ink),
    0 calc(var(--g) * -1) 0 var(--ink),
    0 calc(var(--g) * 1) 0 var(--ink),
    calc(var(--g) * 2) calc(var(--g) * 2) 0 var(--ink);
}

.logo-tag {
  display: inline-block;
  margin-top: calc(var(--g) * 4);
  padding: 0.1em 0.7em;
  background: rgba(20, 18, 42, 0.78);
  font-size: max(12px, calc(var(--g) * 6));
}

/* on a phone-size river the title sits lower and smaller, clear of the top bar */
@container (max-width: 520px) {
  #logo {
    inset: 15% 0 auto;
  }
  .logo-km {
    font-size: calc(var(--g) * 25);
  }
  .logo-en {
    font-size: calc(var(--g) * 14);
  }
  .logo-tag {
    margin-top: calc(var(--g) * 2);
  }
}

/* ---------- race overlays ---------- */

#hud {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
  font-size: max(12px, calc(var(--g) * 6));
}

#app[data-screen='race'] #hud {
  display: block;
}

#app[data-screen='race'] #bar,
#app[data-screen='results'] #bar,
#app[data-screen='vs'] #bar {
  display: none;
}

.hud-top {
  position: absolute;
  inset: calc(var(--g) * 3) calc(var(--g) * 3) auto;
  display: flex;
  align-items: center;
  gap: calc(var(--g) * 4);
}

.hud-stat {
  display: flex;
  align-items: baseline;
  gap: 0.35em;
  min-width: 5.2em;
  padding: 0.1em 0.5em;
  background: rgba(20, 18, 42, 0.86);
  white-space: nowrap;
}

.hud-stat.right {
  justify-content: flex-end;
}

.hud-stat b {
  font-weight: 400;
  font-size: 1.5em;
  line-height: 1.2;
  color: var(--gold);
}

.hud-stat.ahead b {
  color: var(--jade);
}

.hud-stat.behind b {
  color: #ff8a7a;
}

.hud-stat span {
  color: var(--dim);
}

.track {
  position: relative;
  flex: 1;
  height: max(18px, calc(var(--g) * 9));
}

.track-line {
  position: absolute;
  inset: 50% 0 auto;
  height: max(4px, calc(var(--g) * 2));
  transform: translateY(-50%);
  background: rgba(20, 18, 42, 0.86);
  box-shadow: inset 0 0 0 max(1px, calc(var(--g) * 0.5)) var(--cream);
}

.track-flag {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: max(6px, calc(var(--g) * 3));
  background:
    repeating-conic-gradient(var(--ink) 0 25%, #fff 0 50%) 0 0 / max(6px, calc(var(--g) * 3)) max(6px, calc(var(--g) * 3));
}

.track-mark {
  position: absolute;
  top: 50%;
  left: 0;
  width: max(14px, calc(var(--g) * 7));
  height: max(14px, calc(var(--g) * 7));
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 max(1px, calc(var(--g) * 0.5)) var(--ink);
  opacity: 0.8;
}

.track-mark.you {
  opacity: 1;
  box-shadow: 0 0 0 max(1px, calc(var(--g) * 0.5)) var(--gold);
  z-index: 1;
}

#rivalTag {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.05em 0.5em 0.05em 0.2em;
  transform: translate(-50%, -100%);
  background: rgba(20, 18, 42, 0.8);
  box-shadow: 0 0 0 max(1px, calc(var(--g) * 0.5)) #bfe9ff;
  color: #dff4ff;
  font-size: max(10px, calc(var(--g) * 5));
  line-height: 1.5;
  white-space: nowrap;
  pointer-events: none;
}

/* On a phone the river is only about 210px tall: a 32px ticker covered the boat's hull, in the
   menus and in the shop's preview. A slimmer strip leaves the boat clear. */
@media (max-width: 520px) {
  #ticker,
  #ticker .ticker-line {
    height: 20px;
  }

  #ticker .ticker-line,
  html[lang='km'] #ticker .ticker-line {
    font-size: 12px;
    line-height: 20px;
  }
}

/* organiser only: a quiet "Remove" under a board row's name */
.row-remove {
  display: block;
  margin-top: 2px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--red, #c94a3a);
  font: inherit;
  font-size: 11px;
  text-decoration: underline;
  cursor: pointer;
}

/* On a phone the lists need the height more than the river does: on the leaderboard, Ranked, the
   organiser's screens, titles, quests and How to play the river is a short strip (the top bar
   and the skyline stay), so about three more rows fit. The shop keeps the whole river: its boat
   is the preview. */
@media (max-width: 520px) {
  #app[data-screen='board'] #stage,
  #app[data-screen='ranked'] #stage,
  #app[data-screen='organiser'] #stage,
  #app[data-screen='titles'] #stage,
  #app[data-screen='quests'] #stage,
  #app[data-screen='help'] #stage,
  #app[data-screen='alerts'] #stage,
  #app[data-screen='festday'] #stage,
  #app[data-screen='awards'] #stage,
  #app[data-screen='facts'] #stage,
  #app[data-screen='statement'] #stage {
    aspect-ratio: auto;
    height: 84px;
  }

  #app[data-screen='board'] #scene,
  #app[data-screen='ranked'] #scene,
  #app[data-screen='organiser'] #scene,
  #app[data-screen='titles'] #scene,
  #app[data-screen='quests'] #scene,
  #app[data-screen='help'] #scene,
  #app[data-screen='alerts'] #scene,
  #app[data-screen='festday'] #scene,
  #app[data-screen='awards'] #scene,
  #app[data-screen='facts'] #scene,
  #app[data-screen='statement'] #scene {
    height: auto;
    aspect-ratio: 16 / 9;
  }
}

/* Fingers need more than 28px: the top bar's buttons are 40px tall on a touch screen. */
@media (pointer: coarse) {
  #bar .chip {
    min-height: 40px;
  }
}

/* the share card before it is saved (a computer has no share sheet) */
.share-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.share-card {
  width: min(100%, 240px);
  height: auto;
  image-rendering: auto;
}

/* Beside the river the panel is narrow: four results buttons keep one row. */
#app.side .row.foot .btn {
  padding-left: 12px;
  padding-right: 12px;
}

/* a rival in the lower lane (Festival Cup) wears its tag under the hull */
#rivalTag[data-below] {
  transform: translate(-50%, 0);
}

/* the rival has left the picture: the tag waits at that edge and points the way */
#rivalTag[data-away='behind']::before {
  content: '\25C0';
  color: var(--gold);
}

#rivalTag[data-away='ahead']::after {
  content: '\25B6';
  color: var(--gold);
}

#youTag {
  position: absolute;
  z-index: 2;
  padding: 0.05em 0.5em;
  transform: translate(0, -50%);
  background: rgba(20, 18, 42, 0.8);
  box-shadow: 0 0 0 max(1px, calc(var(--g) * 0.5)) var(--gold);
  color: var(--gold);
  font-size: max(10px, calc(var(--g) * 5));
  line-height: 1.5;
  white-space: nowrap;
  pointer-events: none;
}

#youTag[hidden] {
  display: none;
}

#rivalTag canvas {
  width: 1.4em;
  height: 1.4em;
}

#rivalTag b {
  font-weight: 400;
  color: var(--gold);
}

#banner {
  position: absolute;
  inset: 26% 0 auto;
  text-align: center;
  font-size: calc(var(--g) * 26);
  line-height: 1.2;
  color: var(--gold);
  text-shadow:
    calc(var(--g) * -1) 0 0 var(--ink),
    calc(var(--g) * 1) 0 0 var(--ink),
    0 calc(var(--g) * -1) 0 var(--ink),
    0 calc(var(--g) * 1) 0 var(--ink),
    calc(var(--g) * 2) calc(var(--g) * 2) 0 var(--red-dark);
  pointer-events: none;
}

#banner.small {
  font-size: calc(var(--g) * 16);
}

#banner.lose {
  color: var(--dim);
}

html[lang='km'] #banner {
  font-family: 'Moul', var(--font);
  font-size: calc(var(--g) * 22);
}

html[lang='km'] #banner.small {
  font-size: calc(var(--g) * 14);
}

/* No transforms on text: scaled glyphs pick up stray lines on some GPUs. */
#banner.pop {
  animation: pop 0.3s steps(3, end);
}

@keyframes pop {
  from {
    color: #ffffff;
    letter-spacing: 0.35em;
  }
  to {
    letter-spacing: 0;
  }
}

/* ---------- the deck under the river ---------- */

#deck {
  flex: 1;
  min-height: 0;
  width: min(100vw, max(var(--stage-w), calc(420px * var(--ui-zoom, 1))));
  overflow-y: auto;
  background: var(--indigo);
  scrollbar-color: var(--indigo-3) var(--indigo);
}

/* A wide computer screen, on the menus: the river on the left, the panel on the right.
   layout() in ui.js decides when, and sets --stage-w, --side-w, and the padding. The pair
   is centred, and the panel is only as tall as its menu (it scrolls if the window is short),
   so nothing sits on the viewport edge. */
#app.side {
  box-sizing: border-box;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: var(--side-gap, 28px);
  padding:
    max(var(--side-pad-y, 36px), env(safe-area-inset-top, 0px))
    max(var(--side-pad-x, 40px), env(safe-area-inset-right, 0px))
    max(var(--side-pad-y, 36px), env(safe-area-inset-bottom, 0px))
    max(var(--side-pad-x, 40px), env(safe-area-inset-left, 0px));
}

#app.side #krama {
  display: none;
}

#app.side #deck {
  flex: 0 0 auto;
  width: var(--side-w);
  height: auto;
  min-height: 0;
  max-height: calc(var(--vvh, 100dvh) - 2 * var(--side-pad-y, 36px));
  align-self: center;
}

#app.side #panel {
  min-height: 0;
}

#panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* on a large window everything in the deck is drawn bigger (see layout() in ui.js) */
  zoom: var(--ui-zoom, 1);
  min-height: calc(100% / var(--ui-zoom, 1));
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
}

h1,
h2,
p {
  margin: 0;
}

h2 {
  font-size: 24px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--gold);
}

html[lang='km'] h2 {
  font-size: 20px;
  line-height: 1.6;
}

.note {
  color: var(--dim);
  line-height: 1.6;
}

.warn {
  color: #ffb4a6;
}

.note.good-news {
  color: var(--gold);
}

.quest-now {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quest-now .note {
  font-size: 13px;
  line-height: 1.35;
}

html[lang='km'] .quest-now .note {
  font-size: 15px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.row.end {
  justify-content: flex-end;
}

.row.spread {
  justify-content: space-between;
}

.grow {
  flex: 1;
}

/* room to scroll the last lines out from behind a sticky Back / buy bar */
.grow:has(+ .foot),
.grow:has(+ .buybar) {
  padding-bottom: calc(8rem + env(safe-area-inset-bottom));
}

/* buttons look like painted planks: flat colour, hard edge, a darker lip below */
.btn {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 6px 16px calc(6px + var(--px) * 2);
  border: 0;
  background: var(--indigo-2);
  color: var(--cream);
  box-shadow:
    inset 0 calc(var(--px) * -2) 0 0 var(--indigo-3),
    0 calc(var(--px) * -1) 0 0 var(--ink),
    0 var(--px) 0 0 var(--ink),
    calc(var(--px) * -1) 0 0 0 var(--ink),
    var(--px) 0 0 0 var(--ink);
  line-height: 1.4;
  text-align: center;
  cursor: pointer;
}

.btn:hover {
  background: #343170;
}

.btn:active {
  transform: translateY(var(--px));
  box-shadow:
    inset 0 calc(var(--px) * -1) 0 0 var(--indigo-3),
    0 calc(var(--px) * -1) 0 0 var(--ink),
    0 var(--px) 0 0 var(--ink),
    calc(var(--px) * -1) 0 0 0 var(--ink),
    var(--px) 0 0 0 var(--ink);
}

.btn.primary {
  background: var(--red);
  box-shadow:
    inset 0 calc(var(--px) * -2) 0 0 var(--red-dark),
    inset 0 var(--px) 0 0 #e86a4f,
    0 calc(var(--px) * -1) 0 0 var(--ink),
    0 var(--px) 0 0 var(--ink),
    calc(var(--px) * -1) 0 0 0 var(--ink),
    var(--px) 0 0 0 var(--ink);
}

.btn.primary:hover {
  background: #d9443a;
}

.btn.big {
  min-height: 64px;
  font-size: 24px;
}

.btn.small {
  min-height: 36px;
  padding: 4px 12px calc(4px + var(--px) * 2);
  font-size: 13px;
}

.btn.ping {
  box-shadow:
    inset 0 calc(var(--px) * -2) 0 0 var(--indigo-3),
    0 calc(var(--px) * -1) 0 0 var(--gold),
    0 var(--px) 0 0 var(--gold),
    calc(var(--px) * -1) 0 0 0 var(--gold),
    var(--px) 0 0 0 var(--gold);
  animation: ping 1.2s ease-in-out infinite;
}

@keyframes ping {
  50% {
    box-shadow:
      inset 0 calc(var(--px) * -2) 0 0 var(--indigo-3),
      0 calc(var(--px) * -1) 0 0 #fff3c4,
      0 var(--px) 0 0 #fff3c4,
      calc(var(--px) * -1) 0 0 0 #fff3c4,
      var(--px) 0 0 0 #fff3c4;
  }
}

html[lang='km'] .btn.small {
  font-size: 16px;
}

/* Icon, then the label (and its sub-label) as one block, centered. */
.btn.has-ico {
  flex-direction: row;
  gap: calc(var(--px) * 4);
  min-width: 0;
  max-width: 100%;
}

.btn.has-ico .btn-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  max-width: 100%;
}

.btn.has-ico .btn-copy > span,
.btn.has-ico .btn-copy > small {
  max-width: 100%;
}

html[lang='km'] .btn.big {
  font-size: 20px;
}

.btn small {
  font-size: 12px;
  color: #ffd9c9;
  opacity: 0.95;
}

.btn:not(.primary) small {
  color: var(--dim);
}

.btn[disabled] {
  background: var(--indigo);
  color: #7d77a3;
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--indigo-3),
    0 var(--px) 0 0 var(--indigo-3),
    calc(var(--px) * -1) 0 0 0 var(--indigo-3),
    var(--px) 0 0 0 var(--indigo-3);
  cursor: default;
  transform: none;
}

:focus-visible {
  outline: var(--px) solid var(--cream);
  outline-offset: calc(var(--px) * 2);
}

.menu {
  display: grid;
  gap: 12px;
}

/* Board and Shop, side by side under the two ways to play. */
.menu .duo {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.settings {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  align-items: center;
  margin-top: 2px;
}

.setting {
  display: flex;
  align-items: center;
  gap: 8px;
}

.setting > span {
  color: var(--dim);
}

.setting-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1 1 14em;
}

/* Settings sits at the right of the word-pack row, and under it when the row is too narrow. */
.settings > .btn.to-settings {
  margin-left: auto;
}

/* The note under a setting wraps inside the panel; it must never make the menu wider than the screen. */
.settings > * {
  max-width: 100%;
  min-width: 0;
}

.setting-col .note {
  margin: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.setting-col .note {
  font-size: 12px;
  line-height: 1.4;
}

html[lang='km'] .setting-col .note {
  font-size: 15px;
}

.home-link {
  align-self: flex-start;
  min-height: 36px;
  padding: 6px 2px;
  color: var(--gold);
  text-decoration: none;
}

.home-link:hover {
  color: var(--cream);
}

/* a two-way switch: the pressed half is filled */
.seg {
  display: inline-flex;
  max-width: 100%;
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--ink),
    0 var(--px) 0 0 var(--ink),
    calc(var(--px) * -1) 0 0 0 var(--ink),
    var(--px) 0 0 0 var(--ink);
}

.seg.wrap {
  flex-wrap: wrap;
}

.seg button {
  min-height: 36px;
  padding: 2px 12px;
  border: 0;
  background: var(--indigo-2);
  color: var(--dim);
  cursor: pointer;
}

.seg button[aria-pressed='true'] {
  background: var(--gold);
  color: var(--ink);
}

.seg.small button {
  min-height: max(28px, calc(var(--g, 2px) * 12));
  padding: 0 0.6em;
}

/* ---------- typing deck ---------- */

.type {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  min-height: 0;
  text-align: center;
}

.type-hint {
  min-height: 24px;
  color: var(--gold);
}

.type-word {
  display: flex;
  justify-content: center;
  font-size: clamp(32px, 9vw, 56px);
  line-height: 1.25;
  white-space: nowrap;
}

/* Jersey 15 is narrow and draws small for its size, so it is set larger in the same space. */
.type-word:not(.km) {
  font-family: 'Jersey 15', var(--font);
  font-size: clamp(42px, 14vw, 72px);
  line-height: 1;
  letter-spacing: 0.03em;
}

.type-word.km {
  font-family: 'Nokora', var(--font);
  font-weight: 700;
  font-size: clamp(34px, 10vw, 60px);
  line-height: 1.75;
}

.type-word .ch {
  position: relative;
  padding: 0 0.04em;
  color: var(--c-untyped, var(--cream));
}

.type-word .ch.done {
  color: var(--c-correct, var(--gold));
}

/* The blank where the space key belongs, open at the top like the mark on a key. */
.type-word .ch.space {
  display: inline-block;
  width: 0.5em;
  height: 0.3em;
  align-self: flex-end;
  margin: 0 0 0.16em 0.14em;
  padding: 0;
  box-sizing: border-box;
  border: solid currentColor;
  border-width: 0 max(3px, 0.06em) max(3px, 0.06em);
  opacity: 0.75;
}

.type-word .ch.now::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.05em;
  height: max(3px, 0.09em);
  background: var(--c-correct, var(--gold));
}

.type-word.bad {
  position: relative;
  animation: shake 0.18s steps(3, end);
}

.type-word.bad .ch.now {
  color: var(--c-wrong, #ff7a6a);
}

@keyframes shake {
  0% {
    left: -6px;
  }
  50% {
    left: 6px;
  }
  100% {
    left: 0;
  }
}

.type-next {
  min-height: 1.6em;
  color: var(--c-untyped, #cfc9e2);
  white-space: nowrap;
  overflow: hidden;
  max-width: 100%;
}

.type-next.km {
  font-size: 18px;
}

.type-next:not(.km) {
  font-family: 'Jersey 15', var(--font);
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0.03em;
}

.type-sentence {
  font-family: 'Jersey 15', var(--font);
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: 0.03em;
  min-height: 2.3em;
  text-align: center;
  white-space: normal;
  overflow: hidden;
  max-width: 100%;
  color: var(--c-untyped, #cfc9e2);
}

.type-sentence .done {
  opacity: 0.45;
}

.type-sentence .now {
  color: var(--c-correct, var(--gold));
}

/* Khmer needs its own face and more room between lines for the marks above and below. */
.type-sentence.km {
  font-family: 'Nokora', var(--font);
  font-size: 19px;
  line-height: 1.55;
  letter-spacing: 0;
  min-height: 3.1em;
}

@media (max-width: 520px) {
  .type-sentence {
    font-size: 18px;
  }

  .type-sentence.km {
    font-size: 16px;
  }
}

.type-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  min-height: 30px;
}

.pips {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.pips i {
  width: 12px;
  height: 12px;
  background: var(--indigo-3);
}

.pips i.on {
  background: var(--gold);
}

.pips-hint {
  color: var(--dim);
  font-size: 11px;
  line-height: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 8em;
}

html[lang='km'] .pips-hint {
  font-size: 13px;
}

.next-key {
  color: var(--dim);
}

/* ---------- the game's own keys (touch screens) ---------- */

.type.with-keys {
  gap: 2px;
}

/* its messages are about the phone's keyboard, which is not in use */
.type.with-keys .type-hint {
  display: none;
}

.keys {
  flex: none;
  width: calc(100% + 16px);
  max-width: 600px;
  margin: 0 -8px;
  align-self: center;
  touch-action: none;
}

.keys-layer {
  display: none;
  flex-direction: column;
  gap: 6px;
}

.keys[data-layer='0'] .keys-layer[data-layer='0'],
.keys[data-layer='1'] .keys-layer[data-layer='1'] {
  display: flex;
}

.keys-row {
  display: flex;
  justify-content: center;
  gap: 3px;
}

.key {
  flex: 0 0 calc((100% - 27px) / 10);
  min-width: 0;
  max-width: 56px;
  height: clamp(42px, 6.6vh, 56px);
  padding: 0 0 var(--px);
  border: 0;
  background: var(--indigo-2);
  color: var(--cream);
  box-shadow:
    inset 0 calc(var(--px) * -2) 0 0 var(--indigo-3),
    0 0 0 var(--px) var(--ink);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  touch-action: none;
}

.keys.cols-11 .key {
  flex-basis: calc((100% - 30px) / 11);
}

/* twelve to a row, as on a phone's Khmer keyboard: four rows, so each is a little lower */
.keys.cols-12 .key,
.keys.cols-12 .key-gap {
  flex: 0 0 calc((100% - 33px) / 12);
  height: clamp(38px, 5.4vh, 50px);
}

.keys.cols-12 .keys-layer {
  gap: 5px;
}

.keys.km.cols-12 .key {
  font-size: 18px;
}

.keys.km .key.two {
  font-size: 14px;
  letter-spacing: -1px;
}

.keys.km .key {
  font: 700 20px/1 'Nokora', var(--font);
}

/* Shift: at the left of the bottom row */
.keys .key.shift {
  background: var(--indigo-3);
  font: 18px/1 system-ui, sans-serif;
}

.keys .key.shift.held {
  background: var(--cream);
  color: var(--ink);
}

.keys .key.space {
  flex: 0 0 56%;
  width: 56%;
  max-width: 56%;
  letter-spacing: 0.2em;
}

.keys.km .key.space {
  font-size: 16px;
  letter-spacing: 0;
}

.keys-row.space-row {
  justify-content: center;
}

/* One more row for the space bar: keep the keys a little shorter so a 375 x 812 phone still fits. */
.keys.with-space .keys-layer {
  gap: 4px;
}

.keys.with-space .key {
  height: 42px;
}

/* Khmer only: the key to press next */
.key.next {
  background: var(--gold);
  color: var(--ink);
  box-shadow:
    inset 0 calc(var(--px) * -2) 0 0 #b98a1c,
    0 0 0 var(--px) var(--ink);
}

.key.down {
  background: var(--cream);
  color: var(--ink);
}

.next-key b {
  font: 700 22px/1 'Nokora', var(--font);
  color: var(--cream);
  padding-left: 4px;
}

.quit {
  min-height: 30px;
  padding: 2px 10px calc(2px + var(--px) * 2);
  font-size: 12px;
}

/* The word sits on the keys, and Quit moves to the corner of the deck (a second tap confirms). */
#app.phone-race #deck {
  display: flex;
  flex-direction: column;
}

#app.phone-race #panel {
  position: relative;
  flex: 1;
}

#app.phone-race .type.with-keys {
  justify-content: flex-end;
}

/* The streak row is only as tall as the squares, so the gap down to the keys stays the panel's 12px. */
#app.phone-race .type-meta {
  min-height: 0;
  align-items: flex-end;
}

#app.phone-race .pips-hint {
  flex: 1 1 0;
}

#app.phone-race .quit {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  white-space: nowrap;
  min-height: 28px;
  padding: 2px 8px calc(2px + var(--px) * 2);
  font-size: 12px;
}

#app.phone-race .quit.restart {
  right: auto;
  left: 6px;
}

#app.phone-race .quit:active {
  transform: none;
}

/* ---------- the Khmer keyboard guide ---------- */

.combo {
  padding-left: 8px;
  color: var(--gold);
  font-size: 12px;
}

.kb {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  max-width: 600px;
  margin-top: 2px;
  user-select: none;
}

.kb-row {
  display: flex;
  gap: 2px;
}

.kb .gap,
.kb .cap {
  --u: 1;
  flex: var(--u) 1 0;
  min-width: 0;
}

.kb .w15 { --u: 1.5; }
.kb .w175 { --u: 1.75; }
.kb .w225 { --u: 2.25; }
.kb .w275 { --u: 2.75; }
.kb .w4 { --u: 4; }
.kb .w6 { --u: 6; }

.kb .cap {
  position: relative;
  height: clamp(26px, 4.4vh, 38px);
  overflow: hidden;
  background: var(--indigo-2);
  box-shadow: inset 0 -2px 0 var(--ink);
  color: var(--dim);
}

/* the Latin letter printed on the key, for keyboards with no Khmer on them */
.kb .cap small {
  position: absolute;
  right: 3px;
  bottom: 4px;
  font-size: 8px;
  line-height: 1;
  opacity: 0.6;
}

.kb .cap b {
  position: absolute;
  font: 400 12px/1.25 'Nokora', var(--font);
  white-space: nowrap;
}

/* As on a real keycap: the plain letter bottom left, the Shift letter top right. */
.kb .cap .up {
  top: 0;
  right: 4px;
}

.kb .cap .lo {
  bottom: 1px;
  left: 4px;
  color: var(--cream);
}

.kb .mod {
  background: var(--indigo-3);
}

.kb .mod small {
  right: auto;
  left: 4px;
  bottom: 5px;
  opacity: 1;
}

.kb .cap.on {
  background: var(--gold);
  box-shadow: inset 0 -2px 0 #a3741c;
  color: #6b4a10;
}

.kb .cap.on small,
.kb .cap.on b {
  color: #6b4a10;
  opacity: 1;
}

.kb .cap.on-lo .lo,
.kb .cap.on-up .up {
  color: var(--ink);
  font-weight: 700;
  font-size: 15px;
}

.kb .cap.on-lo .up,
.kb .cap.on-up .lo {
  opacity: 0.45;
}

/* With the guide on screen the deck spreads out so each keycap has room for its letters. */
#app.guided #deck {
  width: min(100vw, max(var(--stage-w), calc(640px * var(--ui-zoom, 1))));
}

#app.guided .type {
  gap: 2px;
}

#app.guided .type-hint {
  min-height: 18px;
  font-size: 12px;
}

#app.guided .type-word.km {
  font-size: clamp(30px, 6.5vh, 52px);
  line-height: 1.5;
}

/* Phones bring their own Khmer keyboard, which covers this part of the screen anyway. */
@media (pointer: coarse), (max-width: 520px) {
  .kb,
  .combo {
    display: none;
  }
}

/* ---------- versus cards ---------- */

.vs {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: stretch;
}

.vs-mid {
  align-self: center;
  font-size: 24px;
  color: var(--red);
  text-shadow: var(--px) var(--px) 0 var(--ink);
}

.who {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 10px;
  background: var(--indigo-2);
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--ink),
    0 var(--px) 0 0 var(--ink),
    calc(var(--px) * -1) 0 0 0 var(--ink),
    var(--px) 0 0 0 var(--ink);
}

.who.ghost {
  box-shadow:
    0 calc(var(--px) * -1) 0 0 #7fc6e8,
    0 var(--px) 0 0 #7fc6e8,
    calc(var(--px) * -1) 0 0 0 #7fc6e8,
    var(--px) 0 0 0 #7fc6e8;
}

.who canvas {
  flex: none;
  width: 48px;
  height: 48px;
}

.who-text {
  min-width: 0;
  line-height: 1.45;
}

/* The name keeps one line and gives up letters first; the crown and its title go to the next
   line when they do not fit beside it (they used to be clipped to a gold sliver). */
.who-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 6px;
  min-width: 0;
}

.who-name .nm {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.who-text .title-tag {
  max-width: 100%;
  margin-top: 2px;
}

.who-kind {
  font-size: 12px;
  color: var(--dim);
}

.who-best {
  color: var(--gold);
}

/* ---------- results ---------- */

.result-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}

.result-head .title-tag {
  max-width: 100%;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.stat {
  padding: 6px 4px;
  background: var(--indigo-2);
  text-align: center;
  line-height: 1.35;
}

.stat b {
  display: block;
  font-weight: 400;
  font-size: 24px;
  color: var(--gold);
}

.stat span {
  font-size: 12px;
  color: var(--dim);
}

.pay {
  display: grid;
  gap: 2px;
}

.pay div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.pay .sum {
  margin-top: 4px;
  padding-top: 4px;
  border-top: var(--px) dashed var(--indigo-3);
  font-size: 24px;
  color: var(--gold);
}

html[lang='km'] .pay .sum {
  font-size: 20px;
}

/* daily quests: a flat bar, a gold fill, and a row that may wrap on a phone */
.qlist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--indigo-2);
  border: var(--px) solid var(--ink);
}

.qname {
  flex: 1 1 10rem;
  min-width: 0;
  line-height: 1.45;
}

.qbar {
  flex: 1 1 72px;
  min-width: 72px;
  height: calc(var(--px) * 6);
  background: var(--indigo);
  border: var(--px) solid var(--ink);
}

.qbar div {
  height: 100%;
  background: var(--gold);
}

.qcount {
  flex: 0 0 auto;
  color: var(--cream);
}

.qpay {
  flex: 0 0 auto;
  color: var(--gold);
}

.qrow .btn {
  flex: 0 0 auto;
  min-height: 36px;
  margin-left: auto;
}

html[lang='km'] .qname {
  line-height: 1.6;
}

/* ---------- shop ---------- */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tabs button {
  min-height: 36px;
  padding: 2px 10px;
  border: 0;
  background: var(--indigo-2);
  color: var(--dim);
  cursor: pointer;
}

.tabs button[aria-selected='true'] {
  background: var(--gold);
  color: var(--ink);
}

.goods {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
}

.good {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
  border: 0;
  background: var(--indigo-2);
  color: var(--cream);
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--ink),
    0 var(--px) 0 0 var(--ink),
    calc(var(--px) * -1) 0 0 0 var(--ink),
    var(--px) 0 0 0 var(--ink);
  line-height: 1.35;
  text-align: center;
  cursor: pointer;
}

.good canvas {
  width: 96px;
  height: 64px;
}

.good .price {
  font-size: 12px;
  color: var(--gold);
}

.good .price.own {
  color: var(--jade);
}

.good[aria-pressed='true'] {
  background: #343170;
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--gold),
    0 var(--px) 0 0 var(--gold),
    calc(var(--px) * -1) 0 0 0 var(--gold),
    var(--px) 0 0 0 var(--gold);
}

.good.r-rare {
  box-shadow:
    0 calc(var(--px) * -1) 0 0 #3d8bff,
    0 var(--px) 0 0 #3d8bff,
    calc(var(--px) * -1) 0 0 0 #3d8bff,
    var(--px) 0 0 0 #3d8bff;
}

.good.r-epic {
  box-shadow:
    0 calc(var(--px) * -1) 0 0 #b05cff,
    0 var(--px) 0 0 #b05cff,
    calc(var(--px) * -1) 0 0 0 #b05cff,
    var(--px) 0 0 0 #b05cff;
}

.good.r-legend {
  box-shadow:
    0 calc(var(--px) * -1) 0 0 #ffc93c,
    0 var(--px) 0 0 #ffc93c,
    calc(var(--px) * -1) 0 0 0 #ffc93c,
    var(--px) 0 0 0 #ffc93c,
    inset 0 0 12px rgba(255, 201, 60, 0.55);
}

.chip.r-common {
  color: var(--dim);
}

.chip.r-rare {
  color: #3d8bff;
}

.chip.r-epic {
  color: #b05cff;
}

.chip.r-legend {
  color: #ffc93c;
}

.buybar,
.foot {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 0 -14px -14px;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--ink);
}

.buybar {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.buy-info {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  line-height: 1.4;
}

.buy-info .chip {
  flex: none;
  min-height: 22px;
  padding: 0 0.45em;
  font-size: 12px;
}

html[lang='km'] .buy-info .chip,
html[lang='km'] .buy-info .note {
  font-size: 15px;
}

.buy-info .note {
  flex: none;
  font-size: 12px;
}

.buy-name {
  flex: 1 1 6em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- leaderboard ---------- */

.board {
  display: grid;
  gap: 4px;
}

.board-row {
  display: grid;
  grid-template-columns: 2.4em 28px minmax(0, 1fr) auto auto auto;
  gap: 8px;
  align-items: center;
  min-height: 40px;
  padding: 2px 8px;
  background: var(--indigo-2);
  line-height: 1.3;
}

.board-row.me {
  background: #4a3a22;
  box-shadow: inset var(--px) 0 0 0 var(--gold);
}

.boat-face {
  position: relative;
  width: 28px;
  height: 28px;
  justify-self: center;
}

.boat-face .boat-crown {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translate(-50%, -55%);
  line-height: 0;
  pointer-events: none;
}

.board-row canvas {
  width: 28px;
  height: 28px;
}

/* Reigning champion: a small gold crown and the title, beside the name. */
.king-mark {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  max-width: 100%;
  color: var(--gold);
  line-height: 1.2;
}

.king-mark canvas {
  width: 18px;
  height: 14px;
  flex: none;
  image-rendering: pixelated;
  animation: crown-bob 1s steps(2, end) infinite;
}

.king-title {
  min-width: 0;
  color: var(--gold);
}

html[lang='km'] .king-title {
  line-height: 1.6;
}

.chip .king-mark canvas,
.board-row .king-mark canvas,
#rivalTag .king-mark canvas {
  width: 16px;
  height: 12px;
  margin: 0;
}

/* 7×5 crown drawn at exactly 2×. No bob here: the ticker should stay still and quiet. */
#ticker .king-mark canvas {
  width: 14px;
  height: 10px;
  margin: 0;
  animation: none;
}

#ticker .king-mark {
  gap: 4px;
  height: 32px;
}

@media (max-width: 520px) {
  .chip .king-title,
  #rivalTag .king-title {
    display: none;
  }
}

.board-rank {
  color: var(--dim);
  text-align: right;
}

.board-name {
  min-width: 0;
  overflow: hidden;
}

/* the name gives up its width first, so a title chip cannot push the row past the screen */
.board-name .nm-line {
  display: flex;
  align-items: center;
  gap: calc(4px + var(--px) * 2);
  min-width: 0;
  /* Room for the title chip's one-pixel shadow, which .board-name overflow would clip. */
  padding: var(--px) 0 var(--px) var(--px);
}

.board-name .nm {
  flex: 0 1 auto;
  min-width: 3.5em;
  padding-right: var(--px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-name .title-tag {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 9em;
  margin-right: var(--px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.25;
}

/* a worn title: small text in a chip, one step of pixel border in the tier colour */
.title-tag {
  display: inline-block;
  max-width: 100%;
  padding: 0 0.4em;
  background: rgba(20, 18, 42, 0.86);
  font-size: 11px;
  line-height: 1.5;
  white-space: nowrap;
  vertical-align: 1px;
}

html[lang='km'] .title-tag {
  font-size: 14px;
}

.title-tag.r-common {
  color: var(--dim);
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--dim),
    0 var(--px) 0 0 var(--dim),
    calc(var(--px) * -1) 0 0 0 var(--dim),
    var(--px) 0 0 0 var(--dim);
}

.title-tag.r-rare {
  color: #3d8bff;
  box-shadow:
    0 calc(var(--px) * -1) 0 0 #3d8bff,
    0 var(--px) 0 0 #3d8bff,
    calc(var(--px) * -1) 0 0 0 #3d8bff,
    var(--px) 0 0 0 #3d8bff;
}

.title-tag.r-epic {
  color: #b05cff;
  box-shadow:
    0 calc(var(--px) * -1) 0 0 #b05cff,
    0 var(--px) 0 0 #b05cff,
    calc(var(--px) * -1) 0 0 0 #b05cff,
    var(--px) 0 0 0 #b05cff;
}

.title-tag.r-legend {
  color: #ffc93c;
  box-shadow:
    0 calc(var(--px) * -1) 0 0 #ffc93c,
    0 var(--px) 0 0 #ffc93c,
    calc(var(--px) * -1) 0 0 0 #ffc93c,
    var(--px) 0 0 0 #ffc93c,
    0 0 8px rgba(255, 201, 60, 0.55);
}

/* ---------- titles ---------- */

.tlist {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px;
  border: 0;
  background: var(--indigo-2);
  color: inherit;
  font: inherit;
  line-height: 1.4;
  text-align: left;
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--ink),
    0 var(--px) 0 0 var(--ink),
    calc(var(--px) * -1) 0 0 0 var(--ink),
    var(--px) 0 0 0 var(--ink);
}

button.trow {
  cursor: pointer;
}

button.trow:hover {
  background: var(--indigo-3);
}

.trow[aria-pressed='true'] {
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--gold),
    0 var(--px) 0 0 var(--gold),
    calc(var(--px) * -1) 0 0 0 var(--gold),
    var(--px) 0 0 0 var(--gold);
}

.trow.locked {
  opacity: 0.45;
}

.tneed {
  flex: 1 1 8em;
  min-width: 0;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.4;
}

.tlock {
  flex: none;
  color: var(--dim);
  font-size: 12px;
}

html[lang='km'] .tneed,
html[lang='km'] .tlock {
  font-size: 15px;
}

/* "a crew beat your run": a line above the menu, gold while there is news */
.nudge {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--indigo-2);
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--gold),
    0 var(--px) 0 0 var(--gold),
    calc(var(--px) * -1) 0 0 0 var(--gold),
    var(--px) 0 0 0 var(--gold);
}

.nudge > span {
  flex: 1 1 12em;
  min-width: 0;
  line-height: 1.4;
}

.nudge .btn {
  flex: none;
}

.btn.alert {
  min-height: 40px;
  font-size: 13px;
}

.btn.alert.fresh {
  background: var(--gold);
  color: var(--ink);
}

html[lang='km'] .btn.alert {
  font-size: 16px;
}

.board-row.alert-row {
  grid-template-columns: 28px minmax(0, 1fr) auto;
}

/* a run waiting for the organiser: the two decisions sit side by side, including at 375px */
.board-row.held-row {
  grid-template-columns: 28px minmax(0, 1fr);
}

.board-row.held-row .held-why {
  display: block;
  color: var(--gold);
  white-space: normal;
}

.board-row.held-row .held-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
}

.board-row.held-row .held-actions .btn {
  flex: 1 1 0;
  min-width: 0;
  padding-left: 6px;
  padding-right: 6px;
}

.org-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

.org-form .field {
  font-size: 16px;
  min-height: 40px;
}

.org-form .pick,
.org-form .pick-box {
  max-width: none;
}

.org-form .row .btn {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
}

.color-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.color-row input[type='color'] {
  width: 64px;
  height: 40px;
  padding: 2px;
  border: 0;
  background: var(--cream);
  cursor: pointer;
}

/* the 14-day table scrolls inside itself, so a 375px screen does not scroll the page sideways */
.stat-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.stat-table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  font-size: 12px;
  line-height: 1.35;
}

.stat-table th,
.stat-table td {
  padding: 4px 8px;
  text-align: right;
  white-space: nowrap;
  border-bottom: var(--px) solid var(--indigo-3);
}

.stat-table th {
  color: var(--gold);
  font-weight: 400;
}

.stat-table th:first-child,
.stat-table td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--indigo);
}

html[lang='km'] .stat-table {
  font-size: 14px;
}

/* a quiet text button, used for the organiser entry at the bottom of settings */
button.text-btn {
  flex: 1 0 100%;
  align-self: flex-start;
  min-height: 36px;
  margin: 0;
  padding: 6px 2px;
  border: 0;
  background: none;
  color: var(--dim);
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}

button.text-btn:hover {
  color: var(--cream);
}

html[lang='km'] button.text-btn {
  font-size: 16px;
}

/* the ranks left out between the top of the board and the player */
.board-gap {
  padding: 2px 0;
  color: var(--dim);
  text-align: center;
  letter-spacing: 4px;
}

/* a phone typed this run: 5 x 8 pixels, drawn bigger so the mark is readable */
.board-name .dev-mark {
  flex: none;
  width: 10px;
  height: 16px;
  margin-left: 0;
  vertical-align: -3px;
  image-rendering: pixelated;
}

/* the crew's province, small under its name */
.board-name small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--dim);
  font-size: 11px;
  line-height: 1.2;
}

html[lang='km'] .board-name small {
  font-size: 13px;
}

/* ---------- settings: letter colours ---------- */

.letters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: var(--px) solid var(--indigo-3);
}

.letters h3 {
  margin: 0;
  color: var(--gold);
  font-size: 16px;
  font-weight: 400;
}

.letter-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

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

.letter-row span {
  flex: 1;
  min-width: 0;
}

.letter-row input[type='color'] {
  width: 44px;
  height: 36px;
  padding: 0;
  border: var(--px) solid var(--cream);
  background: transparent;
}

.letter-hex {
  width: 7.5em;
  flex: none;
}

.letter-preview {
  background: var(--indigo);
  padding: 8px 4px;
}

.letter-preview .type-word {
  font-size: 32px;
}

.letter-preview .type-word.km {
  font-size: 28px;
}

.letter-warn {
  color: var(--gold);
}

/* ---------- settings: volume sliders ---------- */

.vol-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 460px;
}

.vol-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--dim);
}

.vol-value {
  color: var(--gold);
  font-weight: 400;
}

.vol {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 44px; /* a tall touch target; the track itself is drawn thinner */
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.vol::-webkit-slider-runnable-track {
  height: 12px;
  background: var(--indigo-3);
  box-shadow: 0 0 0 var(--px) var(--ink);
}

.vol::-moz-range-track {
  height: 12px;
  background: var(--indigo-3);
  box-shadow: 0 0 0 var(--px) var(--ink);
}

.vol::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 32px;
  margin-top: -10px;
  border: 0;
  border-radius: 0;
  background: var(--gold);
  box-shadow: 0 0 0 var(--px) var(--ink);
}

.vol::-moz-range-thumb {
  width: 20px;
  height: 32px;
  border: 0;
  border-radius: 0;
  background: var(--gold);
  box-shadow: 0 0 0 var(--px) var(--ink);
}

/* ---------- settings: the account box ---------- */

.account {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 460px;
  margin-top: 6px;
  padding-top: 12px;
  border-top: var(--px) solid var(--indigo-3);
}

.account h3 {
  margin: 0;
  color: var(--gold);
  font-size: 16px;
  font-weight: 400;
}

.email-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.email-form .field {
  max-width: none;
  font-size: 20px;
}

.account a.btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

/* ---------- the privacy page: an ordinary page of text that scrolls ---------- */

body.doc {
  height: auto;
  overflow: auto;
  user-select: text;
  -webkit-user-select: text;
}

.doc main {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 18px 60px;
  font: 16px/1.7 'Nokora', system-ui, sans-serif;
  image-rendering: auto;
}

.doc h1,
.doc h2 {
  color: var(--gold);
  font-family: var(--font);
  font-weight: 400;
  line-height: 1.3;
}

.doc h1 {
  font-size: 26px;
}

.doc h2 {
  margin-top: 28px;
  font-size: 18px;
}

.doc a {
  color: var(--gold);
}

.doc hr {
  margin: 36px 0;
  border: 0;
  border-top: var(--px) solid var(--indigo-3);
}

/* a drop-down in the same dress as the name field */
.pick {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  max-width: 420px;
  color: var(--dim);
}

.pick-box {
  font-size: 18px;
  min-height: 44px;
  max-width: 300px;
  cursor: pointer;
}

@keyframes ranked-pop {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* This month: rank, face, name, speed. The name column shrinks so a long
   name is cut, on a phone and beside the river. */
.board-body,
.board-body .board,
.hall {
  min-width: 0;
}

.board-row.month-row {
  min-width: 0;
  grid-template-columns: 28px 28px minmax(0, 1fr) auto;
}

.board-row.month-row .board-name .nm {
  flex: 1 1 auto;
  min-width: 0;
}

.month-score {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  justify-self: end;
}

.month-score b {
  color: var(--gold);
  white-space: nowrap;
}

.month-score small {
  color: var(--dim);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}

html[lang='km'] .month-score small {
  font-size: 13px;
}

.month-head {
  margin: 0;
  color: var(--cream);
  font-size: 18px;
  font-weight: 400;
  line-height: 1.45;
}

.note.month-you {
  color: var(--gold);
}

/* Sign-in note: the sentence and its small button share a line and wrap on a phone. */
.note.month-you:has(.btn) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.note.month-you:has(.btn) > span {
  flex: 1 1 12em;
  min-width: 0;
}

.note.month-you .btn {
  flex: none;
}

.hall-month {
  margin: 14px 0 0;
  color: var(--cream);
  font-size: 18px;
  font-weight: 400;
  line-height: 1.45;
}

/* One list of a closed month: its name on a line of its own, its three players under it. */
.hall-list {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 14px;
  min-width: 0;
  margin-top: 8px;
}

.hall-list-name {
  flex: 0 0 100%;
  color: var(--dim);
  font-size: 13px;
}

html[lang='km'] .hall-list-name {
  font-size: 15px;
}

.hall-player {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
}

.hall-player .nm {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hall-pos,
.hall-nobody {
  color: var(--dim);
}

.hall-pts {
  flex: none;
  color: var(--gold);
  margin-left: 6px;
  white-space: nowrap;
}

.hall-wpm {
  flex: none;
  color: var(--dim);
  margin-left: 6px;
  white-space: nowrap;
}

/* The organiser's month check. Cards stack, and every line wraps on a 360px phone. */
.month-org,
.month-close,
.month-preview-view,
.rev-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.month-org h3 {
  margin: 0;
  color: var(--cream);
  font-size: 18px;
  font-weight: 400;
  line-height: 1.45;
}

.month-org .seg.wrap {
  display: flex;
  max-width: 100%;
}

.month-org .seg.wrap button,
.month-org .note,
.month-org .held-actions .btn {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.month-org .held-actions {
  flex-wrap: wrap;
}

.rev-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  padding: 8px;
  background: var(--indigo-2);
  box-shadow: inset 0 0 0 var(--px) var(--indigo-3);
  line-height: 1.4;
}

.rev-head {
  margin: 0;
  color: var(--cream);
  font-size: 16px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.rev-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 0.4em;
  background: var(--indigo);
  color: var(--dim);
  font-size: 11px;
  line-height: 1.5;
  vertical-align: 1px;
}

.rev-elig {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.rev-elig.ok {
  color: var(--gold);
}

.rev-elig.no {
  color: #ffb4a6;
}

.rev-run {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.rev-run > span {
  /* wide enough that the Void button drops under the line on a phone instead of squeezing it */
  flex: 1 1 16em;
  min-width: 0;
  overflow-wrap: anywhere;
}

.rev-run .btn {
  flex: 0 1 auto;
  margin-left: auto;
  max-width: 100%;
  min-width: 0;
  min-height: 32px;
  padding: 2px 8px calc(2px + var(--px) * 2);
  font-size: 12px;
  white-space: normal;
}

.rev-run.warn > span {
  color: #ffb4a6;
}

.rev-card > .btn,
.month-preview-view > .btn,
.month-close > .btn {
  align-self: flex-start;
  max-width: 100%;
  white-space: normal;
}

html[lang='km'] .month-org h3,
html[lang='km'] .rev-head,
html[lang='km'] .rev-elig,
html[lang='km'] .rev-run {
  line-height: 1.6;
}

html[lang='km'] .rev-tag {
  font-size: 13px;
}

html[lang='km'] .rev-run .btn {
  font-size: 14px;
}

/* The organiser's log. Each line is a small card: the same fill and padding as the review card. */
.log-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.log-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  max-width: 100%;
  padding: 8px;
  background: var(--indigo-2);
  line-height: 1.4;
  overflow: hidden;
}

.log-row b {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.log-row span,
.log-row small {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-row small {
  color: var(--dim);
  font-size: 11px;
  line-height: 1.2;
}

html[lang='km'] .log-row small {
  font-size: 13px;
}

@media (max-width: 520px) {
  .board-row.month-row {
    grid-template-columns: 28px 24px minmax(0, 1fr) auto;
  }

}

/* Still beside the river: marks and the title chip go to a second line when the name needs the
   first one, and the two small lines under them (the crown's title, the province) share one.
   Phones keep their own tighter rows. */
#app.side .board-row .board-name .nm-line {
  flex-wrap: wrap;
  gap: 2px 6px;
}

#app.side .board-row .board-name .nm-line .title-tag {
  flex: none;
  max-width: 100%;
}

.board-row .btn {
  min-height: 32px;
  padding: 2px 10px calc(2px + var(--px) * 2);
  font-size: 12px;
}

.cheer-qr {
  display: block;
  width: 220px;
  height: auto;
  image-rendering: auto;
}

.cheer-cost {
  color: var(--gold);
  font-size: 18px;
  line-height: 1.45;
}

.field[readonly] {
  background: #e7dcb8;
}

.field {
  width: 100%;
  max-width: 420px;
  min-height: 48px;
  padding: 6px 12px;
  border: 0;
  background: var(--cream);
  color: var(--ink);
  font-size: 24px;
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--ink),
    0 var(--px) 0 0 var(--ink),
    calc(var(--px) * -1) 0 0 0 var(--ink),
    var(--px) 0 0 0 var(--ink);
  user-select: text;
  -webkit-user-select: text;
}

.steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.steps li {
  padding-left: 1.4em;
  text-indent: -1.4em;
  line-height: 1.6;
}

.steps li::before {
  content: '\25B6';
  display: inline-block;
  width: 1.4em;
  text-indent: 0;
  color: var(--gold);
}

/* ---------- odds and ends ---------- */

#kbd {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  font-size: 16px; /* under 16px, iPhones zoom the page on focus */
  pointer-events: none;
}

#toast {
  position: fixed;
  left: 50%;
  /* high on the river, clear of the boat and the buttons */
  top: calc(var(--stage-w) * 0.5625 * 0.2);
  z-index: 5;
  max-width: 90vw;
  padding: 6px 14px;
  transform: translateX(-50%);
  background: var(--gold);
  color: var(--ink);
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--ink),
    0 var(--px) 0 0 var(--ink),
    calc(var(--px) * -1) 0 0 0 var(--ink),
    var(--px) 0 0 0 var(--ink);
  text-align: center;
  pointer-events: none;
  visibility: hidden;
}

#toast.on {
  visibility: visible;
}

#rotate {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--ink);
  font-size: 24px;
  text-align: center;
}

/* a phone on its side has no room for the river and a keyboard */
@media (orientation: landscape) and (max-height: 430px) and (pointer: coarse) {
  #rotate {
    display: flex;
  }
}

@media (min-width: 900px) and (min-height: 760px) {
  :root {
    --px: 3px;
  }
  .goods {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}

@media (max-width: 520px) {
  body {
    overflow-x: hidden;
  }
  #app,
  #deck,
  #panel {
    max-width: 100%;
  }
  #deck {
    width: 100%;
  }
  .board-controls {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--indigo);
    gap: 6px;
  }
  .board-controls > .seg.tabs {
    display: flex;
    flex: 1 0 100%;
    flex-wrap: nowrap;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }
  .board-controls > .seg.tabs button {
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    padding: 2px 1px;
    font-size: 13px;
    white-space: nowrap;
  }
  html[lang='km'] .board-controls > .seg.tabs button {
    font-size: 15px;
  }

  .stats {
    grid-template-columns: repeat(3, 1fr);
  }
  .stat b {
    font-size: 16px;
  }
  .vs {
    grid-template-columns: 1fr;
  }
  .vs-mid {
    display: none;
  }
  .btn.big {
    min-height: 56px;
  }
  .menu .duo {
    gap: 8px;
  }
  .menu .duo .btn {
    padding-left: 6px;
    padding-right: 6px;
    font-size: 14px;
  }
  html[lang='km'] .menu .duo .btn {
    font-size: 16px;
  }
  .board-row {
    grid-template-columns: 2em 24px minmax(0, 1fr) auto auto;
    gap: 6px;
    padding: 2px 6px;
  }
  .board-row canvas {
    width: 24px;
    height: 24px;
  }
  .boat-face {
    width: 24px;
    height: 24px;
  }
}

@keyframes crown-bob {
  50% {
    transform: translateY(-1px);
  }
}

@media (prefers-reduced-motion: reduce) {
  #banner.pop,
  .type-word.bad,
  .btn.ping,
  .king-mark canvas {
    animation: none;
  }
}

/* The cheer button leads the menu: gold frame, so it reads as something special, not one more setting. */
.btn.cheer-bar {
  background: var(--indigo-2, #2b2a5c);
  color: var(--gold);
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--gold),
    0 var(--px) 0 0 var(--gold),
    calc(var(--px) * -1) 0 0 0 var(--gold),
    var(--px) 0 0 0 var(--gold);
  animation: cheer-glow 2.4s steps(2) infinite;
}

.btn.cheer-bar small {
  color: var(--cream);
}

@keyframes cheer-glow {
  50% {
    background: #3a3580;
  }
}

/* Site sponsors. Under the river on the title screen only — never over the playfield,
   the ticker, or the race keys. A race leaves this at display:none so the deck is unchanged. */
.site-sponsors {
  display: none;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
}

#app[data-screen='title'] .site-sponsors.is-on {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  max-height: 52px;
  padding: 4px 10px;
  background: #14122a;
  border-bottom: var(--px) solid var(--gold);
  font-family: 'Nokora', system-ui, sans-serif;
}

.site-sponsor-label {
  flex: none;
  margin: 0;
  color: var(--gold);
  font-size: 13px;
  line-height: 1.2;
}

.site-sponsor-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 18px), transparent);
  mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 18px), transparent);
}

.site-sponsor-row::-webkit-scrollbar {
  display: none;
}

.site-sponsor-link {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  color: var(--cream);
  font-size: 12px;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}

.site-sponsor-link:hover .site-sponsor-tag {
  text-decoration: underline;
}

.site-sponsor-link:focus-visible {
  outline: var(--px) solid var(--cream);
  outline-offset: 2px;
}

.site-sponsor-logo {
  display: block;
  height: 22px;
  width: auto;
  max-width: none;
  object-fit: contain;
}

.site-sponsor-name {
  color: var(--gold);
}

.site-sponsor-tag {
  color: var(--dim);
}


/* Sign-in on the title screen. Empty until the sign-in service answers. */
.title-signin:empty {
  display: none;
}

.title-signin > .note {
  margin: 0;
  color: var(--dim);
  font-size: 12px;
}

/* Google's own colours: a white button with the four-colour G, so it reads as Google at a glance. */
.btn.google {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  background: #fff;
  color: #1f1f1f;
  text-decoration: none;
  box-shadow:
    inset 0 calc(var(--px) * -2) 0 0 #c9c9d6,
    0 calc(var(--px) * -1) 0 0 var(--ink),
    0 var(--px) 0 0 var(--ink),
    calc(var(--px) * -1) 0 0 0 var(--ink),
    var(--px) 0 0 0 var(--ink);
}

.btn.google img {
  flex: none;
  image-rendering: auto;
}

/* Keep the bar short on a phone: Google and "Other ways" share one row under the line. */
.title-signin.nudge .btn {
  min-height: 40px;
  padding: 6px 8px calc(6px + var(--px) * 2);
  font-size: 13px;
}

.title-signin.nudge {
  gap: 8px 6px;
}

.title-signin.nudge > span {
  flex-basis: 100%;
}

/* On a phone the word pack and Settings share one row: Settings shows its gear only. The word
   stays in the page (hidden from sight, not from screen readers). Raven, 2026-11-20. */
@media (max-width: 520px) {
  .menu .settings {
    column-gap: 10px;
  }

  .settings > .btn.to-settings {
    min-width: 48px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .settings > .btn.to-settings canvas.ico {
    width: calc(var(--px) * 12);
    height: calc(var(--px) * 12);
  }

  .settings > .btn.to-settings .btn-copy {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* ---------- Festival Cup (ship 4) ---------- */

/* "Did you know?": a picture from img/cup.png and a card of text */
.fact {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px;
  background: var(--indigo-2);
  box-shadow: inset var(--px) 0 0 0 var(--gold);
}

.fact-pic {
  flex: none;
  width: 72px;
  height: 72px;
  image-rendering: pixelated;
}

.fact-text {
  min-width: 0;
}

.fact-head {
  color: var(--gold);
  font-size: 14px;
}

.fact-text p {
  margin: 2px 0 0;
  font-size: 14px;
  line-height: 1.35;
}

.facts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fest-leg {
  margin-top: -4px;
}

#panel h3 {
  margin: 6px 0 0;
  font-weight: 400;
  font-size: 16px;
  color: var(--gold);
}

/* after a day: every pair, then the table */
.fest-pairs,
.fest-table {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fest-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 6px;
  padding: 2px 6px;
  background: var(--indigo-2);
  font-size: 13px;
}

.fest-pair .fp-boat {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--dim);
}

.fest-pair .fp-boat.won {
  color: var(--cream);
}

.fest-pair .fp-v {
  color: var(--dim);
}

.fest-pair.you,
.fest-row.you {
  background: #4a3a22;
  box-shadow: inset var(--px) 0 0 0 var(--gold);
}

.fest-row {
  display: grid;
  grid-template-columns: 2em minmax(0, 1fr) 3.4em 4.6em;
  gap: 6px;
  align-items: center;
  padding: 2px 6px;
  background: var(--indigo-2);
  font-size: 13px;
}

.fest-row .fr-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fest-row .fr-wins {
  color: var(--gold);
}

.fest-row .fr-time {
  text-align: right;
  color: var(--dim);
}

/* the awards: the ribbon cutting, then the trophy, pennant and aesthetics award */
.ribbon-pic {
  display: block;
  width: 100%;
  max-width: 640px;
  height: auto;
  aspect-ratio: 16 / 9;
  image-rendering: pixelated;
}

.awards {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.award {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 4px 8px;
  background: var(--indigo-2);
}

.award.you {
  box-shadow: inset var(--px) 0 0 0 var(--gold);
}

.award-pic {
  flex: none;
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
}

/* ---------- the server's purse (signed in) ---------- */

.pay-note {
  margin-top: 2px;
}

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

.st-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 3px 8px;
  background: var(--indigo-2);
  font-size: 13px;
}

.st-row .st-when {
  color: var(--dim);
}

.st-row .st-what {
  overflow-wrap: anywhere;
}

.st-row .st-amt {
  color: var(--jade);
}

.st-row .st-amt.minus {
  color: var(--pink);
}
