@font-face {
  font-family: 'Oswald';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../assets/fonts/oswald-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: hsl(230, 25%, 10%);
  --fg: hsl(210, 20%, 98%);
  --card: hsl(230, 25%, 12%);
  --primary: hsl(43, 96%, 58%);
  --primary-fg: hsl(230, 25%, 10%);
  --sky-400: #38bdf8;
  --sky-500: #0ea5e9;
  --muted: hsl(230, 20%, 20%);
  --muted-fg: hsl(215, 15%, 70%);
  --destructive: hsl(340, 82%, 52%);
  --border: hsl(230, 20%, 20%);
  --font: 'Oswald', sans-serif;
  --spot-size: 11.5%;
  --piece-scale: 1.2;
  --piece-padding: 16%;
  --marker-scale: 0.75;
  --cursor-size: 26.4px;
}

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

html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: var(--font); font-weight: 600; background: var(--bg); color: var(--fg);
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
  -webkit-font-smoothing: antialiased;
  background-image: url('../assets/images/bg-texture.png');
  background-size: cover; background-position: center; background-attachment: fixed;
}
body { position: fixed; inset: 0; }

#app {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}

.menu-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; width: 100%; max-width: 384px;
  padding: clamp(.5rem, 2svh, 2rem) 0; gap: clamp(.5rem, 1.5svh, 1rem);
  overflow-y: auto; overflow-x: hidden;
}
.logo-wrap {
  flex: 0 1 auto; display: flex; align-items: center; justify-content: center;
  min-height: 0; width: 100%; padding: 0 1rem;
  max-height: clamp(100px, 40svh, 45vh);
}
.logo-img {
  max-height: 100%; max-width: 100%; object-fit: contain;
  filter: drop-shadow(0 25px 25px rgba(0,0,0,0.15));
  animation: fadeZoom .7s ease-out;
}
@keyframes fadeZoom { from{opacity:0;transform:scale(.9)} to{opacity:1;transform:scale(1)} }

.menu-btns {
  display: flex; flex-direction: column;
  gap: clamp(.35rem, 1.5svh, .75rem); width: 100%;
  padding: 0 clamp(.5rem, 3vw, 1rem);
  flex-shrink: 1; min-height: 0; overflow-y: auto;
}
.menu-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: clamp(.375rem, 2vw, .75rem); }

.btn {
  display: flex; align-items: center; justify-content: center; gap: .75rem;
  padding: clamp(.5rem, 1.5svh, .875rem) clamp(.75rem, 2vw, 1.25rem); border-radius: .75rem;
  border: 2px solid rgba(255,255,255,.1); font-family: var(--font);
  font-size: clamp(.875rem, 3vw, 1rem); font-weight: 700; cursor: pointer;
  transition: background .2s, border-color .2s, transform .2s, filter .2s; color: white; background: rgba(255,255,255,.05);
}
.btn:hover { background: rgba(255,255,255,.1); }
.btn:active { transform: scale(.97); }

.btn-pvb {
  height: clamp(2.25rem, 7svh, 3.5rem); font-size: clamp(.85rem, 3vw, 1.125rem);
  background: hsla(43,96%,58%,.2); border-color: hsla(43,96%,58%,.4);
}
.btn-pvb:hover { background: hsla(43,96%,58%,.3); }
.btn-pvp { height: clamp(2.25rem, 7svh, 3.5rem); font-size: clamp(.85rem, 3vw, 1.125rem); }
.btn-icons { display: flex; align-items: center; gap: 6px; }
.btn-icons svg:nth-child(2) { color: var(--primary); animation: pulse 2s cubic-bezier(.4,0,.6,1) infinite; }

.btn-sm {
  height: auto; min-height: clamp(2.75rem, 10svh, 4.5rem); font-size: clamp(.65rem, 2.4vw, .9rem);
  flex-direction: column; gap: clamp(2px, .5svh, 5px); padding: clamp(.4rem, 1.5svh, 1.1rem) .5rem;
  background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.1);
  overflow: hidden; justify-content: center; align-items: center;
}
.btn-sm svg { flex-shrink: 0; width: clamp(1.2rem, 5vw, 2.2rem); height: clamp(1.2rem, 5vw, 2.2rem); }
.btn-sm span {
  display: block; width: 100%; text-align: center; color: rgba(255,255,255,.9);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; line-height: 1.1;
  font-size: clamp(.6rem, 2.4vw, .9rem); font-weight: 600;
}
.btn-sm:hover { background: rgba(255,255,255,.1); }

