/* ===== Design tokens ===== */
:root {
  --color-bg: #03051a;
  --color-surface: rgba(12, 16, 40, 0.72);
  --color-surface-cell: rgba(7, 10, 26, 0.72);
  --color-border: rgba(170, 200, 255, 0.18);
  --color-muted: rgba(220, 235, 255, 0.65);
  --color-text: #ffffff;

  --color-player: #31d2ff;
  --color-player-light: #c9f3ff;
  --color-player-glow: rgba(0, 195, 255, 0.65);
  --color-player-glow-strong: rgba(0, 195, 255, 0.95);
  --color-player-subtle: rgba(0, 195, 255, 0.14);

  --color-enemy: #ff3b4a;
  --color-enemy-light: #ffe6e8;
  --color-enemy-glow: rgba(255, 59, 74, 0.62);
  --color-enemy-glow-strong: rgba(255, 59, 74, 0.95);
  --color-enemy-subtle: rgba(255, 59, 74, 0.16);

  --color-jump: #facc15;
  --color-jump-subtle: rgba(250, 204, 21, 0.15);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 20px;

  --board-size: 6;
  --cell-gap: 6px;
  --board-max-width: 500px;
}

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

body {
  margin: 0;
  background-color: var(--color-bg);
  background-image:
    linear-gradient(rgba(3, 5, 26, 0.72), rgba(3, 5, 26, 0.72)),
    url('../img/bg.png'),
    radial-gradient(1200px 800px at 50% 38%, rgba(50, 80, 255, 0.18), transparent 62%),
    radial-gradient(900px 700px at 20% 30%, rgba(0, 220, 255, 0.12), transparent 58%),
    radial-gradient(900px 700px at 78% 28%, rgba(255, 40, 80, 0.12), transparent 58%),
    radial-gradient(1200px 900px at 50% 110%, rgba(0, 195, 255, 0.12), transparent 62%),
    radial-gradient(1200px 900px at 50% -10%, rgba(255, 59, 74, 0.08), transparent 55%);
  background-size: cover, cover, auto, auto, auto, auto, auto;
  background-position: center, center, center, center, center, center, center;
  background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat;
  touch-action: none;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: var(--color-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  /* Prefer the "small viewport" unit on mobile browsers to avoid URL-bar jumps. */
  min-height: 100svh;
  overflow: hidden;
}

/* Hide game screen when welcome is open */
body.is-welcome-open .hud,
body.is-welcome-open .game-board,
body.is-welcome-open .game-screen-actions {
  visibility: hidden;
  pointer-events: none;
}

body::before {
  content: '';
  position: fixed;
  inset: -20%;
  pointer-events: none;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.16) 0 1px, transparent 2px) 0 0 / 190px 190px,
    radial-gradient(circle at 70% 35%, rgba(255, 255, 255, 0.12) 0 1px, transparent 2px) 0 0 / 240px 240px,
    radial-gradient(circle at 40% 70%, rgba(255, 255, 255, 0.1) 0 1px, transparent 2px) 0 0 / 280px 280px,
    radial-gradient(circle at 60% 62%, rgba(255, 255, 255, 0.08) 0 1px, transparent 2px) 0 0 / 320px 320px;
  opacity: 0.55;
  filter: blur(0.2px);
}

