:root {
  --page-bg: #f09a7a;
  --page-bg-player-two: #7fbfc8;
  --board-bg: #fcebcf;
  --player-one: #f38868;
  --player-two: #7bc3cb;
  --slate: #57636e;
  --roll-red: #d65b53;
  --roll-blue: #5b93b0;
  --grid-line: #f5e0bd;
  --cream-shadow: #f8d9b1;
  --white: #ffffff;
  --purple-stroke: #875c78;
  --bonus-purple: #8a35c9;
  --valid-glow: rgba(214, 91, 83, 0.22);
  --valid-glow-blue: rgba(91, 147, 176, 0.24);
  --locked-outline: #ffd86f;
  --text-dark: #2f3742;
  --font-main: system-ui, "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
}

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

/* Almost every size in this file is in `rem`, so scaling the root font-size
   fluidly with viewport width shrinks the whole board together as the
   screen narrows, instead of only at the two fixed breakpoints below. That
   closes the "dead zone" between them (~431-699px) where nothing used to
   shrink even though the board kept losing width, which is what caused
   score-board cells/icons/buttons to overflow into each other on
   in-between phone widths. 16px at >=700px (unchanged from before this
   rule existed) down to 13px at <=320px. */
html {
  font-size: clamp(13px, calc(10.5px + 0.79vw), 16px);
}

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

body {
  background: var(--page-bg);
  color: var(--text-dark);
  font-family: var(--font-main);
  transition: background 180ms ease;
}

body.player-two-turn {
  background: var(--page-bg-player-two);
}

body.is-splash {
  background: #9ec4d4;
}

button,
input,
textarea,
select {
  font: inherit;
}

/* Android bars can cover the bottom even when the safe-area inset is 0
   (docs/PLATFORM_RULES.md 6.2). */
.page {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  padding:
    2rem
    max(24px, env(safe-area-inset-right, 0px))
    max(40px, calc(env(safe-area-inset-bottom, 0px) + 24px))
    max(24px, env(safe-area-inset-left, 0px));
}

.app-shell {
  width: min(100%, 31rem);
  position: relative;
}

.home-button {
  width: 2.2rem;
  height: 2.2rem;
  border: 0.22rem solid rgba(87, 99, 110, 0.42);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 0.22rem 0 rgba(87, 99, 110, 0.16);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
}

.home-button.is-hidden {
  display: none;
}

/* TEMP: visible build tag so cache/deploy fixes can be confirmed at a
   glance (this game has a service worker with a cache-first fetch
   strategy — sw.js — so a stale phone/browser can silently keep serving
   old CSS/JS after a fix ships; bump this string whenever CACHE_NAME in
   sw.js is bumped, so "still on the old version" is obvious without
   opening devtools). Requested 2026-09-17; remove once no longer needed. */
.build-tag {
  position: fixed;
  left: 50%;
  bottom: max(0.3rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 30;
  color: rgba(87, 99, 110, 0.55);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  pointer-events: none;
}

.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding:
    max(1.2rem, env(safe-area-inset-top))
    max(24px, env(safe-area-inset-right, 0px))
    max(40px, calc(env(safe-area-inset-bottom, 0px) + 24px))
    max(24px, env(safe-area-inset-left, 0px));
}

.splash-screen::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: #9ec4d4;
  background-image: url("./assets/splash-bg.webp");
  background-position: center top;
  background-size: cover;
  background-repeat: no-repeat;
}

.splash-screen.is-hidden,
.game-card.is-hidden,
.splash-screen[hidden],
.game-card[hidden],
.splash-best.is-hidden {
  display: none;
}

.splash-best {
  margin: 0;
  align-self: center;
  padding: 0.3rem 0.9rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #fffaf1;
  font-size: 0.95rem;
  font-weight: 800;
}

.splash-nav-btn {
  position: absolute;
  top: max(1rem, env(safe-area-inset-top));
  z-index: 20;
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #ffffff;
  box-shadow: 0 0.2rem 0.55rem rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.splash-nav-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.splash-back-button {
  left: 1rem;
}

#settings-button {
  right: 1rem;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.settings-row {
  display: grid;
  grid-template-columns: auto 1fr 4.2rem;
  align-items: center;
  gap: 0.55rem;
}

.settings-name {
  font-size: 0.85rem;
  font-weight: 800;
  color: #1f2933;
}

.settings-points {
  min-width: 0;
  height: 2rem;
  border-radius: 0.55rem;
  border: 0.14rem solid rgba(15, 23, 42, 0.18);
  background: rgba(15, 23, 42, 0.04);
  color: #1f2933;
  text-align: center;
  font-weight: 800;
}

.settings-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.08);
  color: #1f2933;
}

/* Rows of the shared white .options-panel-sheet (game-header.css): rule
   settings on the splash, reverse dice selection in a match. */
.game-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  cursor: pointer;
}

.game-toggle-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1f2933;
}

.game-toggle-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.game-toggle-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.6rem;
  height: 1.6rem;
  padding: 0 0.4rem;
  border-radius: 0.5rem;
  background: rgba(15, 23, 42, 0.08);
  color: #1f2933;
  font-size: 0.72rem;
  font-weight: 800;
}

.splash-actions {
  position: relative;
  z-index: 10;
  width: min(100%, 24rem);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}

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

.splash-play,
.splash-choice,
.splash-join-button {
  border: 0;
  border-radius: 1rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 0.4rem 1rem rgba(0, 0, 0, 0.28);
  transition: transform 160ms ease, filter 160ms ease;
}

.splash-play:active,
.splash-choice:active,
.splash-join-button:active,
.splash-share:active,
.splash-cancel:active,
.splash-nav-btn:active {
  transform: scale(0.97);
}

.splash-play {
  width: 100%;
  min-height: 3.4rem;
  background: #7bc3cb;
  color: #2a2538;
  font-size: 1.05rem;
  padding: 0.7rem 1rem;
}

.splash-play.is-waiting-code {
  background: rgba(42, 32, 28, 0.82);
  color: #fffaf1;
  font-size: clamp(2.2rem, 12vw, 3.6rem);
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  animation: waiting-code-pulse 1.45s ease-in-out infinite;
}

.splash-cancel,
.splash-share {
  width: 100%;
  min-height: 2.8rem;
  border: 0.12rem solid rgba(255, 255, 255, 0.4);
  border-radius: 0.85rem;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  display: none;
}

