/* ============================================
   DARK MODE & COLOR FORCING PREVENTION
   ============================================ */

:root {
  /* The ink of the texts. --ink is the text on the panels (light, translucent white), --ink-bg the one that sits straight
     on the background (the title, "BOT turn"...). A background that does not suit them says its own (body.ink-*, see
     syncInk in linotte.js): a dark sky has light texts on it and a slate ink on the panels. */
  --ink: #3d240c;
  --ink-bg: rgba(0, 0, 0, .7);
  --ink-bg-soft: rgba(0, 0, 0, .5);
  --ink-bg-shadow: 0 .05em 0 rgba(255, 255, 255, .4);
  /* the tiles of the combinations and the calls under them: white symbols on a translucent veil, which a bright sky
     would swallow (a background with a bright sky says a deeper veil, body.ink-*) */
  --zone-bg: #ffffff5e;
  --zone-border: #fff;
  --result-icon: #fffeff; /* the symbols of the combinations */
  --result-icon-on: #fffeff; /* ... and the one the dice make */
  --result-on: #409ff8; /* the blue of a combination the dice make (a theme gives its own) */
  --call-on-border: #ffea00; /* the border of a call that lights up yellow (a dark one keeps it readable on a bright theme) */

  /* "only light" opts out of the browsers that darken pages by themselves
     (Samsung Internet's dark mode for websites, Chrome's auto dark mode). */
  color-scheme: only light !important;

  /* Motion tokens. Anything that answers a tap (dice, buttons, calls,
     pieces) uses --tap with --ease-out; something appearing on the board is
     a state change and gets --state; things leaving use --ease-in.
     Celebrations (fairy trail, points, winner) keep their own timings. */
  --tap: 150ms;
  --state: 200ms;
  --ease-out: cubic-bezier(.25, 1, .5, 1);
  --ease-in: cubic-bezier(.5, 0, .75, 0);

  /* Running text (rules, captions, credits): Atkinson Hyperlegible, a face
     drawn for legibility (open counters, letters that can't be confused).
     Changa One stays for headings and names. */
  --text-font: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
}

html {
  color-scheme: only light !important;
}

body {
  /* filter: none !important; */
  mix-blend-mode: normal !important;
  background-blend-mode: normal !important;
  /* color-scheme: light !important; */
  forced-color-adjust: none;
  font-family: "Changa One", sans-serif;
  -webkit-font-smoothing: antialiased;
}

* {
  forced-color-adjust: none !important;
}

/* Prevent dark mode from affecting images and SVGs */
@media (prefers-color-scheme: dark) {

  img,
  svg {
    filter: none !important;
    -webkit-filter: none !important;
    mix-blend-mode: normal !important;
  }
}


/* Force SVG images to display correctly */
img[src$=".svg"],
img[src*=".svg"] {
  filter: none !important;
  -webkit-filter: none !important;
}


/* ============================================
   RESET
   ============================================ */

.fullscreen {
  height: calc(var(--vh) * 100);
}

/* No global backface-visibility:hidden here any more: on every element it
   pushed Safari (and Chrome, for anything with a transform) to paint each
   one on its own compositing layer, placed at sub-pixel offsets -- which is
   what made button and dice borders look thicker on one side and blurry.
   Only the clock tiles and the coin flip actually show a back face (3D
   flips), and they set it themselves. */
* {
  box-sizing: border-box;
}

/* The game's height: the screen, minus the in-game banner's place below it
   when there is one (not for Pro; see .game-ad-slot in ads.css). The
   game's sizes are taken off this, so it shrinks a little to leave the
   banner room instead of running under it. */
:root {
  --ad-h: 0px;
  --game-h: calc(100dvh - var(--ad-h));
}

body.game-ad {
  --ad-h: 60px; /* a 50px banner and at least 10px clear of the game */
  --game-h: calc(100dvh - var(--ad-h));
}

html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  font-family: sans-serif;
  min-height: 100%;
  /* No double-tap zoom: quick taps on dice and buttons are play, not zoom. */
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  padding: 0;
  overscroll-behavior: none;
  color: black;
}

/* Horizontal overflow is clipped on html (that's the viewport's scroll
   container), NOT on body: body gets rotated 180deg by FLIP, and an
   overflow clip on a rotating element clips its children to its rotated box,
   which sliced corners off the board mid-rotation. */
html {
  overflow-x: hidden;
}




/* ============================================
   BODY & MAIN CONTAINER
   ============================================ */

.body {
  text-align: center;
  background-color: whitesmoke;
  background-image: var(--own-bg, var(--default-bg));
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
}

.flex-block {
  /* --col-w is the width of the "mobile column" the game is laid out in
     (the whole screen in portrait, the sidebar in landscape -- see the
     media queries below). Everything inside is authored in em against a
     16px base at a 375px column, so scaling the font with the column (and
     capping it by height, so a short screen shrinks the controls instead of
     overflowing) scales the whole UI to phones, tablets and desktops.
     The result is rounded to a whole pixel so em-based borders, radii and
     rings land on whole pixels too instead of values like 3.58px. */
  --col-w: min(100vw, 700px);
  /* The board's own width (same formula as .div-table's width below; the
     landscape block replaces it). The board scales its details off this,
     not off the column's font -- see .div-table. */
  --board-w: min(calc(var(--col-w) * .95), calc(var(--game-h) * .58));
  font-size: round(down, min(calc(var(--col-w) * 0.04267), calc(var(--game-h) * .01971)), 1px);
  display: flex;
  flex-flow: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 700px;
  min-height: calc(var(--vh) * 100 - var(--ad-h));
  min-height: var(--game-h);
  margin-left: auto;
  margin-right: auto;
  /* Notch / home indicator (viewport-fit=cover is on). */
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

/* A short portrait screen has no room left over above the players: the level badge
   that overhangs their boxes would touch the screen's edge, so it gets a little room
   (a notch's inset, when there is one, is already more than that). */
@media (orientation: portrait) and (max-height: 700px) {
  .flex-block {
    padding-top: max(env(safe-area-inset-top, 0px), .6em);
  }
}

/* Groups info/results/dice/buttons for wider/landscape layouts below.
   display:contents makes the wrapper invisible to the flex layout, so on
   mobile portrait its children act as direct .flex-block flex items
   exactly as before (their own `order` values still control the stack). */
.side-panel {
  display: contents;
}





/* ============================================
   INFO SECTION
   ============================================ */

.div-info {
  display: grid;
  grid-template-rows: auto;
  /* The menu button and the countdown each get the same side column (12% of the
     row, never less than the button), so the players and the VS sit in the middle
     of the row, which is as wide as the board. */
  grid-template-columns: max(12%, 2.5em) minmax(0, 1fr) max(12%, 2.5em);
  grid-auto-columns: 0;
  align-self: flex-start;
  /* A tenth of the screen's height, as it always was, but never taller than the board's
     width allows (on a wide, short window the row stays in proportion). */
  height: min(10dvh, calc(var(--board-w) * .24));
  width: var(--board-w);
  margin: auto;
  user-select: none;
  order: 1;
}

.players {
  flex-flow: row;
  grid-template-rows: auto;
  grid-template-columns: minmax(0, 1fr) 10% minmax(0, 1fr);
  grid-auto-flow: row;
  justify-content: stretch;
  place-items: center;
  display: grid;
}

.player {
  border-radius: .625em; /* 10px on the phone, scaling with the column */
  width: min(calc(var(--col-w) * 0.27), 100%);
  max-width: 200px;
  height: 100%;
  max-height: 200px;
  border: .25em solid rgba(0, 0, 0, 0.35);
}

/* The glow of the player on turn: a ring of the piece's colour around the box that breathes, from .25em to .5em of solid colour
   outside its border. It is a plain rounded block of that colour behind the box, a little bigger than it, that swells and
   shrinks (a scale: the graphics chip's); only its rim shows. It used to animate box-shadow, which the CPU redraws at every
   frame, all game long. (.players isolates, so the block stays behind the box and not behind the page.) */
.players {
  isolation: isolate;
}

.player.current::before {
  content: "";
  position: absolute;
  inset: -.5em; /* .25em outside the box's border */
  z-index: -1;
  border-radius: .875em;
  background-color: inherit; /* the colour of the box itself (its piece's): never a leftover of another game's */
  pointer-events: none;
  animation: glowBreath 2s infinite ease-in-out;
}

.div-block-15 {
  grid-column-gap: 0;
  grid-row-gap: 0;
  grid-template-rows: 60% 20% 20%;
  grid-template-columns: 1fr;
  grid-auto-columns: 1fr;
  place-items: center stretch;
  width: auto;
  height: 90%;
  display: grid;
}

.textPlayer {
  color: black;
  font-size: 4vw;
}

.textPlayer.t1 {
  font-size: 2em;
  /* Online opponents have arbitrary names: never let one push the box wide. */
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.textPlayer.t2 {
  font-size: 1em;
}


/* The box of a player takes the colour of their piece: when it is dark (the penguin, a black or a navy piece) the texts and
   the little icons turn light and the edge turns pale, whatever the piece (applyPlayerVisuals in linotte.js). */
/* One soft light tone for what is on a dark box: the texts, the little icons and the ring around it (not a pure white: it
   shouts on a black piece). */
.player.dark-box {
  --dark-tone: rgba(255, 255, 255, .66);
  border-color: var(--dark-tone);
}

.player.dark-box .textPlayer {
  color: var(--dark-tone);
}

.player.dark-box .pawn,
.player.dark-box .coin {
  filter: invert(1);
  opacity: .66;
}

.pawn {
  display: block;
  background-image: url("resources/images/p105-pawn.svg");
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  width: 0.9em;
  aspect-ratio: 1/1;
}

.coin {
  background-image: url("resources/images/p105-coin.svg");
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  width: 1em;
  aspect-ratio: 1/1;
}

.vs {
  margin-left: 0;
  margin-right: 0;
  background-image: url("resources/images/g10456.svg");
  width: 100%;
  height: 100%;
  background-position: 50%;
  background-repeat: no-repeat;
  background-size: contain;
}

.div-info-left {
  display: flex;
  align-items: center;
  justify-content: center;
}

.options {
  background-image: url("resources/images/g10455.svg");
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  width: 2.5em;
  aspect-ratio: 1/1;
}

.div-info-right {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* While paused (see setPaused in linotte.js) the countdown fades and a pause
   symbol sits over it. */
.clock {
  transition: opacity .3s ease;
}

.div-info-right.paused .clock {
  opacity: .3;
}

/* The last 5 seconds of the player's own turn (see clockWarn in linotte.js): the digits turn red and the
   clock beats once a second, swelling with a red glow, a little more each time (--beat-scale). */
.div-info-right.warn .clock-tile .half {
  color: #ff5a47;
}

.div-info-right.beat .clock {
  animation: clockBeat .9s cubic-bezier(.2, .7, .3, 1);
}

@keyframes clockBeat {
  0% { transform: scale(var(--beat-scale, 1.3)); filter: drop-shadow(0 0 .7em rgba(255, 70, 50, .95)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(255, 70, 50, 0)); }
}

@media (prefers-reduced-motion: reduce) {
  .div-info-right.beat .clock { animation: none; }
}

.clock-pause {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 1.1em;
  height: 1.4em;
  box-sizing: border-box;
  border-left: .4em solid #000;
  border-right: .4em solid #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
  z-index: 1;
}

.div-info-right.paused .clock-pause {
  opacity: 1;
  animation: clockPausePulse 1.1s ease-in-out infinite;
}

@keyframes clockPausePulse {
  0%, 100% { opacity: .35; transform: scale(.9); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* Timer ----------*/
.clock {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.2em;
  width: 100%;
  height: 90%;
}

.clock-tile {
  position: relative;
  width: 2em;
  height: 2.5em; /* 40px on the phone; a fixed 40px squashed it on tablets */
}

.half {
  position: absolute;
  left: 0;
  width: 100%;
  height: 50%;
  overflow: hidden;
  color: #fdb800cc;
  display: flex;
  justify-content: center;
  font-size: 1.8em;
  font-weight: bold;
  font-family: sans-serif;
  /* The flip clones turn past 90deg (rotateX); their back must not show. */
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.half span {
  display: block;
}

.top {
  top: 0;
  transform-origin: bottom;
  border-radius: 0.1em 0.1em 0 0;
  /* The tile's 2.5em height in this element's own (1.8x) em: 40px and 2px
     on the phone, scaling with the column. */
  line-height: 1.389em;
  background: #2d1a09;
  border-bottom: .0695em solid rgba(54, 33, 14, 0.2); /* 2px on the phone (.0694 lands a hair under and rounds down) */
}

.bottom {
  bottom: 0;
  transform-origin: top;
  border-radius: 0 0 0.1em 0.1em;
  line-height: 0px;
  background: #3f240d;
}

.flipTop {
  animation: flipTop .3s forwards;
}

.flipBottom {
  animation: flipBottom .3s forwards;
}

/*----------*/



.div-block-16 {
  margin: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 3px;
}

.div-block-17 {
  margin: auto;
  justify-content: center;
  align-items: center;
  display: flex;
  gap: 10px;
}






/* ============================================
   TABLE SECTION
   ============================================ */

.div-table {
  /* The board's em scale follows the board itself: 16px on the 356px board
     of a 375px phone, and proportionally more on a bigger board. Without
     this the frame, the corners and the tile highlight followed the
     column's font instead, which on tablets is capped by the screen height
     (portrait) or set by the narrow sidebar (landscape) -- they came out
     thin and square next to the much larger tiles. */
  font-size: round(down, calc(var(--board-w) * 0.045), 1px);
  background-color: rgb(96, 56, 19);
  border: .75vw solid rgb(96, 56, 19);
  border-width: .3125em; /* 5px on the phone's board */
  border-radius: 1.3em;
  /* Also bounded by height, so a short portrait window (split-screen,
     browser chrome, small phone) shrinks the board instead of pushing
     ROLL/DONE off the bottom. */
  width: var(--board-w);
  aspect-ratio: 1 / 1;
  margin: auto;
  margin-top: calc(var(--game-h) * .01);
  order: 2;
  transition: transform .6s ease;
}

/* FLIP (same-table/hotseat only -- see #flip-table-btn in linotte.js), in
   portrait: the game (.flex-block) and the panels that belong to whoever's
   turn it is (menu, winner screen, sheets, messages) turn 180deg, in place,
   so whoever's now facing the screen gets an upright view of their own turn,
   instead of reading everything upside down after passing the device across
   the table. Not the <body> itself: turning it made the banner (fixed to the
   screen) jump and disappear mid-turn on phones. The board gets an EXTRA
   180deg on top of that, canceling the game's own rotation -- it's the one
   shared physical object between both players and has to stay the same way
   up no matter whose turn it is. */
.div-table {
  transition: transform .6s ease;
  /* The board is a layer of its own all the time, not only while it turns. The effects of a sky (a bolt, a petal, a glint)
     come and go as layers of their own, and each time the page's layers change the browser may paint again what lies
     over them: the lit tiles' rings and the pieces were seen to drop out for one frame, mostly around a lightning. With
     its own layer the board is painted once and left alone. */
  will-change: transform;
}

@media (orientation: portrait) {
  .flex-block {
    transition: transform .6s ease;
  }

  /* Turned upside down, what the page keeps clear at its top (the notch) lands
     at the bottom and the other way round: it is moved down by the difference
     of the two (nothing to lay out again, so the turn stays smooth). */
  body.table-flipped .flex-block {
    transform: translateY(calc(env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px))) rotate(180deg);
  }

  body.table-flipped .div-table {
    transform: rotate(-180deg);
  }

  #options-overlay,
  #winner-overlay,
  #online-overlay {
    transition: rotate .6s ease;
  }

  /* The toast keeps its own fade and slide (online.css) next to the turn; its swiping aside runs on
     `translate`, which the turn (`rotate`) doesn't touch. */
  #toast {
    transition: rotate .6s ease, opacity 150ms cubic-bezier(.25, 1, .5, 1), transform 150ms cubic-bezier(.25, 1, .5, 1), translate 200ms cubic-bezier(.25, 1, .5, 1);
  }

  #toast.dragging {
    transition: rotate .6s ease, opacity 150ms, transform 150ms;
  }

  body.table-flipped #options-overlay,
  body.table-flipped #winner-overlay,
  body.table-flipped #online-overlay,
  body.table-flipped #toast {
    rotate: 180deg;
  }
}

/* Effects drawn in screen coordinates (the fairy-trail canvas covers the
   whole page and its points come from getBoundingClientRect) stay as they
   are: nothing that carries them turns. */
.fairy-canvas {
  transition: rotate .6s ease;
}

/* The board keeps its layout for both players (it's the shared object), but
   each tile's symbol turns 180deg with the page so it reads the right way up
   for whoever's turn it is. The symbol is drawn by a pseudo-element (image
   comes from the tile's --tile-img, see #t00 etc.) so only it rotates --
   the tile itself, its corners and the pieces on it stay put. */
.tile {
  position: relative;
}

.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--tile-img); /* (the symbols' urls start from the root: the themes use them from their own folders) */
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