.btn-primary-solid {
  background: var(--primary); color: var(--primary-fg);
  border-color: var(--primary); font-weight: 700;
}
.btn-primary-solid:hover { filter: brightness(1.1); }

.btn-outline {
  background: transparent; border-color: rgba(255,255,255,.2);
  color: white;
}
.btn-outline:hover { background: rgba(255,255,255,.1); }

.btn-ghost {
  background: transparent; border-color: transparent;
  color: rgba(255,255,255,.6);
}
.btn-ghost:hover { color: white; }

.btn-disabled { opacity: .4; cursor: not-allowed; background: rgba(255,255,255,.1); color: rgba(255,255,255,.3); }
.btn-flex { flex: 1; }
.btn-diff {
  height: clamp(2rem, 6svh, 3rem); font-size: clamp(.85rem, 3vw, 1.125rem); text-transform: capitalize;
}
.btn-diff:hover { background: hsla(43,96%,58%,.2); border-color: hsla(43,96%,58%,.4); }

.game-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  width: 100%; height: 100%;
  padding: clamp(0.25rem, 1.5svh, 1rem) 1rem 0.5rem;
  padding-top: calc(clamp(0.25rem, 1.5svh, 1rem) + env(safe-area-inset-top));
  padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
  gap: clamp(.25rem, 1svh, 1rem); overflow: hidden;
}
.top-section {
  width: 100%; max-width: 448px; display: flex; flex-direction: column;
  gap: .5rem; z-index: 10; flex-shrink: 0;
}
.top-bar { display: flex; justify-content: space-between; align-items: center; }
.top-left { display: flex; flex-direction: column; }
.top-right { display: flex; gap: .5rem; }

.game-title { font-size: 1.125rem; font-weight: 700; color: rgba(255,255,255,.9); }
.subtitle { font-size: 10px; color: rgba(255,255,255,.65); }

.timer-row { display: flex; align-items: center; gap: .75rem; }
.clock-icon { display: flex; color: rgba(255,255,255,.6); }
.clock-txt { font-size: 10px; color: rgba(255,255,255,.6); font-family: monospace; }
.timer-bar-wrap { width: 5rem; height: .25rem; background: rgba(255,255,255,.1); border-radius: 9999px; overflow: hidden; }
.timer-bar { height: 100%; background: var(--primary); border-radius: 9999px; transition: width 1s linear; }
.timer-txt { font-size: 10px; color: hsla(43,96%,58%,.7); font-family: monospace; }

.game-msg {
  font-size: clamp(12px, 3svh, 15px); font-weight: 700; color: var(--primary);
  text-transform: uppercase; letter-spacing: .15em; text-align: center;
  height: 1.2rem; display: flex; align-items: center; justify-content: center;
  margin-top: 0.25rem;
  animation: pulse 2s cubic-bezier(.4,0,.6,1) infinite;
  text-shadow: 0 0 10px rgba(255,215,0,0.3);
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.7} }

.icon-btn {
  width: 2.75rem; height: 2.75rem; min-width: 44px; min-height: 44px; border-radius: 50%;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1);
  color: white; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .2s; font-family: var(--font);
}
.icon-btn:hover { background: rgba(255,255,255,.1); }
.icon-btn-concede {
  background: rgba(127,29,29,.3); border-color: rgba(239,68,68,.3); color: #f87171;
}
.icon-btn-concede:hover { background: rgba(127,29,29,.5); color: #fca5a5; }

.progress-bar { width: 100%; background: rgba(255,255,255,.05); border-radius: 9999px; height: 6px; margin-top: .25rem; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 9999px; transition: width .3s ease; }

.board-wrap {
  position: relative;
  width: var(--board-size, min(90vw, 420px));
  height: var(--board-size, min(90vw, 420px));
  aspect-ratio: 1/1; border-radius: 1rem; overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,.5);
  border: 1px solid rgba(255,255,255,.1); touch-action: none;
  flex-shrink: 0; min-height: 0; min-width: 0;
}
.board-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.spots { position: absolute; inset: 0; width: 100%; height: 100%; }

