@import url("https://fonts.googleapis.com/css2?family=Kalam:wght@300;400;700&display=swap");
:root {
  --box: 60px;
  --avatar-game: clamp(52px, 14vw, 96px);
  --dice-game: clamp(52px, 14vw, 96px);
  --dice-icon: clamp(28px, 7vw, 72px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Kalam", cursive;
  -webkit-tap-highlight-color: transparent;
}

html {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  max-width: 100vw;
  overflow: hidden;
}
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  min-height: 100dvh;
  max-width: 100vw;
  overflow: hidden;
}
button:hover {
  cursor: pointer;
}
button,
.selectBox,
.arrow,
.diceBox {
  touch-action: manipulation;
}

.container {
  margin: auto;
  width: min(1440px, 100%);
  max-width: 100%;
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 12px;
}
.boardArea {
  padding: 12px;
  width: 100%;
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}
.bigBoard {
  width: min(calc(var(--box) * 10), 100%);
  max-width: 100%;
  aspect-ratio: 1;
  position: relative;
}
.gamePlayers {
  flex: 1 1 320px;
  min-width: 0;
  max-width: 100%;
  padding: 12px;
}
.playersBox {
  background-color: #ffffff6b;
  height: auto;
  border-radius: 24px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(8px, 2vw, 20px);
  padding: clamp(10px, 2vw, 20px);
  overflow: hidden;
}
.playerCard {
  border-radius: 12px;
  background-color: #ffffff88;
  padding: clamp(8px, 2vw, 16px);
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.level1 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.level1 img {
  width: var(--avatar-game);
  height: var(--avatar-game);
  max-width: 42%;
  flex: 0 0 auto;
  aspect-ratio: 1;
  border-radius: 100%;
  object-fit: cover;
}
.diceBox {
  width: var(--dice-game);
  height: var(--dice-game);
  max-width: 42%;
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
  aspect-ratio: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 12px;
  transition: transform 0.12s ease, opacity 0.12s ease;
  overflow: hidden;
}
.diceBox:hover {
  cursor: pointer;
}
.diceBox:active {
  transform: scale(0.96);
}
.diceBox.dice-disabled {
  opacity: 0.55;
  pointer-events: none;
}
.diceImg {
  font-size: var(--dice-icon);
  line-height: 1;
  opacity: 0;
  transform: rotate(360deg) scale(0);
  animation: zoomInRotate 0.55s 1 forwards;
}
@keyframes zoomInRotate {
  0% {
    opacity: 0;
    transform: rotate(180deg) scale(0.2);
  }
  100% {
    opacity: 1;
    transform: rotate(0) scale(1);
  }
}
#dice1 {
  color: #ff3737;
}
#dice2 {
  color: #2455db;
}
#dice3 {
  color: #2c974b;
}
#dice4 {
  color: #ffa116;
}
.level2 {
  width: 100%;
  min-width: 0;
  margin: 8px 0 0;
}
.level2 div {
  background-color: #ffffff88;
  width: 100%;
  padding: clamp(6px, 1.5vw, 12px);
  border-radius: 12px;
  font-size: clamp(14px, 2.5vw, 18px);
  letter-spacing: 0.5px;
  font-weight: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.board {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  aspect-ratio: 1;
  box-shadow: -9px -9px 20px 5px rgba(0, 0, 0, 0.1),
    9px 9px 20px 5px rgba(0, 0, 0, 0.1);
}

.potsBoard {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  max-width: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
}

.box {
  max-width: 100%;
  aspect-ratio: 1;
  width: min(100%, 60px);
  flex-wrap: wrap;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px;
  /* border: 1px solid; */
}
.pot {
  width: calc(var(--box) / 3);
  aspect-ratio: 1;
  border-radius: 100%;
  transform: scale(1);
  margin: 0;
  position: relative;
  animation: zoomIn 0.5s infinite;
}
.pot::after {
  content: "";
  width: 12px;
  aspect-ratio: 1;
  border-radius: 100%;
  z-index: 2;
  position: absolute;
  top: -6px;
  left: 4px;
}
.redPot {
  background: radial-gradient(
    circle at 50% 120%,
    #f68181,
    #ef7676 10%,
    #940505 80%,
    #450606 100%
  );
}
.redPot::after {
  background: radial-gradient(
    circle at 50% 120%,
    #f68181,
    #ef7676 10%,
    #940505 80%,
    #450606 100%
  );
}
.bluePot {
  background: radial-gradient(
    circle at 50% 120%,
    #8183f6,
    #8176ef 10%,
    #051a94 80%,
    #050606 100%
  );
}
.bluePot::after {
  background: radial-gradient(
    circle at 50% 120%,
    #8183f6,
    #8176ef 10%,
    #051a94 80%,
    #050606 100%
  );
}
.greenPot {
  background: radial-gradient(
    circle at 50% 120%,
    #8ff681,
    #b7ef76 10%,
    #059424 80%,
    #050605 100%
  );
}
.greenPot::after {
  background: radial-gradient(
    circle at 50% 120%,
    #8ff681,
    #b7ef76 10%,
    #059424 80%,
    #050605 100%
  );
}
.yellowPot {
  background: radial-gradient(
    circle at 50% 120%,
    #f4f681,
    #efe776 10%,
    #948a05 80%,
    #060605 100%
  );
}
.yellowPot::after {
  background: radial-gradient(
    circle at 50% 120%,
    #f4f681,
    #efe776 10%,
    #948a05 80%,
    #060605 100%
  );
}
.exitPot {
  width: calc(var(--box) / 3);
  aspect-ratio: 1;
  border-radius: 100%;
  transform: scale(0.5);
  animation: zoomOut 1s 1 forwards;
}
.redExit {
  background-color: #ff6b6b;
}
.blueExit {
  background-color: #8176ef;
}
.greenExit {
  background-color: #b7ef76;
}
.yellowExit {
  background-color: #efe776;
}
@keyframes zoomIn {
  0% {
    transform: scale(0.5);
  }
  50% {
    transform: scale(1);
  }
  100% {
    transform: scale(0.5);
  }
}
@keyframes zoomOut {
  0% {
    transform: scale(0.7);
  }
  100% {
    transform: scale(0);
  }
}

@keyframes shadeIn {
  0% {
    transform: scale(0.8);
  }
  50% {
    transform: scale(1);
  }
  100% {
    filter: hue-rotate(1);
    transform: scale(0.8);
  }
}
.screen {
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding:
    max(12px, var(--safe-t))
    max(12px, var(--safe-r))
    max(12px, var(--safe-b))
    max(12px, var(--safe-l));
  background-image: url("images/screen1.webp");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
}

#screen1,
#screen2 {
  flex: 1 1 auto;
  min-height: 0;
}