body.table-flipped .tile::before {
  rotate: 180deg;
}

.grid {
  grid-column-gap: 0;
  grid-row-gap: 0;
  background-color: rgb(97, 57, 21);
  border-radius: 1.3em;
  grid-template-rows: 1fr 1fr 1fr 1fr 1fr;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
  grid-auto-columns: 1fr;
  justify-content: center;
  place-items: center;
  min-width: 100%;
  min-height: 100%;
  display: grid;
}

.tile {
  background-color: rgb(228, 209, 187);
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  /* 2px per tile on the phone (4px between two), growing with the board
     like every other thickness. */
  border: .125em solid #603813;
  grid-template-rows: auto auto;
  width: 100%;
  height: 100%;
  margin: 0;
  display: block;
}


/* The corner tiles curve exactly with the board: the board's 1.3em outer
   corner minus its .3125em frame, so the two arcs share a centre (they
   were 1.1em, 1.8px off on the phone), and so does a highlight on a corner
   tile, whose ring widens that same radius. */
.tile {
  --corner-r: calc(1.3em - .3125em);
}

.tile.tlc {
  border-top-left-radius: var(--corner-r);
}

.tile.trc {
  border-top-right-radius: var(--corner-r);
}

.tile.blc {
  border-bottom-left-radius: var(--corner-r);
}

.tile.brc {
  border-bottom-right-radius: var(--corner-r);
}

/* A lit tile. From the bottom: the board's tiles, a skin's water and drops (1), the pieces (2), and over them all the
   ring of the lit tile (3): it is a layer of its own (the ::after), because the tile itself stays at the bottom. The
   ring is an outline drawn by it, in the colour the script gives the tile (outline-color, inherited). */
.tile_highlighted {
  outline-style: none; /* the ring is the ::after's */
  border-radius: .3125em;
}

.tile_highlighted::after {
  content: "";
  position: absolute;
  inset: -.125em; /* the tile's border box */
  z-index: 3;
  pointer-events: none;
  border-radius: inherit;
  /* All three in em of the board's scale (see .div-table), so the highlight
     keeps the phone's proportions on any board size: on the phone these are
     exactly -5px / 10px / 5px, so the 10px ring sits half inside the tile
     and half outside (on an edge tile it ends flush with the board's 5px
     frame). */
  outline: .625em solid;
  outline-color: inherit;
  outline-offset: -.3125em;
}

.grid {
  grid-template-rows: 1fr 1fr 1fr 1fr 1fr;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
  position: static;
}

.wrapPiece {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  /* The .img-bounce placement animation (animations.css) ends on
     "transform: scale(1)" with fill-mode forwards, which sticks around
     permanently -- and ANY non-"none" transform value, even scale(1),
     creates its own stacking context. That silently made this element's
     z-index:auto rank BELOW the fairy-trail canvas's explicit positive
     z-index (auto/0 always loses to any explicit z-index > 0, regardless
     of DOM order), no matter what z-index the .piece inside it had. An
     explicit z-index here, once a piece has actually landed, puts this
     wrapper's own stacking context above the canvas instead. */
  position: relative;
  z-index: 2;
  /* Same reason as .wrapDie: the jump of one piece must not change the layers of the others. */
  will-change: transform;
}

.piece {
  width: 100%;
  height: 100%;
  border-radius: 2em;
  background-position: 50% 50%;
  background-size: 80% 80%;
  background-repeat: no-repeat;
  opacity: 1;
  /* Promoted into its own stacking layer, above the fairy-trail canvas
     (shared/fairyTrail.js, z-index:1) -- so the sparkle burst plays
     underneath the token that just landed instead of covering it. */
  position: relative;
  z-index: 2;
}

.img-bounce {
  animation: bounceIn .5s ease-out forwards; /* 2.7.0 timing */
}

.img-disappear {
  animation: bounceOut .2s ease-out forwards; /* 2.7.0 timing */
}

#t00 {
  --tile-img: url("/resources/images/g10481.svg");
}

#t01 {
  --tile-img: url("/resources/images/g10483.svg");
}

#t02 {
  --tile-img: url("/resources/images/g10495.svg");
}

#t03 {
  --tile-img: url("/resources/images/g10484.svg");
}

#t04 {
  --tile-img: url("/resources/images/g10486.svg");
}

#t10 {
  --tile-img: url("/resources/images/g10482.svg");
}

#t11 {
  --tile-img: url("/resources/images/g10492.svg");
}

#t12 {
  --tile-img: url("/resources/images/g10496.svg");
}

#t13 {
  --tile-img: url("/resources/images/g10491.svg");
}

#t14 {
  --tile-img: url("/resources/images/g10485.svg");
}

#t20 {
  --tile-img: url("/resources/images/g10493.svg");
}

#t21 {
  --tile-img: url("/resources/images/g10491.svg");
}

#t22 {
  --tile-img: url("/resources/images/g10498.svg");
}

#t23 {
  --tile-img: url("/resources/images/g10495.svg");
}

#t24 {
  --tile-img: url("/resources/images/g10497.svg");
}

#t30 {
  --tile-img: url("/resources/images/g10486.svg");
}

#t31 {
  --tile-img: url("/resources/images/g10496.svg");
}

#t32 {
  --tile-img: url("/resources/images/g10497.svg");
}

#t33 {
  --tile-img: url("/resources/images/g10493.svg");
}

#t34 {
  --tile-img: url("/resources/images/g10481.svg");
}

#t40 {
  --tile-img: url("/resources/images/g10483.svg");
}

#t41 {
  --tile-img: url("/resources/images/g10482.svg");
}

#t42 {
  --tile-img: url("/resources/images/g10492.svg");
}

#t43 {
  --tile-img: url("/resources/images/g10485.svg");
}

#t44 {
  --tile-img: url("/resources/images/g10484.svg");
}




/* ============================================
   RESULT AND CALL SECTION
   ============================================ */

.div-resultsAndCalls {
  width: var(--board-w); /* the same width as the board, the dice and ROLL/DONE */
  aspect-ratio: 5.45 / 1;
  order: 3;
  margin: auto;
  margin-top: var(--gap);
}

.result {
  position: relative;
}

/* bolla */
.result::after {
  font-size: 2em;
  content: attr(data-tip);
  position: absolute;
  bottom: 145%;
  left: 50%;
  transform: translateX(-50%) scale(.5);

  background: whitesmoke;
  color: #603813;
  font-size: .75em;
  padding: .333em .667em;
  border-radius: .667em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--tap) var(--ease-out), transform var(--tap) var(--ease-out);
}

/* freccina */
.result::before {
  content: "";
  position: absolute;
  bottom: 102%;
  left: 50%;
  transform: translateX(-50%);
  border: .5em solid transparent;
  border-top-color: whitesmoke;
  opacity: 0;
  transition: opacity var(--tap) var(--ease-out);
}

/* stato visibile */
.result.tip-on::after,
.result.tip-on::before {
  opacity: 1;
  transform: translateX(-50%) scale(1.3);
}


.results {
  /* .14em = the phone's 2.25px (it was .6vw, which grew with the screen's
     width rather than the column). */
  grid-column-gap: .14em;
  grid-row-gap: .14em;
  grid-template-rows: auto;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
  grid-auto-columns: 1fr;
  height: 65%;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  display: grid;
}

.result {
  background-color: var(--zone-bg);
  border: .125em solid var(--zone-border); /* 2px on the phone */
  border-radius: .5em; /* 8px on the phone */
  /* The background art behind the tile is blurred, so its shapes don't
     read as part of the combination's symbol. */
  -webkit-backdrop-filter: blur(.375em);
  backdrop-filter: blur(.375em);
}