.spots.spots--settling {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.spot {
  position: absolute; width: var(--spot-size);
  aspect-ratio: 1/1; height: auto;
  margin: 0;
  transform: translate(-50%, -50%);
  border-radius: 50%; border: none; background: transparent;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  outline: none; z-index: 20; transition: transform .2s, box-shadow .2s, background .2s;
  -webkit-tap-highlight-color: transparent; padding: 0;
}

.piece-wrap {
  width: 100%; height: 100%; padding: var(--piece-padding);
  transform: scale(var(--piece-scale)); pointer-events: none; transition: transform .28s cubic-bezier(.2,.9,.2,1);
}
.piece-wrap.piece-new { animation: pieceIn .3s ease-out; }

.piece-wrap.piece-lift .piece-img { animation: pieceBounce .6s infinite; transform-origin: center; }
.piece-wrap.piece-lift.piece-new { animation: pieceIn .3s ease-out; }
@keyframes pieceBounce {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
@media (prefers-reduced-motion: reduce) { .piece-wrap.piece-lift .piece-img { animation: none; transform: none; } .piece-wrap.piece-lift { box-shadow: none; } }
.piece-img {
  width: 100%; height: 100%; object-fit: contain;
  filter: drop-shadow(0 4px 3px rgba(0,0,0,.07)) drop-shadow(0 2px 2px rgba(0,0,0,.06));
}
@keyframes pieceIn { from { transform: scale(0); opacity: 0; } to { transform: scale(var(--piece-scale)); opacity: 1; } }

.spot-place-gold,
.spot-place-silver {
  background: transparent;
}
.spot-place-gold::before,
.spot-place-silver::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  margin: 0;
  width: calc(100% * var(--marker-scale));
  height: calc(100% * var(--marker-scale));
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: background .2s;
}
.spot-place-gold::before { background: rgba(160,30,30,.55); animation: markerPulse 1.6s ease-in-out infinite; }
.spot-place-gold:hover::before { background: rgba(160,30,30,.8); }
.spot-place-silver::before { background: rgba(20,60,160,.45); animation: markerPulse 1.6s ease-in-out infinite; }
.spot-place-silver:hover::before { background: rgba(20,60,160,.7); }
@keyframes markerPulse {
  0%,100% { transform: translate(-50%,-50%) scale(1); opacity: 1; }
  50% { transform: translate(-50%,-50%) scale(1.25); opacity: .5; }
}

.spot-sel-gold {
  box-shadow: 0 0 0 4px var(--primary), 0 0 20px rgba(255,215,0,.8);
  transform: translate(-50%, -50%) scale(1.1); z-index: 25;
}
.spot-sel-silver {
  box-shadow: 0 0 0 4px var(--sky-400), 0 0 20px rgba(56,189,248,.8);
  transform: translate(-50%, -50%) scale(1.1); z-index: 25;
}

.spot-vt-gold {
  box-shadow: 0 0 0 2px var(--primary); background: hsla(43,96%,58%,.2);
  animation: pulse 2s cubic-bezier(.4,0,.6,1) infinite;
  transform: translate(-50%, -50%) scale(1.1);
}
.spot-vt-silver {
  box-shadow: 0 0 0 2px var(--sky-400); background: rgba(14,165,233,.2);
  animation: pulse 2s cubic-bezier(.4,0,.6,1) infinite;
  transform: translate(-50%, -50%) scale(1.1);
}

.spot-cansel-gold,
.spot-cansel-silver {
  box-shadow: 0 0 0 3px rgba(34,197,94,.7), 0 0 12px rgba(34,197,94,.4);
  cursor: pointer;
  animation: canselPulse 1.4s ease-in-out infinite;
}
@keyframes canselPulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(34,197,94,.7), 0 0 12px rgba(34,197,94,.4); }
  50% { box-shadow: 0 0 0 3px rgba(34,197,94,.35), 0 0 6px rgba(34,197,94,.2); }
}

.spot-removable {
  box-shadow: 0 0 0 4px var(--destructive);
  animation: bounce .6s infinite; cursor: pointer; z-index: 30;
  will-change: transform;
}

.spot-hl {
  box-shadow: 0 0 0 2px var(--primary); background: hsla(43,96%,58%,.3);
  animation: pulse 2s cubic-bezier(.4,0,.6,1) infinite;
  transform: translate(-50%, -50%) scale(1.1);
}