#screen1 .s1-card,
#screen2 .s1-card {
  flex: 0 1 auto;
  width: min(680px, 100%);
}

@media only screen and (min-width: 1361px) {
  .gamePlayers {
    flex: 0 1 min(440px, 36vw);
    min-width: 280px;
    max-width: 480px;
  }
}

@media only screen and (max-width: 1360px) {
  .container {
    flex-direction: column;
    gap: 12px;
  }
  .gamePlayers {
    flex: 0 0 auto;
    width: min(640px, 100%);
    margin: 0 auto;
  }
  #screen3 > .container {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
    width: 100%;
  }
  #screen3 .boardArea {
    flex: 1 1 0;
    min-height: 0;
    max-width: 100%;
    width: 100%;
    container-type: size;
  }
  #screen3 .bigBoard {
    width: min(100cqw, 100cqh, calc(var(--box) * 10));
    height: min(100cqw, 100cqh);
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1;
    flex-shrink: 0;
  }
}

@media only screen and (max-width: 700px) {
  :root {
    --avatar-game: clamp(44px, 18vw, 64px);
    --dice-game: clamp(44px, 18vw, 64px);
    --dice-icon: clamp(24px, 9vw, 40px);
  }
  .boardArea {
    padding: 0;
  }
  .gamePlayers {
    padding: 0;
    width: min(600px, 100%);
  }
  .playersBox {
    border-radius: 12px;
    gap: 6px;
    padding: 6px;
  }
  .playerCard {
    border-radius: 8px;
    padding: 8px;
  }
  .level2 {
    width: 100%;
    margin: 6px 0 0;
  }
  .level2 div {
    background-color: unset;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: clamp(12px, 3.5vw, 14px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Mobile / tablet landscape — no page scroll; game players stacked vertically */
@media only screen and (orientation: landscape) and (max-width: 1100px) {
  :root {
    --avatar-game: clamp(28px, 8.5vh, 44px);
    --dice-game: clamp(28px, 8.5vh, 44px);
    --dice-icon: clamp(18px, 6.5vh, 30px);
  }

  .screen {
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
    padding:
      max(4px, var(--safe-t))
      max(6px, var(--safe-r))
      max(4px, var(--safe-b))
      max(6px, var(--safe-l));
  }

  /* --- Screen 1: player count (fit START on screen) --- */
  #screen1 .s1-card {
    margin: 0 auto;
    width: min(640px, 96vw);
    max-height: calc(100% - 8px);
    padding: clamp(6px, 1.8vh, 12px) clamp(10px, 2.5vw, 16px);
  }
  #screen1 .s1-card h1 {
    font-size: clamp(1.1rem, 5vh, 1.65rem);
    line-height: 1.05;
  }
  #screen1 .s1-card .subHeading {
    font-size: clamp(0.7rem, 2.8vh, 0.95rem);
    margin: 2px 0 6px;
  }
  #screen1 .choose {
    margin: 4px 0 6px;
    gap: 6px;
  }
  #screen1 .selectBox {
    aspect-ratio: auto;
    height: clamp(44px, 15vh, 64px);
    padding: 4px 2px;
  }
  #screen1 .selectBox span:first-child {
    font-size: clamp(1.35rem, 6.5vh, 2rem);
    line-height: 1;
  }
  #screen1 .selectBox span:last-child {
    font-size: clamp(0.62rem, 2.4vh, 0.8rem);
    line-height: 1;
  }
  #screen1 .startBtn {
    width: min(200px, 52vw);
    height: clamp(38px, 10vh, 46px);
    font-size: clamp(0.95rem, 3.8vh, 1.15rem);
    margin: 4px auto 0;
  }

  /* --- Screen 3: board + vertical player stack --- */
  #screen3 {
    overflow: hidden;
    max-height: 100%;
    height: 100%;
  }
  #screen3 > .container {
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    gap: 6px;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: 100%;
    overflow: hidden;
    padding:
      calc(36px + max(2px, var(--safe-t)))
      max(4px, var(--safe-r))
      max(2px, var(--safe-b))
      max(4px, var(--safe-l));
  }
  #screen3 .boardArea {
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    align-self: stretch;
    padding: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  #screen3 .boardArea {
    container-type: size;
  }
  #screen3 .bigBoard {
    position: relative;
    flex: 0 0 auto;
    width: min(
      100cqw,
      100cqh,
      calc(100vw - clamp(148px, 26vw, 200px) - 24px)
    );
    height: min(100cqw, 100cqh);
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1;
    margin: 0 auto;
    container-type: inline-size;
  }
  #screen3 .bigBoard .pot,
  #screen3 .bigBoard .exitPot {
    width: calc(100cqw / 30);
  }
  #screen3 .bigBoard .pot::after {
    width: calc(100cqw / 83);
    top: calc(-100cqw / 500);
    left: calc(100cqw / 250);
  }
  #screen3 .gamePlayers {
    flex: 0 0 clamp(148px, 26vw, 200px);
    width: clamp(148px, 26vw, 200px);
    min-width: 140px;
    max-width: 200px;
    align-self: stretch;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  #screen3 .playersBox {
    display: flex;
    flex-direction: column;
    gap: 4px;
    height: 100%;
    max-height: 100%;
    padding: 4px;
    border-radius: 10px;
    overflow: hidden;
    grid-template-columns: unset;
  }
  #screen3 .playerCard {
    flex: 1 1 0;
    min-height: 0;
    padding: 4px 5px;
    justify-content: center;
  }
  #screen3 .playerCard[style*="display: none"] {
    display: none !important;
    flex: 0 0 0 !important;
  }
  #screen3 .level1 {
    gap: 4px;
  }
  #screen3 .level2 {
    margin-top: 2px;
  }
  #screen3 .level2 div {
    padding: 2px 4px;
    font-size: clamp(10px, 2.6vh, 13px);
    background-color: rgba(255, 255, 255, 0.45);
  }
  #screen3 .game-pause-btn {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 0.75rem;
  }

  /* --- Screen 2: 2×2 grid fits short landscape iframe (no scroll) --- */
  #screen2 .s1-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    width: min(720px, 98vw);
    max-height: calc(100% - 6px);
    margin: 0 auto;
    padding: clamp(4px, 1.2vh, 8px) clamp(6px, 2vw, 12px);
    overflow: hidden;
  }
  #screen2 .s1-card h1 {
    flex: 0 0 auto;
    font-size: clamp(0.9rem, 4.2vh, 1.25rem);
    line-height: 1.05;
    margin: 0 0 clamp(2px, 0.8vh, 4px);
  }
  #screen2 .cards {
    flex: 0 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: minmax(0, auto);
    gap: clamp(3px, 0.9vh, 6px);
    width: 100%;
    overflow: hidden;
    align-content: center;
  }
  #screen2 .card {
    min-width: 0;
    min-height: 0;
    max-height: clamp(52px, 21vh, 76px);
    padding: clamp(2px, 0.7vh, 5px);
    border-radius: 8px;
    justify-content: center;
  }
  #screen2 .profile {
    gap: 2px;
  }
  #screen2 .selectImage img {
    width: clamp(28px, 8vh, 44px);
    border-width: 2px;
  }
  #screen2 .arrow {
    padding: 0 1px;
  }
  #screen2 .arrow span {
    font-size: clamp(16px, 4vh, 22px);
  }
  #screen2 .inputName {
    padding: 2px 0 0;
    width: 100%;
  }
  #screen2 .inputName input {
    padding: clamp(2px, 0.7vh, 5px) clamp(4px, 1.2vw, 8px);
    font-size: clamp(10px, 2.5vh, 13px);
    letter-spacing: 0;
  }
  #screen2 .btn-row {
    flex: 0 0 auto;
    margin-top: clamp(3px, 0.9vh, 6px);
    gap: 6px;
  }
  #screen2 .btn-row .startBtn {
    width: min(130px, 40vw);
    height: clamp(34px, 8vh, 42px);
    min-height: 34px;
    font-size: clamp(0.8rem, 2.8vh, 1rem);
    margin: 0;
  }
}

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

