/* ============ Shared screen pieces ============ */
.screen-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: .75rem;
  width: min(900px, 100%);
  margin-bottom: 1.4rem;
}

.screen-header > :first-child { justify-self: start; }
.screen-header > :last-child { justify-self: end; }

.screen-footer {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-top: auto;
  padding-top: 1.4rem;
  padding-bottom: .5rem;
}

.back-btn { width: 54px; height: 54px; }

/* ============ Main menu ============ */
.corner-toggles {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: var(--gutter);
  z-index: 5;
  display: flex;
  gap: 14px;
}

.corner-toggles .round-btn { width: 64px; height: 64px; }

/* The background picture already shows the logo (its bottom edge sits 38% down the 3:2 picture,
   which is drawn max(screen height, width / 1.5) tall and centred), so the buttons start just below it. */
#screen-menu {
  --logo-bottom: calc(50vh - .12 * max(100vh, 66.667vw));
  --logo-bottom: calc(50dvh - .12 * max(100dvh, 66.667vw));
}

.menu-content {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(520px, 100%);
  margin-top: max(0px, calc(var(--logo-bottom) - 4px));
}

/* Only for screen readers: the picture shows the title */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.menu-buttons {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: min(400px, 100%);
}

/* A soft dark halo so the buttons stand out from the busy picture */
.menu-buttons::before {
  content: '';
  position: absolute;
  inset: -16% -14%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(14, 34, 60, .4), rgba(14, 34, 60, 0));
  pointer-events: none;
}

.menu-buttons .pill { width: 100%; min-height: 70px; font-size: clamp(1.4rem, 5vw, 1.9rem); justify-content: flex-start; padding-left: 1.4em; }
.menu-buttons .pill-xl { min-height: 86px; font-size: clamp(1.8rem, 6.5vw, 2.6rem); }
.menu-buttons .pill span { flex: 1; text-align: center; margin-right: 1.2em; }
.menu-buttons .pill-xl span { margin-right: 1em; }

.menu-buttons .pill { --enter: pop-in .5s var(--ease-bounce) var(--enter-delay, 0s) backwards; }
.menu-buttons .pill:nth-child(1) { --enter-delay: .7s; }
.menu-buttons .pill:nth-child(2) { --enter-delay: .82s; }
.menu-buttons .pill:nth-child(3) { --enter-delay: .94s; }

/* ============ Game mode screen ============ */
.mode-buttons {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  width: min(420px, 100%);
  margin: auto 0 1.4rem;
}

.mode-buttons .pill { width: 100%; justify-content: flex-start; padding-left: 1.2em; }
.mode-buttons .pill .pill-emoji { width: 1.6em; text-align: center; }
.mode-buttons .pill span:last-child { flex: 1; text-align: center; margin-right: 1.6em; }

.mode-buttons .pill { --enter: pop-in .45s var(--ease-bounce) var(--enter-delay, 0s) backwards; }
.mode-buttons .pill:nth-child(2) { --enter-delay: .08s; }
.mode-buttons .pill:nth-child(3) { --enter-delay: .16s; }
.mode-buttons .pill:nth-child(4) { --enter-delay: .24s; }

#btn-howto { margin-bottom: auto; }

/* ============ Player setup ============ */
.seats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.1rem;
  width: min(1100px, 100%);
}

.seat {
  display: flex;
  flex-direction: column;
  gap: .7rem;
  width: min(250px, 100%);
  padding: .9rem 1rem 1rem;
  border-radius: var(--radius);
  text-shadow: 0 2px 0 rgba(60, 30, 10, .6);
  animation: pop-in .4s var(--ease-bounce) backwards;
}

.seat:nth-child(2) { animation-delay: .06s; }
.seat:nth-child(3) { animation-delay: .12s; }
.seat:nth-child(4) { animation-delay: .18s; }

.seat-head {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.seat-pawn {
  flex: none;
  width: 52px;
  height: 62px;
  display: grid;
  place-items: end center;
}

.seat-pawn .pawn-svg { width: 46px; animation: bob 2.4s ease-in-out infinite; }

.seat-label {
  font-size: 1.45rem;
  font-weight: 700;
  -webkit-text-stroke: .08em var(--wood-edge);
  paint-order: stroke fill;
}

.seat-sub {
  display: block;
  font-size: .95rem;
  font-weight: 600;
  color: #ffe9c7;
}

.bot-badge { margin-left: auto; font-size: 1.7rem; }

/* Pawn color choices */
.color-choices {
  display: flex;
  justify-content: space-between;
  gap: .3rem;
  padding: .35rem .4rem;
  border-radius: 14px;
  background: rgba(60, 30, 10, .35);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .3);
}

.color-choice {
  display: grid;
  place-items: end center;
  width: 48px;
  height: 52px;
  padding: 2px 0 3px;
  border: 3px solid transparent;
  border-radius: 12px;
  background: none;
  cursor: pointer;
  transition: transform .15s var(--ease-bounce), background .2s;
}