/* The symbol of each combination is one drawing (resources/images/g1.svg ... g8.svg, a plain glyph), painted in a colour:
   an element inside the box (.rico) is cut out by a mask, like the symbols of the tiles, so a background only has to say
   which colour with --result-icon (white by default; a pale sky asks for a colour of its own), and --result-icon-on for the
   combination the dice make (white). No second set of drawings for any theme. (The box's own ::before and ::after are the
   bubble that names the combination.) */
.rico {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-color: var(--result-icon, #fffeff);
  -webkit-mask: var(--result-img) center / 100% no-repeat;
  mask: var(--result-img) center / 100% no-repeat;
}

#rr0 { --result-img: url("/resources/images/g1.svg"); }
#rr1 { --result-img: url("/resources/images/g2.svg"); }
#rr2 { --result-img: url("/resources/images/g3.svg"); }
#rr3 { --result-img: url("/resources/images/g4.svg"); }
#rr4 { --result-img: url("/resources/images/g5.svg"); }
#rr5 { --result-img: url("/resources/images/g6.svg"); }
#rr6 { --result-img: url("/resources/images/g7.svg"); }
#rr7 { --result-img: url("/resources/images/g8.svg"); }

.result.highlighted {
  background-color: var(--result-on);
}

.result.highlighted .rico {
  background-color: var(--result-icon-on, #fffeff);
}

.calls {
  grid-column-gap: .14em;
  grid-row-gap: .14em;
  grid-template-rows: auto;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
  grid-auto-columns: 1fr;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  display: grid;
}

.call {
  height: 30%;
  background-color: var(--zone-bg);
  border: .125em solid var(--zone-border); /* 2px on the phone */
  border-radius: 20px;
  margin: .5em .25em 1em;
  visibility: hidden;
  margin-top: calc(var(--game-h) * .01);
}

.call.selectable {
  visibility: visible;
}

/* The checked look is a plain style, not the end of a "forwards" animation:
   a filled animation keeps a transform on the element for good, which puts
   it on its own layer and softens its edges. The animation is only the lift. */
.call.checked {
  background-color: #ffea00;
  border: .125em solid var(--call-on-border);
  border-radius: 20px;
  margin: .5em .25em .7em; /* .7em = the phone's 3vw */
  animation: bounceCall .3s ease-out; /* 2.7.0 timing */
}




/* ============================================
   DICE SECTION
   ============================================ */
.div-dice {
  grid-template-rows: auto;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
  grid-auto-columns: 1fr;
  place-items: center;
  height: calc(var(--game-h) * .1);
  max-height: 45%;
  width: var(--board-w);
  margin: auto;
  margin-top: 0;
  display: grid;
  order: 4;
  /* The dice size their corners and selection ring off this tray (cqi
     units in .die), not off the column's font. */
  container-type: inline-size;
}

/* Portrait: a die is 17% of the tray's width (each in its own fifth, so the row is a
   little narrower than the board, on purpose), or as tall as the height allows. The tray
   is a little taller than the die (as it always was: a tenth of the screen), the die
   centered in it. The room left over in the column is shared in equal parts below each
   row (auto margins, see the rows' margins), so the spaces between rows are alike.
   (The landscape layout sizes all of this its own way, below.) */
@media (orientation: portrait) {
  .div-dice {
    --die: min(calc(var(--board-w) * .17), calc(var(--game-h) * .095));
    /* The air around the die is 37% of it on a phone of today's size, and goes down to
       nothing as the screen gets shorter, so the column still fits above the banner. */
    height: calc(var(--die) + clamp(0px, calc((var(--game-h) - 560px) * .15), calc(var(--die) * .37)));
    max-height: none;
  }

  .div-dice .wrapDie {
    width: var(--die);
  }
}

.wrapDie {
  aspect-ratio: 1/1;
  isolation: isolate; /* the die's shadow sits behind its picture, inside this box */
  width: 85%;
  /* Whole even pixels (so also whole device pixels at 2x/3x): the dice are a
     sprite scaled to the box, and at a fractional size like 60.56px the
     sprite's thick outline rasterizes a pixel thinner on one side, which
     reads as the die being slightly off-center. */
  width: round(down, 85%, 2px);
  background-position: 50%;
  transition: transform var(--tap) var(--ease-out);
  /* A layer of its own all the time: a die that starts its tap animation would otherwise become a new layer in the middle of the
     others, and the browser paints all of them again over one frame (seen on a phone as every die dropping out for an instant). */
  will-change: transform;
}

/* Game over: dice, results/calls and ROLL are dead weight and get dimmed
   to the exact same 0.5 the bot's-turn dimming uses (see divsOpacity in
   linotte.js), while DONE stays 100% visible and clickable — it still
   works, reopening the winner overlay if the player dismissed it to look
   at the board. !important because #div-dice/#div-resultsAndCalls/
   #div-buttons also carry a per-turn inline opacity from divsOpacity()
   (dimming whichever side isn't the local player's turn) — an inline
   style otherwise always outranks this class, so without it a game that
   ends on "my turn" (opacity:1 inline) would silently keep everything
   fully visible instead of dimming it. */
.game-over-dim {
  opacity: 0.5 !important;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.die {
  /* em scale proportional to the die itself (a die is 17% of the tray's
     width, or the tray's height when that's smaller -- see .wrapDie), so its
     corner radius and selection ring look the same on a phone and a tablet:
     16px for the phone's 60px die. */
  font-size: round(down, calc(min(17cqi, 100cqh) * .2667), 1px);
  border-radius: 0.75em;
  position: relative;
  /* how far inside the picture the shadow's square sits (see ::before) */
  --die-gap: .1875em;
  width: 100%;
  aspect-ratio: 1 / 1;
  background-repeat: no-repeat;
  /* 7 faces */
  background-size: 700% 100%;
  /* No translateZ(0)/will-change: they gave every die its own compositor
     layer, rasterized at a fractional offset (blurry, uneven outline) --
     only visible until the die was selected, because the selection
     animation swaps the transform out. */
}

.die::before {
  /* The shadow and the selection ring are not drawn by the die itself but by a square a few px smaller, concentric
     and behind its picture: the picture's corners never match the box's exactly, and this way whatever is left
     uncovered at a corner is filled by the shadow (or the yellow of the ring) instead of showing the table. Their
     spread grows by the same gap, so the outside is exactly where it was. */
  content: "";
  position: absolute;
  inset: var(--die-gap);
  border-radius: inherit;
  z-index: -1;
  pointer-events: none;
}

.die.black-shadow::before {
  box-shadow: rgb(0, 0, 0, .4) .1875em .3125em .4375em calc(.1875em + var(--die-gap));
}

/* the red die has its own, hotter shadow */
.die.red-shadow::before {
  box-shadow: rgba(255, 59, 59, 0.6) .3125em .3125em .625em calc(.125em + var(--die-gap));
}

/* Same idea as .call.checked: the ring is a plain style (declared after
   .die.black-shadow/.red-shadow, so it replaces their shadow), and the
   press animation doesn't stay filled on the die afterwards. */
.die.selected::before {
  box-shadow: rgb(255, 234, 0) 0 0 0 calc(var(--select-ring, .3125em) + var(--die-gap));
}

/* The press is played by the wrapper, on its own `scale` (it composes with the wrapper's tilt): a transform on the die
   itself would make it a layer of its own, and the square behind its picture (::before) would jump in front of it
   for the length of the animation. */
.wrapDie:has(> .die.selected) {
  animation: bounceDieWrap .3s ease-out; /* 2.7.0 timing */
}

/* (the generic .selected below gives a ring and a press to everything else; a die takes neither: see above and ::before) */
.die.selected {
  box-shadow: none;
  animation: none;
}

/* The selection ring is .3em of the element's own font size, so the larger
   text of the section titles and the FLIP/PLAY style buttons made it much
   thicker than on the 16px icon/option selections. Same px for all of them. */
.title.selected,
.opt-btn.selected {
  --select-ring: 4.8px;
}

.die::after {
  opacity: 1;
  width: 100%;
  aspect-ratio: 1 / 1;
  box-shadow: rgb(65, 252, 18) .1875em .3125em .4375em .1875em;
}


/* A visible place for the keyboard (and the switch and the screen reader's cursor): a ring on whatever is
   focused, only when it is the keyboard that focused it. */
[role="button"]:focus-visible,
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: .1875em solid #1f4fd8;
  outline-offset: .125em;
}

/* ============================================
   BUTTON SECTION
   ============================================ */
.div-buttons {
  grid-column-gap: 5vh;
  grid-row-gap: 0;
  grid-template-rows: auto;
  grid-template-columns: 1fr 1fr;
  grid-auto-columns: 1fr;
  place-items: center;
  margin: auto;
  margin-top: var(--gap);
  display: grid;
  user-select: none;
  order: 5;
  width: var(--board-w);
  /* Nudged to the middle of the room between the dice and the banner, without
     moving anything else (see centerButtons in linotte.js). */
  position: relative;
  top: var(--btn-shift, 0px);
}

.flex-block {
  --gap: calc(var(--game-h) * .01); /* a row's fixed top margin (the room left over is shared by auto margins) */
}

.button {
  border-radius: .5625em; /* 9px at 16px */
  width: 100%;
  /* Whole even pixels so the left/right borders land on the device pixel grid
     instead of rendering a pixel thicker on one side. */
  width: round(down, 100%, 2px);
  min-height: 3em;
  max-height: 6em;
  margin: auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* One border for every button (ROLL/DONE, end-game DONE, home modes,
   online sheets, NEW GAME, chat, the help page's play button, the demos'
   restart/close and ROLL/DONE): 3px of black at 50% over the button's own
   colour, so each one reads as a darker shade of itself at the same
   strength. Chosen by eye next to the round icons (options, back), whose
   circle and lines are 13 units of 180.86 -- 2.88px on the phone's 40px
   icon.
   Where the icons grow with the game (the demos' buttons, the winner card)
   the borders grow with them. Every thickness is the phone's value in the
   element's own em (or the card's cqw), so it keeps its proportion whenever
   the element is scaled. ROLL/DONE are a step heavier, below. */
:root {
  --btn-border-color: rgba(0, 0, 0, .5);
  /* em, resolved on each button: 3px at 16px (home, sheets, menus), and
     proportionally less on the short-screen sheets' 13px. */
  --btn-border: .1875em solid var(--btn-border-color);
}

.button {
  border: var(--btn-border);
}

/* ROLL/DONE (and the end-of-game DONE) are a step heavier: 4px on the
   phone (.25em of the column's 16px), growing with the game on a tablet.
   The demos are a smaller copy of the game (13px em on the phone), so the
   same .25em keeps their ROLL/DONE in proportion (3.25px there). */
.flex-block .button,
.demo-rail .button {
  border: .25em solid var(--btn-border-color);
}

/* Press feedback, the same on every button: it sinks a little and darkens
   while the finger is on it, and springs back on release. Driven by the
   .is-pressed class (set on pointerdown in linotte.js, held for at least a
   moment) instead of :active, which iOS Safari only applies to elements
   with touch listeners and which a quick tap ends before it shows. */
.button,
.lu-btn,
.winner-button,
.chat-fab,
.options,
#icon-back,
#winner-icon-back,
.rules-play,
.demo-icon-btn,
.home-profile,
.home-pro,
.home-settings,
.home-extra,
.home-ad {
  transition: transform var(--tap) var(--ease-out), filter var(--tap) var(--ease-out);
}

.is-pressed {
  transform: scale(.94);
  filter: brightness(.85);
  transition-duration: 60ms;
}

/* Not usable right now (DONE before the turn's first roll, ROLL with no
   rolls left): washed out towards grey, and it doesn't react to a press.
   Opaque on purpose: with opacity the player's background showed through
   and tinted it (a green background made ROLL look green). */
.button.is-inactive,
#consent-continue[aria-disabled="true"] {
  filter: saturate(.3) contrast(.55) brightness(1.2);
  cursor: default;
}

/* setBotControlsDisabled() sets this during the bot's turn — without this
   rule it was purely an accessibility hint with no visual/interactive
   effect, so roll/done (and the dice/results/calls it's also applied to)
   still looked and felt tappable even though clicks were already no-ops.
   Opacity during the bot's turn is handled uniformly by divsOpacity()'s
   container-level opacity (div-dice/div-resultsAndCalls/div-buttons all
   set to the same value) instead of here, so dice, calls and buttons all
   end up at the exact same dimmed level — a per-element opacity rule here
   too would stack on top of the container's and double-dim just the
   buttons. */
[aria-disabled="true"] {
  pointer-events: none;
}

.button.done {
  background-color: rgb(70, 94, 228);
}

/* Layers of their own all the time (same reason as .wrapDie): a press or a nudge that makes one of them a layer in the
   middle of the others made the ROLL button drop out for a frame when its counter changed. */
.button.roll,
.button.done {
  will-change: transform;
}

.button.roll {
  background-color: rgb(250, 59, 151);
}

/* DONE, when it is the next thing to do and nothing was touched for a while
   (see "NUDGING THE DONE BUTTON" in linotte.js; ROLL does the same at the start of a turn): a small shake, then a rest, in
   a loop. */
.button.done.nudge,
.button.roll.nudge {
  animation: doneNudge 2.6s ease-in-out infinite;
}

@keyframes doneNudge {
  0%, 22%, 100% { transform: none; }
  3% { transform: translateX(-3px) rotate(-2deg); }
  6% { transform: translateX(3px) rotate(2deg); }
  9% { transform: translateX(-2.5px) rotate(-1.6deg); }
  12% { transform: translateX(2.5px) rotate(1.6deg); }
  15% { transform: translateX(-1.5px) rotate(-1deg); }
  18% { transform: translateX(1.5px) rotate(1deg); }
}

@media (prefers-reduced-motion: reduce) {
  .button.done.nudge,
  .button.roll.nudge { animation: none; }
}

/* Vs-bot only: swapped in for ROLL+DONE while it's the bot's turn (see
   divsOpacity() in linotte.js), spanning both grid columns so it reads as
   one centered status line instead of sitting in a single button slot. */
.turn-label {
  grid-column: 1 / -1;
  min-height: 3em;
  max-height: 6em;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .1em;
}

/* The opponent's roll, like the ROLL button's own count: what they have left. */
.turn-label-roll {
  font-family: "Changa One", sans-serif;
  font-size: 1.05em;
  letter-spacing: .04em;
  color: var(--ink-bg-soft);
}

/* font-size lives on the child, not .turn-label itself -- same split as
   .button/.text-button -- so this element's own min-height:3em above
   resolves against the same root em .button's does, instead of against
   its own (then much larger) font-size and ending up visibly taller. */
.turn-label-text {
  font-family: "Changa One", sans-serif;
  font-size: 1.6em;
  color: var(--ink-bg);
  text-shadow: var(--ink-bg-shadow);
  text-align: center;
}

/* Vs-bot only: replaces ROLL+DONE once the game is over (see
   checkGameOver() in linotte.js) -- green instead of DONE's usual blue so
   it doesn't read as "one more normal turn", it's the one button left. */
.button.end-game-done {
  grid-column: 1 / -1;
  width: 60%;
  background-color: rgb(46, 160, 90);
}

.text-button {
  color: #fff;
  margin: auto;
  font-size: 2em;
  font-weight: 400;
  line-height: 100%;
  text-decoration: none;
}


/* ============================================
   RESPONSIVE: TABLET / DESKTOP / LANDSCAPE
   ============================================ */

@media (orientation: portrait) and (min-width: 600px) {
  .flex-block {
    /* The phone's own column-to-height ratio (375 / 812 = 46.18%), so a
       tablet shows the phone scaled up: the board, the player boxes, the
       strip, the dice and ROLL/DONE all grow by the same factor. With 64dvh
       the board and the strip grew with the width while the font (and so
       everything sized in em) was held back by the height: on an iPad the
       board was 30 ems wide instead of 22, ROLL/DONE came out flat, the
       player boxes squarer, the countdown squashed, and DONE touched the
       bottom edge. */
    --col-w: min(700px, calc(var(--game-h) * .4618));
    max-width: var(--col-w);
  }
}

/* Landscape (phones rotated, tablets, desktop): a tall column no longer
   fits the viewport height at all, so the board and the rest of the UI
   sit side by side instead, each sized off the shared height budget. */
@media (orientation: landscape) {
  .flex-block {
    /* One spacing step from the 8/16/24 scale for the screen edges, the
       board-to-rail gap and the gaps inside the rail (8px on short phones,
       see below). */
    --edge: 16px;
    --inset-x: calc(env(safe-area-inset-left, 0px) + env(safe-area-inset-right, 0px));
    --inset-y: calc(env(safe-area-inset-top, 0px) + env(safe-area-inset-bottom, 0px));
    --side-chrome: calc(3 * var(--edge) + var(--inset-x)); /* gap + left/right padding below, kept in sync */
    /* The rail never gets narrower than 360px (that's what lets its eight
       combination tiles reach a ~44px touch target), except on very small
       phones, where it stops at half the screen so the board stays playable. */
    --rail-min: min(max(360px, 34vw), 50vw);
    /* The board is a square sized off the height, but always leaves the
       rail its minimum width, and never takes more than the share of the
       width it has on a landscape phone (rail about 1.2x the board): with
       58vw a 1024x768 tablet got a 594px board next to a rail no wider
       than a phone's, so every control looked shrunk beside the board. */
    --board: min(calc(var(--game-h) * .94), calc(var(--game-h) - var(--inset-y)), 900px,
      calc((100vw - var(--side-chrome)) / 2.2),
      calc(100vw - var(--rail-min) - var(--side-chrome)));
    /* ...and the sidebar takes whatever width is left, up to 700px (the
       portrait column's limit). The font (and so every control in it)
       scales with that width. */
    --side-w: min(calc(100vw - var(--board) - var(--side-chrome)), 700px);
    /* The game column inside the rail keeps the size it has next to the
       board in portrait: about the board's width (375px column, 356px board
       on the phone). Sized off the rail's width alone it grew to 450px+ on
       a landscape phone, everything in it looked oversized and, with the
       browser's bars taking height, no longer fitted. */
    --col-w0: min(var(--side-w), calc(var(--board) * 1.05));
    /* ...then about 20% larger, taking the room out of the gaps between the
       rows: never wider than the rail, never taller than the board can hold
       (the rows add up to about 0.72 x the column's width, plus the gaps). */
    --col-w: min(var(--side-w), calc(var(--board) * 1.24),
      calc((var(--board) - 3 * var(--edge)) / .72));
    --board-w: var(--board);
    font-size: round(down, calc(var(--col-w) * 0.04267), 1px);
    flex-flow: row nowrap;
    max-width: none;
    width: 100%;
    height: calc(var(--vh) * 100 - var(--ad-h));
    height: var(--game-h);
    min-height: 0;
    gap: var(--edge);
    padding: env(safe-area-inset-top, 0px) max(var(--edge), env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(var(--edge), env(safe-area-inset-left, 0px));
  }

  .div-table {
    order: 1;
    width: auto;
    height: var(--board);
    aspect-ratio: 1 / 1;
    margin: 0;
    flex: 0 0 auto;
  }

  /* The rail is the phone's column, scaled to the rail's width: every row
     keeps the size and proportions it has in portrait (square combination
     tiles, the same player boxes, dice and buttons centred). The rows run
     the board's full height -- the players line up with its top edge,
     ROLL/DONE with its bottom edge -- with equal gaps in between. */
  .side-panel {
    display: flex;
    flex-flow: column;
    justify-content: space-between;
    order: 2;
    /* On a phone that's the board's height; on a tablet the board is much
       taller than the rows need, so the rail stops at about its own width
       and sits centred beside the board instead of spreading its rows
       100px apart. */
    height: min(var(--board), calc(var(--col-w) * 1.05));
    width: var(--side-w);
    /* The rail spans the space next to the board; its rows use the game
       column's width (--col-w), centred in it. */
    padding-inline: calc((var(--side-w) - var(--col-w)) / 2);
    flex: 0 0 auto;
    gap: var(--edge);
  }

  /* The four rows share one width and one centre line, so they stack as a
     single block (in portrait the buttons were 90%: here all are 95%). */
  .side-panel>.div-info,
  .side-panel>.div-resultsAndCalls,
  .side-panel>.div-dice,
  .side-panel>.div-buttons {
    flex: 0 0 auto;
    width: 95%;
    margin: 0 auto;
  }

  /* Portrait's 10dvh tall info row, as a share of the column's width
     (81px on the 375px phone), so the player boxes keep their shape. */
  .side-panel>.div-info {
    height: calc(var(--col-w) * .216);
    grid-template-columns: max(12%, 44px) auto max(12%, 44px);
  }

  /* Dice sized by width as in portrait (10dvh would be far too short on a
     landscape phone); the row grows to fit them. */
  .side-panel>.div-dice {
    height: auto;
    max-height: none;
    padding-block: 4px;
  }

  /* ROLL/DONE keep the size they had before the rows grew (the --col-w0
     font): only their width follows the shared column. */
  .side-panel>.div-buttons {
    font-size: round(down, calc(var(--col-w0) * 0.04267), 1px);
  }

  /* The call pills were sized in vw/dvh, which on a wide, short screen made
     them thinner and their "called" lift twice as tall. In em they keep the
     portrait phone's proportions (8px gap, 8.4px pill, 11px lift at 16px). */
  .side-panel .call {
    height: .525em;
    margin-top: .5em;
  }

  .side-panel .call.checked {
    margin-bottom: .7em;
  }

  /* Portrait's .6vw gap (2.25px on the phone) was 5px here, which made the
     combination tiles narrower than tall. */
  .side-panel .results,
  .side-panel .calls {
    gap: .14em;
  }

  /* 44px minimum touch targets, whatever the rail's font size works out to. */
  .side-panel .button.roll,
  .side-panel .button.done,
  .side-panel .button.end-game-done {
    min-height: max(3.2em, 44px);
  }

  /* The menu button: not the 44px of a touch target (it came out as tall as a player's
     box); a little smaller, centered in height on the players' boxes. */
  .side-panel .options {
    width: max(2.1em, 32px);
  }

  /* FLIP in landscape: turning the whole page would swap the board over to
     the other side of the screen. Here the board doesn't move by a pixel:
     only the game column (and the full-screen panels that belong to the
     player whose turn it is) turn upside down, in place. The tile symbols
     still turn (body.table-flipped .tile::before, above). */
  body.table-flipped .div-table {
    transform: none;
  }

  body.table-flipped .fairy-canvas {
    rotate: none;
  }

  .side-panel,
  #options-overlay,
  #winner-overlay {
    transition: rotate .6s ease;
  }

  body.table-flipped .side-panel,
  body.table-flipped #options-overlay,
  body.table-flipped #winner-overlay {
    rotate: 180deg;
  }
}

/* Short landscape phones: the next step down the spacing scale. */
@media (orientation: landscape) and (max-height: 430px) {
  .flex-block {
    --edge: 8px;
  }
}

/* Rotating or resizing the window re-lays everything out at once; nothing
   may animate that reflow itself (it reads as the UI sliding around). The
   class is set for a moment by the resize handler in linotte.js. */
html.is-resizing *,
html.is-resizing *::before,
html.is-resizing *::after {
  transition: none !important;
}

/* Reduced motion: the always-on loops stop; what answers a tap stays, shortened. */
@media (prefers-reduced-motion: reduce) {
  .player.current::before {
    animation: none;
  }

  .is-pressed {
    transform: none;
  }

  .wrapDie:has(> .die.selected),
  .selected {
    animation-duration: 0.01ms;
  }
}




/* ============================================
    HOME SCREEN
   ============================================ */
/* The home screen lives in home.css. */

/* SOON: on anything shown but not working yet (sign-in, purchases, shop,
   stats). In em, so it keeps its proportion with the element it sits on:
   10px on the phone's 16px buttons. Those elements still answer a tap
   with a short "coming soon" message. */
.has-soon {
  position: relative;
}

.soon-badge {
  position: absolute;
  top: -.55em;
  right: -.4em;
  z-index: 1;
  padding: 0 .5em;
  border-radius: .5em;
  background: #3d240c;
  color: #fff;
  font: 600 .625rem / 1.6 system-ui, sans-serif;
  font-size: .625em;
  letter-spacing: .02em;
  pointer-events: none;
  white-space: nowrap;
}


/* ============================================
    OPTIONS OVERLAY
   ============================================ */

.options-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

/* Opened from the home screen: above it, and without the Game tab (the
   modes are on the home itself). */
.options-overlay[data-context="home"] {
  z-index: 65;
}

.options-overlay[data-context="home"] #icon-tab1 {
  display: none;
}