/* ===== Logo (welcome overlay) ===== */
.welcome__logo {
  margin: 0 0 0.35rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

.welcome__logo-img {
  width: min(92%, 420px);
  height: auto;
  display: block;
  filter: drop-shadow(0 0 18px rgba(0, 195, 255, 0.22)) drop-shadow(0 0 22px rgba(255, 59, 74, 0.18));
}

/* Screen-reader only (e.g. turn announcement) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== Game screen actions (home left, retry right) ===== */
.game-screen-actions {
  position: fixed;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 40;
  pointer-events: none;
}

.game-screen-actions__btn {
  pointer-events: auto;
}

.game-screen-actions__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(175, 210, 255, 0.25);
  border-radius: var(--radius-md);
  background: rgba(10, 14, 36, 0.65);
  backdrop-filter: blur(10px);
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.game-screen-actions__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.game-screen-actions__icon svg {
  display: block;
}

.game-screen-actions__btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.game-screen-actions__btn--home {
  box-shadow: 0 0 14px rgba(0, 195, 255, 0.18);
}

.game-screen-actions__btn--home:hover {
  box-shadow: 0 0 20px var(--color-player-glow);
}

.game-screen-actions__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.game-screen-actions__btn--retry:hover {
  color: var(--color-enemy-light);
  box-shadow: 0 0 18px var(--color-enemy-glow);
}

.game-screen-actions__btn--help:hover {
  color: var(--color-player-light);
  box-shadow: 0 0 18px var(--color-player-glow);
}

.game-screen-actions__btn:active {
  transform: scale(0.97);
}

/* ===== How to play pop-up ===== */
/* (How-to-play now reuses the same `.modal` system.) */

/* ===== HUD ===== */
.hud {
  /* Match the game board width so header and board align */
  width: min(92vw, var(--board-max-width));
  display: grid;
  /* Three equal columns so player, turn bar, and enemy
     are spaced evenly across the header */
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  gap: 16px;
  justify-items: stretch;
  margin: 0 0 14px;
  background: transparent;
  padding: 0;
  border: 0;
}

.hud__side {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  width: 100%;
}

.hud__side--player {
  justify-content: flex-start;
}

.hud__side--enemy {
  justify-content: flex-end;
}

.hud__side-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud__side-main--right {
  align-items: flex-end;
}

.hud__vs {
  position: relative;
  width: 100%;
  padding: 0;
  justify-self: center;
}

.hud__vs-track {
  position: relative;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(0, 195, 255, 0.18), rgba(255, 255, 255, 0.10), rgba(255, 59, 74, 0.18));
  box-shadow: 0 0 14px rgba(0, 0, 0, 0.55);
  /* Allow the rotating turn indicator ring to sit fully above the track
     instead of being clipped by the bar's bounds. */
  overflow: visible;
  border: 1px solid rgba(175, 210, 255, 0.22);
  background-clip: padding-box;
}

.hud__vs-track::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0, 195, 255, 0.35), transparent 40%, transparent 60%, rgba(255, 59, 74, 0.35));
  mix-blend-mode: screen;
  opacity: 0.7;
}

.hud__vs-marker {
  position: absolute;
  top: 50%;
  width: 26px;
  height: 16px;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(0, 195, 255, 0.95), rgba(70, 220, 255, 0.35));
  box-shadow: none;
  z-index: 1;
  transition: left 0.35s cubic-bezier(0.22, 0.61, 0.36, 1), box-shadow 0.25s ease-out, background 0.25s ease-out;
}

.hud__vs-marker--player {
  left: 18%;
}

.hud__vs-marker--enemy {
  left: 82%;
  background: linear-gradient(135deg, rgba(255, 59, 74, 0.95), rgba(255, 130, 140, 0.35));
  box-shadow: none;
}

.hud__vs-marker::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: inherit;
  border: 1px solid rgba(10, 14, 36, 0.85);
}

.score-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 112px;
  padding: 12px 16px;
  border-radius: 999px;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: rgba(8, 10, 26, 0.62);
  border: 1px solid rgba(175, 210, 255, 0.22);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.55);
  position: relative;
  overflow: hidden;
}

.score-box--player {
  color: var(--color-player);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.55), 0 0 22px rgba(0, 195, 255, 0.18);
}

.score-box--enemy {
  color: var(--color-enemy);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.55), 0 0 22px rgba(255, 59, 74, 0.18);
}

.score-box--player::before {
  content: '';
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.92), rgba(0, 195, 255, 0.85) 48%, rgba(0, 90, 255, 0.25) 100%);
  box-shadow: none;
  flex: 0 0 auto;
}

.score-box--enemy::after {
  content: '×';
  font-weight: 900;
  font-size: 1.3rem;
  line-height: 1;
  color: rgba(255, 255, 255, 0.86);
  margin-left: 2px;
  text-shadow: none;
  opacity: 0.95;
}

/* Active turn: light armor glow on side panels */
.hud__side--active .score-box {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.55);
}

/* ===== Game board ===== */
.game-board {
  display: grid;
  grid-template-columns: repeat(var(--board-size), 1fr);
  gap: var(--cell-gap);
  padding: var(--cell-gap);
  background: linear-gradient(180deg, rgba(10, 14, 36, 0.62), rgba(7, 10, 26, 0.58));
  border-radius: 18px;
  width: min(92vw, var(--board-max-width));
  aspect-ratio: 1 / 1;
  position: relative;
  border: 1px solid rgba(175, 210, 255, 0.22);
  box-shadow:
    0 22px 60px rgba(0, 0, 0, 0.58),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset;
}