.splash-share {
  background: #25D366; /* WhatsApp Green */
  color: white;
  border: none;
  font-size: 1.1rem;
  min-height: 3.2rem;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.splash-share::before {
  content: "";
  display: inline-block;
  width: 20px;
  height: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8'/%3E%3Cpolyline points='16 6 12 2 8 6'/%3E%3Cline x1='12' y1='2' x2='12' y2='15'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

.splash-share.is-visible {
  display: flex;
}

.splash-cancel.is-visible {
  display: block;
}

.splash-play:disabled,
.splash-share:disabled,
.splash-cancel:disabled,
.splash-join-button:disabled,
.splash-choice:disabled {
  cursor: default;
  opacity: 0.72;
}

.splash-name-row.is-hidden,
.splash-join.is-hidden,
.splash-play.is-hidden,
.splash-choice.is-hidden {
  display: none;
}

.splash-join {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.2rem;
}

.splash-label {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 0.08rem 0.28rem rgba(0, 0, 0, 0.55);
}

.splash-name-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.2rem;
}

.splash-name-heading {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.player-name-avatar {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 0.08rem solid rgba(255, 255, 255, 0.55);
}

.player-name-avatar[hidden] {
  display: none;
}

.splash-name-input {
  min-height: 2.9rem;
  border-radius: 1rem;
  border: 0.12rem solid rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.45);
  color: #fffaf1;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.4rem 0.9rem;
}

.splash-name-input::placeholder {
  color: rgba(255, 250, 241, 0.55);
}

.splash-name-input:focus {
  border-color: rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 0 0.18rem rgba(255, 255, 255, 0.16);
}

.splash-choice-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
}

.splash-choice {
  width: 100%;
  min-height: 3.4rem;
  min-width: 0;
  font-size: 1.05rem;
  padding: 0.7rem 1rem;
  color: #2a2538;
  white-space: normal;
  line-height: 1.15;
}

.splash-choice-local {
  background: #f3c247;
}

.splash-choice-robot {
  background: #6cc75f;
}

/* Graphics experiment entry point - kept visually distinct (dashed border,
   watercolor-toned background) so it reads as a test variant, not a third
   equally-supported mode. */
.splash-choice-robot-test {
  background: #e8dcc4;
  border: 0.14rem dashed rgba(42, 37, 56, 0.35);
}

.splash-choice-resume {
  background: #fffaf1;
  border: 0.18rem solid #2a2538;
}

.opponent-away-banner {
  margin: 0 0.35rem 0.75rem;
  padding: 0.55rem 0.85rem;
  border-radius: 0.85rem;
  background: #2a2538;
  color: #fffaf1;
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
  overflow-wrap: anywhere;
}

.opponent-away-banner.is-hidden {
  display: none;
}

.splash-flag {
  padding: 0.45rem;
  display: grid;
  place-items: center;
}

.flag-icon {
  display: block;
  width: 2rem;
  height: 1.4rem;
  border-radius: 0.22rem;
  box-shadow: inset 0 0 0 0.08rem rgba(47, 55, 66, 0.12);
}

.flag-en {
  background:
    linear-gradient(
      180deg,
      #c83d46 0% 14.28%,
      #ffffff 14.28% 28.56%,
      #c83d46 28.56% 42.84%,
      #ffffff 42.84% 57.12%,
      #c83d46 57.12% 71.4%,
      #ffffff 71.4% 85.68%,
      #c83d46 85.68% 100%
    );
  position: relative;
  overflow: hidden;
}

.flag-en::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 42%;
  height: 57%;
  background: #2452a3;
  border-top-left-radius: 0.22rem;
}

.flag-en::after {
  content: "";
  position: absolute;
  top: 0.16rem;
  left: 0.16rem;
  width: 0.18rem;
  height: 0.18rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  box-shadow:
    0.34rem 0 0 rgba(255, 255, 255, 0.95),
    0.68rem 0 0 rgba(255, 255, 255, 0.95),
    0 0.24rem 0 rgba(255, 255, 255, 0.95),
    0.34rem 0.24rem 0 rgba(255, 255, 255, 0.95),
    0.68rem 0.24rem 0 rgba(255, 255, 255, 0.95),
    0 0.48rem 0 rgba(255, 255, 255, 0.95),
    0.34rem 0.48rem 0 rgba(255, 255, 255, 0.95),
    0.68rem 0.48rem 0 rgba(255, 255, 255, 0.95);
}

.flag-fr {
  background: linear-gradient(90deg, #2d5fb8 0 33.33%, #ffffff 33.33% 66.66%, #d64d4d 66.66% 100%);
}

.splash-join-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
}

.splash-code-input {
  min-width: 0;
  min-height: 3.4rem;
  border-radius: 1rem;
  border: 0.12rem solid rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.45);
  color: #fffaf1;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 1.15rem;
  font-weight: 1000;
  padding: 0.4rem 0.8rem;
  outline: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.splash-code-input::placeholder {
  color: rgba(255, 250, 241, 0.55);
}

.splash-code-input:focus {
  border-color: rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 0 0.18rem rgba(255, 255, 255, 0.16);
}

.splash-join-button {
  min-height: 3.4rem;
  background: #3d2b22;
  color: #fffaf1;
  font-size: 0.98rem;
  padding: 0.4rem 1rem;
}

.splash-status,
.splash-error {
  display: none;
  margin: -0.2rem 0 0;
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
  text-shadow: 0 0.08rem 0.25rem rgba(0, 0, 0, 0.55);
}

.splash-status.is-visible,
.splash-error.is-visible {
  display: block;
}

.splash-status {
  color: #fffaf1;
}

.splash-status.is-visible {
  animation: waiting-status-fade 1.45s ease-in-out infinite;
}

.splash-error {
  color: #ffb4ae;
}

.game-card {
  position: relative;
}

.game-card.yatzy-hit {
  animation: yatzy-stage-pop 900ms cubic-bezier(0.22, 1, 0.36, 1);
}

.game-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
  padding: 0 0.35rem;
}

.game-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

/* Small icon button opening the in-game settings panel (language, dice
   selection preference for whichever player is currently taking their
   turn) - sized to match .home-button on the same row. */
.game-settings-button {
  width: 2.2rem;
  height: 2.2rem;
  min-width: 2.2rem;
  border-radius: 50%;
  flex: 0 0 auto;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex: 0 1 auto;
  min-width: 0;
}

.robot-toggle {
  border: 0.22rem solid rgba(87, 99, 110, 0.45);
  background: rgba(255, 255, 255, 0.9);
  color: var(--slate);
  border-radius: 999px;
  min-height: 2.35rem;
  padding: 0.35rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  cursor: pointer;
  box-shadow: 0 0.2rem 0 rgba(87, 99, 110, 0.14);
  flex-shrink: 0;
}

.robot-toggle.is-active {
  background: linear-gradient(180deg, #fff3b5, #ffd85b);
  border-color: rgba(87, 99, 110, 0.75);
}

/* Icon-only (YAM-UI-02): same circular icon-button footprint as
   .home-button/.game-settings-button on the same header row, no text label. */
.restart-button {
  width: 2.2rem;
  height: 2.2rem;
  min-width: 2.2rem;
  border: 0.22rem solid rgba(87, 99, 110, 0.45);
  background: rgba(252, 235, 207, 0.95);
  color: var(--slate);
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 0.2rem 0 rgba(87, 99, 110, 0.14);
  flex-shrink: 0;
}

.emoji-trigger {
  position: absolute;
  right: 0;
  bottom: 1.15rem;
  z-index: 15;
}

.emoji-trigger-button {
  width: 2.7rem;
  height: 2.7rem;
  border-radius: 50%;
  border: 0.22rem solid rgba(87, 99, 110, 0.4);
  background: rgba(255, 255, 255, 0.95);
  font-size: 1.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0.28rem 0 rgba(87, 99, 110, 0.18);
}

.emoji-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 25;
}