/* HOME in the Game tab. */
.game-home {
  display: flex;
  justify-content: center;
  padding: 0 5%;
}

.button.game-home-btn {
  width: 90%;
  min-height: 3em;
  margin: 1em auto 0;
  background-color: rgb(150, 130, 110);
}

/* Settings are a single phone-width column on every screen size; on wide
   screens it's centered instead of stretching its rows across the window. */
.opt-header,
.opt-pages {
  width: 100%;
  max-width: 520px;
}

.hidden {
  display: none;
}

.opt-bg {
  position: absolute;
  inset: 0;
  background-image: var(--own-bg, var(--default-bg));
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  z-index: -1;
}

/* options overlay header */
.opt-header {
  position: relative;
  display: grid;
  /* back, Game, Options, Help, Ranking, Stats, Level road */
  grid-template-columns: repeat(7, 1fr);
  align-items: center;
  height: 60px;
  padding: 0 14px;
  box-sizing: border-box;
  /* A layer of its own all the time (see .div-table): the tab icons were seen to vanish for one frame every few seconds
     over a moving sky. */
  will-change: transform;
}

.icon {
  display: block;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  height: 36px;
  aspect-ratio: 1/1;
  margin: 0;
  justify-self: center;
}

/* The arrow is drawn by ::after. Opened from the home, the menu's header
   takes the home's scale and its top bar's box, so the arrow sits exactly
   where the home's options icon was, and that icon's gear (::before) turns
   into the arrow. */