.cell {
  background: radial-gradient(140% 140% at 40% 28%, rgba(32, 46, 96, 0.22), rgba(7, 10, 26, 0.74) 55%, rgba(7, 10, 26, 0.88) 100%);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.08s;
  border: 1px solid rgba(175, 210, 255, 0.16);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35) inset;
}

.cell:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background: radial-gradient(140% 140% at 40% 28%, rgba(48, 78, 180, 0.26), rgba(7, 10, 26, 0.74) 55%, rgba(7, 10, 26, 0.88) 100%);
}

.cell:active {
  transform: scale(0.99);
}

.cell--highlight-clone {
  background: var(--color-player-subtle);
  border-color: rgba(0, 195, 255, 0.55);
  box-shadow: inset 0 0 14px rgba(0, 195, 255, 0.22), 0 0 16px rgba(0, 195, 255, 0.12);
}

.cell--highlight-jump {
  background: var(--color-jump-subtle);
  border-color: var(--color-jump);
  box-shadow: inset 0 0 14px rgba(250, 204, 21, 0.18), 0 0 14px rgba(250, 204, 21, 0.10);
}

.cell__hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  opacity: 0.6;
}

.cell__hint--clone {
  background: var(--color-player);
}

.cell__hint--jump {
  background: var(--color-jump);
}

/* ===== Pieces ===== */
.piece {
  width: 72%;
  height: 72%;
  position: absolute;
  top: 14%;
  left: 14%;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    opacity 0.2s, filter 0.2s;
  transform: scale(0);
  filter: drop-shadow(0 0 14px rgba(255, 255, 255, 0.02));
}

.piece--spawned {
  transform: scale(1);
}

.piece--player {
  border-radius: 999px;
  background: transparent;
  border: 6px solid rgba(0, 195, 255, 0.92);
  box-shadow:
    0 0 18px rgba(0, 195, 255, 0.65),
    0 0 34px rgba(0, 195, 255, 0.22);
  position: absolute;
}

.piece--enemy {
  background: transparent;
  position: absolute;
}

.piece--enemy::before,
.piece--enemy::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 92%;
  height: 10px;
  background: rgba(255, 59, 74, 0.95);
  border-radius: 999px;
  transform-origin: center;
  box-shadow:
    0 0 18px rgba(255, 59, 74, 0.62),
    0 0 34px rgba(255, 59, 74, 0.22);
}

.piece--enemy::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.piece--enemy::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.piece--selected {
  filter: drop-shadow(0 0 18px rgba(255, 255, 255, 0.35));
  opacity: 0.95;
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  /* Keep the same game background visible behind the overlay. */
  background: rgba(2, 6, 23, 0.68);
  backdrop-filter: blur(6px) saturate(1.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal--hidden {
  display: none !important;
}

.modal__card {
  background:
    radial-gradient(160% 140% at 20% 10%, rgba(0, 195, 255, 0.10), transparent 55%),
    radial-gradient(150% 140% at 95% 10%, rgba(255, 59, 74, 0.08), transparent 52%),
    rgba(8, 10, 26, 0.70);
  border: 1px solid rgba(175, 210, 255, 0.22);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: min(92vw, 420px);
  text-align: center;
  box-shadow:
    0 25px 55px rgba(0, 0, 0, 0.62),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 0 28px rgba(0, 195, 255, 0.14),
    0 0 22px rgba(255, 59, 74, 0.10);
  animation: welcomeCardIn 0.35s ease-out;
  position: relative;
}

.modal__card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 40%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 9px);
  opacity: 0.18;
  mix-blend-mode: overlay;
}

.modal__card > * {
  position: relative;
  z-index: 1;
}

.modal__icon {
  font-size: 64px;
  line-height: 1;
  margin: 0 0 10px;
  filter: drop-shadow(0 0 18px rgba(255, 255, 255, 0.10));
  text-shadow:
    0 0 18px rgba(0, 195, 255, 0.14),
    0 0 16px rgba(255, 59, 74, 0.10);
}

