:root {
  --navy: #05245f;
  --blue: #138cff;
  --red: #f3293e;
  --green: #08b54a;
  --yellow: #ffd42a;
  --app-height: 100dvh;
  --hud-height: 52px;
  color: #fff;
  background: #072b72;
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", system-ui, sans-serif;
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  height: var(--app-height);
  background:
    radial-gradient(ellipse at 50% 38%, #1774bb66, #06235e 88%),
    url("/background.svg") center/230px,
    #0a3e85;
}
button,
input {
  font: inherit;
}
button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:disabled {
  cursor: default;
  filter: saturate(0.5) brightness(0.75);
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
canvas:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}
button:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--button-shadow, #05245f);
}
a {
  color: inherit;
  text-decoration: none;
}
[hidden] {
  display: none !important;
}
svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.game-shell {
  width: min(100%, 660px);
  height: var(--app-height);
  padding: max(8px, env(safe-area-inset-top))
    max(4px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom))
    max(4px, env(safe-area-inset-left));
  margin: auto;
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr) 116px;
  position: relative;
}
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 3px;
  min-width: 0;
}
.game-logo {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 25px;
  font-weight: 950;
  line-height: 0.85;
  font-style: italic;
  letter-spacing: -0.8px;
  color: #ffe24d;
  text-shadow:
    0 2px 0 #9a591b,
    0 3px 0 #041c4d;
}
.game-logo small {
  display: block;
  font-size: 6px;
  font-style: normal;
  letter-spacing: 1.5px;
  color: #d7edff;
  text-shadow: none;
  margin-top: 6px;
}
.logo-die {
  font-size: 31px;
  color: #fff;
  transform: rotate(-13deg);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}