#icon-back {
  position: relative;
}

#icon-back::after,
.options-overlay[data-context="home"] #icon-back::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("resources/images/t001.svg") center / contain no-repeat;
}

.options-overlay[data-context="home"] #icon-back::before {
  background-image: url("resources/images/g10455.svg");
  animation: iconMorphOut var(--morph) var(--ease-out) forwards;
}

.options-overlay[data-context="home"] #icon-back::after {
  animation: iconMorphIn var(--morph) var(--ease-out) both;
}

/* The two rings are the same circle, so turning them shows only the
   symbol inside changing. */
:root {
  --morph: 320ms;
}

@keyframes iconMorphOut {
  to { opacity: 0; transform: rotate(-120deg); }
}

@keyframes iconMorphIn {
  from { opacity: 0; transform: rotate(120deg); }
}

@media (prefers-reduced-motion: reduce) {
  @keyframes iconMorphOut { to { opacity: 0; } }
  @keyframes iconMorphIn { from { opacity: 0; } }
}

/* The header in the home's units and in its top bar's box (.home-top: the
   same width, top padding and height), the back arrow first in it like the
   options icon, the two tabs centred. */
.options-overlay[data-context="home"] .opt-header {
  font-size: var(--home-scale);
  width: min(100% - 2em, 26.875em);
  max-width: none;
  height: 2.75em;
  margin: .75em 0 1em;
  padding: 0;
  /* back, Options, Help, Ranking, Stats, Level road: spread over the bar */
  grid-template-columns: repeat(6, auto);
  justify-content: space-between;
}

.options-overlay[data-context="home"] .icon {
  height: 2.75em;
  margin: 0;
}

.options-overlay[data-context="home"] #icon-back {
  justify-self: start;
}

.options-overlay[data-context="home"] .icon {
  justify-self: auto;
}

.options-overlay[data-context="home"] .tab-indicator {
  margin-top: 0;
  top: calc(100% + .625em);
  width: 3em;
  height: .5em;
  border-radius: .25em;
}

@media (orientation: landscape) {
  .options-overlay[data-context="home"] .opt-header {
    width: calc(100% - 2em);
  }
}

#icon-tab1 {
  background-image: url("resources/images/t002.svg");
}

#icon-tab2 {
  background-image: url("resources/images/t003.svg");
}

#icon-tab3 {
  background-image: url("resources/images/t004.svg");
}

#icon-tab4 {
  background-image: url("resources/images/ranking.svg");
}

#icon-tab5 {
  background-image: url("resources/images/stats.svg");
}

#icon-tab6 {
  background-image: url("resources/images/levelroad.svg");
}

/* The menu over a winner screen (opened from the level-up's LEVEL ROAD):
   above the winner card (70) and the sheets (90), under the toasts (95). */
.options-overlay.is-top {
  z-index: 94;
}


/* ---------- the menu's pages share one look ----------
   Game, Options and Help in the same translucent card as Ranking, Stats
   (see .opt-sheet.sheet above): a heading in Changa One, no outlined pill,
   thin lines between the sections. */
.opt-sheet .title,
.opt-flow .title {
  width: auto;
  height: auto;
  margin: 0 0 .5em;
  border: 0;
  border-radius: 0;
  font-family: "Changa One", sans-serif;
  font-weight: 400;
  font-size: 1.5em;
  line-height: 1.1;
  color: var(--ink);
  -webkit-text-fill-color: var(--ink);
}

.opt-flow #rules-goal,
.opt-sheet #rules-goal,
#page-game .opt-sheet .title {
  font-size: 1.9em;
}

.opt-sheet section {
  width: 100%;
  margin: 0;
}

.opt-sheet section + section,
.opt-sheet .separator + section + section {
  padding-top: .9em;
  border-top: 1px solid rgba(0, 0, 0, .15);
}

.opt-sheet .separator {
  display: none;
}

.opt-sheet .car-list-wrapper {
  width: 100%;
}

/* The translucent white of the buttons would vanish on the card. */
.opt-sheet .opt-btn,
.opt-flow .opt-btn {
  background-color: rgba(0, 0, 0, .08);
}

/* Help: the text sits straight on the card. */
:is(.opt-sheet, .opt-flow) .rules {
  padding-bottom: 0;
}

:is(.opt-sheet, .opt-flow) .rules-section {
  margin-bottom: 0;
}

.opt-sheet .rules-section + .rules-section {
  margin-top: .9em;
}

:is(.opt-sheet, .opt-flow) .rules-section > .rules-block,
:is(.opt-sheet, .opt-flow) .rules-combos,
:is(.opt-sheet, .opt-flow) .rules-foot {
  width: 100%;
}

:is(.opt-sheet, .opt-flow) .rules-block {
  padding: 0;
  background: none;
}

:is(.opt-sheet, .opt-flow) .rules-combos .rules-block {
  padding: 0;
  min-height: 0;
}

:is(.opt-sheet, .opt-flow) .rules-block.rules-score {
  padding: 0;
}

:is(.opt-sheet, .opt-flow) .rules-icon {
  background-color: rgba(0, 0, 0, .5);
  border-color: rgba(0, 0, 0, .35);
}

.opt-sheet .rules-foot {
  margin-top: 1.5em;
  border-top-color: rgba(0, 0, 0, .15);
}


.opt-flow .separator {
  display: none;
}

/* Captions under a title: what is chosen now (the titles themselves stay). */
.opt-current {
  margin: -.3em 0 .6em;
  text-align: center;
  font-family: "Changa One", sans-serif;
  font-size: .95em;
  color: var(--ink);
  opacity: .65;
}

.opt-current:empty {
  display: none;
}

/* Help: one card per section, like the level road's, straight on the
   background. */
.opt-flow .rules {
  padding: 0 .8em 1.5em;
  display: flex;
  flex-direction: column;
  gap: .7em;
}

.opt-flow .rules-section,
.opt-flow .rules-foot {
  margin: 0;
  width: auto;
  padding: .75em .9em .9em;
  box-sizing: border-box;
  border: .125em solid rgba(0, 0, 0, .18);
  border-radius: .9em;
  background: rgba(255, 255, 255, .88);
  color: var(--ink);
}

/* A page title in its own island, like the level road's and Options'. It has no
   margin: the space to the next island is the stack's own gap (.7em of the
   page, 11.2px), the same between every two islands of every page. */
.page-heading {
  margin: 0;
  padding: .3em .6em .35em;
  text-align: center;
  font: 1.7em/1.1 "Changa One", sans-serif;
  border-radius: .55em;
  background: rgba(255, 255, 255, .88);
  border: .075em solid rgba(0, 0, 0, .18);
  color: var(--ink);
}

/* The end of the help page is not about how to play: a short thick line, more room than between the
   instruction islands, and a title of its own (see "About Linotte" in index.html). */
.rules-about-sep {
  height: 0;
  width: 28%;
  margin: 1.9em auto .9em;
  border-top: .25em solid rgba(0, 0, 0, .3);
  border-radius: 999px;
}

/* Options: one island per option, like the help's sections. */
.opt-stack {
  padding: 0 .8em 1.5em;
  display: flex;
  flex-direction: column;
  gap: .7em;
}

.opt-flow section {
  margin: 0;
  padding: .75em .9em .9em;
  box-sizing: border-box;
  border: .125em solid rgba(0, 0, 0, .18);
  border-radius: .9em;
  background: rgba(255, 255, 255, .88);
  color: var(--ink);
  text-align: center;
}

.opt-flow .car-list-wrapper {
  width: 100%;
}

/* Stats, ranking: the sheets' content, in a translucent card on the menu's
   background. */
.opt-sheet.sheet {
  width: auto;
  max-height: none;
  overflow: visible;
  margin: 0 .8em 1.5em;
  /* The same island as Options', the help's and the road's: border, corners,
     background and padding (the .sheet of the dialogs has a thicker border and
     rounder corners). */
  padding: .75em .9em .9em;
  border: .125em solid rgba(0, 0, 0, .18);
  border-radius: .9em;
  background: rgba(255, 255, 255, .88);
  box-shadow: none;
  font-size: 16px;
}

.opt-sheet .sheet-view {
  display: flex;
}

#icon-tab1.disabled {
  opacity: 0.35;
  pointer-events: none; /* click disabled*/
  cursor: default;
}

.tab-indicator {
  margin-top: 70px;
  position: absolute;
  height: 8px;
  width: 60px;
  background: black;
  opacity: 50%;
  border-radius: 4px;
  transition: left var(--state) var(--ease-out);
}

/* A page that comes in by a swipe slides in from the side it came from. */
.opt-page.slide-in-next {
  animation: optSlideNext .24s ease-out;
}

.opt-page.slide-in-prev {
  animation: optSlidePrev .24s ease-out;
}

@keyframes optSlideNext { from { opacity: 0; transform: translateX(32px); } }
@keyframes optSlidePrev { from { opacity: 0; transform: translateX(-32px); } }

@media (prefers-reduced-motion: reduce) {
  .opt-page.slide-in-next,
  .opt-page.slide-in-prev {
    animation: none;
  }
}

/* pages */
.opt-pages {
  flex: 1;
  overflow: hidden;
  margin-top: 1em;
}

.opt-page {
  height: 100%;
  overflow-y: auto;
}

.opt-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  /* Same box the sound icons draw into their SVGs (white at 50% opacity,
     80x32, .4em radius) so text buttons here match the sound icons they replaced exactly;
     selection is the shared .selected glow ring. */
  background-color: rgba(255, 255, 255, .5);
  height: 32px;
  /* 80px like the sound icons, wider when the word is (RESTART, RICOMINCIA, RECOMMENCER). */
  width: auto;
  min-width: 80px;
  padding: 0 .7em;
  box-sizing: border-box;
  white-space: nowrap;
  border-radius: .4em;
  margin: auto;
  font-size: 1.2em;
}

/* The Game buttons stacked, the whole block as wide as its widest row (PAUSE and RESTART); GIVE UP is a row of
   its own under them, as wide as they are together. */
.game-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
}

/* The buttons in the first row are all as wide as the widest of them (RESTART, RICOMINCIA...), so GIVE UP
   under them lines up with their outer edges. */
.game-actions .car-list {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 14px;
  justify-content: center;
  /* room at the two ends for the yellow ring of a pressed button (PAUSE is on while paused): the list scrolls sideways,
     so it clips whatever sticks out of it, and these buttons have no spacers at the ends */
  padding-left: 8px;
  padding-right: 8px;
}

.game-actions .car-list::before,
.game-actions .car-list::after {
  display: none;
}

.game-actions .car-btn .opt-btn {
  width: 100%;
  min-width: 0;
}

.giveup-row {
  margin: .5em 8px .3em; /* the same 8px as the list above, so it lines up with the buttons' edges */
}

.giveup-row .opt-btn {
  width: 100%;
  margin: 0;
}

.car-btn {
  flex: none;
  height: 40px;
  background-color: transparent;
  scroll-snap-align: center;
  border-radius: 1em;
}