.modal__title {
  font-size: 2.05rem;
  font-weight: 900;
  margin: 0 0 0.5rem;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.modal__title--victory {
  color: var(--color-player);
}

.modal__title--defeat {
  color: var(--color-enemy);
}

.modal__title--draw {
  color: var(--color-text);
}

.modal__title--info {
  font-size: 1.25rem;
  color: var(--color-player);
  margin-bottom: 1rem;
}

.modal__message {
  color: var(--color-muted);
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
}

.modal__list {
  margin: 0 0 1.25rem;
  padding-left: 1.25rem;
  color: var(--color-muted);
  font-size: 0.9rem;
  line-height: 1.65;
  text-align: left;
}

.modal__list li {
  margin-bottom: 0.55rem;
}

.modal__list strong {
  color: var(--color-text);
}

.modal__actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.modal__button {
  background:
    linear-gradient(135deg, rgba(0, 195, 255, 0.95), rgba(59, 130, 246, 0.85)),
    radial-gradient(140% 120% at 20% 20%, rgba(255, 255, 255, 0.22), transparent 60%);
  border: 1px solid rgba(175, 210, 255, 0.28);
  padding: 12px 30px;
  color: var(--color-bg);
  font-weight: bold;
  font-size: 1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  margin-top: 20px;
  letter-spacing: 0.08em;
  transition: transform 0.12s ease, box-shadow 0.22s ease, filter 0.22s ease;
  box-shadow:
    0 12px 24px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(0, 0, 0, 0.22) inset,
    0 0 22px rgba(0, 195, 255, 0.28);
}

.modal__button--ghost {
  margin-top: 0;
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-text);
  border: 1px solid rgba(175, 210, 255, 0.22);
  box-shadow:
    0 12px 24px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(0, 0, 0, 0.22) inset;
}

.modal__button--ghost:hover {
  filter: none;
  background: rgba(255, 255, 255, 0.09);
  box-shadow:
    0 14px 28px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(0, 0, 0, 0.18) inset,
    0 0 24px rgba(175, 210, 255, 0.14);
}

.modal__button:hover {
  filter: brightness(1.03);
  box-shadow:
    0 14px 28px rgba(0, 0,  0, 0.42),
    0 0 0 1px rgba(0, 0, 0, 0.18) inset,
    0 0 30px rgba(0, 195, 255, 0.42);
}

.modal__button:active {
  transform: scale(0.95);
}

.modal__card--victory {
  box-shadow:
    0 25px 55px rgba(0, 0, 0, 0.62),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 0 42px rgba(0, 195, 255, 0.22),
    0 0 18px rgba(0, 195, 255, 0.18);
}

.modal__card--defeat {
  box-shadow:
    0 25px 55px rgba(0, 0, 0, 0.62),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 0 38px rgba(255, 59, 74, 0.20),
    0 0 18px rgba(255, 59, 74, 0.14);
}

/* ===== Welcome / Start pop-up ===== */
.welcome {
  position: fixed;
  inset: 0;
  /* No overlay tint: show bg.png directly behind the card. */
  background: transparent;
  backdrop-filter: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: welcomeFadeIn 0.4s ease-out;
}

.welcome.welcome--hidden {
  display: none !important;
}

@keyframes welcomeFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.welcome__card {
  background:
    radial-gradient(160% 140% at 20% 10%, rgba(0, 195, 255, 0.10), transparent 55%),
    radial-gradient(150% 140% at 95% 10%, rgba(255, 59, 74, 0.08), transparent 52%),
    rgba(8, 10, 26, 0.70);
  border: 1px solid rgba(175, 210, 255, 0.22);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow:
    0 25px 55px rgba(0, 0, 0, 0.62),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 0 28px rgba(0, 195, 255, 0.14),
    0 0 22px rgba(255, 59, 74, 0.10);
  animation: welcomeCardIn 0.35s ease-out;
  position: relative;
}

.welcome__card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 40%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 9px);
  opacity: 0.18;
  mix-blend-mode: overlay;
}

.welcome__card > * {
  position: relative;
  z-index: 1;
}

@keyframes welcomeCardIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.welcome__tagline {
  text-align: center;
  color: var(--color-muted);
  font-size: 0.92rem;
  margin: 0 0 1.5rem;
  letter-spacing: 0.01em;
}

.welcome__field {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
}

.welcome__chips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.welcome__chip-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.welcome__chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 10px;
  border-radius: 999px;
  border: 1px solid rgba(175, 210, 255, 0.22);
  background: rgba(8, 10, 26, 0.50);
  backdrop-filter: blur(10px);
  color: rgba(255, 255, 255, 0.88);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.2s, box-shadow 0.2s, background 0.2s, color 0.2s, filter 0.2s;
  user-select: none;
}

.welcome__chip:hover {
  border-color: rgba(255, 255, 255, 0.22);
  filter: brightness(1.03);
}

.welcome__chip:active {
  transform: scale(0.98);
}