/* Screen 1 */

.s1-card {
  backdrop-filter: blur(2px);
  background-color: #ffffff6b;
  width: min(680px, 100%);
  max-height: calc(100% - 16px);
  padding: clamp(16px, 4vw, 32px);
  margin: 0 auto;
  text-align: center;
  border-radius: 16px;
  overflow: hidden;
}
.s1-card h1 {
  font-size: 48px;
  color: #333;
}
.s1-card .subHeading {
  font-size: 24px;
  font-weight: 300;
  margin: 16px 0;
}
.choose {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 2vw, 16px);
  margin: 16px 0;
  width: 100%;
}
.selectBox {
  aspect-ratio: 1;
  min-width: 0;
  max-width: 100%;
  background-color: #ffffff88;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  border-radius: 95% 10% 86% 14% / 10% 90% 10% 90%;
  transition: background 0.25s ease, color 0.25s ease, transform 0.2s ease;
  padding: 8px 4px;
}
.selected {
  background: linear-gradient(45deg, #2455db 10%, #6d94ff);
  color: #fff;
}
.selectBox:hover {
  cursor: pointer;
  transform: translateY(-2px);
  box-shadow: #8d8d8d 0px 12px 24px -10px;
}
.selectBox span:first-child {
  font-size: 64px;
  display: block;
  line-height: 96px;
}
.selectBox span:last-child {
  font-size: 24px;
  line-height: 12px;
  font-weight: 300;
}
.startBtn {
  border-radius: 95% 10% 86% 14% / 10% 90% 10% 90%;
  width: min(280px, 100%);
  min-height: 48px;
  height: 72px;
  border: none;
  font-size: 32px;
  background-color: #2455db;
  color: #fff;
  margin: 16px 0;
}
.startBtn.ghost {
  background-color: #ffffffaa;
  color: #333;
}
.btn-row,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}
.btn-row .startBtn,
.modal-actions .startBtn {
  margin: 0;
  width: min(220px, 46vw);
  flex: 1 1 160px;
  max-width: 280px;
}
.info {
  font-size: 20px;
  font-weight: 300;
}
@media only screen and (max-width: 768px) {
  /* Tablet */
  .s1-card {
    padding: 16px;
    margin: 16px auto;
  }
  .s1-card h1 {
    font-size: 32px;
  }
  .s1-card .subHeading {
    font-size: 18px;
  }
}
@media only screen and (max-width: 600px) {
  /* Tablet Vertical*/
  .s1-card {
    margin: 0 auto;
    padding: clamp(12px, 3vw, 16px);
  }
  .selectBox span:first-child {
    font-size: 48px;
    line-height: 48px;
  }
  .choose {
    column-gap: 4px;
  }
  .selectBox span:last-child {
    font-size: 16px;
    line-height: 12px;
  }
  .startBtn {
    width: 140px;
    height: 56px;
    font-size: 24px;
    margin: 16px 0;
  }
  .info {
    font-size: 14px;
  }
  .pot {
    width: calc(var(--box) / 5);
  }
  .pot::after {
    width: 7.2px;
    top: -3.6px;
    left: 2.4px;
  }
}

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