/* The switches island (sound, vibration, animations): a button with an icon for each, a word under it; yellow while on
   (.selected, the shared ring). */
.switches {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px 22px;
  padding: 8px 8px 2px; /* room for the ring of a pressed button */
}

.switch-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.switch-btn {
  cursor: pointer;
  margin: 0;
}

.switch-btn svg {
  display: block;
  width: 22px;
  height: 22px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.switch-btn svg .line {
  fill: none;
}

/* the speaker and the little stars are solid, the phone's outline is not */
.switch-btn svg rect {
  fill: none;
}

.switch-label {
  font-size: .95em;
  line-height: 1;
}

section {
  margin-bottom: 1vh;
  justify-items: center;
  margin-bottom: 2vh;
}

.title {
  height: 38px;
  width: 90%;
  margin: auto;
  border-radius: 10px;
  border: rgba(0, 0, 0, .5) solid 3px;
  display: flex;
  justify-content: center;
  align-content: center;
  /* 7vw alone grew without limit on wide screens (100px+ on a desktop,
     overlapping everything under it): capped at its 375px-phone size. */
  font-size: min(7vw, 26px);

    color: #000;
  -webkit-text-fill-color: #000;
  isolation: isolate;
}

.separator {
  height: 15px;
}

/* ============================================
   HELP: HOW TO PLAY
   Built from the same pieces as the other option tabs: each section opens
   with the .title pill, its text sits on the translucent white of .opt-btn,
   and each combination icon is the strip's own .result tile, standing
   straight on the background like it does under the board. Nothing is
   opaque or hard-coloured, so the page takes on whichever background the
   player picked. Changa One for headings and names, sans-serif for
   sentences, everything left-aligned.
   ============================================ */
.rules {
  padding-bottom: 24px;
}

.rules-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

/* .title is a div elsewhere; as a heading it must not pick up h2's own
   margins and bold weight. */
.title.rules-h {
  margin: 0 auto;
  font-weight: 400;
}

.rules-block {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px; /* same as .title */
  /* A touch more opaque than .opt-btn's .5, so long text stays readable
     on busy or dark backgrounds. */
  background-color: rgba(255, 255, 255, .62);
  color: #000;
  font-family: var(--text-font);
  font-size: 16px;
  line-height: 1.5;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Blocks that stand alone in a section line up with the .title pill above. */
.rules-section > .rules-block {
  width: 90%;
  margin: 0 auto;
}

.rules-block p {
  margin: 0;
}

.rules-steps {
  margin: 0;
  padding-left: 1.5em;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rules-steps li {
  padding-left: .2em;
}

.rules-steps li::marker {
  font-family: "Changa One", sans-serif;
}

.rules-note,
.rules-desc,
.rules-sub {
  color: rgba(0, 0, 0, .78);
}

.rules-combos {
  list-style: none;
  width: 90%;
  margin: 0 auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rules-combos > li {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.rules-combos .rules-block {
  gap: 0;
  padding: 8px 12px;
  min-height: 44px;
}

/* Exactly the strip's .result tile: translucent white, white frame. */
.rules-icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background-color: #ffffff5e;
  border: .125em solid #fff; /* 2px on the phone */
  overflow: hidden;
}

.rules-icon img {
  display: block;
  width: 100%;
  height: 100%;
}

.rules-name {
  display: block;
  font-family: "Changa One", sans-serif;
  font-size: 1.1em;
  line-height: 1.25;
}

.rules-desc {
  display: block;
}

.rules-sub {
  margin: 6px 0 0;
  padding-left: 1.1em;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* A table can't be a flex box: undo that part of .rules-block. */
.rules-block.rules-score {
  display: table;
  border-collapse: separate;
  border-spacing: 0;
  padding: 4px 14px;
  font-variant-numeric: tabular-nums;
}

.rules-score td {
  padding: 8px 0;
  border-bottom: 1px solid rgba(0, 0, 0, .1);
}

.rules-score tr:last-child td {
  border-bottom: 0;
}

.rules-score td:last-child {
  text-align: right;
  font-weight: 700;
}

/* Version, credits and the piece-design notice: set apart from the rules
   by space and a thin line (the app's black-at-low-opacity), straight on
   the background like the rest of the menu's plain text. */
.rules-foot {
  width: 90%;
  margin: 96px auto 0;
  padding-top: 20px;
  border-top: 1px solid rgba(0, 0, 0, .35);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--text-font);
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
  color: rgba(0, 0, 0, .78);
}

.rules-foot p {
  margin: 0;
}

.rules-foot a {
  color: inherit;
}

.rules-foot-name {
  font-family: "Changa One", sans-serif;
  font-size: 16px;
  color: #000;
}

.rules-foot-h {
  margin: 14px 0 0;
  font-family: "Changa One", sans-serif;
  font-weight: 400;
  font-size: 15px;
  color: #000;
}

.rules-credits {
  margin: 0;
  padding-left: 1.1em;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* carousel */
.car-list-wrapper {
  position: relative;
  width: 90%;
  display: block;
}

.car-list {
  display: flex;
  gap: 15px;
  padding: 2vh 0;
  min-width: 90%;
  margin: auto;
  list-style: none;
  overflow-x: scroll;
  /* No CSS snap at all: not `mandatory`, which cuts a swipe short, and not even `proximity`, which on a phone still takes the swipe
     over as soon as the finger is up (the items are close together, so every stop is "near" one). The swipe runs on with the phone's
     own momentum; where it ends, the list settles on the nearest item with a short slide (linotte.js, settleList). */
  scrollbar-width: none;
}

.car-list::before,
.car-list::after {
  content: "";
  flex: 0 0 12px;
}

/* Centred when it all fits; when it doesn't, it starts at the left and scrolls (a plain `justify-content: center` would
   cut off the start of an overflowing list, out of reach of the scrolling): the free space goes to margins on the two
   end spacers. */
.list-centered {
  justify-content: flex-start;
}

.list-centered::before {
  margin-left: auto;
}

.list-centered::after {
  margin-right: auto;
}

/* A list with arrows: room at its two ends, so the first and the last item are not under an arrow (36px wide, 6px out). */
.car-list-wrapper:has(> .car-button) .car-list::before,
.car-list-wrapper:has(> .car-button) .car-list::after {
  flex-basis: 38px;
}

.car-item {
  height: 70px;
  aspect-ratio: 1/1;
  background-color: transparent;
  scroll-snap-align: center;
  border-radius: 1em;
}

.car-item-content {
  height: 100%;
  overflow: hidden;
}

button.car-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;

  width: 36px;
  aspect-ratio: 1/1;
  box-sizing: border-box;

  /* The round buttons' recipe (see .rules-play): the shared border, translucent white, a dark
     chevron drawn with the same weight as the border. */
  background-color: rgba(255, 255, 255, .7);
  border: 3px solid var(--btn-border-color);
  border-radius: 50%;
  padding: 0;
  cursor: pointer;

  background-repeat: no-repeat;
  background-position: center;
  background-size: 52%;
}

/* A bigger area to tap than the drawn circle. */
button.car-button::before {
  content: "";
  position: absolute;
  inset: -6px;
}

button.car-button.previous {
  left: -6px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-opacity='.75' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 4.5 7.5 12 15 19.5'/%3E%3C/svg%3E");
}

button.car-button.next {
  right: -6px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-opacity='.75' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 4.5 16.5 12 9 19.5'/%3E%3C/svg%3E");
}

.flipped {
  /* Upside-down on purpose -- a visual pun for what it actually does now
     (see #flip-table-btn in linotte.js), not a "this is disabled" signal,
     so unlike before it no longer sits dimmed like an inert placeholder. */
  /* `rotate`, not `transform`: the shared .selected bounce animation ends on
     transform: scale(1) with fill-mode forwards, which would wipe a transform
     rotation the moment this button gets selected. */
  rotate: 180deg;
}

.car-item[hidden], #page-options section[hidden] {
  display: none !important;
}

/* a theme's card: the size and corners of the other options (its name is the line under the title). Its picture has the
   same rounded corners as theirs (transparent, in the png). */
.theme-options {
  cursor: pointer;
}

.theme-options img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The game is out of sight under the home or the options: nothing in it needs to move meanwhile. */
body.game-covered .flex-block,
body.game-covered .flex-block *,
body.game-covered .player.current::before {
  animation-play-state: paused !important;
}

.board-options,
.skin-options {
  border-radius: .35em; /* the board previews: the outline and corners of "Table style" */
}

.die-options {
  border-radius: 1em;
}

/* The background previews carry their own rounded corners (transparent, in the png: 14.4% of the side), so the
   selection ring follows them and nothing is clipped: the same for every one, locked or not. */
.car-item-content.bg-options,
.theme-options {
  overflow: visible;
  border-radius: 14.4%;
}

.selected {
  box-shadow: rgb(255, 234, 0) 0 0 0 var(--select-ring, .3125em);
  animation: bounceDie .3s ease-out; /* 2.7.0 timing */
}


/* ============================================
   COIN FLIP OVERLAY
   ============================================ */
/* Every class here is prefixed "flip-coin-" (or bare .flip-coin for the
   spinning element itself) -- the codebase already has a generic .coin
   class (the small points-icon in the player box, styled completely
   differently), and reusing that name here made this component silently
   hijack that unrelated element's styling (it also grabbed the same
   .coin selector, blowing the tiny points icon up to a 120px circle)
   instead of just not matching anything. */

.flip-coin-overlay.hidden {
  /* Same specificity as the bare .hidden{display:none} rule elsewhere in
     this file (one class each) — whichever is declared LAST in the
     stylesheet wins a tie, so on its own .hidden here would lose to this
     block's own display:flex below and never actually hide anything.
     The compound selector (two classes) outranks either alone,
     regardless of source order. */
  display: none;
}

.flip-coin-overlay {
  position: fixed;
  inset: 0;
  z-index: 80; /* above options-overlay (50) and winner-overlay (70) -- can be triggered from either flow */
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(4px);
}

.flip-coin-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.flip-coin-perspective {
  perspective: 600px;
}

.flip-coin {
  position: relative;
  width: 120px;
  height: 120px;
  transform-style: preserve-3d;
}

/* Flat color + solid border, same recipe as .button.roll/.button.done
   elsewhere in this file -- this app never uses gradients, so the coin
   doesn't either; its two faces read as a coin from the thick contrasting
   border ring alone, with a bold flat-color digit for the face itself. */
.flip-coin-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.flip-coin-digit {
  font-family: "Changa One", sans-serif;
  font-size: 2.8em;
  line-height: 1;
}

.flip-coin-front {
  background-color: rgb(232, 185, 35);
  border: .4em solid rgb(138, 103, 8);
}

.flip-coin-front .flip-coin-digit {
  color: rgb(138, 103, 8);
}

.flip-coin-back {
  background-color: rgb(205, 215, 222);
  border: .4em solid rgb(94, 116, 134);
  transform: rotateY(180deg);
}

.flip-coin-back .flip-coin-digit {
  color: rgb(94, 116, 134);
}

.flip-coin-result {
  font-family: "Changa One", sans-serif;
  color: #fff;
  font-size: 1.4em;
  min-height: 1.4em;
  text-align: center;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .5);
}


/* ============================================
   WINNER OVERLAY
   ============================================ */

.winner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 70;
  backdrop-filter: blur(5px);
}

/* The winner card is a square that scales as one piece: everything in it
   is sized in cqw (1cqw = 1% of the card's width), so rotating or resizing
   the screen changes its size but never its layout. The proportions are the
   portrait phone's original card (338px wide): 40px back icon, 112px piece,
   45px title, 30px points, 40px NEW GAME button. */
.modal {
  position: fixed;
  z-index: 100;
  /* Whichever side of the screen is shorter, so the whole square is always
     on screen, and never larger than a comfortable card on a tablet. */
  --card: min(90vw, 90dvh, 480px);
  width: var(--card);
  aspect-ratio: 1/1;
  container-type: size;
  margin: auto;
  opacity: 1;
  /* 6% of the card. Not 6cqw: on the card itself cqw measures the screen
     (its own container units only apply to its children), which made the
     corners far too round in landscape. */
  border-radius: calc(var(--card) * .06);
  /* The buttons' 3px on the phone's 337px card, scaling with the card
     (resolved in each child, where cqw means this card). */
  --winner-border: .891cqw solid var(--btn-border-color);
  background-color: whitesmoke;
  background-position: 0, 0;
  background-repeat: no-repeat;
  background-size: cover;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.modal::after {
  opacity: 0;
  transition: opacity 1s ease;
}

.winner-container {
  display: flex;
  margin: 0 auto;
  width: 90%;
  height: 100%;
}

.v-winner-table {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
}

.h-winner-table {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-top: 17cqw;
}

/* Pinned to the card's top-left corner (the card is the positioned box). */
#winner-icon-back {
  position: absolute;
  top: 4cqw;
  left: 3cqw;
  width: 11.8cqw;
  aspect-ratio: 1/1;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  background-image: url("resources/images/t001.svg");
  cursor: pointer;
}

.piece-popup-container {
  width: 33cqw;
  aspect-ratio: 1/1;
  border-radius: 3cqw;
  border: 1.187cqw solid rgba(0, 0, 0, 0.35); /* 4px on the phone's card */
  background-color: var(--glow);
}

.pulse {
  animation: pulseShadow 2s infinite ease-in-out;
}

.piece-popup-wrap {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: center;
  will-change: transform;
}

.animate-wrap {
  animation: springOut 700ms cubic-bezier(.22, 1.25, .32, 1) forwards;
}

.piece-popup {
  display: block;
  width: 100%;
  height: 100%;
  background-position: center;
  background-size: 70%;
  background-repeat: no-repeat;
  opacity: 1;
  filter: drop-shadow(0 2.4cqw 2.4cqw rgba(0, 0, 0, 0.5));
  will-change: transform;
}

.animate-piece {
  animation: spinOut 700ms cubic-bezier(.22, .9, .3, 1) forwards;
}

/* Was an invisible twin of the back icon, keeping the piece centred; the
   icon is now pinned to the corner, so it isn't needed. */
.winner-right {
  display: none;
}

/* --fit (set by fitWinnerText in linotte.js) shrinks a text that doesn't
   fit the card's width -- a long random name, "Your opponent left. You
   win!" -- and .wraps lets the longest ones go onto two lines instead of
   getting too small. */
.winner-text {
  margin-top: 4cqw;
  max-width: 100%;
  font-size: calc(13.3cqw * var(--fit, 1));
  line-height: 1.1;
  white-space: nowrap;
  text-align: center;
  color: var(--ink-bg-soft); /* the ink of what sits straight on the background: follows the theme */
}

.winner-text.wraps {
  white-space: normal;
  text-wrap: balance;
}

.winner-points {
  font-size: 9cqw;
  line-height: 1.1;
  font-weight: bold;
  color: #ffea00;
  -webkit-text-stroke: .5px rgba(0, 0, 0, .3);
}

/* The continuous shine loop lives on an INNER span (see animateWinnerPoints
   in linotte.js), not on .winner-points itself: that outer element already
   gets its own one-shot pop-in animation (.winner-points-reveal, in
   animations.css) when the score is revealed, and a single element can't
   run two different `animation` shorthand declarations from two classes at
   once -- whichever class's `animation` property wins the cascade replaces
   the other entirely rather than blending (the exact bug .img-bounce vs
   .piece-jump hit earlier). Splitting the loop onto a child sidesteps that
   completely: the pop-in transform applies to the outer div, the glow pulse
   applies to the inner span, and both run at once undisturbed.
   Flat color throughout (no gradient, no background-clip:text) -- the rest
   of the app doesn't use gradients, so the "shine" here is a glow pulse
   (text-shadow blur/intensity animating) instead of a sweeping highlight. */
.winner-points-shine {
  /* Mostly solid gold, with a wide-ish soft bright band that glides across
     once per loop -- not the whole text visibly being a gradient at rest,
     the way an earlier version read. Widened from an earlier, much
     narrower band (40%-60%) -- a narrow band crossing a wide positional
     range is only actually over the visible text for a handful of
     animation-frames, reading as an instant flash rather than a glide,
     however slow the keyframes themselves are timed. */
  background: linear-gradient(100deg, #ffea00 0%, #ffea00 30%, #fffceb 50%, #ffea00 70%, #ffea00 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  /* Without this, some engines never actually repaint a text-clipped
     gradient's `background-position` frame to frame -- confirmed earlier
     this session: getComputedStyle shows the animation technically
     running, but the same value paints every frame, so it looks frozen. */
  will-change: background-position;
}

.winner-button {
  border-radius: 2.7cqw;
  width: 100%;
  height: 11.8cqw;
  margin: auto 0 4cqw;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  font-size: 9.5cqw;
  color: white;
  background-color: #409ff8;
  border: var(--winner-border);
}

#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9050;
}
/* ============================================
   BASE STYLES
   ============================================ */

article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
menu,
nav,
section,
summary {
  display: block;
}

audio,
canvas,
progress,
video {
  vertical-align: baseline;
  display: inline-block;
}

audio:not([controls]) {
  height: 0;
  display: none;
}

[hidden],
template {
  display: none;
}

a {
  background-color: transparent;
}

a:active,
a:hover {
  outline: 0;
}

abbr[title] {
  border-bottom: 1px dotted;
}

b,
strong {
  font-weight: bold;
}

dfn {
  font-style: italic;
}

mark {
  color: #000;
  background: #ff0;
}

small {
  font-size: 80%;
}

sub,
sup {
  vertical-align: baseline;
  font-size: 75%;
  line-height: 0;
  position: relative;
}

sup {
  top: -.5em;
}

sub {
  bottom: -.25em;
}

img {
  border: 0;
  vertical-align: middle;
  max-width: 100%;
  display: inline-block;
}

svg:not(:root) {
  overflow: hidden;
}

hr {
  box-sizing: content-box;
  height: 0;
}

pre {
  overflow: auto;
}

code,
kbd,
pre,
samp {
  font-family: monospace;
  font-size: 1em;
}

td,
th {
  padding: 0;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

button,
[type="button"],
[type="reset"] {
  cursor: pointer;
  appearance: button;
  border: 0;
}

/* ============================================
   CHAT REACTIONS
   Online games only. A round button (placed by placeChatFab in linotte.js,
   between the two players or in a corner) opens a FAN of icons, like the
   Dock's stacks: they leave the button along a curve, each with a short
   label on its side that only the sender reads. Tapping one sends it (the
   receiver sees just the icon, tossed to the middle of the screen); the
   bell is a nudge: the board shakes and rings for both.
   ============================================ */

.chat-fab {
  position: fixed;
  left: calc(var(--fab-x, -100px) - var(--fab-size, 44px) / 2);
  top: calc(var(--fab-y, -100px) - var(--fab-size, 44px) / 2);
  width: var(--fab-size, 44px);
  height: var(--fab-size, 44px);
  padding: 0;
  border-radius: 50%;
  /* Translucent white like the other round controls, with the app's thin
     bubble icon (chat.svg) in black at 50%. */
  background: rgba(255, 255, 255, .55) url("resources/images/chat.svg") center / 68% no-repeat;
  border: 3px solid rgba(0, 0, 0, .35);
  box-sizing: border-box;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .2);
  z-index: 47; /* above the fan it opens, to close it again */
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .2s;
}

.chat-fab[hidden],
.chat-fan[hidden] {
  display: none;
}

/* The button's place: a third column beside DONE, in online games only
   (body.chat-on, set by syncChat). ROLL and DONE give it room; the turn
   label, which replaces them on the opponent's turn, keeps out of it. The
   button itself is fixed and follows this slot. */
.chat-slot {
  display: none;
}

body.chat-on .div-buttons {
  /* ROLL and DONE take all the room the chat button leaves (no empty column on
     the left to keep them centered: they were too narrow for ROLL in Italian). */
  grid-template-columns: 1fr 1fr 3em; /* the chat button is as tall as ROLL and DONE (min-height 3em): it was a fixed 44px, higher than them on the phones where they are smaller */
  grid-column-gap: 8px;
}

body.chat-on .div-buttons > .button.roll {
  grid-column: 1;
  grid-row: 1;
}

body.chat-on .div-buttons > .button.done {
  grid-column: 2;
  grid-row: 1;
}

/* Centered on the screen, not just between the two buttons' columns (that was 26px to the left of it): it spans
   the whole row and keeps clear of the chat button with the same room on both sides (its width and the gap). */
body.chat-on .div-buttons > .turn-label {
  grid-column: 1 / -1;
  grid-row: 1;
  box-sizing: border-box;
  padding-inline: calc(3em + 8px);
}

body.chat-on .chat-slot {
  display: block;
  grid-column: 3;
  grid-row: 1;
  width: 3em;
  height: 3em;
}

/* Open: only a little more solid, it doesn't turn. */
.chat-fab[aria-expanded="true"] {
  background-color: rgba(255, 255, 255, .85);
}

.chat-fan {
  position: fixed;
  inset: 0;
  z-index: 45; /* above the board, below options/home/winner/flip-coin overlays */
}

.chat-fan-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  transition: background .15s;
}

