:root {
  --ink: #03142c;
  --deep: #041d3d;
  --navy: #082b52;
  --panel: rgba(5, 25, 56, .92);
  --pearl: #fff7d6;
  --foam: #dffff8;
  --aqua: #6df8e9;
  --cyan: #20cbd7;
  --coral: #ff789d;
  --gold: #ffd668;
  --violet: #9c73ef;
  --abyss: #1d1748;
  --tile-light-a: #c7fff2;
  --tile-light-b: #50d5d5;
  --tile-dark-a: #7d6ad4;
  --tile-dark-b: #263f83;
  --battle-ease: cubic-bezier(.16, .8, .18, 1);
  --focus: #fff293;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  min-width: 320px;
  overflow-x: hidden;
  color: white;
  background: #021025;
  font-family: Inter, ui-rounded, "SF Pro Rounded", "Avenir Next", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, a { font: inherit; }
button, select, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }

.tidal-app {
  position: relative;
  min-height: 100dvh;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% 16%, rgba(80, 247, 231, .22), transparent 28%),
    linear-gradient(180deg, rgba(2, 20, 49, .22), rgba(2, 9, 29, .92)),
    url("assets/chess/undersea-castle-arena.webp") center / cover fixed;
}
.tidal-app::before {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(2, 9, 28, .76), transparent 27% 73%, rgba(2, 9, 28, .76)),
    radial-gradient(ellipse at 50% 110%, rgba(7, 255, 224, .18), transparent 54%);
}
.tidal-app[data-theme="medieval"] {
  --ink: #251106;
  --deep: #31170b;
  --navy: #512711;
  --panel: rgba(38, 17, 9, .94);
  --pearl: #fff1c3;
  --foam: #fff3d3;
  --aqua: #f5c968;
  --cyan: #bf7037;
  --coral: #c75247;
  --gold: #ffd776;
  --violet: #aa6e8e;
  --abyss: #32152c;
  --tile-light-a: #f7e0aa;
  --tile-light-b: #d5ae68;
  --tile-dark-a: #874a50;
  --tile-dark-b: #3e1e32;
  --focus: #ffdc70;
  background:
    radial-gradient(circle at 50% 11%, rgba(255, 210, 107, .2), transparent 29%),
    linear-gradient(180deg, rgba(60, 24, 10, .1), rgba(18, 6, 7, .9)),
    url("assets/chess/medieval/castle-arena.webp") center / cover fixed;
}
.tidal-app[data-theme="medieval"]::before {
  background:
    linear-gradient(90deg, rgba(22, 7, 5, .8), transparent 29% 71%, rgba(22, 7, 5, .8)),
    radial-gradient(ellipse at 50% 112%, rgba(255, 177, 76, .2), transparent 53%);
}