.round-button {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2px solid #65abed;
  border-radius: 11px;
  color: white;
  background: linear-gradient(#2779cd, #164a9d);
  box-shadow:
    0 3px 0 #031b4d,
    inset 0 1px 0 #ffffff38;
  font-size: 27px;
  font-weight: 800;
}
.connection {
  position: relative;
  width: 8px;
  height: 8px;
  overflow: hidden;
  color: transparent;
  font-size: 0;
  flex-shrink: 0;
}
.connection span {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffbe3b;
  box-shadow: 0 0 7px #ffbe3b80;
}
.connection[data-connected="true"] span {
  background: #4ff58d;
  box-shadow: 0 0 7px #4ff58d80;
}
.room-share {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #041e5280;
  border: 1px solid #4b83b8;
  border-radius: 10px;
  padding: 3px 4px 3px 8px;
}
.room-label {
  font-size: 8px;
  color: #9cc6ee;
  font-weight: 800;
}
#room-code {
  font-size: 12px;
  letter-spacing: 1px;
}
.room-share .round-button {
  width: 27px;
  height: 27px;
  border: none;
  border-radius: 6px;
  box-shadow: none;
}
.room-share svg {
  width: 16px;
  height: 16px;
}
.arena {
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: var(--hud-height) var(--board-size, 280px) var(
      --hud-height
    );
  align-content: center;
  column-gap: 6px;
}
.player-seats {
  display: contents;
}
.board-stage {
  grid-row: 2;
  grid-column: 1/-1;
  position: relative;
  width: var(--board-size, 280px);
  height: var(--board-size, 280px);
  place-self: center;
  min-height: 0;
}
.canvas-wrap {
  position: absolute;
  inset: 0;
  border-radius: 9px;
  overflow: hidden;
  box-shadow:
    0 5px 0 #031842,
    0 10px 24px #00153670;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
  background: #072b72;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
}
.loading-die {
  font-size: 55px;
  color: #ffdc43;
}
.player {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(var(--board-size, 280px) / 2 - 4px);
  min-width: 0;
  padding: 5px 4px;
  position: relative;
}
.seat-1 {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
  align-self: end;
}
.seat-2 {
  grid-column: 2;
  grid-row: 1;
  justify-self: start;
  align-self: end;
}
.seat-0 {
  grid-column: 1;
  grid-row: 3;
  justify-self: end;
  align-self: start;
}
.seat-3 {
  grid-column: 2;
  grid-row: 3;
  justify-self: start;
  align-self: start;
}
.seat-2,
.seat-3 {
  flex-direction: row-reverse;
  text-align: right;
}
.player-icon {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 29px;
  line-height: 1;
  background: linear-gradient(140deg, #fff, #c6e6ff);
  border: 3px solid var(--player-color);
  box-shadow: 0 3px 0 #031a4e;
}
.player-icon img {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  border-radius: inherit;
}
.player.active .player-icon {
  border-color: #ffdd3e;
  box-shadow:
    0 0 0 2px #fff0a4,
    0 0 16px #ffdb4b7a,
    0 3px 0 #031a4e;
}
.player.active:after {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #ffe351;
  position: absolute;
  bottom: 0;
  left: 20px;
}
.player.seat-0.active:after,
.player.seat-3.active:after {
  bottom: auto;
  top: 0;
  border-top: none;
  border-bottom: 6px solid #ffe351;
}
.player.seat-2.active:after,
.player.seat-3.active:after {
  left: auto;
  right: 20px;
}
.player-info {
  min-width: 0;
}
.player-name {
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-shadow: 0 2px #031b4e;
}
.player-sub {
  font-size: 10px;
  font-weight: 600;
  color: #b3d7fa;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-badge {
  color: #ffea79;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.4px;
  margin-top: 2px;
}
.player.empty .player-icon {
  background: #06275e;
  border-style: dashed;
  color: #90bbe4;
  font-size: 23px;
  box-shadow: none;
  opacity: 0.7;
}
.player.empty .player-name {
  color: #a1c3e4;
  font-weight: 600;
  font-size: 11px;
}
.player.empty .player-sub {
  color: #7fa9d1;
}
.control-area {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  align-items: end;
  width: min(100%, 430px);
  justify-self: center;
  padding: 0 18px 5px 6px;
  min-height: 0;
}
#room-panel {
  min-width: 0;
  grid-column: 2;
  grid-row: 1;
}
.help-button {
  grid-column: 1;
  grid-row: 1;
  font-size: 23px;
  margin-bottom: 5px;
  border-color: #fcda56;
  color: #ffe37d;
}
#lobby-controls {
  padding-top: 5px;
}
#lobby-hint {
  text-align: center;
  color: #c8e5ff;
  font-size: 12px;
  font-weight: 700;
  margin: 0 0 12px;
  min-height: 16px;
}
.game-button {
  --button-shadow: #093773;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  border: 2px solid #ffffff50;
  border-radius: 13px;
  font-size: 17px;
  font-weight: 900;
  line-height: 1.1;
  text-shadow: 0 1px 1px #00000035;
  box-shadow:
    0 5px 0 var(--button-shadow),
    inset 0 2px 0 #ffffff40;
  padding: 10px 14px;
}
.game-button span {
  font-size: 22px;
  line-height: 1;
}
.green-button {
  --button-shadow: #006221;
  background: linear-gradient(#29d665, #08a33d);
  color: #fff;
  border-color: #8af396;
}
.gold-button {
  --button-shadow: #b96b08;
  background: linear-gradient(#ffe973, #ffbe1f);
  color: #5e3308;
  border-color: #fff0a5;
  text-shadow: 0 1px 0 #ffffff60;
}
.blue-button {
  --button-shadow: #063a8c;
  background: linear-gradient(#43b9ff, #1275df);
  color: #fff;
  border-color: #8edbff;
}
.red-button {
  --button-shadow: #8b1730;
  background: linear-gradient(#ff6982, #e92648);
  color: #fff;
  border-color: #ffa9b7;
}
#game-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  grid-template-rows: 26px 22px 44px;
  gap: 4px 14px;
}
.turn-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  grid-column: 1;
  grid-row: 1;
}
.turn-line h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 850;
  letter-spacing: 0.1px;
  text-shadow: 0 2px #041e56;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#turn-color {
  display: block;
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid #ffffff80;
  box-shadow: 0 0 7px currentColor;
}
.dice-row {
  display: contents;
}
.die {
  grid-column: 2;
  grid-row: 1/4;
  width: 100px;
  height: 100px;
  align-self: center;
  justify-self: end;
  position: relative;
  background: linear-gradient(140deg, #fff, #d9edff);
  border: 3px solid #ffe17a;
  border-radius: 22px;
  box-shadow:
    0 5px 0 #a36c18,
    0 7px 12px #01184470,
    inset 0 0 0 2px white;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 19px;
  gap: 6px;
  transform: rotate(-5deg);
  touch-action: manipulation;
  isolation: isolate;
}
.die:disabled {
  filter: none;
}
.die[data-ready="true"]::after {
  content: "";
  position: absolute;
  inset: -7px;
  border: 3px solid #ffe567;
  border-radius: 27px;
  box-shadow:
    0 0 15px #ffda4f,
    inset 0 0 9px #ffda4f90;
  animation: dice-ready 1.2s ease-in-out infinite alternate;
  pointer-events: none;
}
.die:active:not(:disabled) {
  transform: rotate(-5deg) translateY(3px);
}
.die i {
  border-radius: 50%;
  background: #0b2760;
  visibility: hidden;
  box-shadow: inset 0 1px 1px #00000040;
}
.die > span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 44px;
  color: #5384b4;
  font-weight: 900;
}
.die:not([data-face="0"]) > span {
  display: none;
}
.die[data-face="1"] i:nth-child(5),
.die[data-face="2"] i:nth-child(1),
.die[data-face="2"] i:nth-child(9),
.die[data-face="3"] i:nth-child(1),
.die[data-face="3"] i:nth-child(5),
.die[data-face="3"] i:nth-child(9),
.die[data-face="4"] i:nth-child(1),
.die[data-face="4"] i:nth-child(3),
.die[data-face="4"] i:nth-child(7),
.die[data-face="4"] i:nth-child(9),
.die[data-face="5"] i:nth-child(1),
.die[data-face="5"] i:nth-child(3),
.die[data-face="5"] i:nth-child(5),
.die[data-face="5"] i:nth-child(7),
.die[data-face="5"] i:nth-child(9),
.die[data-face="6"] i:nth-child(1),
.die[data-face="6"] i:nth-child(3),
.die[data-face="6"] i:nth-child(4),
.die[data-face="6"] i:nth-child(6),
.die[data-face="6"] i:nth-child(7),
.die[data-face="6"] i:nth-child(9) {
  visibility: visible;
}
#turn-instruction {
  grid-column: 1;
  grid-row: 2;
  align-self: center;
  margin: 0;
  color: #c5e1ff;
  font-size: 13px;
  line-height: 1.25;
  text-align: center;
}
#rematch,
#pawn-choices {
  grid-column: 1;
  grid-row: 3;
}
#rematch {
  font-size: 16px;
}
.pawn-choices {
  display: flex;
  align-items: stretch;
  gap: 5px;
}
.pawn-choices button {
  --button-shadow: #b96b08;
  flex: 1;
  padding: 0;
  min-width: 0;
  border: 2px solid #fff0a5;
  border-radius: 10px;
  background: linear-gradient(#ffe973, #ffbe1f);
  box-shadow: 0 4px 0 #b96b08;
  color: #603509;
  font-weight: 900;
  font-size: 21px;
}
.pawn-choices button:disabled {
  opacity: 0.45;
  filter: grayscale(0.5);
}
.board-banner {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  transform: translateY(-50%);
  padding: 16px 12px;
  background: #06265af0;
  border: 2px solid #ffdf65;
  border-radius: 16px;
  box-shadow: 0 6px 0 #03153a;
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 7px;
  pointer-events: none;
}
.board-banner > span {
  color: #ffe14e;
  font-size: 28px;
  font-weight: 900;
}
.board-banner strong {
  font-size: 20px;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.15;
}
.board-banner small {
  color: #c5e0fa;
  font-size: 12px;
}
.victory > span {
  font-size: 45px;
}
.game-dialog {
  position: fixed;
  inset: auto;
  left: 50%;
  top: calc(var(--visual-top, 0px) + var(--app-height) / 2);
  margin: 0;
  transform: translate(-50%, -50%);
  color: #fff;
  background: radial-gradient(ellipse at top, #1d78bd, #0b3982 60%, #062965);
  border: 3px solid #65b4f0;
  border-radius: 24px;
  box-shadow:
    0 0 0 3px #032056,
    0 9px 0 #031c4b,
    0 22px 65px #000b;
  padding: 24px;
  width: min(350px, calc(100vw - 30px));
  max-height: calc(var(--app-height) - 28px);
  overflow: hidden;
}
.game-dialog::backdrop {
  background: #001942aa;
  backdrop-filter: blur(3px);
}
.home-brand {
  display: flex;
  position: relative;
  flex-direction: column;
  align-items: center;
  outline: none;
}
.home-brand h1 {
  margin: 0;
  font-size: 63px;
  line-height: 1;
  font-weight: 950;
  font-style: italic;
  letter-spacing: -2px;
  color: #ffe359;
  -webkit-text-stroke: 1px #fff0a3;
  text-shadow:
    0 4px 0 #a15708,
    0 7px 0 #032153,
    0 9px 12px #001b4b;
}
.home-die {
  font-size: 40px;
  line-height: 0.8;
  color: #fff;
  transform: rotate(-16deg);
  margin-bottom: 4px;
}
.home-stars {
  color: #ffe255;
  letter-spacing: 7px;
  font-size: 14px;
  margin: 12px 0 0 6px;
  text-shadow: 0 2px #914706;
}
.join-subtitle {
  text-align: center;
  color: #c4e3ff;
  font-size: 12px;
  margin: 13px 0 21px;
}
label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 7px;
  color: #e2f2ff;
}
input {
  width: 100%;
  min-width: 0;
  height: 45px;
  background: #f6fbff;
  border: 2px solid #7abbea;
  border-radius: 10px;
  color: #132c59;
  padding: 0 12px;
  font-size: 16px;
  box-shadow: inset 0 2px 4px #0825571a;
}
input::placeholder {
  color: #7991ac;
  font-size: 13px;
}
input:focus-visible {
  outline-color: #ffdc55;
}
#create {
  margin-top: 13px;
  font-size: 16px;
}
.color-picker {
  border: 0;
  padding: 0;
  margin: 10px 0 0;
}
.color-picker legend {
  padding: 0;
  margin-bottom: 5px;
  color: #e2f2ff;
  font-size: 11px;
  font-weight: 800;
}
.color-picker legend span {
  color: #9fc5e9;
  font-weight: 500;
}
.color-options {
  display: flex;
  align-items: center;
  gap: 8px;
}
.color-options button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 4px;
  border: 2px solid #96c7f0;
  border-radius: 50%;
  background: #092b63;
  cursor: pointer;
}
.color-options button span {
  width: 23px;
  height: 23px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--choice-color);
  box-shadow: inset 0 2px 2px #ffffff55;
}
.color-options button[aria-checked="true"] {
  border: 3px solid #fff0a1;
  box-shadow:
    0 0 0 2px #ffca3a,
    0 0 12px #ffe05c;
}
.color-options button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.color-options button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}
.color-options button[data-color-choice="0"] {
  --choice-color: #f3293e;
}
.color-options button[data-color-choice="1"] {
  --choice-color: #08b54a;
}
.color-options button[data-color-choice="2"] {
  --choice-color: #ffd42a;
}
.color-options button[data-color-choice="3"] {
  --choice-color: #138cff;
}
.settings-colors {
  gap: 4px;
}
.settings-colors button {
  width: 36px;
  height: 36px;
}
.color-setting-row {
  align-items: center;
}
.or {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #91bfe6;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  margin: 22px 0 15px;
}
.or:before,
.or:after {
  content: "";
  height: 1px;
  flex: 1;
  background: #78a8d044;
}
.join-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 106px;
  gap: 8px;
}
.join-row input {
  text-transform: uppercase;
  font-size: 15px;
  letter-spacing: 1px;
}
.join-row .game-button {
  min-height: 45px;
  font-size: 13px;
  padding: 8px;
  border-radius: 10px;
}
.join-footer {
  text-align: center;
  color: #8fbbe7;
  font-size: 10px;
  margin: 20px 0 0;
}
.join-footer span {
  color: #ffdc54;
  margin: 0 6px;
}
.dialog-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.dialog-title h2 {
  font-size: 25px;
  font-weight: 900;
  margin: 0;
  color: #ffe268;
  text-shadow: 0 2px #764510;
}
.dialog-title > span {
  font-size: 35px;
  color: white;
}
.menu-dialog[open] {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 18px;
}
.menu-dialog .dialog-title,
.setting-row {
  grid-column: 1 / -1;
  margin: 0;
}
.menu-dialog .game-button {
  min-height: 44px;
  font-size: 14px;
  padding: 8px;
  gap: 5px;
}
.menu-dialog .game-button + .game-button {
  margin: 0;
}
.menu-game-actions {
  display: flex;
  grid-column: 1 / -1;
  gap: 8px;
}
.menu-game-actions .game-button {
  flex: 1;
  min-width: 0;
  font-size: 12px;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  min-height: 44px;
}
.setting-row strong,
.setting-row label {
  font-size: 14px;
  font-weight: 800;
  margin: 0;
}
.setting-row small {
  display: block;
  font-size: 10px;
  color: #c5e1ff;
  margin-top: 4px;
}
.setting-switch,
#pawn-count {
  flex: 0 0 66px;
  min-height: 44px;
  border: 2px solid #88c4f5;
  border-radius: 11px;
  color: #fff;
  background: #082c68;
  font-size: 16px;
  font-weight: 900;
  text-align: center;
  padding: 5px 8px;
}
.setting-switch[aria-checked="true"] {
  color: #082c31;
  background: #57f19b;
  border-color: #b0ffcc;
}
#pawn-count:disabled {
  opacity: 0.5;
}
#invite-note {
  font-size: 13px;
  color: #c2dfff;
  line-height: 1.5;
  margin: 0 0 20px;
}
.rules-goal {
  color: #fff;
  font-size: 14px;
  margin: 0 0 15px;
  font-weight: 800;
}
.rules-dialog ol {
  list-style: none;
  margin: 0 0 23px;
  padding: 0;
  counter-reset: rule;
  display: grid;
  gap: 18px;
}
.rules-dialog li {
  position: relative;
  padding-left: 34px;
  counter-increment: rule;
}
.rules-dialog li:before {
  content: counter(rule);
  position: absolute;
  top: 0;
  left: 0;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #ffdc43;
  border: 1px solid #fff2a4;
  color: #683d0a;
  font-weight: 900;
  font-size: 14px;
  box-shadow: 0 3px 0 #aa6b0e;
}
.rules-dialog li b {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
  color: #fff3b6;
}
.rules-dialog li span {
  display: block;
  font-size: 12px;
  line-height: 1.4;
  color: #c7e1fc;
}
.alert {
  margin-top: 12px;
  background: #9b2548;
  border: 1px solid #ff8b9e;
  color: #fff;
  padding: 9px 11px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  border-radius: 10px;
}
#toast-layer {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 58px;
  z-index: 5;
  pointer-events: none;
}
#toast-layer .alert,
#toast-layer .invite-note {
  width: fit-content;
  margin: 0 auto;
  max-width: 100%;
  box-shadow: 0 4px 10px #041e5680;
}
.invite-note {
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid #6cd9ff;
  background: #064b91;
  color: #fff;
  font-size: 12px;
  line-height: 1.3;
}
.rolling {
  animation: roll 0.65s ease-in-out;
}
@keyframes roll {
  0%,
  100% {
    transform: rotate(-5deg);
  }
  20% {
    transform: translateY(-10px) rotate(70deg) scale(1.08);
  }
  45% {
    transform: translateY(0) rotate(180deg) scale(0.94);
  }
  70% {
    transform: translateY(-7px) rotate(285deg) scale(1.04);
  }
  90% {
    transform: rotate(365deg);
  }
}
@keyframes dice-ready {
  from {
    opacity: 0.55;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1.045);
  }
}
@media (max-width: 355px) {
  :root {
    --hud-height: 48px;
  }
  .game-shell {
    grid-template-rows: 44px minmax(0, 1fr) 110px;
    padding-left: max(4px, env(safe-area-inset-left));
    padding-right: max(4px, env(safe-area-inset-right));
  }
  .game-logo {
    font-size: 22px;
  }
  .logo-die {
    font-size: 25px;
  }
  .room-label {
    display: none;
  }
  .room-share {
    gap: 5px;
    padding-left: 6px;
  }
  #room-code {
    font-size: 11px;
    letter-spacing: 0.7px;
  }
  .header-actions {
    gap: 5px;
  }
  .player-icon {
    width: 48px;
    height: 48px;
    font-size: 31px;
    border-radius: 12px;
  }
  .player {
    gap: 6px;
  }
  .player-name {
    font-size: 11px;
  }
  .player-sub {
    font-size: 8px;
    margin-top: 3px;
  }
  .control-area {
    gap: 8px;
    padding-left: 4px;
    padding-right: 16px;
  }
  #game-controls {
    grid-template-columns: minmax(0, 1fr) 94px;
    column-gap: 12px;
  }
  .die {
    width: 90px;
    height: 90px;
    padding: 16px;
  }
  #turn-instruction {
    font-size: 12px;
  }
}
@media (min-width: 356px) and (max-width: 699px) {
  .player-icon {
    width: 50px;
    height: 50px;
    font-size: 33px;
    border-radius: 13px;
  }
}
@media (min-width: 700px) and (min-height: 650px) {
  :root {
    --hud-height: 77px;
  }
  .game-shell {
    grid-template-rows: 58px minmax(0, 1fr) 132px;
    padding-bottom: 23px;
  }
  .game-logo {
    font-size: 31px;
  }
  .player-icon {
    width: 56px;
    height: 56px;
    font-size: 38px;
    border-radius: 15px;
  }
  .player-name {
    font-size: 16px;
  }
  .player-sub {
    font-size: 12px;
  }
  .player-badge {
    font-size: 10px;
  }
  .control-area {
    width: 430px;
  }
}
@media (max-height: 500px) and (min-aspect-ratio: 4/3) {
  :root {
    --hud-height: 45px;
  }
  .game-shell {
    width: min(100%, 1000px);
    grid-template-columns: minmax(0, 1fr) 240px;
    grid-template-rows: 42px minmax(0, 1fr);
    column-gap: 12px;
    padding-top: 5px;
    padding-bottom: 8px;
  }
  .game-header {
    grid-column: 1/-1;
  }
  .arena {
    grid-column: 1;
    grid-row: 2;
  }
  .control-area {
    grid-column: 2;
    grid-row: 2;
    align-self: center;
    padding-right: 8px;
    gap: 8px;
  }
  .player-icon {
    width: 34px;
    height: 34px;
    font-size: 22px;
    border-radius: 9px;
  }
  .player {
    gap: 5px;
    padding-top: 3px;
    padding-bottom: 3px;
  }
  .player-name {
    font-size: 10px;
  }
  .player-sub {
    font-size: 8px;
    margin-top: 2px;
  }
  .player-badge {
    display: none;
  }
  #game-controls {
    grid-template-columns: minmax(0, 1fr) 90px;
    grid-template-rows: 26px 40px 46px;
    column-gap: 12px;
  }
  .die {
    width: 88px;
    height: 88px;
    padding: 15px;
  }
  #rematch {
    font-size: 13px;
    padding: 8px;
    gap: 4px;
  }
  .turn-line h2 {
    font-size: 13px;
  }
  #turn-instruction {
    font-size: 10px;
  }
}
@media (max-height: 570px) {
  .game-dialog {
    padding: 18px;
    border-radius: 19px;
  }
  .home-brand h1 {
    font-size: 43px;
  }
  .home-die {
    font-size: 28px;
  }
  .home-stars {
    display: none;
  }
  .join-subtitle {
    margin: 9px 0 13px;
    font-size: 11px;
  }
  .join-footer {
    margin-top: 13px;
  }
  .or {
    margin-top: 17px;
    margin-bottom: 11px;
  }
  .rules-dialog ol {
    gap: 12px;
    margin-bottom: 16px;
  }
  .rules-dialog li span {
    font-size: 11px;
  }
  .dialog-title {
    margin-bottom: 10px;
  }
  .rules-goal {
    font-size: 12px;
    margin-bottom: 12px;
  }
}
@media (max-height: 420px) {
  .menu-dialog[open] {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    width: min(440px, calc(100vw - 28px));
  }
  .menu-dialog .dialog-title,
  .menu-dialog p {
    grid-column: 1 / -1;
    margin: 0;
  }
  .menu-dialog .game-button + .game-button {
    margin-top: 0;
  }
  .menu-dialog .setting-row {
    min-height: 40px;
  }
  .menu-dialog .setting-switch,
  .menu-dialog #pawn-count {
    min-height: 40px;
  }
  .home-brand,
  .join-subtitle,
  .join-footer {
    display: none;
  }
  .game-dialog {
    padding: 16px;
  }
  .rules-dialog li span {
    font-size: 10px;
  }
  .rules-dialog li b {
    font-size: 12px;
    margin-bottom: 2px;
  }
  .rules-dialog ol {
    gap: 9px;
    margin-bottom: 14px;
  }
  .rules-dialog .game-button {
    min-height: 41px;
    font-size: 15px;
  }
  .dialog-title h2 {
    font-size: 23px;
  }
  .rules-goal {
    font-size: 11px;
    margin-bottom: 10px;
  }
}
html[data-keyboard="true"] .home-brand,
html[data-keyboard="true"] .join-subtitle,
html[data-keyboard="true"] .join-footer {
  display: none;
}
html[data-keyboard="true"] .join-dialog .color-picker {
  display: none;
}
@media (max-height: 280px) {
  .join-dialog .color-picker {
    display: none;
  }
}
html[data-keyboard="true"] .game-dialog {
  padding: 14px 18px;
}
html[data-keyboard="true"] .or {
  margin: 12px 0 8px;
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation: none !important;
    transition: none !important;
  }
}