.chat-fan.is-open .chat-fan-backdrop {
  background: rgba(0, 0, 0, .18);
}

.chat-fan-items {
  position: absolute;
  left: var(--fab-x, 0);
  top: var(--fab-y, 0);
  width: 0;
  height: 0;
}

/* Each item sits on the button and flies out to --dx/--dy when the fan
   opens, one after the other (--i), springing a little past its place. */
.chat-fan-item {
  position: absolute;
  left: calc(var(--item-size, 44px) / -2);
  top: calc(var(--item-size, 44px) / -2);
  width: var(--item-size, 44px);
  height: var(--item-size, 44px);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  opacity: 0;
  transform: translate(0, 0) scale(.3);
  transition: transform .16s cubic-bezier(.3, 1.3, .5, 1), opacity .1s;
  transition-delay: calc((var(--n) - var(--i)) * 6ms); /* closing: the far ones go first */
  -webkit-tap-highlight-color: transparent;
}

.chat-fan.is-open .chat-fan-item {
  opacity: 1;
  transform: translate(var(--dx), var(--dy)) scale(1);
  transition-delay: calc(var(--i) * 10ms);
}

.chat-fan-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .3));
  pointer-events: none;
}

/* The label: a small pill on the side of the icon, away from the curve. */
.chat-fan-label {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  padding: .15em .7em;
  border-radius: 1em;
  background: rgba(255, 255, 255, .9);
  color: var(--ink);
  font: 15px/1.25 "Changa One", sans-serif;
  white-space: nowrap;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .18);
  pointer-events: none;
}

.chat-fan[data-side="left"] .chat-fan-label {
  right: calc(100% + 8px);
}

.chat-fan[data-side="right"] .chat-fan-label {
  left: calc(100% + 8px);
}

.chat-fan-item.is-wait {
  filter: grayscale(1);
  opacity: .5 !important;
}

.chat-fan-item:active img {
  transform: scale(.9);
}

/* The nudge: the board shakes (MSN-style), both players'. `translate` and
   `rotate` are their own properties, so they add to the board's own
   transform (the table flip) instead of replacing it. */
body.nudge .div-table {
  animation: nudgeShake .8s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes nudgeShake {
  0%, 100% { translate: 0 0; rotate: 0deg; }
  8% { translate: -12px 3px; rotate: -1.4deg; }
  16% { translate: 12px -3px; rotate: 1.4deg; }
  24% { translate: -11px 2px; rotate: -1.2deg; }
  32% { translate: 11px -2px; rotate: 1.2deg; }
  42% { translate: -8px 2px; rotate: -.9deg; }
  52% { translate: 8px -2px; rotate: .9deg; }
  64% { translate: -5px 1px; rotate: -.5deg; }
  76% { translate: 4px -1px; rotate: .4deg; }
  88% { translate: -2px 0; rotate: -.2deg; }
}

@media (prefers-reduced-motion: reduce) {
  body.nudge .div-table { animation: none; }
  .chat-fan-item { transition: none; }
}

.chat-toss-stage {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 95; /* above winner (70) and coin-flip (80) overlays, so a toss still reads even mid-celebration */
  overflow: hidden;
}

/* ...but not over the options menu: nothing from the game shows on top of
   it while it's open. */
body:has(#options-overlay:not(.hidden)) .chat-toss-stage {
  visibility: hidden;
}

.chat-toss-emoji {
  position: fixed;
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  /* No transition/animation here on purpose: left/top/transform/opacity
     are all driven frame-by-frame from JS for the entire lifetime of a
     toss (see throwChatEmoji in linotte.js) -- the curved flight, the
     organic wander while it holds, and the burst are each continuous
     motion a CSS transition/keyframe (which only interpolates between a
     couple of fixed stops) can't produce on their own. */
}

.chat-toss-emoji img {
  display: block;
  width: 56px;
  height: 56px;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .3));
}