.spot-mill {
  box-shadow: 0 0 0 3px var(--primary), 0 0 16px rgba(255,215,0,.6);
  animation: millPulse 1.2s ease-in-out infinite;
  will-change: box-shadow;
}
@keyframes millPulse {
  0%,100% { box-shadow: 0 0 0 3px var(--primary), 0 0 16px rgba(255,215,0,.6); }
  50% { box-shadow: 0 0 0 5px var(--primary), 0 0 24px rgba(255,215,0,.9); }
}

@keyframes bounce {
  0%,100% { transform: translate(-50%, -50%) scale(1.1) translateY(0); }
  50%      { transform: translate(-50%, -50%) scale(1.1) translateY(-4px); }
}

.player-cards {
  width: 100%; max-width: 448px;
  display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; z-index: 10;
  flex-shrink: 0;
}
.pcard {
  padding: clamp(.4rem, 1svh, .75rem); border: none; border-radius: .75rem;
  background: rgba(255,255,255,.05);
  display: flex; flex-direction: column; align-items: center; gap: .25rem;
  transition: opacity .3s, box-shadow .3s, background .3s;
}
.pcard-inactive { opacity: .5; }
.pcard-active-gold { box-shadow: 0 0 0 2px var(--primary); background: hsla(43,96%,58%,.1); }
.pcard-active-silver { box-shadow: 0 0 0 2px var(--sky-400); background: rgba(14,165,233,.1); }

.pcard-icon { width: 1.5rem; height: 1.5rem; }
.pcard-name { font-size: 10px; color: var(--muted-fg); text-transform: uppercase; letter-spacing: .1em; }
.pcard-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; font-size: 10px; margin-top: .25rem; }
.stat { background: rgba(0,0,0,.4); padding: 2px .5rem; border-radius: .25rem; border: 1px solid rgba(255,255,255,.05); }
.stat-left-gold { background: hsla(43,96%,58%,.2); color: var(--primary-fg); border-color: transparent; }
.stat-left-silver { background: rgba(14,165,233,.2); color: #bae6fd; border-color: transparent; }
.stat-score { background: rgba(127,29,29,.4); color: #fca5a5; border-color: rgba(239,68,68,.2); }

.win-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.9); padding: 1rem;
  animation: fadeIn .3s ease;
}
.win-card {
  background: var(--card); border: 1px solid rgba(255,255,255,.1);
  padding: clamp(1rem, 3svh, 2rem); border-radius: 1.5rem; max-width: 24rem; width: 100%;
  text-align: center; box-shadow: 0 25px 50px -12px rgba(0,0,0,.5);
  animation: scaleIn .3s ease;
  max-height: calc(100svh - 2rem); overflow-y: auto;
}
.win-trophy { color: var(--primary); margin-bottom: clamp(.5rem, 1.5svh, 1rem); display: flex; justify-content: center; }
.win-gameover { color: var(--destructive); margin-bottom: clamp(.5rem, 1.5svh, 1rem); display: flex; justify-content: center; }
.win-title { font-size: clamp(1.1rem, 3svh, 1.5rem); font-weight: 700; color: white; margin-bottom: .5rem; }
.win-stats { display: flex; justify-content: center; gap: 1rem; font-size: .875rem; color: rgba(255,255,255,.7); margin-bottom: .5rem; }
.win-time { font-size: .875rem; color: var(--muted-fg); margin-bottom: clamp(.75rem, 2svh, 1.5rem); }
.win-btns { display: flex; flex-direction: column; gap: clamp(.4rem, 1svh, .75rem); }
.win-btns .btn { width: 100%; padding: clamp(.6rem, 1.5svh, 1.25rem); border-radius: .75rem; }

@keyframes fadeIn { from{opacity:0} to{opacity:1} }
@keyframes scaleIn { from{transform:scale(.8)} to{transform:scale(1)} }

.modal-ov {
  position: fixed; inset: 0; z-index: 50;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,.8); padding: clamp(.5rem, 2svh, 1rem);
  animation: fadeIn .2s ease;
}
.modal-card {
  background: var(--card); border: 1px solid rgba(255,255,255,.1);
  padding: clamp(1rem, 2.5svh, 1.5rem); border-radius: 1rem; max-width: 24rem; width: 100%;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,.5); animation: scaleIn .2s ease;
  max-height: calc(100svh - 1rem); overflow-y: auto;
  display: flex; flex-direction: column;
}
.modal-scroll { max-height: min(85vh, calc(100svh - 6rem)); overflow-y: auto; }