/* Header */
.app-hud {
  position: sticky;
  z-index: 100;
  top: 0;
  min-height: 74px;
  padding: 8px max(18px, env(safe-area-inset-right)) 8px max(18px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid rgba(176, 255, 244, .24);
  background: linear-gradient(180deg, rgba(8, 39, 73, .97), rgba(3, 19, 44, .95));
  box-shadow: 0 8px 32px rgba(0, 6, 24, .48), inset 0 -1px rgba(112, 241, 230, .08);
  backdrop-filter: blur(18px);
}
.brand-lockup { width: max-content; display: flex; align-items: center; gap: 10px; color: white; text-decoration: none; }
.brand-copy strong, .brand-copy small { display: block; }
.brand-copy strong { font-size: 20px; font-weight: 1000; letter-spacing: -.045em; }
.brand-copy small { margin-top: 1px; color: var(--aqua); font-size: 8px; font-weight: 1000; letter-spacing: .18em; text-transform: uppercase; }
.brand-pearl {
  width: 46px;
  height: 50px;
  display: grid;
  place-items: center;
  border: 3px solid #fff9ce;
  border-radius: 49% 51% 44% 56%;
  color: #164a6a;
  background: radial-gradient(circle at 31% 21%, #fff 0 10%, #dcfff8 24%, #72d9df 62%, #b5945a 100%);
  box-shadow: inset -6px -8px 11px rgba(18, 65, 91, .28), 0 5px 0 #58435d, 0 0 20px rgba(92, 248, 231, .3);
  font-size: 23px;
  font-weight: 1000;
  transform: rotate(-4deg);
}
.match-title { min-width: 340px; display: flex; align-items: center; justify-content: center; gap: 11px; text-align: left; }
.match-title > span:last-child small, .match-title > span:last-child strong { display: block; }
.match-title small { color: #8ef7ec; font-size: 8px; font-weight: 1000; letter-spacing: .18em; }
.match-title strong { font-family: Georgia, "Times New Roman", serif; color: #fff5c5; font-size: 18px; letter-spacing: -.02em; }
.match-gem { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid rgba(255, 246, 193, .5); border-radius: 50%; color: #fff5bb; background: radial-gradient(circle at 35% 25%, #8cfbee, #187d9f 52%, #122756); box-shadow: inset 0 2px rgba(255,255,255,.25), 0 5px 10px rgba(0,0,0,.35); font-size: 20px; }
.hud-actions { justify-self: end; display: flex; gap: 8px; }
.hud-button {
  min-height: 45px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid rgba(192, 255, 246, .25);
  border-radius: 999px;
  color: #effffc;
  background: rgba(255,255,255,.075);
  box-shadow: inset 0 1px rgba(255,255,255,.12);
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
}
.hud-button:hover { background: rgba(113, 244, 232, .14); }
.hud-button[aria-pressed="false"] { opacity: .68; }
.hud-button.icon-only { width: 45px; padding: 0; font-size: 17px; }
.tidal-app:not(.is-playing) [data-action="show-settings"] { display:none; }
.tidal-app[data-theme="medieval"] .app-hud { border-bottom-color:rgba(255,213,122,.3); background:linear-gradient(180deg,rgba(68,31,18,.97),rgba(30,12,12,.96)); }
.tidal-app[data-theme="medieval"] .brand-pearl { color:#5c2c17; background:radial-gradient(circle at 31% 21%,#fff9dd 0 10%,#ffd981 29%,#c56d32 67%,#6c2d26 100%); box-shadow:inset -6px -8px 11px rgba(80,25,18,.28),0 5px 0 #4b1f1e,0 0 20px rgba(255,195,90,.25); }
.tidal-app[data-theme="medieval"] .match-gem { background:radial-gradient(circle at 35% 25%,#ffe6a2,#a7542e 54%,#42192b); }

/* Main game composition */
.game-shell {
  width: min(1720px, calc(100% - 24px));
  min-height: calc(100dvh - 74px);
  margin: 0 auto;
  padding: 15px 0 22px;
  display: grid;
  grid-template-columns: clamp(220px, 16.2vw, 276px) minmax(540px, 1fr) clamp(280px, 21vw, 352px);
  align-items: start;
  gap: clamp(12px, 1.35vw, 24px);
}
.player-rail, .coach-rail { min-width: 0; }

.turn-card {
  position: relative;
  min-height: 170px;
  padding: 21px 18px 17px 112px;
  overflow: hidden;
  border: 2px solid rgba(254, 242, 183, .7);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(21, 101, 125, .98), rgba(5, 32, 68, .98));
  box-shadow: inset 0 2px rgba(255,255,255,.24), inset 0 -14px 28px rgba(0, 10, 42, .3), 0 8px 0 #08263f, 0 18px 35px rgba(0, 5, 23, .48), 0 0 30px rgba(90, 245, 232, .14);
}
.turn-card[data-side="b"] { border-color: rgba(205, 163, 255, .75); background: linear-gradient(145deg, rgba(73, 50, 137, .98), rgba(14, 20, 64, .98)); }
.turn-waterline { position: absolute; z-index: 1; inset: 0; opacity: .16; background: repeating-radial-gradient(ellipse at 20% 20%, transparent 0 16px, #bafff6 19px 21px, transparent 24px 42px); animation:waterline 9s linear infinite; }
@keyframes waterline { to { transform: translate(8%, 7%) rotate(4deg) scale(1.08); } }
.turn-character { position: absolute; z-index: 2; left: -10px; bottom: -7px; width: 132px; height: 185px; }
.turn-character img { width: 100%; height: 100%; object-fit: contain; object-position: center bottom; filter: drop-shadow(0 10px 7px rgba(0, 4, 20, .52)); transition: opacity .2s; }
.turn-card-copy { position: relative; z-index: 3; min-width: 0; }
.turn-side, .turn-card-copy strong, .turn-card-copy p { display: block; }
.turn-side { color: #a3fff4; font-size: 8px; font-weight: 1000; letter-spacing: .14em; }
.turn-card[data-side="b"] .turn-side { color: #e3c8ff; }
.turn-card-copy strong { margin-top: 4px; overflow: hidden; color: #fffbd8; font-size: clamp(18px, 1.42vw, 23px); font-weight: 1000; letter-spacing: -.045em; text-overflow: ellipsis; white-space: nowrap; }
.turn-card-copy p { margin: 9px 0 0; color: #d9f4f4; font-size: 11px; font-weight: 800; line-height: 1.35; }
.turn-crown { position: absolute; z-index: 2; right: 13px; bottom: 2px; color: rgba(255, 243, 169, .24); font-size: 68px; filter: drop-shadow(0 0 12px rgba(255, 234, 125, .35)); }

.player-cards { margin-top: 20px; display: grid; gap: 9px; }
.player-card {
  position: relative;
  min-height: 79px;
  padding: 10px 34px 10px 70px;
  display: flex;
  align-items: center;
  border: 1px solid rgba(182, 226, 233, .17);
  border-radius: 21px;
  background: linear-gradient(145deg, rgba(10, 36, 74, .93), rgba(4, 22, 52, .94));
  box-shadow: inset 0 1px rgba(255,255,255,.1), 0 7px 18px rgba(0, 5, 23, .32);
  transition: transform .25s, border-color .25s, filter .25s;
}
.player-card.is-active { border-color: rgba(255, 242, 164, .85); filter: brightness(1.13); transform: translateX(6px) scale(1.025); box-shadow: inset 0 1px rgba(255,255,255,.2), 0 0 0 3px rgba(102, 245, 229, .12), 0 9px 24px rgba(0, 5, 23, .46); }
.player-avatar { position: absolute; left: 5px; bottom: 4px; width: 64px; height: 78px; }
.player-avatar img { width: 100%; height: 100%; object-fit: contain; object-position: center bottom; filter: drop-shadow(0 6px 4px rgba(0,0,0,.4)); }
.player-card-copy { min-width: 0; }
.player-card-copy small, .player-card-copy strong, .player-card-copy em { display: block; }
.player-card-copy small { color: #8af6ec; font-size: 7px; font-weight: 1000; letter-spacing: .11em; }
.abyss-player .player-card-copy small { color: #d8bcff; }
.player-card-copy strong { margin-top: 3px; overflow: hidden; font-size: 14px; font-weight: 1000; text-overflow: ellipsis; white-space: nowrap; }
.player-card-copy em { margin-top: 3px; color: #b8d0df; font-size: 9px; font-style: normal; font-weight: 800; }
.side-token { position: absolute; right: 12px; color: #fff1a0; font-size: 23px; opacity: .75; }
.abyss-player .side-token { color: #ba9dff; }
.versus-seal { position: relative; z-index: 4; height: 0; display: grid; place-items: center; }
.versus-seal span { width: 32px; height: 32px; display: grid; place-items: center; border: 2px solid #fbe8a0; border-radius: 50%; color: #fff9d1; background: #132f57; box-shadow: 0 4px 9px rgba(0,0,0,.35); font-size: 8px; font-weight: 1000; }

.captured-vault {
  margin-top: 20px;
  padding: 14px;
  border: 1px solid rgba(176, 233, 235, .2);
  border-radius: 22px;
  background: rgba(3, 19, 47, .78);
  box-shadow: inset 0 1px rgba(255,255,255,.1), 0 9px 24px rgba(0,0,0,.3);
  backdrop-filter: blur(12px);
}
.vault-heading { display: flex; align-items: center; gap: 8px; color: #eafffa; font-size: 11px; }
.vault-heading span { color: #7affec; }
.capture-row { margin-top: 10px; }
.capture-row small { display: block; margin-bottom: 5px; color: #769ab0; font-size: 7px; font-weight: 1000; letter-spacing: .12em; }
.capture-row > div { min-height: 25px; display: flex; align-items: center; flex-wrap: wrap; gap: 2px; color: #fff4c5; font-size: 22px; filter: drop-shadow(0 2px 1px rgba(0,0,0,.5)); }
.capture-row [data-color="b"] { color: #a98af2; }
.captured-mini { width:27px; height:31px; display:grid; place-items:center; }
.captured-mini img { max-width:100%; max-height:100%; object-fit:contain; filter:drop-shadow(0 3px 2px rgba(0,0,0,.5)); }

/* Physical board */
.board-column { min-width: 0; }
.board-topline { min-height: 39px; padding: 0 8px 7px; display: flex; align-items: center; justify-content: space-between; }
.turn-pill { display: flex; align-items: center; gap: 8px; color: #dffff8; font-size: 10px; font-weight: 1000; letter-spacing: .04em; }
.turn-pill i { width: 9px; height: 9px; border: 2px solid #eaffd8; border-radius: 50%; background: #4cf0d3; box-shadow: 0 0 12px #4cf0d3; animation:turnPulse 1.7s ease-in-out infinite; }
@keyframes turnPulse { 50% { transform: scale(1.45); opacity: .65; } }
.text-button { min-height: 38px; padding: 0 12px; border: 0; border-radius: 11px; color: #b9dae5; background: rgba(1, 13, 39, .42); cursor: pointer; font-size: 9px; font-weight: 900; }
.text-button:hover { color: white; background: rgba(84, 235, 225, .12); }
.board-wrap {
  position: relative;
  width: min(100%, calc(100dvh - 132px));
  aspect-ratio: 1;
  margin-inline: auto;
  padding: clamp(15px, 1.55vw, 25px);
  border: clamp(5px, .55vw, 9px) solid rgba(239, 255, 238, .82);
  border-radius: clamp(25px, 2.7vw, 42px);
  background:
    linear-gradient(135deg, rgba(167, 255, 239, .55), transparent 20% 80%, rgba(255, 213, 119, .45)),
    linear-gradient(145deg, #296e83, #0b385d 48%, #462c74);
  box-shadow:
    inset 0 3px rgba(255,255,255,.5),
    inset 0 -8px 14px rgba(1,12,36,.4),
    0 8px 0 #17445c,
    0 15px 0 #071c36,
    0 27px 50px rgba(0, 4, 19, .62),
    0 0 45px rgba(69, 235, 221, .17);
  isolation: isolate;
  transform: perspective(1300px) rotateX(4deg) rotateZ(.12deg);
  transform-origin: 50% 82%;
  transition: transform .45s var(--battle-ease), box-shadow .45s;
}
.tidal-app.is-flat .board-wrap { transform:none; }
.board-wrap.is-reorienting { pointer-events:none; }
.board-wrap.is-reorienting .chess-board { animation:boardReorient .42s cubic-bezier(.45,0,.25,1) both; }
@keyframes boardReorient { 0% { opacity:1; transform:scale(1) rotateZ(0); filter:brightness(1); } 46% { opacity:.28; transform:scale(.945) rotateZ(-1.4deg); filter:brightness(1.5); } 54% { opacity:.28; transform:scale(.945) rotateZ(1.4deg); filter:brightness(1.5); } 100% { opacity:1; transform:scale(1) rotateZ(0); filter:brightness(1); } }
.board-wrap::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 5px;
  border: 2px solid rgba(255, 243, 187, .42);
  border-radius: calc(clamp(25px, 2.7vw, 42px) - 8px);
  pointer-events: none;
}
.chess-board {
  position: relative;
  z-index: 3;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  overflow: visible;
  border: 3px solid rgba(255, 238, 177, .75);
  border-radius: 14px;
  background: #0c3559;
  box-shadow: inset 0 0 18px rgba(0,0,0,.42), 0 5px 0 #082a45, 0 10px 22px rgba(0,0,0,.44);
}
.board-square {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
  display: grid;
  place-items: center;
  overflow: visible;
  border: 0;
  border-right: 1px solid rgba(255,255,255,.12);
  border-bottom: 1px solid rgba(1, 22, 52, .2);
  background: transparent;
  cursor: pointer;
  isolation: isolate;
}
.board-square::before {
  content: "";
  position: absolute;
  z-index: -2;
  inset: 0;
  background:
    radial-gradient(circle at 27% 20%, rgba(255,255,255,.3) 0 2%, transparent 3% 100%),
    linear-gradient(145deg, var(--square-a), var(--square-b));
  box-shadow: inset 0 3px rgba(255,255,255,.25), inset 0 -7px rgba(2, 20, 54, .17);
  transition: transform .18s var(--battle-ease), filter .18s, box-shadow .18s;
}
.board-square.light { --square-a: var(--tile-light-a); --square-b: var(--tile-light-b); }
.board-square.dark { --square-a: var(--tile-dark-a); --square-b: var(--tile-dark-b); }
.board-square:hover::before, .board-square:focus-visible::before { z-index: -1; transform: translateY(-4px) scale(1.04); filter: brightness(1.13) saturate(1.08); box-shadow: inset 0 3px rgba(255,255,255,.4), inset 0 -7px rgba(2,20,54,.17), 0 7px 12px rgba(0,7,32,.38); }
.board-square:focus-visible { z-index: 8; outline: 4px solid #fff4a2; outline-offset: -4px; }
.board-square.is-selected { z-index: 12; }
.board-square.is-selected::before { transform: translateY(-7px) scale(1.065); filter: brightness(1.2) saturate(1.22); box-shadow: inset 0 0 0 4px #fff7ad, inset 0 4px rgba(255,255,255,.5), 0 9px 0 rgba(6,76,104,.75), 0 12px 24px rgba(0,0,0,.46), 0 0 28px #7cfff0; animation:selectedTile 1.3s ease-in-out infinite; }
@keyframes selectedTile { 50% { filter: brightness(1.35) saturate(1.25); box-shadow: inset 0 0 0 4px #fffad0, inset 0 4px rgba(255,255,255,.5), 0 9px 0 rgba(6,76,104,.7), 0 13px 26px rgba(0,0,0,.44), 0 0 40px #7cfff0; } }
.board-square.is-legal { z-index: 8; }
.board-square.is-legal::after {
  content: "";
  position: absolute;
  z-index: 5;
  width: 28%;
  aspect-ratio: 1;
  border: 3px solid rgba(255, 252, 202, .92);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, white, #5cf5dc 38%, #108db3 72%);
  box-shadow: 0 3px 0 rgba(3,58,82,.75), 0 0 13px #71fff0;
  animation:legalRipple 1.2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes legalRipple { 50% { transform: scale(1.22); filter: brightness(1.2); } }
.board-square.is-capture::after { width: 76%; background: transparent; border: 5px solid #ffdc72; box-shadow: inset 0 0 17px rgba(255, 112, 143, .52), 0 0 0 3px rgba(255,255,255,.58), 0 0 20px #ff7f9d; animation:captureTarget .85s ease-in-out infinite; }
@keyframes captureTarget { 50% { transform: scale(.88) rotate(4deg); border-color: #fff4b0; filter: brightness(1.2); } }
.board-square.last-move::before { box-shadow: inset 0 0 0 5px rgba(255, 229, 98, .7), inset 0 3px rgba(255,255,255,.35), inset 0 -7px rgba(2,20,54,.16); filter: brightness(1.15); }
.board-square.is-check::before { animation:checkAlarm .72s ease-in-out infinite; box-shadow: inset 0 0 0 5px #fff, 0 0 28px #ff3f6c; }
@keyframes checkAlarm { 50% { filter: hue-rotate(-18deg) brightness(1.3); background: linear-gradient(145deg,#ff7899,#9b255e); } }
.board-square.move-landing .piece-shell { animation:pieceLand .48s var(--battle-ease); }
@keyframes pieceLand { 0% { transform: translateY(-45%) scale(1.28); filter: brightness(1.7) drop-shadow(0 14px 10px rgba(0,0,0,.6)); } 70% { transform: translateY(8%) scale(.94); } 100% { transform: none; } }
.square-label { position: absolute; z-index: 7; color: rgba(2,35,66,.62); font-size: clamp(7px, .62vw, 10px); font-weight: 1000; line-height: 1; pointer-events: none; text-shadow: 0 1px rgba(255,255,255,.3); }
.dark .square-label { color: rgba(225,255,249,.63); text-shadow: 0 1px rgba(0,0,0,.28); }
.square-label.file { right: 5px; bottom: 4px; }
.square-label.rank { left: 5px; top: 4px; }
.board-glow { position: absolute; z-index: 1; inset: 10%; border-radius: 50%; pointer-events: none; box-shadow: 0 0 70px 18px rgba(83, 245, 230, .28); filter: blur(20px); }
.board-corner { position: absolute; z-index: 12; width: 25px; height: 25px; display: grid; place-items: center; border: 2px solid #ffefb5; border-radius: 50%; color: #fff9d0; background: radial-gradient(circle,#47d5cf,#173a68); box-shadow: 0 3px 5px rgba(0,0,0,.4), 0 0 10px rgba(93,255,235,.35); font-size: 9px; }
.corner-nw { left: 4px; top: 4px; }.corner-ne { right: 4px; top: 4px; }.corner-sw { left: 4px; bottom: 4px; }.corner-se { right: 4px; bottom: 4px; }
.tidal-app[data-theme="medieval"] .board-wrap { border-color:#f8dea0; background:linear-gradient(135deg,#d89b4e,#6d341e 43%,#321522 78%,#bc7135); box-shadow:inset 0 3px rgba(255,250,211,.62),inset 0 -8px 14px rgba(35,9,7,.45),0 8px 0 #64321e,0 15px 0 #2d1316,0 27px 50px rgba(13,3,5,.68),0 0 42px rgba(255,189,77,.16); }
.tidal-app[data-theme="medieval"] .chess-board { border-color:#ffe3a0; background:#391728; box-shadow:inset 0 0 18px rgba(30,7,8,.55),0 5px 0 #602b20,0 10px 22px rgba(0,0,0,.5); }
.tidal-app[data-theme="medieval"] .board-glow { box-shadow:0 0 70px 18px rgba(255,184,73,.22); }
.tidal-app[data-theme="medieval"] .board-corner { border-color:#ffe3a0; color:#fff1b4; background:radial-gradient(circle,#d79545,#5e2a24); }

/* High-resolution CSS/vector pieces */
.piece-shell {
  position: relative;
  z-index: 4;
  width: 112%;
  height: 126%;
  display: grid;
  place-items: center;
  transform-origin: 50% 82%;
  transition: transform .2s var(--battle-ease), filter .2s;
  pointer-events: none;
}
.piece-shell[data-piece="p"] { width:108%; height:116%; }
.piece-shell[data-piece="r"],.piece-shell[data-piece="n"] { width:116%; height:124%; }
.piece-shell[data-piece="q"],.piece-shell[data-piece="k"],.piece-shell[data-piece="b"] { width:116%; height:132%; }
.piece-art { position:absolute; z-index:3; inset:0; width:100%; height:100%; object-fit:contain; object-position:center bottom; filter:drop-shadow(0 8px 5px rgba(0,4,21,.55)); transform:translateZ(16px); }
.piece-shell[data-color="w"] .piece-art { filter:drop-shadow(0 8px 5px rgba(0,4,21,.54)) drop-shadow(0 0 5px rgba(255,245,186,.32)); }
.piece-shell[data-color="b"] .piece-art { filter:drop-shadow(0 8px 5px rgba(0,4,21,.62)) drop-shadow(0 0 6px rgba(152,112,255,.38)); }
.tidal-app[data-piece-style="classic"] .piece-shell { width:101%; height:117%; }
.tidal-app[data-piece-style="classic"] .piece-shell[data-piece="p"] { width:96%; height:108%; }
.tidal-app[data-piece-style="classic"] .piece-shell[data-piece="r"],.tidal-app[data-piece-style="classic"] .piece-shell[data-piece="n"] { width:105%; height:114%; }
.tidal-app[data-piece-style="classic"] .piece-shell[data-piece="q"],.tidal-app[data-piece-style="classic"] .piece-shell[data-piece="k"],.tidal-app[data-piece-style="classic"] .piece-shell[data-piece="b"] { width:106%; height:119%; }
.tidal-app[data-theme="medieval"] .piece-shell[data-color="w"] .piece-art { filter:drop-shadow(0 8px 5px rgba(26,7,5,.56)) drop-shadow(0 0 5px rgba(255,220,136,.28)); }
.tidal-app[data-theme="medieval"] .piece-shell[data-color="b"] .piece-art { filter:drop-shadow(0 8px 5px rgba(20,4,7,.65)) drop-shadow(0 0 6px rgba(196,91,105,.3)); }
.board-square:hover .piece-shell { transform: translateY(-7%) scale(1.06) rotate(-1deg); }
.piece-glyph {
  position: relative;
  z-index: 3;
  margin-top: -12%;
  font-family: "Arial Unicode MS", "DejaVu Sans", "Times New Roman", serif;
  font-size: clamp(29px, 4.2vw, 68px);
  font-weight: 900;
  line-height: 1;
  transform: scaleX(.88);
}
.piece-shell[data-color="w"] .piece-glyph {
  color: #fffbe4;
  -webkit-text-stroke: 1px #9f7738;
  text-shadow: 0 1px #fff, 0 2px #e5d79e, 0 3px #c6ae69, 0 4px #97743f, 0 6px 3px rgba(0,0,0,.46), 0 0 11px rgba(255,246,183,.5);
}
.piece-shell[data-color="b"] .piece-glyph {
  color: #34275e;
  -webkit-text-stroke: 1px #9d80dd;
  text-shadow: 0 1px #c5adff, 0 2px #8067bf, 0 3px #4a367b, 0 4px #251b4b, 0 6px 3px rgba(0,0,0,.58), 0 0 11px rgba(142,112,242,.6);
}
.piece-pedestal {
  position: absolute;
  z-index: 2;
  left: 13%;
  right: 13%;
  bottom: 5%;
  height: 22%;
  border: 2px solid rgba(255,255,255,.52);
  border-radius: 50%;
  transform: perspective(100px) rotateX(54deg);
}
.piece-shell[data-color="w"] .piece-pedestal { background: radial-gradient(ellipse at 42% 25%, #fffad7, #65e8dd 45%, #137895 76%); box-shadow: inset 0 3px white, 0 7px 0 #0a526c, 0 10px 8px rgba(0,0,0,.4), 0 0 12px #73f7e8; }
.piece-shell[data-color="b"] .piece-pedestal { background: radial-gradient(ellipse at 42% 25%, #d8c1ff, #7e5ec4 45%, #26204e 76%); box-shadow: inset 0 3px #e4d6ff, 0 7px 0 #19163d, 0 10px 8px rgba(0,0,0,.48), 0 0 12px #9272e2; }
.piece-bubble { position: absolute; z-index: 5; right: 15%; top: 20%; width: 9%; aspect-ratio: 1; border: 1px solid rgba(230,255,252,.9); border-radius: 50%; opacity: 0; }
.move-ghost { position: absolute !important; z-index: 35 !important; margin: 0 !important; pointer-events: none !important; filter: drop-shadow(0 13px 8px rgba(0,0,0,.56)); }
.board-square.is-selected .piece-shell { animation:selectedPiece 1.4s ease-in-out infinite; }
@keyframes selectedPiece { 50% { transform: translateY(-10%) scale(1.08); filter: drop-shadow(0 0 9px #fff8bb); } }
.board-square.is-selected .piece-bubble { animation:pieceBubble 1.1s ease-out infinite; }
@keyframes pieceBubble { from { opacity: 0; transform: translateY(100%) scale(.3); } 30% { opacity: .9; } to { opacity: 0; transform: translate(-10px,-45px) scale(1.2); } }

.mobile-turn-strip { display: none; }

/* Teaching panel */
.coach-rail { display: grid; gap: 12px; }
.math-gate, .teacher-card, .move-scroll {
  border: 1px solid rgba(188, 245, 239, .21);
  border-radius: 25px;
  background: linear-gradient(150deg, rgba(8, 37, 75, .96), rgba(3, 17, 44, .96));
  box-shadow: inset 0 1px rgba(255,255,255,.12), 0 9px 25px rgba(0, 5, 21, .36);
  backdrop-filter: blur(14px);
}
.math-gate { padding: 16px; border-color: rgba(255, 229, 133, .5); background: linear-gradient(150deg, rgba(73, 54, 118, .98), rgba(18, 24, 65, .98)); }
.lesson-label { color: #ffe58d; font-size: 8px; font-weight: 1000; letter-spacing: .15em; }
.math-shell { margin-top: 9px; display: flex; align-items: center; gap: 11px; }
.math-orb { width: 47px; height: 47px; flex: 0 0 auto; display: grid; place-items: center; border: 3px solid #fff3ae; border-radius: 50%; color: #402c6d; background: radial-gradient(circle at 32% 27%, #fff, #ffd86b 40%, #f08382 79%); box-shadow: inset -4px -5px rgba(92,41,111,.2), 0 5px 0 #39244d, 0 0 14px rgba(255,216,106,.36); font-weight: 1000; }
.math-shell small, .math-shell strong { display: block; }
.math-shell small { color: #ddcbf5; font-size: 9px; font-weight: 800; }
.math-shell strong { margin-top: 2px; color: white; font-size: 25px; font-weight: 1000; }
.math-answers { margin-top: 12px; display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; }
.math-answer { min-height: 48px; border: 2px solid rgba(255,255,255,.35); border-radius: 14px; color: #24355d; background: linear-gradient(180deg,#fff9c7,#77eadc); box-shadow: inset 0 2px white, 0 5px 0 #285974; cursor: pointer; font-size: 17px; font-weight: 1000; }
.math-answer:active { transform: translateY(4px); box-shadow: inset 0 2px white, 0 1px 0 #285974; }
.math-answer.is-wrong { animation:nope .35s ease; background: linear-gradient(180deg,#ffe1e3,#ff8b9f); }
@keyframes nope { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.math-gate p { margin: 10px 0 0; color: #d7cee9; font-size: 9px; font-weight: 800; text-align: center; }

.teacher-card { padding: 17px; }
.teacher-heading { display: flex; align-items: center; gap: 10px; }
.teacher-orb { width: 45px; height: 45px; display: grid; place-items: center; border: 2px solid #c1fff6; border-radius: 50%; color: #fff4c3; background: radial-gradient(circle at 35% 30%,#2fd9d2,#135d88 58%,#142752); box-shadow: inset 0 2px rgba(255,255,255,.25),0 5px 0 #062540,0 0 15px rgba(68,243,228,.23); font-size: 23px; }
.teacher-heading small, .teacher-heading strong { display: block; }
.teacher-heading small { color: #7bf5e9; font-size: 7px; font-weight: 1000; letter-spacing: .16em; }
.teacher-heading strong { margin-top: 2px; font-size: 14px; font-weight: 1000; }
.lesson-message { min-height: 58px; margin: 14px 0 12px; color: #effffd; font-size: 12px; font-weight: 750; line-height: 1.5; }
.lesson-message strong { color: #fff0a0; }
.notation-card { min-height: 68px; padding: 10px 9px 10px 13px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid rgba(255, 239, 168, .38); border-radius: 17px; background: linear-gradient(145deg,rgba(34,94,112,.7),rgba(18,39,81,.76)); box-shadow: inset 0 1px rgba(255,255,255,.12); }
.notation-card small, .notation-card strong { display: block; }
.notation-card small { color: #9af9ef; font-size: 7px; font-weight: 1000; letter-spacing: .14em; }
.notation-card strong { margin-top: 2px; color: #fff7c4; font-family: Georgia, serif; font-size: 22px; }
.notation-card button { width: 43px; height: 43px; flex: 0 0 auto; border: 1px solid rgba(255,255,255,.32); border-radius: 50%; color: white; background: rgba(255,255,255,.09); cursor: pointer; }
.piece-lesson { margin-top: 12px; padding: 10px; display: flex; align-items: center; gap: 10px; border-radius: 15px; background: rgba(0,10,34,.35); }
.piece-lesson > span { color: #fff1ac; font-size: 28px; }
.piece-lesson p { margin: 0; }
.piece-lesson strong, .piece-lesson small { display: block; }
.piece-lesson strong { font-size: 10px; }
.piece-lesson small { margin-top: 2px; color: #b8cfde; font-size: 8px; font-weight: 700; line-height: 1.35; }

.move-scroll { min-height: 190px; max-height: 300px; padding: 15px; overflow: hidden; }
.scroll-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.scroll-heading small, .scroll-heading strong { display: block; }
.scroll-heading small { color: #7beee5; font-size: 7px; font-weight: 1000; letter-spacing: .13em; }
.scroll-heading strong { margin-top: 2px; font-size: 13px; }
.scroll-heading b { color: #7997ab; font-size: 8px; }
.history-head { margin-top: 11px; padding: 0 6px 6px; display: grid; grid-template-columns: 28px 1fr 1fr; color: #668da4; font-size: 7px; font-weight: 1000; letter-spacing: .09em; }
.history-list { max-height: 215px; margin: 0; padding: 0; overflow-y: auto; list-style: none; scrollbar-width: thin; scrollbar-color: #387e92 transparent; }
.history-row { min-height: 34px; padding: 5px 6px; display: grid; grid-template-columns: 28px 1fr 1fr; align-items: center; border-top: 1px solid rgba(255,255,255,.06); color: #dff6f5; font-family: Georgia, serif; font-size: 12px; }
.history-row b { color: #668da4; font-family: Inter, sans-serif; font-size: 8px; }
.history-row span:last-child { color: #cbb6ff; }
.history-row .latest { color: #fff5a7; font-weight: 900; }
.history-empty { padding: 24px 10px; color: #7794a8; font-size: 9px; font-weight: 750; text-align: center; }
.coach-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.secondary-action { min-height: 47px; border: 1px solid rgba(183, 241, 236, .25); border-radius: 14px; color: #dffaf8; background: rgba(5,25,59,.78); box-shadow: inset 0 1px rgba(255,255,255,.1),0 5px 11px rgba(0,0,0,.25); cursor: pointer; font-size: 10px; font-weight: 900; }
.secondary-action:hover { border-color: rgba(124,255,238,.5); background: rgba(15,57,85,.86); }
.secondary-action:disabled { cursor: not-allowed; opacity: .38; }

/* Capture cinematic runs on the real board */
.battle-overlay { position: absolute; z-index: 40; inset: clamp(15px, 1.55vw, 25px); overflow: hidden; border-radius: 14px; opacity: 0; visibility: hidden; pointer-events: none; background: linear-gradient(180deg,rgba(2,28,57,.5),rgba(2,10,32,.82)); transition: opacity .2s, visibility .2s; isolation: isolate; }
.battle-overlay.is-active { opacity: 1; visibility: visible; pointer-events: auto; }
.battle-depth { position: absolute; z-index: -3; inset: 0; background: linear-gradient(180deg,rgba(6,41,79,.1),rgba(2,12,39,.72)),url("assets/chess/undersea-castle-arena.webp") center/cover; transform: scale(1.04); filter: saturate(1.08) brightness(.86); }
.battle-caustics { position: absolute; z-index: -1; inset: -35%; opacity: .28; background: repeating-radial-gradient(ellipse at 45% 30%,transparent 0 23px,rgba(132,255,243,.55) 26px 29px,transparent 32px 57px); animation:causticBattle 8s linear infinite; mix-blend-mode: screen; }
@keyframes causticBattle { to { transform: translate(7%,4%) rotate(5deg) scale(1.06); } }
.battle-nameplate { position: absolute; z-index: 12; left: 4%; top: 4%; padding: 8px 12px; border-left: 4px solid #79f5e9; text-shadow: 0 3px 10px rgba(0,0,0,.7); }
.battle-nameplate small, .battle-nameplate strong { display: block; }
.battle-nameplate small { color: #8df7ec; font-size: 7px; font-weight: 1000; letter-spacing: .17em; }
.battle-nameplate strong { color: #fff1a4; font-size: clamp(15px,2.1vw,28px); font-weight: 1000; letter-spacing: -.04em; }
.battle-piece { position: absolute; z-index: 8; bottom: 13%; width: 34%; height: 69%; transform-origin: 50% 100%; }
.battle-piece .battle-portrait { width: 100%; height: 100%; object-fit: contain; object-position: center bottom; filter: drop-shadow(0 14px 8px rgba(0,0,0,.55)); }
.battle-piece .piece-shell { width: 100%; height: 100%; }
.battle-piece .piece-art { width:100%; height:100%; object-fit:contain; }
.battle-piece .piece-glyph { font-size: clamp(125px,18vw,250px); }
.battle-piece .piece-pedestal { bottom: 0; }
.battle-attacker { left: 7%; }
.battle-defender { left: 59%; width: 31%; }
.battle-shards { position: absolute; z-index: 10; left: 59%; bottom: 13%; width: 31%; height: 69%; pointer-events: none; }
.battle-shard { position: absolute; inset: 0; opacity: 0; --x: 0px; --y: -80px; --r: 20deg; }
.battle-shard > * { width: 100%; height: 100%; }
.battle-shard img { object-fit: contain; object-position: center bottom; filter: brightness(1.45) saturate(.65) hue-rotate(14deg) drop-shadow(0 0 8px #86fff0); }
.battle-shard:nth-child(1) { clip-path: polygon(0 0,45% 0,35% 35%,0 42%); --x:-90px; --y:-80px; --r:-32deg; }
.battle-shard:nth-child(2) { clip-path: polygon(45% 0,100% 0,100% 36%,64% 42%); --x:76px; --y:-115px; --r:39deg; }
.battle-shard:nth-child(3) { clip-path: polygon(0 42%,35% 35%,52% 65%,0 72%); --x:-110px; --y:-15px; --r:-51deg; }
.battle-shard:nth-child(4) { clip-path: polygon(35% 35%,66% 40%,68% 72%,52% 65%); --x:-14px; --y:-145px; --r:25deg; }
.battle-shard:nth-child(5) { clip-path: polygon(66% 40%,100% 36%,100% 72%,68% 72%); --x:105px; --y:-34px; --r:54deg; }
.battle-shard:nth-child(6) { clip-path: polygon(0 72%,52% 65%,43% 100%,0 100%); --x:-72px; --y:73px; --r:43deg; }
.battle-shard:nth-child(7) { clip-path: polygon(52% 65%,68% 72%,78% 100%,43% 100%); --x:9px; --y:90px; --r:-40deg; }
.battle-shard:nth-child(8) { clip-path: polygon(68% 72%,100% 72%,100% 100%,78% 100%); --x:92px; --y:61px; --r:49deg; }
.battle-wave { position: absolute; z-index: 11; left: 37%; bottom: 20%; width: 38%; height: 52%; border-left: clamp(15px,2vw,28px) solid rgba(97,255,243,.94); border-top: 8px solid rgba(255,255,255,.82); border-radius: 50%; opacity: 0; filter: drop-shadow(0 0 12px #41e9e5) drop-shadow(0 0 25px rgba(127,82,255,.6)); transform: rotate(20deg) scale(.2); }
.battle-impact { position: absolute; z-index: 15; left: 70%; top: 45%; width: 35px; height: 35px; border: 6px solid white; border-radius: 50%; opacity: 0; box-shadow: 0 0 20px 9px #65f7ec,0 0 65px 27px rgba(170,99,255,.78); }
.battle-word { position: absolute; z-index: 18; right: 8%; top: 18%; padding: 8px 13px; border: 3px solid #123157; border-radius: 50% 54% 48% 14%; opacity: 0; color: #17385e; background: #fff0a8; box-shadow: 0 6px 0 #39bdc8,0 11px 22px rgba(0,0,0,.42); font-size: clamp(13px,2.2vw,28px); font-weight: 1000; transform: rotate(7deg) scale(.3); }
.battle-bubbles i { position: absolute; z-index: 16; left: 70%; top: 47%; width: var(--size); height: var(--size); border: 2px solid rgba(226,255,252,.88); border-radius: 50%; opacity: 0; box-shadow: inset 2px 2px rgba(255,255,255,.35),0 0 7px rgba(88,235,236,.5); }
.skip-battle { position: absolute; z-index: 25; right: 12px; bottom: 12px; min-height: 38px; padding: 0 12px; border: 1px solid rgba(255,255,255,.28); border-radius: 999px; color: #d7efef; background: rgba(1,14,38,.62); cursor: pointer; font-size: 8px; font-weight: 900; }
.battle-overlay.is-active { animation:battleBoardShake 2.45s linear both; }
.battle-overlay.is-active .battle-attacker { animation:attackerStrike 2.45s var(--battle-ease) both; }
.battle-overlay.is-active .battle-defender { animation:defenderDefeat 2.45s linear both; }
.battle-overlay.is-active .battle-wave { animation:battleWave 2.45s ease-out both; }
.battle-overlay.is-active .battle-impact { animation:battleImpact 2.45s ease-out both; }
.battle-overlay.is-active .battle-word { animation:battleWord 2.45s var(--battle-ease) both; }
.battle-overlay.is-active .battle-shard { animation:battleShatter 2.45s var(--battle-ease) both; }
.battle-overlay.is-active .battle-bubbles i { animation:battleBubble 1.05s var(--delay) var(--battle-ease) both; }
@keyframes battleBoardShake { 0%,45%,52%,100% { transform: translate(0); filter: brightness(1); } 46% { transform: translate(-5px,2px); filter: brightness(1.22); } 48% { transform: translate(5px,-2px); } 50% { transform: translate(-3px,1px); } }
@keyframes attackerStrike { 0%,10% { left:7%; transform:none; } 26% { left:20%; transform:translateY(-5%) rotate(5deg) scale(1.06); } 46% { left:42%; transform:translateY(-9%) rotate(9deg) scale(1.11); filter:brightness(1.2) drop-shadow(0 0 18px #77fff0); } 58%,72% { left:43%; transform:translateY(-6%) scale(1.04); } 90% { left:59%; transform:translateY(-2%) scale(1.02); } 100% { left:59%; transform:none; } }
@keyframes defenderDefeat { 0%,42% { opacity:1; transform:none; filter:none; } 45% { transform:translateX(-5px) rotate(-3deg); } 48% { transform:translateX(7px) rotate(4deg) scale(1.05); filter:brightness(2); } 55% { opacity:1; transform:scale(1.12); filter:brightness(3) saturate(.25) hue-rotate(30deg); } 61%,100% { opacity:0; transform:scale(.72); } }
@keyframes battleWave { 0%,25% { opacity:0; transform:rotate(20deg) scale(.2); } 32% { opacity:1; } 48% { opacity:1; transform:translateX(17%) rotate(3deg) scale(1.1); } 57%,100% { opacity:0; transform:translateX(35%) rotate(-8deg) scale(1.4); } }
@keyframes battleImpact { 0%,46% { opacity:0; transform:translate(-50%,-50%) scale(.2); } 48% { opacity:1; transform:translate(-50%,-50%) scale(1); } 58%,100% { opacity:0; transform:translate(-50%,-50%) scale(6); } }
@keyframes battleWord { 0%,50% { opacity:0; transform:rotate(7deg) scale(.3); } 58% { opacity:1; transform:rotate(-4deg) scale(1.08); } 70% { transform:rotate(2deg) scale(1); } 84%,100% { opacity:0; transform:rotate(7deg) scale(1.4); } }
@keyframes battleShatter { 0%,52% { opacity:0; transform:translate(0) rotate(0) scale(1); } 55% { opacity:1; } 77% { opacity:.88; transform:translate(var(--x),var(--y)) rotate(var(--r)) scale(.78); } 92%,100% { opacity:0; transform:translate(calc(var(--x) * .5),calc(var(--y) * 1.25 - 65px)) rotate(var(--r)) scale(.22); } }
@keyframes battleBubble { 0% { opacity:0; transform:translate(0) scale(.2); } 18% { opacity:.95; } 100% { opacity:0; transform:translate(var(--x),var(--y)) scale(1.22); } }
.tidal-app[data-theme="medieval"] .battle-overlay { background:linear-gradient(180deg,rgba(72,29,13,.42),rgba(25,7,10,.86)); }
.tidal-app[data-theme="medieval"] .battle-depth { background:linear-gradient(180deg,rgba(78,35,14,.12),rgba(21,6,9,.7)),url("assets/chess/medieval/castle-arena.webp") center/cover; }
.tidal-app[data-theme="medieval"] .battle-caustics { opacity:.18; background:repeating-linear-gradient(112deg,transparent 0 58px,rgba(255,214,123,.5) 62px 66px,transparent 70px 120px); }
.tidal-app[data-theme="medieval"] .battle-wave { border-color:rgba(255,203,100,.94); filter:drop-shadow(0 0 12px #ffb445) drop-shadow(0 0 25px rgba(176,52,45,.58)); }
.tidal-app[data-theme="medieval"] .battle-impact { box-shadow:0 0 20px 9px #ffd67a,0 0 65px 27px rgba(188,65,48,.75); }
.tidal-app[data-theme="medieval"] .battle-word { color:#54210f; background:#ffe19a; box-shadow:0 6px 0 #b66031,0 11px 22px rgba(0,0,0,.46); }

/* Setup */
.setup-screen { position: relative; min-height: calc(100dvh - 74px); overflow: hidden; }
.setup-backdrop { position: absolute; inset: 0; background: radial-gradient(circle at 17% 38%,rgba(78,255,232,.2),transparent 31%),linear-gradient(90deg,rgba(2,13,35,.18),rgba(2,12,35,.58)),url("assets/chess/undersea-castle-arena.webp") center/cover; filter: saturate(1.08); }
.setup-backdrop::after { content:""; position:absolute; inset:-45%; opacity:.16; background:repeating-radial-gradient(ellipse at 48% 30%,transparent 0 32px,rgba(121,255,244,.55) 35px 39px,transparent 42px 72px); animation:setupCaustics 12s linear infinite; mix-blend-mode:screen; }
.tidal-app[data-theme="medieval"] .setup-backdrop { background:radial-gradient(circle at 17% 38%,rgba(255,192,80,.16),transparent 31%),linear-gradient(90deg,rgba(30,8,5,.18),rgba(25,7,9,.61)),url("assets/chess/medieval/castle-arena.webp") center/cover; }
.tidal-app[data-theme="medieval"] .setup-backdrop::after { opacity:.11; background:repeating-linear-gradient(112deg,transparent 0 82px,rgba(255,222,146,.5) 86px 91px,transparent 96px 158px); }
@keyframes setupCaustics { to { transform:translate(7%,5%) rotate(6deg) scale(1.07); } }
.setup-shell { position: relative; z-index: 2; width:min(1380px,calc(100% - 38px)); min-height:calc(100dvh - 74px); margin:auto; padding:clamp(24px,4vh,52px) 0; display:grid; grid-template-columns:minmax(370px,1fr) minmax(540px,640px); align-items:center; gap:clamp(35px,6vw,95px); }
.setup-intro { padding: 20px; text-shadow:0 5px 22px rgba(0,4,22,.68); }
.back-home { display:inline-flex; min-height:42px; align-items:center; padding:0 14px; border:1px solid rgba(200,255,247,.28); border-radius:999px; color:#e8fffb; background:rgba(1,19,48,.52); text-decoration:none; font-size:10px; font-weight:900; }
.setup-eyebrow { display:block; margin-top:42px; color:#8affee; font-size:9px; font-weight:1000; letter-spacing:.22em; }
.setup-intro h1 { margin:10px 0 13px; color:#fff9dc; font-family:Georgia,"Times New Roman",serif; font-size:clamp(48px,6vw,84px); line-height:.85; letter-spacing:-.065em; }
.setup-intro h1 em { color:#80f5e6; font-style:normal; text-shadow:0 4px 0 #135c79,0 9px 21px rgba(0,5,23,.58),0 0 30px rgba(87,246,230,.25); }
.setup-intro > p { max-width:550px; margin:0; color:#e1f4f2; font-size:15px; font-weight:750; line-height:1.5; }
.feature-chips { margin-top:22px; display:flex; flex-wrap:wrap; gap:7px; }
.feature-chips span { padding:8px 11px; border:1px solid rgba(201,255,247,.27); border-radius:999px; color:#dbfffa; background:rgba(1,24,56,.55); font-size:8px; font-weight:1000; letter-spacing:.05em; }
.setup-panel { position:relative; padding:clamp(18px,2.2vw,29px); border:2px solid rgba(230,255,246,.56); border-radius:35px; background:linear-gradient(155deg,rgba(12,55,88,.96),rgba(4,20,53,.97)); box-shadow:inset 0 2px rgba(255,255,255,.23),inset 0 -20px 38px rgba(0,6,25,.22),0 11px 0 #082940,0 24px 65px rgba(0,4,19,.58),0 0 45px rgba(74,237,224,.17); backdrop-filter:blur(18px); }
.chess-resume { margin:0 0 15px; padding:12px; display:grid; grid-template-columns:46px minmax(0,1fr) auto auto; align-items:center; gap:10px; border:1px solid rgba(116,245,226,.55); border-radius:19px; background:linear-gradient(135deg,rgba(23,147,158,.35),rgba(8,37,73,.86)); box-shadow:inset 0 1px rgba(255,255,255,.15),0 8px 22px rgba(0,6,28,.25); }
.chess-resume[hidden] { display:none; }
.chess-resume-icon { width:44px; height:44px; display:grid; place-items:center; border-radius:15px; color:#092f4b; background:linear-gradient(#fff4a8,#ffc84f); box-shadow:0 4px 0 #9e5e20; font-size:25px; font-weight:1000; }
.chess-resume-copy { min-width:0; }
.chess-resume-copy small,.chess-resume-copy strong,.chess-resume-copy em { display:block; }
.chess-resume-copy small { color:#8bf6e8; font-size:7px; font-weight:1000; letter-spacing:.1em; }
.chess-resume-copy strong { margin-top:2px; overflow:hidden; color:#fff9da; font-size:14px; text-overflow:ellipsis; white-space:nowrap; }
.chess-resume-copy em { margin-top:2px; color:#b8dbe2; font-size:9px; font-style:normal; font-weight:750; }
.resume-match-button,.discard-match-button { min-height:42px; padding:0 13px; border-radius:13px; font:900 10px/1 inherit; cursor:pointer; }
.resume-match-button { border:1px solid #fff0a2; color:#142d50; background:linear-gradient(#fff098,#ffc447); box-shadow:0 4px 0 #9f6020; }
.discard-match-button { border:1px solid rgba(255,255,255,.22); color:#e9f8f5; background:rgba(255,255,255,.08); }
.tidal-app[data-theme="medieval"] .chess-resume { border-color:rgba(255,213,121,.58); background:linear-gradient(135deg,rgba(143,69,31,.43),rgba(45,14,20,.9)); }
.tidal-app[data-theme="medieval"] .setup-panel { border-color:rgba(255,227,161,.62); background:linear-gradient(155deg,rgba(83,39,22,.97),rgba(31,11,17,.98)); box-shadow:inset 0 2px rgba(255,246,207,.2),inset 0 -20px 38px rgba(22,5,6,.28),0 11px 0 #4f241c,0 24px 65px rgba(13,3,5,.62),0 0 45px rgba(255,185,72,.14); }
.setup-panel-heading { display:flex; align-items:center; gap:11px; padding:0 4px 15px; border-bottom:1px solid rgba(255,255,255,.1); }
.setup-panel-heading > span { width:42px; height:42px; display:grid; place-items:center; border:1px solid rgba(255,248,190,.5); border-radius:50%; color:#fff0a2; background:radial-gradient(circle,#309caa,#17476f); box-shadow:0 4px 0 #092b45; font-size:20px; }
.setup-panel-heading small,.setup-panel-heading strong { display:block; }
.setup-panel-heading small { color:#75ebdf; font-size:7px; font-weight:1000; letter-spacing:.16em; }
.setup-panel-heading strong { margin-top:2px; font-size:18px; font-weight:1000; letter-spacing:-.03em; }
.setup-choice-group { min-width:0; margin:13px 0 0; padding:0; border:0; }
.setup-choice-group legend { margin:0 0 7px 3px; padding:0; color:#bcd6df; font-size:8px; font-weight:1000; letter-spacing:.08em; text-transform:uppercase; }
.visual-choices { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.visual-choice { position:relative; min-width:0; min-height:78px; padding:7px 29px 7px 8px; display:grid; grid-template-columns:76px 1fr; align-items:center; gap:9px; overflow:hidden; border:2px solid rgba(196,245,240,.2); border-radius:16px; color:#ecfffc; background:linear-gradient(145deg,rgba(19,66,91,.72),rgba(11,24,61,.82)); box-shadow:inset 0 1px rgba(255,255,255,.1),0 4px 0 rgba(0,10,34,.7); cursor:pointer; transition:transform .2s,border-color .2s,filter .2s; }
.visual-choice:hover { filter:brightness(1.1); transform:translateY(-2px); }
.visual-choice:has(input:checked) { border-color:#ffe999; box-shadow:inset 0 0 0 2px rgba(255,241,166,.23),0 5px 0 #1d536c,0 0 17px rgba(102,243,228,.2); }
.visual-choice:has(input:focus-visible) { outline:4px solid var(--focus); outline-offset:2px; }
.visual-choice > input { position:absolute; width:1px; height:1px; opacity:0; }
.visual-choice > span:last-of-type { min-width:0; }
.visual-choice strong,.visual-choice small { display:block; }
.visual-choice strong { font-size:10px; font-weight:1000; line-height:1.15; }
.visual-choice small { margin-top:4px; color:#a9c6d2; font-size:7px; font-weight:800; line-height:1.25; }
.visual-choice > i { position:absolute; right:8px; top:8px; width:18px; height:18px; display:grid; place-items:center; border:1px solid rgba(255,255,255,.23); border-radius:50%; opacity:.3; color:#153951; background:rgba(255,255,255,.12); font-size:9px; font-style:normal; font-weight:1000; }
.visual-choice:has(input:checked) > i { opacity:1; background:#ffec9b; box-shadow:0 0 11px rgba(255,225,119,.42); }
.choice-art { width:76px; height:62px; display:grid; place-items:center; overflow:hidden; border:1px solid rgba(255,255,255,.25); border-radius:11px; background-position:center;background-size:cover; box-shadow:inset 0 -20px 22px rgba(0,8,30,.42); }
.choice-art b { display:grid; place-items:center; width:30px; height:34px; border:1px solid rgba(255,245,186,.65); border-radius:50%; color:#fff3a9; background:rgba(5,23,52,.58); box-shadow:0 4px 8px rgba(0,0,0,.45); font-size:19px; }
.world-choice--tidal .choice-art { background-image:linear-gradient(rgba(8,53,83,.1),rgba(2,23,58,.45)),url("assets/chess/undersea-castle-arena.webp"); }
.world-choice--medieval .choice-art { background-image:linear-gradient(rgba(80,34,14,.08),rgba(34,8,10,.46)),url("assets/chess/medieval/castle-arena.webp"); }
.piece-choice { grid-template-columns:76px 1fr; min-height:68px; }
.piece-choice-preview { position:relative; width:76px; height:56px; display:flex; align-items:end; justify-content:center; border:1px solid rgba(255,255,255,.17); border-radius:11px; background:radial-gradient(circle at 50% 70%,rgba(106,247,230,.22),rgba(3,19,48,.72)); }
.piece-choice-preview img { width:52px; height:58px; margin:0 -13px; object-fit:contain; object-position:center bottom; filter:drop-shadow(0 5px 3px rgba(0,0,0,.6)); }
.tidal-app[data-theme="medieval"] .visual-choice { border-color:rgba(255,219,148,.22); background:linear-gradient(145deg,rgba(98,48,25,.8),rgba(44,16,24,.88)); }
.tidal-app[data-theme="medieval"] .visual-choice:has(input:checked) { border-color:#ffe095; box-shadow:inset 0 0 0 2px rgba(255,222,145,.2),0 5px 0 #65301e,0 0 17px rgba(255,185,77,.18); }
.tidal-app[data-theme="medieval"] .piece-choice-preview { background:radial-gradient(circle at 50% 70%,rgba(255,194,91,.2),rgba(41,12,17,.78)); }
.setup-player { position:relative; min-height:158px; padding:18px 14px 14px 133px; border-radius:22px; }
.setup-pearl { background:linear-gradient(90deg,rgba(55,190,184,.18),transparent); }
.setup-abyss { background:linear-gradient(90deg,rgba(133,94,211,.2),transparent); }
.setup-portrait { position:absolute; left:3px; bottom:1px; width:128px; height:166px; }
.setup-portrait img { width:100%; height:100%; object-fit:contain; object-position:center bottom; filter:drop-shadow(0 8px 6px rgba(0,0,0,.52)); }
.setup-player-fields { display:grid; gap:8px; }
.faction-label { color:#8affee; font-size:7px; font-weight:1000; letter-spacing:.15em; }
.setup-abyss .faction-label { color:#d7bcff; }
.setup-player label { display:grid; gap:4px; color:#bcd6df; font-size:8px; font-weight:900; }
.name-row { display:grid; grid-template-columns:1fr auto; gap:6px; }
.setup-player input,.setup-player select,.name-row button { min-height:43px; border:1px solid rgba(198,250,243,.24); border-radius:12px; }
.setup-player input,.setup-player select { width:100%; padding:0 11px; color:#fff; background:rgba(1,14,40,.64); font-size:12px; font-weight:850; }
.setup-player select { appearance:none; background-image:linear-gradient(45deg,transparent 50%,#8cf1e6 50%),linear-gradient(135deg,#8cf1e6 50%,transparent 50%); background-position:calc(100% - 16px) 18px,calc(100% - 11px) 18px;background-size:5px 5px;background-repeat:no-repeat; }
.name-row button { padding:0 9px; color:#193754; background:linear-gradient(180deg,#fff5b5,#77eadb); box-shadow:inset 0 1px white,0 3px 0 #206077; cursor:pointer; font-size:8px; font-weight:1000; }
.setup-divider { height:0; display:grid; place-items:center; }
.setup-divider span { position:relative; z-index:3; width:35px; height:35px; display:grid; place-items:center; border:2px solid #ffed9e; border-radius:50%; color:#fff7cf; background:#18345a; box-shadow:0 5px 0 #081b34; font-size:8px; font-weight:1000; }
.start-match { width:100%; min-height:64px; padding:0 20px; display:grid; grid-template-columns:1fr auto auto; align-items:center; gap:11px; border:3px solid #fff2ab; border-radius:19px; color:#193755; background:linear-gradient(180deg,#fff5b0,#72eee0 55%,#31bdcc); box-shadow:inset 0 2px white,0 7px 0 #165d78,0 14px 24px rgba(0,4,20,.42); cursor:pointer; text-align:left; }
.start-match span { font-size:9px; font-weight:850; }.start-match b { font-size:15px; font-weight:1000; }.start-match i { font-size:24px; font-style:normal; }
.start-match:hover { filter:brightness(1.06); transform:translateY(-2px); }.start-match:active { transform:translateY(5px); box-shadow:inset 0 2px white,0 2px 0 #165d78; }
.privacy-note { margin:13px 0 0; color:#769aac; font-size:8px; font-weight:750; text-align:center; }
.army-preview { width:100%; min-height:46px; margin:2px 0 11px; padding:0 13px; display:grid; grid-template-columns:auto 1fr auto; align-items:center; gap:9px; border:1px solid rgba(174,255,244,.34); border-radius:14px; color:#dcfffa; background:linear-gradient(145deg,rgba(33,101,118,.55),rgba(45,37,100,.64)); box-shadow:inset 0 1px rgba(255,255,255,.12); cursor:pointer; text-align:left; }
.army-preview span { color:#fff0a1; font-size:19px; }.army-preview b { font-size:9px; }.army-preview i { font-size:20px; font-style:normal; }
.army-preview:hover { border-color:#fff0ab; filter:brightness(1.12); }

/* Dialogs */
.game-dialog { width:min(480px,calc(100% - 28px)); padding:30px; border:2px solid rgba(225,255,248,.65); border-radius:30px; color:white; background:linear-gradient(150deg,#0d4970,#06183d 72%); box-shadow:inset 0 2px rgba(255,255,255,.2),0 16px 70px rgba(0,3,18,.72); text-align:center; }
.game-dialog::backdrop { background:rgba(0,8,28,.77); backdrop-filter:blur(8px); }
.dialog-close { position:absolute; right:13px; top:13px; width:42px; height:42px; border:1px solid rgba(255,255,255,.25); border-radius:50%; background:rgba(255,255,255,.08); cursor:pointer; font-size:20px; }
.dialog-icon { width:70px; height:70px; margin:auto; display:grid; place-items:center; border:3px solid #fff0ab; border-radius:50%; color:#fff1ac; background:radial-gradient(circle,#42d2cd,#164c78); box-shadow:0 7px 0 #09243f,0 0 20px rgba(74,241,227,.3); font-size:37px; }
.game-dialog h2 { margin:18px 0 8px; color:#fff8cf; font-family:Georgia,serif; font-size:29px; }
.game-dialog p { color:#d4e9eb; font-size:12px; line-height:1.55; }
.game-dialog ul { padding-left:21px; color:#d9f0f0; font-size:11px; line-height:1.5; text-align:left; }
.game-dialog li+li { margin-top:8px; }
.dialog-primary { min-height:50px; padding:0 24px; border:2px solid #fff1a7; border-radius:15px; color:#173755; background:linear-gradient(180deg,#fff6b8,#72e9dd); box-shadow:0 5px 0 #1a6178; cursor:pointer; font-weight:1000; }
.dialog-eyebrow { display:block; margin-top:16px; color:#7ff5e8; font-size:8px; font-weight:1000; letter-spacing:.18em; }
.settings-dialog { width:min(690px,calc(100% - 24px)); max-height:min(92dvh,820px); padding:25px; overflow:auto; }
.settings-dialog > form { margin:0; }
.settings-dialog h2 { margin-top:8px; }
.settings-dialog > form > p { max-width:510px; margin:0 auto 18px; }
.settings-dialog .dialog-icon { width:58px; height:58px; font-size:27px; }
.settings-section { min-width:0; margin:12px 0 0; padding:0; border:0; text-align:left; }
.settings-section legend,.settings-math-grid label > span { margin:0 0 6px 3px; color:#a9c8d3; font-size:8px; font-weight:1000; letter-spacing:.08em; text-transform:uppercase; }
.settings-segments { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.settings-segments label { position:relative; cursor:pointer; }
.settings-segments input { position:absolute; width:1px; height:1px; opacity:0; }
.settings-segments span { min-height:49px; display:grid; place-items:center; border:2px solid rgba(207,250,245,.2); border-radius:14px; color:#cce3e7; background:rgba(1,14,40,.42); box-shadow:inset 0 1px rgba(255,255,255,.08); font-size:10px; font-weight:950; }
.settings-segments input:checked + span { border-color:#ffe99c; color:#fff7c8; background:linear-gradient(145deg,rgba(52,139,145,.66),rgba(45,42,105,.72)); box-shadow:inset 0 0 0 2px rgba(255,243,171,.15),0 0 15px rgba(97,246,230,.15); }
.settings-segments input:focus-visible + span { outline:4px solid var(--focus); outline-offset:2px; }
.settings-math-grid { margin-top:14px; display:grid; grid-template-columns:1fr 1fr; gap:9px; text-align:left; }
.settings-math-grid label > span { display:block; }
.settings-math-grid select { width:100%; min-height:48px; padding:0 37px 0 12px; border:1px solid rgba(207,250,245,.23); border-radius:13px; appearance:none; color:white; background-color:rgba(1,14,40,.62); background-image:linear-gradient(45deg,transparent 50%,#ffe89d 50%),linear-gradient(135deg,#ffe89d 50%,transparent 50%); background-position:calc(100% - 17px) 21px,calc(100% - 12px) 21px;background-size:5px 5px;background-repeat:no-repeat; font-size:11px; font-weight:900; }
.switch-list { margin-top:14px; display:grid; gap:8px; }
.switch-control { min-height:62px; padding:9px 10px 9px 14px; display:flex; align-items:center; justify-content:space-between; gap:15px; border:1px solid rgba(202,245,240,.17); border-radius:15px; background:rgba(1,14,39,.4); cursor:pointer; text-align:left; }
.switch-control > span strong,.switch-control > span small { display:block; }
.switch-control > span strong { color:#f0fffc; font-size:10px; }
.switch-control > span small { margin-top:3px; color:#91aebb; font-size:8px; font-weight:750; }
.switch-control input { position:absolute; width:1px; height:1px; opacity:0; }
.switch-control > i { position:relative; width:50px; height:29px; flex:0 0 auto; border:2px solid rgba(255,255,255,.2); border-radius:999px; background:#122843; box-shadow:inset 0 3px 7px rgba(0,0,0,.35); }
.switch-control > i::after { content:""; position:absolute; left:3px; top:3px; width:19px; height:19px; border-radius:50%; background:linear-gradient(180deg,#fff,#a9bbc8); box-shadow:0 3px 5px rgba(0,0,0,.4); transition:transform .2s var(--battle-ease),background .2s; }
.switch-control input:checked + i { border-color:#ffe798; background:linear-gradient(90deg,#239b9d,#55dccc); }
.switch-control input:checked + i::after { transform:translateX(21px); background:linear-gradient(180deg,#fff8bd,#ffd66c); }
.switch-control input:focus-visible + i { outline:4px solid var(--focus); outline-offset:2px; }
.settings-actions { margin-top:18px; display:grid; grid-template-columns:1fr 1.35fr; gap:10px; }
.settings-actions .secondary-action,.settings-actions .dialog-primary { width:100%; }
.tidal-app[data-theme="medieval"] .game-dialog { border-color:rgba(255,226,157,.68); background:linear-gradient(150deg,#71391f,#281018 72%); box-shadow:inset 0 2px rgba(255,245,207,.17),0 16px 70px rgba(15,3,5,.76); }
.tidal-app[data-theme="medieval"] .dialog-icon { background:radial-gradient(circle,#d69343,#783621 58%,#3a1821); box-shadow:0 7px 0 #35151a,0 0 20px rgba(255,190,80,.24); }
.tidal-app[data-theme="medieval"] .dialog-primary { color:#57260f; background:linear-gradient(180deg,#fff0b3,#e3a34f); box-shadow:0 5px 0 #74351e; }
.tidal-app[data-theme="medieval"] .settings-segments input:checked + span { background:linear-gradient(145deg,rgba(142,73,35,.72),rgba(83,29,37,.78)); }
.tidal-app[data-theme="medieval"] .switch-control input:checked + i { background:linear-gradient(90deg,#9a4928,#d88c40); }
.tidal-app[data-theme="medieval"] .setup-intro h1 em { color:#ffd783; text-shadow:0 4px 0 #7d351f,0 9px 21px rgba(20,4,5,.7),0 0 30px rgba(255,184,71,.2); }
.tidal-app[data-theme="medieval"] .feature-chips span,.tidal-app[data-theme="medieval"] .back-home { border-color:rgba(255,225,158,.28); color:#fff0c4; background:rgba(49,15,14,.57); }
.tidal-app[data-theme="medieval"] .turn-card { border-color:rgba(255,222,143,.76); background:linear-gradient(145deg,rgba(130,66,31,.98),rgba(45,15,23,.98)); box-shadow:inset 0 2px rgba(255,245,207,.22),inset 0 -14px 28px rgba(35,7,10,.34),0 8px 0 #57291e,0 18px 35px rgba(15,3,5,.52),0 0 30px rgba(255,189,77,.1); }
.tidal-app[data-theme="medieval"] .turn-card[data-side="b"] { border-color:rgba(216,137,146,.75); background:linear-gradient(145deg,rgba(96,37,46,.98),rgba(35,13,25,.98)); }
.tidal-app[data-theme="medieval"] .turn-waterline { background:repeating-linear-gradient(110deg,transparent 0 34px,rgba(255,221,146,.5) 37px 39px,transparent 42px 72px); }
.tidal-app[data-theme="medieval"] .player-card { border-color:rgba(255,219,148,.18); background:linear-gradient(145deg,rgba(65,28,22,.94),rgba(29,12,20,.95)); }
.tidal-app[data-theme="medieval"] .player-card.is-active { border-color:rgba(255,220,126,.9); box-shadow:inset 0 1px rgba(255,247,213,.18),0 0 0 3px rgba(255,187,74,.1),0 9px 24px rgba(15,3,5,.48); }
.tidal-app[data-theme="medieval"] .captured-vault,.tidal-app[data-theme="medieval"] .secondary-action { border-color:rgba(255,218,148,.2); background:rgba(35,12,18,.82); }
.tidal-app[data-theme="medieval"] .math-gate,.tidal-app[data-theme="medieval"] .teacher-card,.tidal-app[data-theme="medieval"] .move-scroll { border-color:rgba(255,220,151,.21); background:linear-gradient(150deg,rgba(70,30,22,.97),rgba(29,10,19,.97)); }
.tidal-app[data-theme="medieval"] .math-gate { border-color:rgba(255,211,116,.55); background:linear-gradient(150deg,rgba(97,43,33,.98),rgba(42,15,28,.98)); }
.tidal-app[data-theme="medieval"] .notation-card { border-color:rgba(255,219,139,.4); background:linear-gradient(145deg,rgba(110,57,29,.72),rgba(60,23,35,.78)); }
.tidal-app[data-theme="medieval"] .teacher-orb { border-color:#ffe1a0;color:#fff0b5;background:radial-gradient(circle at 35% 30%,#d68c40,#793923 58%,#381824);box-shadow:inset 0 2px rgba(255,245,204,.25),0 5px 0 #32141a,0 0 15px rgba(255,180,64,.18); }
.tidal-app[data-theme="medieval"] .mobile-turn-strip { border-color:rgba(255,218,132,.67); background:linear-gradient(145deg,rgba(111,54,29,.97),rgba(40,14,23,.98)); box-shadow:inset 0 1px rgba(255,245,210,.18),0 6px 0 #54261d,0 12px 21px rgba(10,2,4,.4); }
.result-dialog > small { display:block; margin-top:17px; color:#80f7e8; font-size:8px; font-weight:1000; letter-spacing:.2em; }
.result-dialog > div { margin-top:20px; display:flex; align-items:center; justify-content:center; gap:15px; }
.dialog-link { color:#bdf7ee; font-size:10px; font-weight:900; }
.promotion-dialog { width:min(570px,calc(100% - 24px)); }
.promotion-options { margin-top:20px; display:grid; grid-template-columns:repeat(4,1fr); gap:9px; }
.promotion-options button { min-width:0; min-height:130px; padding:7px; display:grid; grid-template-rows:1fr auto; place-items:center; border:2px solid rgba(205,255,248,.38); border-radius:18px; color:#e9fffb; background:linear-gradient(145deg,rgba(24,91,111,.9),rgba(20,31,77,.94)); box-shadow:inset 0 1px rgba(255,255,255,.17),0 6px 0 #08273e; cursor:pointer; }
.promotion-options button:hover { border-color:#fff0a8; filter:brightness(1.15); transform:translateY(-3px); }
.promotion-options .piece-shell { min-height:85px; }
.promotion-options .piece-glyph { font-size:64px; }
.promotion-options b { padding:6px 0; font-size:9px; }
.army-dialog { width:min(1050px,calc(100% - 24px)); max-height:min(92dvh,900px); padding:27px; overflow:auto; }
.army-dialog > small { display:block; color:#81f5e8; font-size:8px; font-weight:1000; letter-spacing:.2em; }
.army-dialog > h2 { margin-top:8px; }
.army-dialog > p { margin:0 auto 17px; max-width:620px; }
.army-section { margin-top:13px; padding:13px; border:1px solid rgba(199,255,247,.2); border-radius:21px; background:linear-gradient(145deg,rgba(30,116,126,.28),rgba(4,19,50,.5)); }
.abyss-army { background:linear-gradient(145deg,rgba(102,65,160,.3),rgba(4,14,44,.58)); }
.army-title { display:flex; align-items:baseline; gap:8px; text-align:left; }
.army-title span { color:#8bfaec; font-size:7px; font-weight:1000; letter-spacing:.15em; }.abyss-army .army-title span { color:#d8bdff; }
.army-title strong { font-size:12px; }
.army-grid { margin-top:8px; display:grid; grid-template-columns:repeat(6,1fr); gap:6px; }
.army-grid figure { min-width:0; height:174px; margin:0; padding:4px 4px 8px; display:grid; grid-template-rows:1fr auto; place-items:center; overflow:hidden; border:1px solid rgba(255,255,255,.12); border-radius:14px; background:radial-gradient(circle at 50% 58%,rgba(87,245,229,.18),transparent 48%),rgba(1,15,43,.42); }
.army-grid img { width:100%; height:145px; object-fit:contain; object-position:center bottom; filter:drop-shadow(0 8px 5px rgba(0,0,0,.52)); transition:transform .24s var(--battle-ease); }
.army-grid figure:hover img { transform:translateY(-4px) scale(1.08); }
.army-grid figcaption { color:#ecfffb; font-size:8px; font-weight:1000; }
.army-dialog > .dialog-primary { margin-top:17px; }

/* Tablet */
@media (max-width: 1160px) {
  .app-hud { grid-template-columns:1fr auto; }
  .match-title { display:none; }
  .game-shell { width:min(920px,calc(100% - 20px)); grid-template-columns:1fr; gap:12px; }
  .player-rail { display:grid; grid-template-columns:1fr auto; align-items:center; gap:12px; }
  .turn-card { min-height:90px; padding:12px 58px 10px 90px; }
  .turn-character { width:95px; height:116px; }
  .turn-card-copy strong { font-size:21px; }
  .player-cards { margin:0; display:flex; align-items:center; gap:7px; }
  .player-card { width:135px; min-height:70px; padding:8px 8px 8px 53px; }
  .player-avatar { width:52px; height:67px; }
  .player-card-copy small,.side-token { display:none; }
  .player-card-copy strong { font-size:11px; }
  .player-card.is-active { transform:translateY(-3px) scale(1.02); }
  .versus-seal { width:0; height:auto; }
  .versus-seal span { width:28px; height:28px; }
  .captured-vault { display:none; }
  .board-wrap { width:min(100%,calc(100dvh - 270px),780px); }
  .coach-rail { grid-template-columns:1fr 1fr; align-items:start; }
  .math-gate { grid-column:1/-1; }
  .teacher-card,.move-scroll { min-height:240px; }
  .coach-actions { grid-column:1/-1; width:min(420px,100%); justify-self:end; }
  .setup-shell { width:min(1030px,calc(100% - 28px)); grid-template-columns:1fr minmax(500px,590px); gap:25px; }
  .setup-intro h1 { font-size:52px; }
}

@media (max-width: 820px) {
  .app-hud { min-height:66px; padding-block:7px; }
  .brand-pearl { width:41px; height:44px; font-size:20px; }
  .brand-copy strong { font-size:17px; }
  .hud-button { min-width:44px; min-height:44px; padding:0 10px; }
  .hud-button b { display:none; }
  .game-shell { min-height:calc(100dvh - 66px); padding-top:9px; }
  .player-rail { display:none; }
  .board-topline { min-height:36px; }
  .board-wrap { width:min(100%,calc(100dvh - 172px)); min-width:0; padding:14px; border-width:5px; border-radius:25px; transform:none; }
  .tidal-app:not(.is-flat) .board-wrap { transform:perspective(1300px) rotateX(1.8deg); }
  .battle-overlay { inset:14px; }
  .mobile-turn-strip { min-height:70px; margin:17px auto 0; padding:7px 12px 7px 67px; display:grid; grid-template-columns:1fr auto; align-items:center; gap:8px; border:2px solid rgba(255,241,171,.63); border-radius:21px; background:linear-gradient(145deg,rgba(14,77,103,.96),rgba(4,27,61,.97)); box-shadow:inset 0 1px rgba(255,255,255,.2),0 6px 0 #08253f,0 12px 21px rgba(0,0,0,.34); }
  .mobile-turn-avatar { position:absolute; width:62px; height:78px; margin-left:-63px; margin-bottom:8px; }
  .mobile-turn-avatar img { width:100%; height:100%; object-fit:contain; filter:drop-shadow(0 5px 3px rgba(0,0,0,.4)); }
  .mobile-turn-strip small,.mobile-turn-strip strong { display:block; }
  .mobile-turn-strip small { color:#91faef; font-size:7px; font-weight:1000; letter-spacing:.12em; }
  .mobile-turn-strip strong { margin-top:2px; font-size:14px; font-weight:1000; }
  .mobile-turn-strip > b { max-width:210px; color:#fff3ad; font-size:10px; text-align:right; }
  .coach-rail { grid-template-columns:1fr; }
  .math-gate { grid-column:auto; }
  .teacher-card,.move-scroll { min-height:0; }
  .move-scroll { max-height:270px; }
  .coach-actions { grid-column:auto; width:100%; }
  .setup-screen { min-height:calc(100dvh - 66px); }
  .setup-shell { min-height:auto; padding:20px 0 40px; display:block; }
  .setup-intro { padding:7px 10px 22px; text-align:center; }
  .back-home { float:left; }
  .setup-eyebrow { clear:both; padding-top:24px; margin-top:0; }
  .setup-intro h1 { font-size:48px; }
  .setup-intro > p { margin-inline:auto; }
  .feature-chips { justify-content:center; }
  .setup-panel { width:min(570px,100%); margin:auto; }
  .army-grid { grid-template-columns:repeat(3,1fr); }
  .army-grid figure { height:190px; }
  .army-grid img { height:160px; }
}

/* iPhone */
@media (max-width: 560px) {
  .app-hud { position:relative; padding-inline:9px; }
  .brand-copy small { font-size:6px; letter-spacing:.13em; }
  .hud-actions { gap:5px; }
  .hud-button { width:42px; min-width:42px; padding:0; }
  .hud-button[data-action="toggle-tilt"] { display:none; }
  .hud-button.icon-only { width:42px; }
  .game-shell { width:100%; padding:5px 6px calc(18px + env(safe-area-inset-bottom)); gap:9px; }
  .board-topline { padding:0 6px 5px; }
  .turn-pill { font-size:9px; }
  .text-button { min-height:35px; }
  .board-wrap { width:100%; padding:6px; border-width:4px; border-radius:20px; box-shadow:inset 0 2px rgba(255,255,255,.5),inset 0 -6px 10px rgba(1,12,36,.4),0 5px 0 #17445c,0 10px 0 #071c36,0 18px 30px rgba(0,4,19,.58); }
  .board-wrap::before { inset:3px; border-radius:14px; }
  .chess-board { border-width:2px; border-radius:8px; }
  .board-corner { display:none; }
  .piece-glyph { font-size:clamp(27px,10.8vw,43px); -webkit-text-stroke-width:.65px !important; }
  .piece-shell { width:115%; height:128%; }
  .piece-shell[data-piece="p"] { width:111%; height:118%; }
  .piece-art { filter:drop-shadow(0 4px 3px rgba(0,4,21,.58)); }
  .piece-pedestal { border-width:1px; }
  .square-label { font-size:6px; }
  .square-label.file { right:2px; bottom:2px; }.square-label.rank { left:2px; top:2px; }
  .board-square.is-selected::before { transform:translateY(-3px) scale(1.04); box-shadow:inset 0 0 0 3px #fff7ad,0 4px 0 rgba(6,76,104,.75),0 7px 12px rgba(0,0,0,.42),0 0 18px #7cfff0; }
  .board-square.is-capture::after { border-width:3px; }
  .battle-overlay { inset:6px; border-radius:8px; }
  .battle-piece { bottom:12%; width:42%; height:67%; }
  .battle-attacker { left:1%; }.battle-defender,.battle-shards { left:57%; width:40%; }
  .battle-piece .piece-glyph { font-size:100px; }
  .battle-nameplate { left:2%; top:2%; }.battle-word { right:3%; top:16%; }
  .skip-battle { right:7px; bottom:7px; min-height:34px; }
  @keyframes attackerStrike { 0%,10% { left:1%; transform:none; } 26% { left:12%; transform:translateY(-4%) rotate(5deg) scale(1.05); } 46% { left:34%; transform:translateY(-8%) rotate(9deg) scale(1.1); filter:brightness(1.2) drop-shadow(0 0 13px #77fff0); } 58%,72% { left:35%; transform:translateY(-5%) scale(1.04); } 90%,100% { left:57%; transform:none; } }
  .mobile-turn-strip { margin:13px 4px 0; }
  .mobile-turn-strip > b { max-width:135px; font-size:8px; }
  .coach-rail { padding:0 4px; }
  .teacher-card,.move-scroll,.math-gate { border-radius:20px; }
  .lesson-message { min-height:0; }
  .setup-shell { width:calc(100% - 14px); }
  .setup-intro h1 { font-size:40px; }
  .setup-intro > p { font-size:12px; }
  .feature-chips { margin-top:14px; }
  .setup-panel { padding:14px; border-radius:25px; }
  .chess-resume { grid-template-columns:42px minmax(0,1fr) auto; }
  .chess-resume .discard-match-button { grid-column:2 / -1; justify-self:start; min-height:38px; }
  .setup-panel-heading { padding-bottom:11px; }
  .visual-choices { grid-template-columns:1fr; }
  .visual-choice { min-height:70px; grid-template-columns:74px 1fr; }
  .choice-art { width:74px; height:56px; }
  .piece-choice-preview { width:74px; height:54px; }
  .setup-player { min-height:145px; padding:14px 5px 12px 98px; }
  .setup-portrait { left:-9px; width:110px; height:148px; }
  .setup-player input,.setup-player select,.name-row button { min-height:42px; }
  .setup-player-fields { gap:6px; }
  .start-match { min-height:59px; }
  .promotion-options { grid-template-columns:repeat(2,1fr); }
  .promotion-options button { min-height:105px; }
  .army-dialog { padding:20px 10px; }
  .army-grid { grid-template-columns:repeat(3,1fr); }
  .army-grid figure { height:145px; }
  .army-grid img { height:118px; }
  .settings-dialog { padding:21px 14px; }
  .settings-math-grid { grid-template-columns:1fr; }
  .settings-actions { grid-template-columns:1fr; }
}

@media (max-width: 370px) {
  .brand-copy small { display:none; }
  .setup-player { padding-left:86px; }
  .setup-portrait { width:95px; }
  .name-row { grid-template-columns:1fr; }
  .name-row button { min-height:34px; }
  .hud-actions { gap:3px; }
  .hud-button { width:39px; min-width:39px; }
  .hud-button.icon-only { width:39px; }
}

@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { animation-duration:.01ms !important; animation-iteration-count:1 !important; scroll-behavior:auto !important; }
  .setup-backdrop::after,.turn-waterline,.battle-caustics { display:none; }
  .board-square::before,.piece-shell { transition:none; }
}