label {
  margin-bottom: 5px;
  font-weight: bold;
  display: block;
}


/* Placeholder line under a section whose feature doesn't exist yet. */
.not-available {
  height: 32px;
  display: flex;
  align-items: center;
  font-size: 1.2em;
  color: rgba(0, 0, 0, .5);
}


/* Play/pause button (Game section of the options menu): two bars while the
   game is running, a triangle while it's paused. */
.pause-icon {
  display: block;
  width: 14px;
  height: 16px;
  box-sizing: border-box;
  border-left: 5px solid #000;
  border-right: 5px solid #000;
}

#pause-btn.is-paused .pause-icon {
  width: 0;
  height: 0;
  border-left: 15px solid #000;
  border-right: none;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
}


/* Earthquake shake of the board (see shakeBoard in linotte.js). Uses the
   separate `translate`/`rotate` properties, not `transform`, so it can't
   clobber the board's own transform while the page is flipped (FLIP gives
   it rotate(-180deg)). Builds up instead of fading out: it's at its
   strongest right before the end, where the winner popup takes over.
   The sign pattern of translate vs rotate is deliberately cycled so the
   stillest corner moves TL->TR->BR->BL: when they always shared a sign, the
   bottom-left corner barely moved and read as a fulcrum. */
.div-table.quake {
  animation: boardQuake .5s linear;
}

@keyframes boardQuake {
  0%   { translate: 0 0; rotate: 0deg; }
  8%  { translate: -0.43px 0.22px; rotate: 0.04deg; }
  15%  { translate: 0.87px 0.43px; rotate: -0.08deg; }
  23%  { translate: 1.3px -0.65px; rotate: 0.12deg; }
  31%  { translate: -1.73px -0.87px; rotate: -0.17deg; }
  38%  { translate: -2.17px 1.08px; rotate: 0.21deg; }
  46%  { translate: 2.6px 1.3px; rotate: -0.25deg; }
  54%  { translate: 3.03px -1.52px; rotate: 0.29deg; }
  62%  { translate: -3.47px -1.73px; rotate: -0.33deg; }
  69%  { translate: -3.9px 1.95px; rotate: 0.38deg; }
  77%  { translate: 4.33px 2.17px; rotate: -0.42deg; }
  85%  { translate: 4.77px -2.38px; rotate: 0.46deg; }
  92%  { translate: -5.2px -2.6px; rotate: -0.5deg; }
  100% { translate: 0 0; rotate: 0deg; }
}

/* A Pro player's badge during a game: a star and their online wins, hung
   on the top edge of their box so it never takes room from the name (the
   server tells both players). */
.player {
  position: relative;
}

.player[data-badge]:not([data-badge=""])::after {
  content: attr(data-badge);
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -55%);
  z-index: 2;
  padding: .05em .55em;
  border-radius: .8em;
  font-family: "Changa One", sans-serif;
  font-size: .75em;
  line-height: 1.25;
  white-space: nowrap;
  background: var(--badge-bg, rgba(255, 255, 255, .9));
  color: var(--badge-ink, #3d240c);
  border: .1em solid rgba(0, 0, 0, .35);
  font-variant-numeric: tabular-nums;
}

/* An online guest's badge ("Guest", where the server gave no level) is the quiet kind: no fill, a thin line and a softer ink,
   so it doesn't weigh like a level. */
.player[data-guest][data-badge]:not([data-badge=""])::after {
  background: var(--guest-bg, transparent); /* a background's ink may give the pastille a fill (themes/README.md, "The ink") */
  color: var(--guest-ink, rgba(0, 0, 0, .55));
  border-color: var(--guest-line, rgba(0, 0, 0, .25));
}

.player.dark-box[data-guest][data-badge]:not([data-badge=""])::after {
  color: var(--guest-ink, rgba(255, 255, 255, .72));
  border-color: var(--guest-line, rgba(255, 255, 255, .32));
}

/* Everyone's level shows; Pro adds the star (in the text). */

/* The player card's level: the badge they wear in the game, bigger, with
   Pro / Free / Guest in small under it. */
.pc-badge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25em;
}

.pc-badge-wrap[hidden],
.pc-badge[hidden] {
  display: none;
}

#ac-badge { cursor: pointer; } /* it leads to the stats */

.pc-badge {
  font-size: 1.9em;
  padding: .05em .7em;
}

.pc-plan {
  font-family: "Changa One", sans-serif;
  font-size: .8em;
  letter-spacing: .1em;
  text-transform: uppercase;
  opacity: .7;
}

.pc-plan.is-pro {
  opacity: 1;
  color: #8a6400;
}

.pc-record[hidden] {
  display: none;
}


/* Winner screen: REMATCH next to NEW GAME (see "Rematch" in linotte.js). */
.winner-buttons {
  display: flex;
  gap: 3cqw;
  width: 100%;
  margin: auto 0 4cqw;
}

.winner-buttons .winner-button {
  flex: 1;
  margin: 0;
  font-size: 7.2cqw;
  white-space: nowrap;
}

.winner-button.rematch {
  background-color: rgb(46, 160, 90);
}

.winner-button.rematch[hidden] {
  display: none;
}

/* Waiting for the other player's answer. */
.winner-button.rematch.is-waiting {
  filter: saturate(.4);
  pointer-events: none;
}

/* The opponent asks: the button says so and draws the eye. */
.winner-button.rematch.is-offered {
  animation: rematchPulse 1s ease-in-out infinite;
}

@keyframes rematchPulse {
  50% { transform: scale(1.05); }
}

@media (prefers-reduced-motion: reduce) {
  .winner-button.rematch.is-offered { animation: none; }
}

/* Language names are longer than the other option words: each button fills
   its grid cell. */
.opt-btn.lang-btn {
  width: 100%;
  padding: 0 .3em;
  font-size: 1em;
  white-space: nowrap;
}

/* Six languages: a grid of three equal columns, two rows, with room between
   the buttons (one row doesn't fit a phone). */
#language-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 90%;
  min-width: 0;
  max-width: 360px;
  margin: 0 auto;
  overflow: visible;
  scroll-snap-type: none;
}

#language-list .car-btn {
  height: auto;
}

/* The carousel's edge spacers would take grid cells here. */
#language-list::before,
#language-list::after {
  content: none;
}

/* Favorite piece in the options: each piece on a tile like the board's
   (same colour and frame), the piece 20% smaller than the tile. The first
   item, "random", is a die. Without Pro they carry a "PRO" tag. */
/* Two classes: beats .car-item-content's overflow: hidden, which cut the
   "PRO" tag hanging below the tile in half (the piece, at 80%, never
   reaches the edges anyway). */
.car-item-content.piece-options {
  overflow: visible;
}

.piece-options {
  position: relative;
  box-sizing: border-box;
  border-radius: .35em;
  background: rgb(228, 209, 187);
  border: .125em solid #603813;
  display: flex;
  align-items: center;
  justify-content: center;
}

.piece-options img {
  width: 80%;
  height: 80%;
  object-fit: contain;
}

.piece-options.is-random img {
  width: 72%;
  height: 72%;
}

/* Without Pro: a gold "PRO" tag with a padlock on each piece's bottom
   edge. The piece keeps its colours: it's there to be wanted. */
body:not(.is-pro) .piece-options.is-pro-only::after,
body.rooms-need-pro:not(.is-pro) #friend-create::after {
  content: "PRO";
  position: absolute;
  bottom: -.55em;
  left: 50%;
  transform: translateX(-50%);
  padding: 0 .4em 0 1.35em;
  font-size: 12px;
  line-height: 1.5;
  border-radius: .7em;
  white-space: nowrap;
  background: rgb(232, 185, 35) .35em center / .85em no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235f4604' stroke-width='2.6' stroke-linecap='round'%3E%3Crect x='5' y='11' width='14' height='10' rx='2' fill='%235f4604'/%3E%3Cpath d='M8 11V8a4 4 0 0 1 8 0v3'/%3E%3C/svg%3E");
  color: #5f4604;
  border: 1.5px solid rgba(0, 0, 0, .35);
}

/* A tap on a player's box opens their card (showPlayerCard in linotte.js). */
.player {
  cursor: pointer;
}

/* Room under the pieces for their "PRO" tag (the list scrolls sideways, so
   it would cut anything hanging below it). */
#piece-list {
  padding-bottom: calc(2vh + 12px);
}

/* Chinese: full-width punctuation ("！", "。", "，") carries half an em of
   empty space, which pushes centred titles and buttons off centre ("你赢了！"
   sat to the left). The font's half-width forms ("halt") keep them centred;
   the rules' paragraphs keep the normal, more readable spacing. */
html:lang(zh) body {
  font-feature-settings: "halt";
}

html:lang(zh) p {
  font-feature-settings: normal;
}

/* CREATE ROOM (in FRIEND's sheet) without Pro: the same tag, hung on the
   button's top-right corner like the SOON badge. FRIEND itself has none:
   joining a friend's room is free for everyone. */
body.rooms-need-pro:not(.is-pro) #friend-create::after {
  bottom: auto;
  left: auto;
  top: -.6em;
  right: -.4em;
  transform: none;
  font-family: "Changa One", sans-serif;
  font-size: .75em;
  z-index: 1;
  pointer-events: none;
}

#friend-create {
  position: relative;
}

/* The player card: their country under the name. */
.player-card-country {
  text-align: center;
  font-size: 1.05em;
}

.player-card-country[hidden] {
  display: none;
}

/* The level badge's colour, a reward for reaching a level (see BADGE_TIERS
   in shared/level.js): on the home, in games (Pro) and in the stats. */
[data-tier="bronze"] { --badge-bg: linear-gradient(135deg, #e3a76f, #b06d32); --badge-ink: #3b1f08; }
[data-tier="silver"] { --badge-bg: linear-gradient(135deg, #f1f4f7, #aab4bf); --badge-ink: #2b333b; }
[data-tier="gold"] { --badge-bg: linear-gradient(135deg, #ffe27a, #e0a812); --badge-ink: #5a3f00; }
[data-tier="ruby"] { --badge-bg: linear-gradient(135deg, #ff7a8f, #b3133a); --badge-ink: #ffffff; }
[data-tier="diamond"] { --badge-bg: linear-gradient(135deg, #b9f3ff, #a98bff); --badge-ink: #1d1a4d; }

/* The level badge: one pastille everywhere (home, player boxes, cards, Pro
   sheet, celebrations, road, stats). Size comes from the font-size of each
   place; the tier gives the colours, Pro a gold frame (and a star in the text). */
.lv-pill {
  display: inline-block;
  padding: .05em .55em;
  border-radius: .8em;
  font-family: "Changa One", sans-serif;
  line-height: 1.25;
  white-space: nowrap;
  background: var(--badge-bg, rgba(255, 255, 255, .9));
  color: var(--badge-ink, #3d240c);
  border: .1em solid rgba(0, 0, 0, .35);
  font-variant-numeric: tabular-nums;
}

/* Pro is the star in front of the text; there is no other frame. */

/* Dice and backgrounds that come with a level: a "🔒 Lv N" tag until then
   (the same tag as the Pro pieces, see applyLevelLocks in linotte.js). They
   keep their real colours: they're there to be wanted. */
.car-item-content.is-level-locked {
  position: relative;
  overflow: visible;
}

.car-item-content.is-level-locked::after {
  content: attr(data-lock);
  position: absolute;
  bottom: -.55em;
  left: 50%;
  transform: translateX(-50%);
  padding: 0 .4em 0 1.35em;
  font-size: 12px;
  line-height: 1.5;
  border-radius: .7em;
  white-space: nowrap;
  background: rgba(255, 255, 255, .95) .35em center / .85em no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233d240c' stroke-width='2.6' stroke-linecap='round'%3E%3Crect x='5' y='11' width='14' height='10' rx='2' fill='%233d240c'/%3E%3Cpath d='M8 11V8a4 4 0 0 1 8 0v3'/%3E%3C/svg%3E");
  color: var(--ink);
  border: 1.5px solid rgba(0, 0, 0, .35);
  font-family: "Changa One", sans-serif;
  pointer-events: none;
}