/* Screen 2 */

.cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.card {
  background-color: #ffffff88;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  border-radius: 16px;
  padding: 16px;
  transition: all 0.5s;
}
.profile {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}
.selectImage img {
  width: 120px;
  border-radius: 100%;
}
.arrow {
  aspect-ratio: 1;
  border-radius: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 6px;
  user-select: none;
  background-color: #ffffff8e;
}
.arrow:hover {
  cursor: pointer;
}
.arrow span {
  font-size: 32px;
}
.inputName {
  width: 100%;
  padding: 16px;
}
.inputName input {
  width: 100%;
  background-color: #ffffff88;
  border: none;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 20px;
  letter-spacing: 2px;
  font-weight: bold;
}
.inputName input:focus {
  outline: none;
  box-shadow: none;
}
/* Player Red */
#profile1 {
  border: 5px solid #ff3737;
}
/* Player Blue */
#profile2 {
  border: 5px solid #4267b2;
}
/* Player Green */
#profile3 {
  border: 5px solid #2c974b;
}
/* Player Yellow */
#profile4 {
  border: 5px solid #ffa116;
}
.next {
  background-color: #2c974b;
}
/* Mobile portrait: 2-column grid (never stack 3–4 rows) */
@media only screen and (max-width: 768px) and (orientation: portrait) {
  #screen2 .s1-card {
    width: min(100%, 440px);
    max-height: calc(100% - 8px);
    overflow: hidden;
    padding: clamp(6px, 1.2vh, 12px);
  }
  #screen2 .s1-card h1 {
    font-size: clamp(1.05rem, 4.2vw, 1.45rem);
    line-height: 1.05;
    margin: 0 0 clamp(4px, 1vh, 8px);
  }
  #screen2 .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(4px, 1vh, 8px);
    width: 100%;
  }
  #screen2 .card {
    min-width: 0;
    min-height: 0;
    padding: clamp(4px, 1vh, 8px);
    border-radius: 10px;
  }
  #screen2 .profile {
    gap: clamp(2px, 0.8vw, 6px);
  }
  #screen2 .selectImage img {
    width: clamp(40px, min(14vw, 16vh), 72px);
    border-width: 3px;
  }
  #screen2 .arrow span {
    font-size: clamp(18px, 5vw, 26px);
  }
  #screen2 .inputName {
    padding: clamp(2px, 0.6vh, 6px) 0 0;
  }
  #screen2 .inputName input {
    padding: clamp(4px, 1vh, 8px) clamp(6px, 2vw, 10px);
    font-size: clamp(11px, 3.2vw, 15px);
    letter-spacing: 0.5px;
  }
  #screen2 .btn-row {
    flex-shrink: 0;
    margin-top: clamp(4px, 1vh, 8px);
    gap: 8px;
  }
  #screen2 .btn-row .startBtn {
    height: clamp(38px, 6vh, 48px);
    min-height: 38px;
    font-size: clamp(0.85rem, 3.5vw, 1.05rem);
  }
}