.color-choice .pawn-svg { width: 32px; }
.color-choice:hover:not(:disabled) { transform: translateY(-3px); }

.color-choice[aria-checked="true"] {
  border-color: #fff;
  background: rgba(255, 255, 255, .28);
  box-shadow: 0 0 0 3px rgba(255, 224, 102, .8), 0 0 14px rgba(255, 224, 102, .9);
}

.color-choice:disabled { opacity: .3; cursor: not-allowed; filter: grayscale(.6); }

/* "Sits at": a tiny screen per choice with the player's edge lit up, on its own line under the label */
.side-row { flex-direction: column; align-items: stretch; gap: .3rem; }
.side-choices {
  display: flex;
  justify-content: space-between;
  gap: .25rem;
  padding: .25rem .3rem;
  border-radius: 14px;
  background: rgba(60, 30, 10, .35);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .3);
}

.side-choice {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 3px solid transparent;
  border-radius: 12px;
  background: none;
  cursor: pointer;
  transition: transform .15s var(--ease-bounce), background .2s;
}

.side-choice:hover { transform: translateY(-2px); }

.side-choice[aria-checked="true"] {
  border-color: #fff;
  background: rgba(255, 255, 255, .28);
  box-shadow: 0 0 0 3px rgba(255, 224, 102, .8), 0 0 14px rgba(255, 224, 102, .9);
}

.side-icon {
  position: relative;
  width: 30px;
  height: 22px;
  border: 3px solid #fff3d6;
  border-radius: 5px;
  background: rgba(255, 255, 255, .12);
}

/* The lit edge: where this player sits */
.side-icon::after {
  content: '';
  position: absolute;
  border-radius: 2px;
  background: #ffe066;
  box-shadow: 0 0 6px #ffe066;
}

.side-bottom::after { left: 2px; right: 2px; bottom: 2px; height: 4px; }
.side-top::after { left: 2px; right: 2px; top: 2px; height: 4px; }
.side-left::after { top: 2px; bottom: 2px; left: 2px; width: 4px; }
.side-right::after { top: 2px; bottom: 2px; right: 2px; width: 4px; }

.name-input {
  width: 100%;
  min-height: var(--tap);
  padding: .35em .9em;
  border: 3px solid var(--wood-edge);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 600;
  outline: none;
  box-shadow: inset 0 3px 4px rgba(0, 0, 0, .15);
}

.name-input:focus { border-color: #1f86ea; box-shadow: 0 0 0 4px rgba(31, 134, 234, .35); }
.name-input::placeholder { color: #a8957c; }

.seat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  font-size: 1.15rem;
}

/* Big − / + stepper */
.stepper {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
}

.stepper button {
  width: 50px;
  height: 50px;
  padding: 0;
  border: 3px solid #b05400;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, #ffd27a, #f58a14 65%, #c96a00);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .18), 0 4px 0 #8a4300;
  color: #fff;
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1;
  -webkit-text-stroke: .06em rgba(0, 0, 0, .35);
  paint-order: stroke fill;
  cursor: pointer;
  transition: transform .1s ease, box-shadow .1s ease;
}

.stepper button:active { transform: translateY(3px); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18), 0 1px 0 #8a4300; }
.stepper button:disabled { filter: grayscale(.8); opacity: .5; cursor: not-allowed; }

.stepper-value {
  min-width: 2.1ch;
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  -webkit-text-stroke: .08em var(--wood-edge);
  paint-order: stroke fill;
}

.stepper-value.bump { animation: tap-bounce .35s var(--ease-bounce); }

/* ============ Settings ============ */
.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .45rem .25rem;
}

.setting-label {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: clamp(1.15rem, 4vw, 1.4rem);
}

.setting-icon { font-size: 1.6rem; text-shadow: none; }

.setting-heading {
  margin: .5rem 0 0;
  padding-top: 1rem;
  border-top: 3px dashed rgba(255, 233, 199, .4);
  font-size: 1.5rem;
  font-weight: 700;
}

.setting-hint {
  margin: -.5rem 0 0;
  font-size: 1rem;
  font-weight: 500;
  color: #ffe9c7;
}

.switch {
  flex: none;
  position: relative;
  width: 88px;
  height: 48px;
  padding: 0;
  border: 4px solid var(--wood-edge);
  border-radius: 999px;
  background: #8c7a66;
  box-shadow: inset 0 4px 6px rgba(0, 0, 0, .35);
  cursor: pointer;
  transition: background .25s ease;
}

.switch::before {
  content: 'OFF';
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  font-size: .8rem;
  font-weight: 700;
  color: #f1e6d6;
  text-shadow: none;
}