.welcome__chip-input:focus-visible + .welcome__chip {
  border-color: rgba(0, 195, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(0, 195, 255, 0.16);
}

.welcome__chip-input:checked + .welcome__chip {
  background:
    radial-gradient(140% 120% at 20% 20%, rgba(255, 255, 255, 0.16), transparent 60%),
    linear-gradient(135deg, rgba(0, 195, 255, 0.32), rgba(255, 59, 74, 0.14));
  border-color: rgba(0, 195, 255, 0.42);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35), 0 0 18px rgba(0, 195, 255, 0.16);
}

.welcome__button {
  display: block;
  width: 100%;
  background:
    linear-gradient(135deg, rgba(0, 195, 255, 0.95), rgba(59, 130, 246, 0.85)),
    radial-gradient(140% 120% at 20% 20%, rgba(255, 255, 255, 0.22), transparent 60%);
  border: 1px solid rgba(175, 210, 255, 0.28);
  padding: 14px 24px;
  color: var(--color-bg);
  font-weight: bold;
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.22s ease, filter 0.22s ease;
  box-shadow:
    0 12px 24px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(0, 0, 0, 0.22) inset,
    0 0 22px rgba(0, 195, 255, 0.28);
}

.welcome__button:hover {
  filter: brightness(1.03);
  box-shadow:
    0 14px 28px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(0, 0, 0, 0.18) inset,
    0 0 30px rgba(0, 195, 255, 0.42);
}

.welcome__button:active {
  transform: scale(0.98);
}

/* ===== Responsive sizing (no element aspect distortion) =====
   We only tune max widths, spacing, and font sizes.
   The board and pieces keep their own aspect ratios via `aspect-ratio` and % sizing. */

/* Safe-area aware fixed actions (iOS notch, etc.) */
.game-screen-actions {
  top: calc(10px + env(safe-area-inset-top));
  left: calc(10px + env(safe-area-inset-left));
  right: calc(10px + env(safe-area-inset-right));
}

/* Desktop (≥1025px) */
@media (min-width: 1025px) {
  :root {
    --board-max-width: 560px;
    --cell-gap: 8px;
  }

  .score-box {
    min-width: 124px;
    font-size: 1.45rem;
  }

  /* Embedded (iframe) desktop: keep site player tighter without changing standalone desktop. */
  :root.is-embedded {
    --board-max-width: 480px;
    --cell-gap: 7px;
  }

  :root.is-embedded .hud {
    gap: 14px;
    margin-bottom: 12px;
  }

  :root.is-embedded .score-box {
    min-width: 112px;
    padding: 10px 14px;
    font-size: 1.25rem;
  }
}

/* Tablet Landscape (769px–1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  :root {
    /* Tablet-only: reduce board/HUD footprint without affecting desktop/mobile. */
    --board-max-width: 480px;
    --cell-gap: 8px;
  }

  .hud {
    gap: 14px;
    margin-bottom: 12px;
  }

  .score-box {
    min-width: 108px;
    padding: 10px 14px;
    font-size: 1.25rem;
  }
}

/* Tablet Portrait (641px–768px) */
@media (min-width: 641px) and (max-width: 768px) {
  :root {
    /* Tablet-only: reduce board/HUD footprint without affecting desktop/mobile. */
    --board-max-width: 460px;
    --cell-gap: 7px;
  }

  .hud {
    gap: 14px;
    margin-bottom: 12px;
  }

  .score-box {
    min-width: 104px;
    padding: 10px 14px;
    font-size: 1.22rem;
  }
}

/* Mobile (≤640px) */
@media (max-width: 640px) {
  :root {
    --board-max-width: 480px;
    --cell-gap: 6px;
  }

  .score-box {
    min-width: 102px;
    padding: 10px 14px;
    font-size: 1.2rem;
  }

  .modal__card {
    padding: 1.6rem;
  }
}

/* Small Mobile (≤480px) */
@media (max-width: 480px) {
  :root {
    --board-max-width: 420px;
    --cell-gap: 5px;
  }

  .hud {
    gap: 12px;
    margin-bottom: 12px;
  }

  .score-box {
    min-width: 92px;
    padding: 9px 12px;
    font-size: 1.1rem;
  }

  .modal__title {
    font-size: 1.75rem;
  }
}

/* Landscape Mobile (orientation: landscape) */
@media (max-width: 900px) and (orientation: landscape) {
  :root {
    /* Constrain width so the board + HUD don't exceed the smaller height. */
    --board-max-width: 420px;
    --cell-gap: 5px;
  }

  .hud {
    margin-bottom: 10px;
  }

  .welcome__card,
  .modal__card {
    max-height: calc(100svh - 24px);
  }
}