/* --------------------------------- */
/* Screen 3 */

#screen3 {
  position: relative;
  justify-content: center;
  align-items: stretch;
  flex-direction: column;
  overflow: hidden;
  max-height: 100%;
  height: 100%;
  width: 100%;
}
#screen3 > .container {
  width: 100%;
  max-width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  margin: 0;
  justify-content: center;
  align-items: stretch;
  padding:
    calc(40px + max(4px, var(--safe-t)))
    max(8px, var(--safe-r))
    max(12px, var(--safe-b))
    max(8px, var(--safe-l));
  box-sizing: border-box;
}
#screen3 .boardArea {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: min(640px, 100%);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
}
#screen3 .bigBoard {
  position: relative;
  width: min(100%, calc(var(--box) * 10), 100cqw, 100cqh);
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1;
  height: auto;
  margin: 0 auto;
  flex-shrink: 0;
}
@supports not (width: 1cqw) {
  #screen3 .bigBoard {
    width: min(100%, calc(var(--box) * 10));
  }
  #screen3 .boardArea {
    min-height: clamp(200px, 42vh, 520px);
  }
}
.game-pause-btn {
  position: absolute;
  top: max(10px, var(--safe-t));
  right: max(10px, var(--safe-r));
  z-index: 120;
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  min-height: 44px;
  font-size: clamp(0.85rem, 2.5vw, 1rem);
  font-weight: 700;
  color: #fff;
  background: rgba(36, 85, 219, 0.92);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  touch-action: manipulation;
}
.game-pause-btn:active {
  transform: scale(0.98);
}
.pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(12px, var(--safe-t)) max(12px, var(--safe-r)) max(12px, var(--safe-b))
    max(12px, var(--safe-l));
  background: rgba(8, 12, 24, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.pause-overlay.hide {
  display: none;
}
.pause-card {
  width: min(420px, 94vw);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 20px;
  padding: 22px 18px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.5);
}
.pause-card h2 {
  margin: 0 0 6px;
  font-size: clamp(1.4rem, 4vw, 1.75rem);
  color: #2455db;
}
.pause-sub {
  margin: 0 0 16px;
  color: #555;
  font-size: 0.95rem;
}
.pause-actions .startBtn {
  width: 100%;
  max-width: none;
  flex: 1 1 100%;
  height: 52px;
  font-size: clamp(1rem, 3vw, 1.25rem);
}
.modal {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  background-color: #000000a8;
  padding: 16px;
}
.modalBody {
  width: min(680px, 100%);
  background-color: #ffffff88;
  backdrop-filter: blur(5px);
  margin: 0px auto;
  border-radius: 24px;
  padding: 16px;
  text-align: center;
}
.modalBody img {
  width: 240px;
  aspect-ratio: 1;
  border-radius: 100%;
}
.modalBody h1 {
  margin: 16px 0 0;
  font-size: clamp(20px, 4vw, 28px);
}
.win-sub {
  margin: 8px 0 12px;
  font-size: 0.95rem;
  color: #444;
}
.mini-lb {
  text-align: left;
  margin: 0 0 14px;
}
.mini-lb h3 {
  text-align: center;
  font-size: 0.9rem;
  margin-bottom: 8px;
  color: #555;
}
.mini-lb ul {
  list-style: none;
  display: grid;
  gap: 6px;
  padding: 0;
}
.mini-lb li {
  display: grid;
  grid-template-columns: 34px 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  font-size: 0.85rem;
}
.mini-lb .rank {
  font-weight: 800;
  color: #2455db;
}
.mini-lb .player {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mini-lb .meta {
  color: #666;
  font-size: 0.75rem;
}
.mini-lb .empty {
  display: block;
  text-align: center;
  color: #666;
}
.hide {
  display: none;
}
#wname {
  color: #2455db;
}

@media only screen and (max-width: 900px) and (orientation: landscape) {
  .modal {
    overflow-y: auto;
    align-items: flex-start;
    padding-top: max(8px, var(--safe-t));
  }
  .modalBody {
    margin: 8px auto;
  }
  .modal-actions .startBtn {
    min-height: 44px;
    height: 48px;
    font-size: 18px;
  }
  .mini-lb li {
    grid-template-columns: 28px 1fr auto;
    font-size: 0.78rem;
  }
  .mini-lb .meta {
    display: none;
  }

}