/* The visual viewport can shrink without changing layout media queries when a
   phone keyboard opens. Keep every entry control reachable in that space. */
html[data-short="true"] .join-dialog {
  padding: 10px 16px;
  max-height: calc(var(--app-height) - 12px);
}
html[data-short="true"] .home-brand,
html[data-short="true"] .join-subtitle,
html[data-short="true"] .join-footer {
  display: none;
}
html[data-short="true"] .join-dialog label {
  font-size: 11px;
  margin-bottom: 3px;
}
html[data-short="true"] .join-dialog input {
  height: 36px;
  font-size: 16px;
}
html[data-short="true"] .join-dialog .game-button {
  min-height: 36px;
  padding: 7px 12px;
  font-size: 14px;
  border-radius: 8px;
}
html[data-short="true"] .join-dialog #create {
  margin-top: 8px;
}
html[data-short="true"] .join-dialog .color-picker {
  margin-top: 5px;
}
html[data-short="true"] .join-dialog .color-options button {
  width: 30px;
  height: 30px;
}
html[data-short="true"] .join-dialog .color-options button span {
  width: 19px;
  height: 19px;
}
html[data-short="true"] .join-dialog #create {
  margin-top: 5px;
}
html[data-short="true"] .join-dialog .or {
  margin: 10px 0 7px;
  font-size: 8px;
}
html[data-short="true"] .join-dialog .alert {
  font-size: 10px;
  padding: 6px;
  margin-top: 8px;
}