.emoji-picker-backdrop.is-hidden {
  display: none;
}

.emoji-picker {
  position: absolute;
  bottom: calc(100% + 0.5rem);
  right: 0;
  z-index: 26;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  width: min(18rem, calc(100vw - 2rem));
  padding: 0.55rem;
  background: rgba(47, 55, 66, 0.92);
  border-radius: 1.1rem;
  box-shadow: 0 0.5rem 1rem rgba(47, 55, 66, 0.28);
}

.emoji-picker.is-hidden {
  display: none;
}

.reaction-tabs {
  display: flex;
  gap: 0.3rem;
}

.reaction-tab {
  flex: 1;
  border: none;
  border-radius: 0.7rem;
  padding: 0.35rem 0.4rem;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.reaction-tab.is-active {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(4, 2.3rem);
  gap: 0.35rem;
  justify-content: center;
}

.emoji-grid.is-hidden,
.gif-pane.is-hidden {
  display: none;
}

.gif-pane {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.gif-search-input {
  width: 100%;
  border: none;
  border-radius: 0.7rem;
  padding: 0.4rem 0.55rem;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 0.8rem;
}

.gif-search-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.gif-search-status {
  margin: 0;
  padding: 0.6rem 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.72rem;
  text-align: center;
}

.gif-search-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  max-height: 12.5rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.gif-option {
  padding: 0;
  border: none;
  border-radius: 0.45rem;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  display: block;
  width: 100%;
  height: 4.4rem;
}

.gif-option img {
  /* iOS Safari/Chrome (WebKit): percentage heights don't reliably resolve on a
     descendant of a <button>, so height:100% falls back to the image's
     intrinsic aspect ratio instead of filling the cell, making landscape
     GIFs look squashed. Use a fixed unit that matches .gif-option instead. */
  display: block;
  width: 100%;
  height: 4.4rem;
  object-fit: cover;
}

.giphy-attribution {
  align-self: flex-end;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-decoration: none;
  text-transform: uppercase;
}

.emoji-option {
  width: 2.3rem;
  height: 2.3rem;
  border: none;
  border-radius: 0.7rem;
  background: transparent;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
}

.emoji-option:hover,
.emoji-option:active {
  background: rgba(255, 255, 255, 0.16);
  transform: scale(1.12);
}

.header-actions {
  width: 100%;
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
}

h1 {
  margin: 0;
  font-size: clamp(1.5rem, 5vw, 2.6rem);
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.score-summary {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}

.score-card {
  background: rgba(252, 235, 207, 0.92);
  border: 0.28rem solid rgba(87, 99, 110, 0.3);
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  box-shadow: 0 0.22rem 0 rgba(87, 99, 110, 0.12);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.score-card.is-active {
  transform: translateY(0.04rem);
  border-color: rgba(87, 99, 110, 0.4);
  box-shadow: 0 0 0 0.22rem rgba(255, 255, 255, 0.38);
}

.score-card-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0;
}

.score-card-player {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  max-width: 6.5rem;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--slate);
}

.score-card-player span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-card-player .player-name-avatar {
  width: 1.2rem;
  height: 1.2rem;
  border-color: rgba(87, 99, 110, 0.35);
}

.score-card-scoreline {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.score-card-value {
  font-size: clamp(1.1rem, 4vw, 1.45rem);
  font-weight: 1000;
  line-height: 1;
  color: var(--slate);
}

.score-card-value.player-one-score {
  color: var(--player-one);
}

.score-card-value.player-two-score {
  color: var(--player-two);
}

.score-card-divider {
  color: var(--slate);
  font-size: clamp(1rem, 3vw, 1.25rem);
  font-weight: 1000;
}

.header-actions {
  flex: 0 0 auto;
}

.selection-action {
  flex: 1 1 0;
  min-height: 5.95rem;
  padding: 1rem 1.1rem;
  border-radius: 1.4rem;
  border: 0.22rem solid var(--slate);
  background: rgba(255, 255, 255, 0.92);
  color: var(--slate);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 0.2rem 0 rgba(87, 99, 110, 0.16);
  font-size: 1.05rem;
}

.selection-action.is-primary {
  background: var(--roll-red);
  color: var(--white);
  border-color: rgba(87, 99, 110, 0.42);
}

body.player-two-turn .selection-action.is-primary {
  background: var(--roll-blue);
}

.selection-action.is-hidden,
.header-actions.is-hidden,
.roll-button.is-hidden {
  display: none;
}

.scoreboard-panel {
  position: relative;
  background: var(--board-bg);
  border: 0.65rem solid var(--slate);
  border-radius: 2rem;
  overflow: hidden;
  box-shadow: 0 0.5rem 0 rgba(87, 99, 110, 0.18);
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.score-group {
  display: grid;
  grid-template-columns: 1.08fr 0.92fr 0.92fr;
  min-width: 0;
}

.score-group + .score-group {
  border-left: 0.22rem solid var(--grid-line);
}

.score-cell {
  min-height: 4.15rem;
  border-right: 0.22rem solid var(--grid-line);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem;
  position: relative;
}

.score-group .score-cell:nth-child(3n) {
  border-right: none;
}

.category-cell {
  background: rgba(255, 240, 209, 0.55);
}

.category-cell.interactive {
  cursor: pointer;
}

.category-cell.valid {
  box-shadow: inset 0 0 0 0.22rem rgba(255, 255, 255, 0.58);
  animation: category-choice-pulse 1.35s ease-in-out infinite;
}

.player-cell {
  /* Square by construction (width comes from the grid column, height
     follows it) instead of a hand-picked rem min-height: the column width
     is driven by viewport/container size while a rem min-height is driven
     by the root font-size, and those two stopped scaling at the same rate
     once the root font-size became fluid (see the `html` rule near the top
     of this file), which is what made these squares squash/stretch instead
     of staying square. align-self: center keeps it centered in its grid
     row without being stretched to match .category-cell's own height. */
  aspect-ratio: 1;
  align-self: center;
  /* Overrides the inherited `.score-cell` min-height (same element, that
     rule is defined earlier in this file) so it can never fight the
     aspect-ratio above and force a non-square height. */
  min-height: 0;
  border-radius: 1rem;
  margin: 0.35rem;
  border: 0.28rem solid transparent;
  font-size: 1.28rem;
  font-weight: 900;
  cursor: default;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.player-cell.player-one {
  background: var(--player-one);
}

.player-cell.player-two {
  background: var(--player-two);
}

.player-cell.interactive {
  cursor: pointer;
}

.player-cell.valid {
  border-color: rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 0 0.25rem var(--valid-glow);
  animation: score-choice-pulse 1.35s ease-in-out infinite;
  color: var(--white);
}

.player-cell.valid.preview-positive {
  font-size: 2.2rem;
  line-height: 1;
}

.player-cell.valid.preview-zero {
  font-size: 1.28rem;
}

body.player-two-turn .player-cell.valid {
  box-shadow: 0 0 0 0.25rem var(--valid-glow-blue);
}

body.player-one-turn .player-cell.player-two {
  opacity: 0.3;
  filter: grayscale(0.55);
}

body.player-two-turn .player-cell.player-one {
  opacity: 0.3;
  filter: grayscale(0.55);
}

body.player-one-turn.scoring-phase .player-cell.player-one.valid {
  background: #e35a51;
  color: var(--white);
  border-color: rgba(255, 245, 244, 0.98);
  box-shadow: 0 0 0 0.34rem rgba(214, 91, 83, 0.28);
  animation: score-choice-pulse-red-strong 1.05s ease-in-out infinite;
}

body.player-two-turn.scoring-phase .player-cell.player-two.valid {
  background: #59aeb8;
  color: var(--white);
  border-color: rgba(243, 253, 255, 0.98);
  box-shadow: 0 0 0 0.34rem rgba(91, 147, 176, 0.3);
  animation: score-choice-pulse-blue-strong 1.05s ease-in-out infinite;
}

.player-cell.selected {
  border-color: var(--slate);
  transform: translateY(0.08rem);
  box-shadow: 0 0 0 0.25rem rgba(87, 99, 110, 0.18);
  animation: none;
}

.player-cell.score-cell-catch {
  animation: score-cell-catch 560ms cubic-bezier(0.22, 1, 0.36, 1);
}

.player-cell.interactive:active {
  transform: translateY(0.08rem);
}

.player-cell.blocked {
  opacity: 0.55;
}

.player-cell.filled {
  color: rgba(47, 55, 66, 0.72);
  filter: grayscale(0.45);
  opacity: 0.55;
}

.spacer-cell {
  opacity: 1;
  pointer-events: none;
}

.category-cell.spacer-cell {
  background: rgba(255, 240, 209, 0.55);
}

.player-cell.spacer-cell {
  border-color: transparent;
  box-shadow: none;
}

.icon-tile {
  width: 100%;
  max-width: 4.25rem;
  aspect-ratio: 1;
  border-radius: 1rem;
  background: var(--white);
  border: 0.28rem solid var(--purple-stroke);
  position: relative;
  display: grid;
  place-items: center;
  color: var(--slate);
  font-weight: 1000;
}

.icon-tile.text-icon {
  font-size: 2.15rem;
  letter-spacing: -0.06em;
}

.icon-tile.word-icon {
  font-size: 1rem;
  letter-spacing: 0.04em;
}

.icon-tile.meta-icon {
  padding: 0.4rem;
  line-height: 0.9;
  font-size: 0.76rem;
  text-align: center;
}

.icon-tile.meta-icon strong {
  display: block;
  font-size: 1.9rem;
  margin-bottom: 0.15rem;
}

.icon-tile .fan {
  position: absolute;
  inset: 0.55rem auto auto 0.6rem;
  width: 2.15rem;
  height: 1.6rem;
}

.icon-tile .fan::before,
.icon-tile .fan::after,
.icon-tile .fan span {
  content: "";
  position: absolute;
  bottom: 0;
  width: 1.02rem;
  height: 1.55rem;
  border-radius: 0.18rem;
  background: var(--slate);
  transform-origin: bottom left;
}

.icon-tile .fan::before {
  left: 0;
  transform: rotate(-24deg);
}

.icon-tile .fan span {
  left: 0.45rem;
  transform: rotate(-7deg);
}

.icon-tile .fan::after {
  left: 0.95rem;
  transform: rotate(12deg);
}

.icon-tile.yatzy-mark {
  overflow: visible;
}

.yatzy-word {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: #f6dc3b;
  text-shadow:
    -0.08em -0.08em 0 #26303c,
    0.08em -0.08em 0 #26303c,
    -0.08em 0.08em 0 #26303c,
    0.08em 0.08em 0 #26303c;
  font-size: 0.82rem;
  font-weight: 1000;
  transform: rotate(-10deg);
  letter-spacing: 0.03em;
}

.question-mark {
  font-size: 2.5rem;
  font-weight: 1000;
}

.house-icon {
  position: relative;
  width: 2.3rem;
  height: 1.8rem;
}

.house-icon::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -0.15rem;
  width: 1.65rem;
  height: 1.65rem;
  background: var(--slate);
  transform: translateX(-50%) rotate(45deg);
  border-radius: 0.15rem;
}

.house-icon::after {
  content: "";
  position: absolute;
  inset: 0.6rem 0.25rem 0 0.25rem;
  background: var(--slate);
  border-radius: 0.12rem;
}

.house-door {
  position: absolute;
  left: 50%;
  bottom: 0.1rem;
  width: 0.55rem;
  height: 0.7rem;
  background: var(--white);
  transform: translateX(-50%);
  border-radius: 0.05rem;
  z-index: 1;
}

.face-die {
  width: 100%;
  max-width: 4.25rem;
  aspect-ratio: 1;
  border-radius: 1rem;
  border: 0.28rem solid var(--purple-stroke);
  background: var(--white);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 0.45rem;
}

.pip-slot {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
}

.pip {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 50%;
  background: #434d59;
  display: block;
}

.bonus-label {
  align-items: center;
  justify-content: flex-start;
  padding-left: 0.75rem;
}

.bonus-stack {
  display: flex;
  flex-direction: column;
  line-height: 0.9;
  gap: 0.2rem;
}

.bonus-stack .bonus-title {
  font-size: 0.95rem;
  font-weight: 1000;
}

.bonus-stack .bonus-value {
  font-size: 2.2rem;
  color: var(--bonus-purple);
  font-weight: 1000;
}

.bonus-progress {
  height: 100%;
  width: auto;
  aspect-ratio: 1 / 1;
  max-width: 100%;
  max-height: 100%;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 0.3rem solid rgba(255, 255, 255, 0.9);
  background: rgba(255, 247, 228, 0.9);
  box-shadow: inset 0 0 0 0.25rem #f1bc8e;
  display: grid;
  place-items: center;
  font-size: 0.9rem;
  font-weight: 1000;
  color: var(--slate);
}

.bonus-progress small {
  font-size: 0.58rem;
  opacity: 0.78;
  display: block;
  margin-top: 0.08rem;
}

.dice-section {
  padding: 1rem 0.2rem 0;
}

.dice-row {
  display: flex;
  gap: 0.7rem;
  justify-content: space-between;
}

.dice-row.is-score-animating .game-die {
  opacity: 0.14;
  transform: scale(0.92);
}

.game-die {
  appearance: none;
  -webkit-appearance: none;
  flex: 1 1 0;
  aspect-ratio: 1;
  border-radius: 1rem;
  background: #69727e;
  border: 0.35rem solid #4b5561;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 0.35rem 0 rgba(87, 99, 110, 0.22);
  color: var(--white);
  display: grid;
  place-items: center;
  cursor: pointer;
  position: relative;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, opacity 160ms ease;
  transform-origin: center bottom;
}

.game-die:disabled {
  cursor: default;
}

.game-die.locked {
  transform: translateY(0.22rem);
  border-color: var(--locked-outline);
  background: #5a6370;
}

.game-die.reverse-selected {
  border-color: #ff7a1f;
  background: #6b3f22;
  box-shadow: 0 0 0 0.2rem rgba(255, 122, 31, 0.35), 0 0.35rem 0 rgba(87, 99, 110, 0.22);
}

.game-die.reverse-selected.armed,
.game-die.reverse-selected.final-selected {
  border-color: #ff7a1f;
  background: #6b3f22;
  box-shadow: 0 0 0 0.2rem rgba(255, 122, 31, 0.35), 0 0.35rem 0 rgba(87, 99, 110, 0.22);
}

.game-die.armed {
  border-color: var(--locked-outline);
  background: #5f6975;
  box-shadow: 0 0 0 0.18rem rgba(255, 216, 111, 0.22), 0 0.35rem 0 rgba(87, 99, 110, 0.22);
}

.game-die.final-selected {
  border-color: var(--locked-outline);
  background: #5a6370;
  box-shadow: 0 0 0 0.18rem rgba(255, 216, 111, 0.22), 0 0.35rem 0 rgba(87, 99, 110, 0.22);
}

.game-die.final-rolled {
  opacity: 0.5;
  filter: grayscale(0.55);
}

.game-die.not-rollable {
  opacity: 0.72;
}

.game-die.rolling {
  animation: die-launch 620ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: var(--die-delay, 0ms);
}

.die-value {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  justify-self: center;
  align-self: center;
  text-align: center;
}

.game-die.rolling .die-value {
  justify-self: center;
  align-self: center;
  margin-inline: auto;
}

.game-die .face-die {
  width: 100%;
  height: 100%;
  max-width: none;
  box-sizing: border-box;
  border-color: #dde3ea;
  background: var(--white);
  padding: 0.38rem;
  margin: auto;
}

/* "Jouer solo (test)" graphics experiment (see render.js's createDieFace):
   the hand-painted image already draws its own border/shadow, so drop this
   div's own border/padding/grid instead of layering a second frame on it. */
/* Not scoped to `.game-die` - createDieFace() is shared with the upper
   category icons' `.icon-tile` (see render.js), which aren't inside a
   `.game-die`. Scoping this to `.game-die .face-die-watercolor` left those
   icons on `background-size: auto` (only the image's top-left corner,
   often no pips at all). */
.face-die.face-die-watercolor {
  border: none;
  background-color: transparent;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  padding: 0;
}

/* "Jouer solo (test)" graphics experiment, continued: the watercolor dice
   above are only half of it - the board chrome around them (frame, category
   tiles, die shell, bonus accent) gets re-skinned from cool slate/white to
   a warm wood/parchment palette so the whole board reads as one hand-drawn
   scene, not a photo/mockup pasted behind the normal flat-color UI. Scoped
   to specific selectors (not the shared --slate/--white variables) so it
   never touches text-on-color contrast elsewhere in the app. */
body.dice-theme-watercolor {
  --wc-wood: #8a5a34;
  --wc-wood-dark: #5c3b22;
  --wc-cream: #f8ecd6;
  --wc-cream-deep: #f1ddb9;
  --wc-gold: #b9852f;
  /* Sampled from the dice-test crops' own paper corners (~253,249,238) so
     the dice-row band blends into the die images instead of showing a
     visibly different cream behind them. */
  --wc-paper: #fdf9ee;
}

body.dice-theme-watercolor .scoreboard-panel {
  background: var(--wc-cream);
  border-color: var(--wc-wood);
  box-shadow: 0 0.5rem 0 rgba(92, 59, 34, 0.25);
}

body.dice-theme-watercolor .score-group + .score-group {
  border-left-color: var(--wc-wood);
}

body.dice-theme-watercolor .score-cell {
  border-right-color: var(--wc-cream-deep);
}

body.dice-theme-watercolor .category-cell,
body.dice-theme-watercolor .category-cell.spacer-cell {
  background: #ffffff;
}

body.dice-theme-watercolor .icon-tile {
  background: var(--wc-cream);
  border-color: var(--wc-wood);
  color: var(--wc-wood-dark);
}

body.dice-theme-watercolor .icon-tile .fan::before,
body.dice-theme-watercolor .icon-tile .fan::after,
body.dice-theme-watercolor .icon-tile .fan span {
  background: var(--wc-wood);
}

/* Seamless-band request: the 5 dice sit inside one continuous wood-framed
   cream strip with no gap or per-die box between them, so the row reads
   as a single smooth image instead of 5 separate button shells. Lock/turn
   state (previously a solid color swap) becomes a thin ring on the die
   face itself so the strip never breaks up. Deliberately no aspect-ratio
   override here: the dice-test crop is kept near-square (die-*.jpg) so
   the exact same image renders correctly both here and in the upper
   category icons (createDieFace() is shared - see render.js) - an
   earlier taller crop fixed this row's shadow but broke those icons by
   making `cover` crop through the pips on their square tiles. */
body.dice-theme-watercolor .dice-row {
  gap: 0;
  background: var(--wc-paper);
  border-radius: 1.1rem;
  padding: 0.3rem;
}

body.dice-theme-watercolor .game-die {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

body.dice-theme-watercolor .game-die.locked,
body.dice-theme-watercolor .game-die.armed,
body.dice-theme-watercolor .game-die.final-selected,
body.dice-theme-watercolor .game-die.reverse-selected,
body.dice-theme-watercolor .game-die.reverse-selected.armed,
body.dice-theme-watercolor .game-die.reverse-selected.final-selected {
  background: transparent;
  border: none;
  box-shadow: none;
}

/* Yellow ring = actually selected (kept for reroll) only. Neither "armed"
   (fresh, unrolled turn) nor "final-selected" (last roll, can't toggle
   anymore) is a player selection, so - unlike the default flat-color
   theme - they get no ring here; only .locked does.
   A plain inset box-shadow rings the whole square crop, including the
   paper margin and the die's own drop shadow below it. Using a ::after
   border instead, inset asymmetrically (tighter on top/sides, pulled up
   more from the bottom), hugs the die's own silhouette so the ring's
   bottom edge lands on/over the shadow rather than framing it. */
body.dice-theme-watercolor .face-die-watercolor {
  position: relative;
}

body.dice-theme-watercolor .game-die.locked .face-die-watercolor::after,
body.dice-theme-watercolor .game-die.reverse-selected .face-die-watercolor::after {
  content: "";
  position: absolute;
  inset: 4% 5% 13% 5%;
  border-radius: 0.6rem;
  pointer-events: none;
}

body.dice-theme-watercolor .game-die.locked .face-die-watercolor::after {
  border: 0.28rem solid var(--locked-outline);
}

body.dice-theme-watercolor .game-die.reverse-selected .face-die-watercolor::after {
  border: 0.28rem solid #ff7a1f;
}

body.dice-theme-watercolor .bonus-stack .bonus-value,
body.dice-theme-watercolor .bonus-progress {
  color: var(--wc-gold);
}

body.dice-theme-watercolor .bonus-progress {
  box-shadow: inset 0 0 0 0.25rem var(--wc-cream-deep);
  background: rgba(248, 236, 214, 0.9);
}

/* Unrolled-die placeholder (die.value === null): matches the dice-row's
   own paper background instead of the default theme's plain white, so an
   unrolled die reads as an empty cutout in the paper rather than a white
   sticker sitting on it. Matching the fill exactly made the star vanish
   completely against the same-colored row - border/box-shadow can't
   trace a clip-path shape, so drop-shadow (which respects the clipped
   silhouette) is used instead to keep a thin wood-toned outline visible. */
body.dice-theme-watercolor .star-shape {
  background: var(--wc-paper);
  filter: drop-shadow(0 0 0.09rem var(--wc-wood)) drop-shadow(0 0 0.09rem var(--wc-wood));
}

.game-die.rolling .face-die,
.game-die.rolling .star-shape {
  animation: die-face-spin 620ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: var(--die-delay, 0ms);
}

.star-shape {
  width: 2.25rem;
  height: 2.25rem;
  background: var(--white);
  clip-path: polygon(50% 0%, 61% 35%, 100% 50%, 61% 65%, 50% 100%, 39% 65%, 0% 50%, 39% 35%);
  transform: rotate(-12deg);
  margin: auto;
}

.controls-panel {
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.roll-button {
  width: 100%;
  border: none;
  border-radius: 1.4rem;
  background: var(--roll-red);
  color: var(--white);
  min-height: 5.95rem;
  box-shadow: 0 0.45rem 0 #c64c45;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  /* Right padding reserves the .emoji-trigger-button's footprint (it floats
     at `right: 0` over this same corner via .emoji-trigger) so the centered
     label/chips can never grow into it and overlap it on narrow screens. */
  padding: 1rem calc(1.2rem + 2.7rem + 0.35rem) 1rem 1.2rem;
  font-weight: 1000;
  cursor: pointer;
}

body.player-two-turn .roll-button {
  background: var(--roll-blue);
  box-shadow: 0 0.45rem 0 #4f809a;
}

.roll-button:disabled,
.roll-button.is-exhausted {
  cursor: default;
  opacity: 0.68;
}

.roll-button.is-exhausted {
  pointer-events: auto;
  cursor: pointer;
}

.go-back-button {
  width: 100%;
  min-height: 3rem;
  border: 0.22rem solid rgba(87, 99, 110, 0.45);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.92);
  color: var(--slate);
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 0.2rem 0 rgba(87, 99, 110, 0.14);
}

.go-back-button:disabled {
  cursor: default;
  opacity: 0.68;
}

.go-back-button.is-hidden {
  display: none;
}

.roll-label {
  font-size: clamp(1.5rem, 6vw, 2.4rem);
  letter-spacing: 0.03em;
}

.roll-indicators {
  display: flex;
  gap: 0.45rem;
}

.roll-chip {
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 0.85rem;
  background: var(--white);
  border: 0.3rem solid var(--slate);
  color: var(--slate);
  display: grid;
  place-items: center;
  font-size: 1.7rem;
  font-weight: 1000;
  box-shadow: 0 0.2rem 0 rgba(87, 99, 110, 0.18);
  opacity: 0.45;
}

.roll-chip.active {
  opacity: 1;
}

.winner-banner {
  position: absolute;
  inset: 0;
  background: rgba(47, 55, 66, 0.42);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.winner-card {
  width: min(100%, 20rem);
  background: var(--board-bg);
  border: 0.4rem solid var(--slate);
  border-radius: 1.6rem;
  padding: 1.3rem 1.2rem;
  text-align: center;
  box-shadow: 0 0.6rem 0 rgba(87, 99, 110, 0.18);
}

.winner-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.45rem;
}

.winner-card p {
  margin: 0.25rem 0;
  font-weight: 800;
}

.celebration-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
  z-index: 20;
}

.yatzy-celebration {
  position: relative;
  width: min(90vw, 32rem);
  min-height: 16rem;
  display: grid;
  place-items: center;
}

.yatzy-burst,
.yatzy-burst::before,
.yatzy-burst::after {
  position: absolute;
  inset: 50%;
  width: 18rem;
  height: 18rem;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  content: "";
}

.yatzy-burst {
  background:
    radial-gradient(circle, rgba(255, 241, 178, 0.9) 0 14%, transparent 15% 100%),
    conic-gradient(from 0deg, rgba(255, 221, 79, 0.9), rgba(255, 111, 97, 0.85), rgba(123, 195, 203, 0.85), rgba(255, 221, 79, 0.9));
  filter: blur(0.04rem);
  opacity: 0.85;
  animation: yatzy-burst-spin 1200ms linear infinite, yatzy-burst-pop 900ms ease-out both;
}

.yatzy-burst::before {
  background:
    repeating-conic-gradient(from 0deg, rgba(255, 255, 255, 0.95) 0deg 8deg, transparent 8deg 18deg);
  transform: translate(-50%, -50%) scale(1.12);
  opacity: 0.55;
  animation: yatzy-burst-spin 1400ms linear infinite reverse;
}

.yatzy-burst::after {
  background:
    radial-gradient(circle, rgba(255, 252, 236, 0.98) 0 30%, rgba(255, 252, 236, 0) 72%);
  transform: translate(-50%, -50%) scale(0.78);
}

.yatzy-particles {
  position: absolute;
  inset: 0;
}

.yatzy-particles span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.7rem;
  height: 2.4rem;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff6a0, #ff6c62);
  transform:
    translate(-50%, -50%)
    rotate(calc(var(--i) * 20deg))
    translateY(-8.6rem)
    scaleY(0.6);
  opacity: 0;
  animation: yatzy-particle-burst 1000ms ease-out forwards;
  animation-delay: calc(var(--i) * 18ms);
}

.yatzy-banner {
  position: relative;
  padding: 1.15rem 1.45rem 1rem;
  border-radius: 1.8rem;
  border: 0.4rem solid #26303c;
  background: linear-gradient(180deg, #fffef7, #ffe18a);
  box-shadow:
    0 1rem 2rem rgba(47, 55, 66, 0.24),
    inset 0 -0.35rem 0 rgba(255, 126, 75, 0.38);
  text-align: center;
  transform: rotate(-4deg);
  animation: yatzy-banner-pop 900ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.yatzy-banner strong {
  display: block;
  font-size: clamp(2.4rem, 12vw, 4.8rem);
  line-height: 0.9;
  color: #ffe539;
  text-shadow:
    -0.07em -0.07em 0 #26303c,
    0.07em -0.07em 0 #26303c,
    -0.07em 0.07em 0 #26303c,
    0.07em 0.07em 0 #26303c;
  letter-spacing: 0.04em;
}

.yatzy-banner span {
  display: block;
  margin-top: 0.45rem;
  font-size: 0.88rem;
  font-weight: 1000;
  letter-spacing: 0.08em;
  color: #37414d;
  text-transform: uppercase;
}

.emoji-celebration {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  animation: emoji-celebration-pop 1.8s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.emoji-celebration-emoji {
  font-size: clamp(3.5rem, 22vw, 6rem);
  line-height: 1;
  filter: drop-shadow(0 0.35rem 0.4rem rgba(47, 55, 66, 0.28));
}

.emoji-celebration-name {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: rgba(47, 55, 66, 0.82);
  color: var(--white);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.03em;
}

.emoji-celebration-gif {
  max-width: 8.5rem;
  max-height: 6.5rem;
  border-radius: 0.7rem;
  object-fit: contain;
  animation: emoji-celebration-pop 5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.defeat-mode-toast {
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  background: rgba(196, 55, 55, 0.9);
  color: var(--white);
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  animation: emoji-celebration-pop 2.2s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes die-launch {
  0% {
    transform: translateY(1rem) scale(0.88) rotate(-8deg);
    opacity: 0.35;
  }

  45% {
    transform: translateY(-0.55rem) scale(1.04) rotate(4deg);
    opacity: 1;
  }

  70% {
    transform: translateY(0.15rem) scale(0.98) rotate(-2deg);
  }

  100% {
    transform: translateY(0) scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes die-face-spin {
  0% {
    transform: scale(0.75) rotate(-16deg);
  }

  55% {
    transform: scale(1.06) rotate(8deg);
  }

  100% {
    transform: scale(1) rotate(0deg);
  }
}

@keyframes score-cell-catch {
  0% {
    transform: translateY(0.08rem) scale(1);
    box-shadow: 0 0 0 0.25rem rgba(87, 99, 110, 0.18);
  }

  48% {
    transform: translateY(0.08rem) scale(1.07);
    box-shadow: 0 0 0 0.44rem rgba(255, 255, 255, 0.78);
  }

  100% {
    transform: translateY(0.08rem) scale(1);
    box-shadow: 0 0 0 0.25rem rgba(87, 99, 110, 0.18);
  }
}

@keyframes score-choice-pulse {
  0%,
  100% {
    transform: translateY(0);
    box-shadow: 0 0 0 0.25rem var(--valid-glow);
  }

  50% {
    transform: translateY(-0.06rem);
    box-shadow: 0 0 0 0.42rem rgba(214, 91, 83, 0.14);
  }
}

body.player-two-turn .player-cell.valid {
  animation: score-choice-pulse-blue 1.35s ease-in-out infinite;
}

@keyframes score-choice-pulse-blue {
  0%,
  100% {
    transform: translateY(0);
    box-shadow: 0 0 0 0.25rem var(--valid-glow-blue);
  }

  50% {
    transform: translateY(-0.06rem);
    box-shadow: 0 0 0 0.42rem rgba(91, 147, 176, 0.16);
  }
}

@keyframes score-choice-pulse-red-strong {
  0%,
  100% {
    transform: translateY(0);
    box-shadow: 0 0 0 0.34rem rgba(214, 91, 83, 0.28);
  }

  50% {
    transform: translateY(-0.07rem);
    box-shadow: 0 0 0 0.52rem rgba(214, 91, 83, 0.18);
  }
}

@keyframes score-choice-pulse-blue-strong {
  0%,
  100% {
    transform: translateY(0);
    box-shadow: 0 0 0 0.34rem rgba(91, 147, 176, 0.3);
  }

  50% {
    transform: translateY(-0.07rem);
    box-shadow: 0 0 0 0.52rem rgba(91, 147, 176, 0.18);
  }
}

@keyframes category-choice-pulse {
  0%,
  100% {
    transform: translateY(0);
    box-shadow: inset 0 0 0 0.22rem rgba(255, 255, 255, 0.58);
  }

  50% {
    transform: translateY(-0.04rem);
    box-shadow: inset 0 0 0 0.34rem rgba(255, 255, 255, 0.82);
  }
}

@keyframes yatzy-stage-pop {
  0% {
    transform: scale(1);
  }

  25% {
    transform: scale(1.01) rotate(-0.4deg);
  }

  50% {
    transform: scale(1.025) rotate(0.35deg);
  }

  100% {
    transform: scale(1) rotate(0deg);
  }
}

@keyframes waiting-code-pulse {
  0% {
    transform: translateY(0);
    box-shadow: 0 0.35rem 0 #c64c45, 0 0 0 rgba(255, 255, 255, 0);
    filter: saturate(1);
  }

  50% {
    transform: translateY(-0.08rem);
    box-shadow: 0 0.45rem 0 #c64c45, 0 0 1.1rem rgba(255, 255, 255, 0.28);
    filter: saturate(1.08);
  }

  100% {
    transform: translateY(0);
    box-shadow: 0 0.35rem 0 #c64c45, 0 0 0 rgba(255, 255, 255, 0);
    filter: saturate(1);
  }
}

@keyframes waiting-status-fade {
  0%,
  100% {
    opacity: 0.58;
  }

  50% {
    opacity: 1;
  }
}

@keyframes yatzy-burst-spin {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }

  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@keyframes yatzy-burst-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.35);
  }

  55% {
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(1.08);
  }

  100% {
    opacity: 0.85;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes yatzy-banner-pop {
  0% {
    opacity: 0;
    transform: translateY(1.8rem) scale(0.55) rotate(-12deg);
  }

  55% {
    opacity: 1;
    transform: translateY(-0.35rem) scale(1.08) rotate(3deg);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(-4deg);
  }
}

@keyframes emoji-celebration-pop {
  0% {
    opacity: 0;
    transform: scale(0.4);
  }

  18% {
    opacity: 1;
    transform: scale(1.15);
  }

  30% {
    transform: scale(1);
  }

  78% {
    opacity: 1;
    transform: scale(1);
  }

  100% {
    opacity: 0;
    transform: scale(0.85);
  }
}

@keyframes yatzy-particle-burst {
  0% {
    opacity: 0;
    transform:
      translate(-50%, -50%)
      rotate(calc(var(--i) * 20deg))
      translateY(-1.5rem)
      scaleY(0.35);
  }

  25% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform:
      translate(-50%, -50%)
      rotate(calc(var(--i) * 20deg))
      translateY(-10.5rem)
      scaleY(1.2);
  }
}

@media (min-width: 700px) {
  .page {
    padding-top: 2.5rem;
  }

  .app-shell {
    width: min(100%, 34rem);
  }

  .score-cell {
    min-height: 4.55rem;
  }

  .dice-section {
    padding-top: 1.2rem;
  }

  .dice-row {
    gap: 0.9rem;
  }
}

@media (max-width: 430px) {
  .home-button {
    width: 2rem;
    height: 2rem;
    border-width: 0.18rem;
  }

  .game-settings-button {
    width: 2rem;
    height: 2rem;
    min-width: 2rem;
  }

  .page {
    padding-top: max(0.6rem, env(safe-area-inset-top));
  }

  .app-shell {
    width: 100%;
  }

  .splash-screen {
    padding-top: max(0.7rem, env(safe-area-inset-top));
  }

  .splash-nav-btn {
    width: 2.1rem;
    height: 2.1rem;
  }

  .splash-back-button {
    left: 0.7rem;
  }

  #settings-button {
    right: 0.7rem;
  }

  .splash-actions {
    gap: 0.65rem;
  }

  .splash-play,
  .splash-choice {
    min-height: 3.05rem;
    font-size: 0.9rem;
  }

  .splash-play.is-waiting-code {
    font-size: clamp(1.9rem, 11vw, 2.8rem);
  }

  .splash-cancel,
  .splash-share {
    min-height: 2.6rem;
    font-size: 0.84rem;
  }

  .splash-code-input,
  .splash-join-button {
    min-height: 3.1rem;
  }

  .splash-flag {
    padding: 0.35rem;
  }

  .flag-icon {
    width: 1.8rem;
    height: 1.26rem;
  }

  .game-header {
    gap: 0.35rem;
    margin-bottom: 0.55rem;
    padding: 0 0.15rem;
  }

  .game-header-row {
    flex-wrap: nowrap;
    gap: 0.35rem;
  }

  .header-title {
    flex-wrap: nowrap;
    gap: 0.3rem;
  }

  h1 {
    font-size: clamp(1.45rem, 8.5vw, 1.9rem);
  }

  .robot-toggle {
    min-height: 2rem;
    padding: 0.24rem 0.6rem;
    font-size: 0.68rem;
    border-width: 0.18rem;
  }

  .restart-button {
    width: 2rem;
    height: 2rem;
    min-width: 2rem;
    border-width: 0.18rem;
  }

  .emoji-trigger {
    right: 0;
    bottom: 0.85rem;
  }

  .emoji-trigger-button {
    width: 2.3rem;
    height: 2.3rem;
    border-width: 0.18rem;
    font-size: 1.05rem;
  }

  .score-summary {
    width: auto;
    flex: 1 1 auto;
    justify-content: flex-end;
    margin-top: 0;
    min-width: 0;
  }

  .score-card {
    padding: 0.28rem 0.55rem;
    border-width: 0.2rem;
  }

  .score-card-value {
    font-size: clamp(0.95rem, 4vw, 1.12rem);
  }

  .score-card-divider {
    font-size: clamp(0.9rem, 3.5vw, 1rem);
  }

  .scoreboard-panel {
    border-width: 0.45rem;
    border-radius: 1.45rem;
  }

  .score-group {
    grid-template-columns: 1.12fr 0.84fr 0.84fr;
  }

  .score-cell {
    min-height: 3.2rem;
    padding: 0.22rem;
    border-right-width: 0.16rem;
  }

  .player-cell {
    margin: 0.18rem;
    border-radius: 0.76rem;
    border-width: 0.2rem;
    font-size: 1rem;
  }

  .player-cell.valid.preview-positive {
    font-size: 1.6rem;
  }

  .player-cell.valid.preview-zero {
    font-size: 1rem;
  }

  .icon-tile,
  .face-die {
    /* No max-width override here (unlike the base rule's 4.25rem cap):
       below this breakpoint the category column itself is already narrow,
       so let the icon fill 100% of it (aspect-ratio keeps it square)
       instead of a second, independently-shrinking rem cap that fell
       behind the column's actual width and left a lot of visible padding
       around a too-small icon. */
    border-radius: 0.74rem;
    border-width: 0.2rem;
  }

  .icon-tile.text-icon {
    font-size: 1.45rem;
  }

  .icon-tile.word-icon {
    font-size: 0.7rem;
    letter-spacing: 0.03em;
  }

  .question-mark {
    font-size: 2rem;
  }

  .bonus-label {
    padding-left: 0.5rem;
  }

  .bonus-stack .bonus-title {
    font-size: 0.72rem;
  }

  .bonus-stack .bonus-value {
    font-size: 1.65rem;
  }

  .bonus-progress {
    border-width: 0.2rem;
    box-shadow: inset 0 0 0 0.16rem #f1bc8e;
    font-size: 0.72rem;
  }

  .dice-section {
    padding: 0.75rem 0 0;
  }

  .dice-row {
    gap: 0.32rem;
  }

  .game-die {
    border-width: 0.22rem;
    border-radius: 0.8rem;
    box-shadow: 0 0.24rem 0 rgba(87, 99, 110, 0.22);
  }

  .game-die .face-die {
    padding: 0.22rem;
  }

  .pip {
    width: 0.48rem;
    height: 0.48rem;
  }

  .star-shape {
    width: 1.7rem;
    height: 1.7rem;
  }

  .controls-panel {
    padding-top: 0.75rem;
    gap: 0.45rem;
  }

  .header-actions {
    gap: 0.5rem;
  }

  .selection-action,
  .roll-button {
    min-height: 4.55rem;
    border-radius: 1.05rem;
  }

  .go-back-button {
    min-height: 2.6rem;
    border-width: 0.18rem;
    border-radius: 0.85rem;
    font-size: 0.84rem;
  }

  .selection-action {
    padding: 0.82rem 0.78rem;
    font-size: 0.9rem;
  }

  .roll-button {
    gap: 0.6rem;
    /* Same reservation as the base rule, resized for the smaller
       .emoji-trigger-button used below this breakpoint (2.3rem). */
    padding: 0.82rem calc(0.9rem + 2.3rem + 0.3rem) 0.82rem 0.9rem;
  }

  .roll-label {
    font-size: clamp(1.12rem, 5.5vw, 1.55rem);
  }

  .roll-chip {
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 0.68rem;
    border-width: 0.22rem;
    font-size: 1.18rem;
  }
}

@media (max-width: 430px) and (max-height: 880px) {
  .score-cell {
    min-height: 2.98rem;
  }

  .dice-section {
    padding-top: 0.65rem;
  }

  .controls-panel {
    padding-top: 0.65rem;
  }

  .selection-action,
  .roll-button {
    min-height: 4.15rem;
  }
}