.modal-hdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: clamp(.5rem, 1.5svh, 1.25rem); flex-shrink: 0; }
.modal-hdr h2 { font-size: clamp(1rem, 3svh, 1.25rem); font-weight: 700; color: white; }
.btn-close {
  width: 2.75rem; height: 2.75rem; border-radius: 50%;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.7); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s; flex-shrink: 0;

  min-width: 44px; min-height: 44px;
}
.btn-close:hover { color: white; background: rgba(255,255,255,.15); }
.btn-close:active { transform: scale(.9); background: rgba(255,255,255,.2); }
.modal-body { display: flex; flex-direction: column; gap: clamp(.4rem, 1svh, .75rem); overflow-y: auto; min-height: 0; flex: 1; }
.modal-foot { display: flex; flex-direction: column; gap: clamp(.4rem, 1svh, .75rem); margin-top: clamp(.5rem, 1.5svh, 1.25rem); flex-shrink: 0; }
.modal-foot .btn { width: 100%; padding: clamp(.5rem, 1.5svh, .75rem); border-radius: .75rem; font-weight: 700; }

.tut-rules { font-size: .875rem; color: rgba(255,255,255,.8); }
.tut-rules h3 { color: var(--primary); font-weight: 700; margin-bottom: .25rem; }
.tut-rules p { line-height: 1.5; margin-bottom: .25rem; }
.tut-rules .sub { color: rgba(255,255,255,.65); margin-top: .25rem; }
.tut-rules > div { margin-bottom: .5rem; }

.hs-table { width: 100%; text-align: left; font-size: .875rem; color: rgba(255,255,255,.8); border-collapse: collapse; }
.hs-table th { padding-bottom: .5rem; border-bottom: 1px solid rgba(255,255,255,.1); }
.hs-table td { padding: .75rem 0; text-transform: capitalize; font-weight: 500; }
.hs-table tr + tr td { border-top: 1px solid rgba(255,255,255,.05); }

.set-label { font-size: .75rem; color: rgba(255,255,255,.6); text-transform: uppercase; letter-spacing: .1em; font-weight: 500; }
.set-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.set-row .btn { height: clamp(2rem, 5svh, 3rem); border-radius: .75rem; }

.platform-mute-label { font-size: .7rem; color: var(--destructive); text-align: center; margin-top: .5rem; letter-spacing: .05em; text-transform: uppercase; }

.info-card {
  width: 100%; max-width: 448px; padding: clamp(.5rem, 1.5svh, 1rem); border: none;
  background: rgba(255,255,255,.05);
  border-radius: .75rem; z-index: 10; flex-shrink: 0;
}
.info-title { color: var(--primary); font-weight: 700; font-size: .875rem; margin-bottom: .25rem; }
.info-text { color: rgba(255,255,255,.8); font-size: .875rem; line-height: 1.5; }
.info-btns { display: flex; gap: .75rem; margin-top: clamp(.5rem, 1svh, 1rem); }
.info-btns .btn { padding: clamp(.4rem, 1svh, .75rem); border-radius: .75rem; font-weight: 700; }

.toast {
  position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%);
  background: var(--destructive); color: white; padding: .5rem 1.25rem;
  border-radius: .5rem; font-size: .875rem; font-weight: 500; z-index: 60;
  animation: toastIn .25s ease, toastOut .25s ease 1.5s forwards;
  pointer-events: none;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(1rem); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

.pause-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(0,0,0,.85);
  animation: fadeIn .2s ease; gap: 1rem;
}
.pause-overlay h2 {
  font-size: 2rem; font-weight: 700; color: var(--primary);
  text-transform: uppercase; letter-spacing: .25em;
}
.pause-overlay p {
  font-size: .875rem; color: rgba(255,255,255,.5);
}

.icon-btn-pause {
  background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.2);
}
.icon-btn-pause:hover { background: rgba(255,255,255,.15); }

.piece-pick-row { display: flex; justify-content: center; gap: 1.5rem; margin-top: .5rem; }
.piece-pick {
  width: clamp(2.5rem, 8svh, 4rem); height: clamp(2.5rem, 8svh, 4rem); border-radius: .75rem; border: 3px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.05); cursor: pointer; padding: .5rem;
  display: flex; align-items: center; justify-content: center; transition: all .2s;
}
.piece-pick img { width: 100%; height: 100%; object-fit: contain; }
.piece-pick.piece-pick-active {
  border-color: var(--primary); background: hsla(43,96%,58%,.15);
  box-shadow: 0 0 12px rgba(255,215,0,.4);
}
.piece-pick:hover:not(.piece-pick-active) { border-color: rgba(255,255,255,.3); }
.piece-pick-disabled {
  opacity: .45; cursor: not-allowed; pointer-events: none;
}