@media (max-height: 420px) {
  .menu-dialog .friendly-setting,
  .menu-dialog .luck-setting {
    grid-column: auto;
    gap: 4px;
  }
  .menu-dialog .friendly-setting strong,
  .menu-dialog .luck-setting strong {
    font-size: 12px;
  }
  .menu-dialog .friendly-setting .setting-switch,
  .menu-dialog .luck-setting .setting-switch {
    flex-basis: 48px;
  }
}

@media (max-height: 340px) {
  .rules-dialog {
    width: min(440px, calc(100vw - 28px));
    padding: 14px 18px;
  }
  .rules-dialog ol {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .menu-dialog {
    padding: 8px 12px;
  }
  .menu-dialog[open] {
    gap: 5px;
  }
  .menu-dialog .dialog-title {
    margin-bottom: 0;
  }
  .menu-dialog .setting-row {
    min-height: 32px;
  }
  .menu-dialog .setting-row small {
    margin-top: 1px;
  }
  .menu-dialog .settings-colors button {
    width: 30px;
    height: 30px;
  }
  .menu-dialog .settings-colors button span {
    width: 19px;
    height: 19px;
  }
  .menu-dialog p {
    margin-bottom: 14px;
  }
  .menu-dialog .game-button {
    min-height: 34px;
    padding: 5px;
    font-size: 12px;
  }
  .menu-dialog .game-button + .game-button {
    margin-top: 0;
  }
  .board-banner {
    padding: 8px;
    gap: 4px;
  }
  .board-banner strong {
    font-size: 16px;
  }
  .board-banner small {
    font-size: 10px;
  }
  .board-banner.victory > span {
    font-size: 28px;
  }
}