.switch[aria-checked="true"] { background: linear-gradient(180deg, #5fd35f, #22a23a); }
.switch[aria-checked="true"]::before { content: 'ON'; left: 11px; right: auto; color: #fff; }

.switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #e6e9ef);
  box-shadow: 0 3px 5px rgba(0, 0, 0, .35);
  transition: transform .3s var(--ease-bounce);
}

.switch[aria-checked="true"] .switch-knob { transform: translateX(40px); }

.age-rows {
  display: flex;
  flex-direction: column;
  gap: .7rem;
}

.age-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .45rem .75rem;
  border-left: 8px solid var(--pc, #fff);
  border-radius: 14px;
  background: rgba(60, 30, 10, .3);
}

.age-avatar {
  flex: none;
  display: grid;
  place-items: end center;
  width: 44px;
  height: 52px;
}

.age-avatar .pawn-svg { width: 38px; }

.age-name {
  flex: 1;
  min-width: 0;
  font-size: 1.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pc-red { --pc: var(--red); }
.pc-green { --pc: var(--green); }
.pc-yellow { --pc: var(--yellow); }
.pc-blue { --pc: var(--blue); }

.saved-badge {
  padding: .3em .9em;
  border: 3px solid #13801b;
  border-radius: 999px;
  background: linear-gradient(180deg, #7be36a, #2fbf2f);
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  -webkit-text-stroke: .06em rgba(0, 0, 0, .3);
  paint-order: stroke fill;
  opacity: 0;
  transform: scale(.6);
  transition: opacity .25s ease, transform .3s var(--ease-bounce);
}

.saved-badge.show { opacity: 1; transform: none; }

/* ============ Leaderboard ============ */
.leaderboard-panel { padding: 1rem 1rem 1.2rem; }

.lb-head,
.lb-row {
  display: grid;
  grid-template-columns: 2.6rem 1fr 5.4rem 5.4rem;
  align-items: center;
  gap: .5rem;
}

.lb-head {
  padding: 0 .7rem .5rem;
  font-size: 1rem;
  color: #ffe9c7;
}

.lb-head span:nth-child(n+3) { text-align: center; }

.lb-list {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.lb-row {
  padding: .45rem .7rem;
  border-radius: 14px;
  background: rgba(60, 30, 10, .3);
  font-size: 1.2rem;
  animation: fade-up .35s ease backwards;
}

.lb-row:nth-child(1) { background: linear-gradient(90deg, rgba(255, 204, 0, .45), rgba(60, 30, 10, .3)); }
.lb-rank { font-size: 1.5rem; text-align: center; text-shadow: none; }
.lb-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-num { text-align: center; font-size: 1.35rem; font-weight: 700; }

.lb-empty {
  margin: .8rem 0;
  font-size: 1.15rem;
  text-align: center;
}

.lb-actions,
.lb-confirm {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .7rem;
  margin-top: 1.1rem;
}

.lb-confirm p { margin: 0; font-size: 1.15rem; }
.lb-confirm-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: .8rem; }

/* ============ How to play ============ */
.howto { width: min(560px, 100%); }

.howto-steps {
  display: flex;
  flex-direction: column;
  gap: .7rem;
  margin: 0 0 1.3rem;
  padding: 0;
  list-style: none;
  text-align: left;
}

.howto-step {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .6rem .8rem;
  border-radius: 14px;
  background: rgba(60, 30, 10, .3);
  animation: fade-up .4s ease both;
}

.howto-art {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .15rem;
  width: 92px;
  height: 62px;
  border: 3px solid var(--wood-edge);
  border-radius: 12px;
  background: var(--paper);
  font-size: 1.6rem;
  white-space: nowrap;
  text-shadow: none;
}

.howto-art .pawn-svg { width: 26px; }
.howto-art .dice-svg { width: 34px; }

.howto-text {
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 1.35;
  text-shadow: 0 2px 0 rgba(60, 30, 10, .6);
}

.howto-text strong { color: #ffe066; font-weight: 700; }

/* ============ Responsive ============ */
@media (max-width: 600px) {
  .seat { width: 100%; }
  .corner-toggles .round-btn { width: 52px; height: 52px; }
  .howto-art { width: 72px; height: 54px; font-size: 1.2rem; }
  .lb-head, .lb-row { grid-template-columns: 2.2rem 1fr 4rem 4rem; }
}

/* Phones held sideways and other short screens */
@media (max-height: 560px) and (orientation: landscape) {
  .menu-buttons { gap: .6rem; width: min(330px, 100%); }
  .menu-buttons .pill { min-height: 48px; font-size: 1.15rem; }
  .menu-buttons .pill-xl { min-height: 56px; font-size: 1.45rem; }
  .screen-header { margin-bottom: .7rem; }
  .mode-buttons { gap: .6rem; }
  .mode-buttons .pill { min-height: 50px; }
  .seat { width: min(220px, 100%); padding: .6rem .8rem; gap: .45rem; }
}