@media (max-height: 700px) and (orientation: portrait) {
  .game-screen { gap: .4rem; padding: .35rem .5rem .25rem; }
  .board-wrap { width: var(--board-size); height: var(--board-size); max-width: min(90vw, 340px); max-height: min(90vw, 340px); }
  .player-cards { max-width: min(90vw, 340px); }
  .top-section { max-width: min(90vw, 340px); }
}
@media (max-height: 600px) and (orientation: portrait) {
  .board-wrap { width: var(--board-size); height: var(--board-size); max-width: min(85vw, 300px); max-height: min(85vw, 300px); }
  .player-cards { max-width: min(85vw, 300px); }
  .top-section { max-width: min(85vw, 300px); }
  .pcard { padding: .35rem; gap: .1rem; }
  .pcard-icon { width: 1rem; height: 1rem; }
  .pcard-name { font-size: 9px; }
  .pcard-stats { font-size: 9px; gap: 3px; }
  .stat { padding: 1px .35rem; }
}

@media (max-height: 500px) and (orientation: portrait) {
  .game-screen { gap: .25rem; padding: .25rem .4rem .15rem; }
  .board-wrap { width: var(--board-size); height: var(--board-size); max-width: min(80vw, 260px); max-height: min(80vw, 260px); }
  .player-cards { max-width: min(80vw, 260px); }
  .top-section { max-width: min(80vw, 260px); }
  .game-title { font-size: .85rem; }
  .game-msg { font-size: 10px; height: .8rem; }
  .icon-btn { width: 2rem; height: 2rem; min-width: 36px; min-height: 36px; }
  :root { --piece-scale: 0.82; --spot-size: 10.5%; }
}

@media (max-width: 430px) and (orientation: portrait) {
  .top-bar { flex-direction: column; align-items: stretch; gap: .5rem; }
  .top-left { width: 100%; }
  .top-right { justify-content: flex-end; flex-wrap: wrap; }
}

@media (min-width: 481px) and (max-width: 899px) and (orientation: portrait) {
  .board-wrap { width: var(--board-size); height: var(--board-size); max-width: min(92vw, 500px); max-height: min(92vw, 500px); }
  .player-cards, .top-section { max-width: min(92vw, 500px); }
}

@media (orientation: landscape) and (max-height: 700px) {
  .menu-screen {
    flex-direction: row; justify-content: center; align-items: center; gap: clamp(1rem, 4vw, 3rem); max-width: none;
    padding: clamp(.35rem, 1.5svh, 1rem); overflow: hidden; height: 100%;
  }
  .menu-screen .logo-wrap {
    max-width: 40%; height: 100%; max-height: 100%; margin: 0; padding: 0;
    flex-shrink: 1;
  }
  .menu-screen .logo-img { height: 100%; width: 100%; object-fit: contain; }
  .menu-screen .menu-btns {
    max-width: 50%; margin: 0; max-height: 100%; overflow-y: auto;
    gap: clamp(.25rem, 1svh, .5rem);
  }

  .game-screen {
    flex-direction: row; flex-wrap: nowrap; justify-content: center; align-items: stretch;
    gap: clamp(.25rem, 1vw, .5rem); padding: clamp(.25rem, 1svh, .5rem); height: 100%;
  }
  .board-wrap {
    order: 1; flex-shrink: 0;
    width: var(--board-size);
    height: var(--board-size);
  }
  .top-section {
    order: 0; width: auto; max-width: clamp(7rem, 18vw, 14rem); min-width: 6rem; flex: 1 1 auto;
    display: flex; flex-direction: column; justify-content: center; overflow-y: auto;
  }
  .top-bar {
    flex-direction: column; align-items: center; border-bottom: none;
    padding-bottom: 0; margin-bottom: .25rem; gap: clamp(.25rem, 1svh, .75rem);
  }
  .top-left { align-items: center; text-align: center; }
  .top-right { justify-content: center; flex-wrap: wrap; gap: .35rem; }
  .top-section .game-title { font-size: clamp(.75rem, 2svh, 1rem); margin-bottom: .15rem; }
  .top-section .game-msg { height: auto; font-size: clamp(9px, 1.8svh, 11px); margin-top: auto; margin-bottom: auto; text-align: center; }

  .player-cards {
    order: 2; width: auto; max-width: clamp(6rem, 15vw, 11rem); min-width: 5rem; flex: 1 1 auto;
    grid-template-columns: 1fr; gap: .35rem; align-content: center;
  }
  .info-card {
    order: 2; width: auto; max-width: clamp(7rem, 18vw, 11rem); min-width: 6rem; flex: 1 1 auto;
    align-self: center; padding: clamp(.25rem, 1svh, .5rem); font-size: .75rem;
    max-height: calc(100svh - 1rem); overflow-y: auto; overflow-x: hidden;
  }
  .info-card .info-title { font-size: .7rem; }
  .info-card .info-text { font-size: .65rem; line-height: 1.3; }
  .info-card .info-btns { flex-direction: column; gap: .25rem; margin-top: .35rem; }
  .info-card .info-btns .btn { padding: .3rem; font-size: .65rem; }
  .pcard { padding: clamp(.2rem, .8svh, .4rem); gap: .1rem; }
  .pcard-icon { width: clamp(.8rem, 2.5svh, 1.2rem); height: clamp(.8rem, 2.5svh, 1.2rem); }
  .pcard-name { font-size: clamp(7px, 1.5svh, 9px); }
  .pcard-stats { font-size: clamp(7px, 1.5svh, 9px); gap: 2px; }
  .stat { padding: 1px .25rem; }

  .btn-pvb, .btn-pvp { height: clamp(1.8rem, 5svh, 3rem); font-size: clamp(.7rem, 2svh, 1rem); }
  .btn-sm { height: auto; min-height: clamp(2.5rem, 7svh, 4rem); font-size: clamp(.55rem, 1.6svh, .8rem); padding: clamp(.2rem, .8svh, .6rem) .4rem; }
  .btn-sm svg { width: clamp(.9rem, 2.8svh, 1.6rem); height: clamp(.9rem, 2.8svh, 1.6rem); }
  .btn-sm span { font-size: clamp(.5rem, 1.5svh, .75rem); }
}

@media (orientation: landscape) and (max-height: 500px) {
  .player-cards { min-width: 4.5rem; max-width: clamp(5rem, 12vw, 8rem); }
  .info-card { max-height: calc(100svh - .5rem); }
  .top-section { min-width: 5rem; max-width: clamp(5rem, 14vw, 8rem); }
  .icon-btn { width: 2rem; height: 2rem; min-width: 32px; min-height: 32px; }
  .top-right { gap: .25rem; }

  :root { --piece-scale: 0.82; --spot-size: 10.5%; }
}

@media (orientation: landscape) and (max-height: 400px) {
  .menu-screen { gap: .5rem; padding: .25rem; }
  .menu-screen .logo-wrap { max-width: 30%; }
  .menu-screen .menu-btns { max-width: 60%; gap: .2rem; }
  .btn-pvb, .btn-pvp { height: clamp(1.5rem, 5svh, 2.2rem); font-size: clamp(.6rem, 2svh, .85rem); gap: .35rem; }
  .btn-sm { height: auto; min-height: clamp(1.5rem, 5svh, 2.5rem); }

  .top-section { min-width: 4rem; max-width: 6rem; }
  .player-cards { min-width: 3.5rem; max-width: 5.5rem; }
  .pcard-name { display: none; }

  :root { --piece-scale: 0.76; --spot-size: 10%; --piece-padding: 18%; }
}

@media (max-height: 500px) and (orientation: landscape) {
  .win-overlay, .modal-ov { padding: .35rem; }
  .win-card { padding: .75rem; border-radius: .75rem; }
  .win-trophy, .win-gameover { margin-bottom: .25rem; }
  .win-trophy svg, .win-gameover svg { width: 32px; height: 32px; }
  .win-title { font-size: 1rem; margin-bottom: .15rem; }
  .win-stats { margin-bottom: .15rem; font-size: .75rem; }
  .win-time { margin-bottom: .5rem; font-size: .75rem; }
  .win-btns { gap: .3rem; }
  .win-btns .btn { padding: .4rem; font-size: .85rem; }
  .modal-card { padding: .75rem; }
  .modal-hdr { margin-bottom: .4rem; }
  .modal-hdr h2 { font-size: .95rem; }
  .btn-close { width: 2rem; height: 2rem; min-width: 36px; min-height: 36px; }
  .btn-diff { height: clamp(1.8rem, 5svh, 2.5rem); font-size: clamp(.75rem, 2.5svh, 1rem); }
  .pause-overlay { gap: .5rem; }
  .pause-overlay h2 { font-size: 1.25rem; letter-spacing: .15em; }

  .landscape-row { flex-direction: row; }
  .landscape-row .btn { flex: 1; margin: 0; padding: .4rem; font-size: .8rem; }

  .set-label { font-size: .65rem; margin-top: .4rem !important; }
  .set-row .btn { height: clamp(1.5rem, 4svh, 2.5rem); font-size: .8rem; }
  .piece-pick { width: clamp(2rem, 6svh, 3rem); height: clamp(2rem, 6svh, 3rem); padding: .3rem; }
  .piece-pick-row { gap: 1rem; margin-top: .25rem; }
}

@media (max-height: 350px) and (orientation: landscape) {
  .modal-card { padding: .5rem; max-height: calc(100svh - .5rem); }
  .modal-hdr { margin-bottom: .25rem; }
  .modal-body { gap: .2rem; }
  .btn-diff { height: clamp(1.5rem, 5svh, 2rem); }
  .tut-rules > div { margin-bottom: .2rem; }
  .tut-rules h3 { font-size: .8rem; }
  .tut-rules p { font-size: .75rem; line-height: 1.3; margin-bottom: .1rem; }
}

@media (min-width: 900px) and (min-height: 700px) {
  .game-screen { justify-content: center; gap: 1.5rem; padding: 2rem; }
  .board-wrap { width: var(--board-size); height: var(--board-size); max-width: min(72vmin, 640px); max-height: min(72vmin, 640px); }
  .player-cards { max-width: min(72vmin, 640px); }
  .top-section { max-width: min(72vmin, 640px); }
}

@media (pointer: fine) and (hover: hover) {
  body { cursor: none; }
  .board-wrap, .spot, .btn, .btn-close, .icon-btn, .menu-screen, .logo-wrap, .piece-pick {
    cursor: none;
  }

  .custom-cursor {
    position: fixed;
    left: 0; top: 0;
    width: var(--cursor-size); height: var(--cursor-size);
    transform: translate(-50%, -50%);
    background: url('../assets/images/cursoridle.webp') center / contain no-repeat;
    pointer-events: none; z-index: 9999;
  }

  html.mouse-down .custom-cursor { background-image: url('../assets/images/cursorclick.webp'); }
}

.bot-anim-layer { position: fixed; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; z-index: 45; }
  .bot-anim-wrap { position: absolute; width: var(--spot-size); height: var(--spot-size); left: 0; top: 0; transform-origin: center; transition: transform .5s cubic-bezier(.25,.1,.25,1); }
  .bot-anim-piece { display: block; width: 100%; height: 100%; object-fit: contain; transform-origin: center; transition: transform .25s cubic-bezier(.2,.9,.3,1), opacity .25s ease; }

@media (min-width: 900px) and (min-height: 700px) {
  #app[data-view="tutorial"] .board-wrap {
    width: var(--board-size); height: var(--board-size); max-width: min(50vmin, 420px); max-height: min(50vmin, 420px);
  }
}

.tut-hand {
  position: absolute;
  width: clamp(32px, 8vmin, 52px);
  height: clamp(32px, 8vmin, 52px);
  pointer-events: none;
  z-index: 40;
  transform: translate(-20%, -16%);
  transform-origin: center bottom;
  animation: tutHandBob .9s ease-in-out infinite;
}
.tut-hand img {
  width: 100%; height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,.65));
  display: block;
}
.tut-hand.fading {
  animation: tutHandFade .32s ease forwards;
}
@keyframes tutHandBob {
  0%, 100% { transform: translate(-20%, -16%) scale(1); }
  50%       { transform: translate(-20%, -16%) scale(.88) translateY(4px); }
}
@keyframes tutHandFade {
  from { opacity: 1; transform: translate(-20%, -16%) scale(1); }
  to   { opacity: 0; transform: translate(-20%, -16%) scale(.7); }
}
.tut-end-msg {
  font-weight: 600;
  color: var(--accent, #e8a238);
  animation: tutEndMsgIn .45s ease;
}
@keyframes tutEndMsgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
