/* ==========================================================================
   Royal Chess — royal.css
   The royal vintage skin for the whole game, loaded last so it dresses every
   screen and dialog defined in base / menus / hud / panels / cinema.css.

   Materials: crimson velvet (primary actions), royal-navy velvet (secondary
   actions), ebony lacquer (cards, plates, cancel), all framed in bevelled
   gold with rivets, filigree corners and crown ornaments.
   Type: Cinzel Decorative for titles, Cinzel for buttons and labels,
   Cormorant Garamond for body text.
   ========================================================================== */

:root {
  --font-display: 'Cinzel Decorative', 'Cinzel', 'Trajan Pro', 'Palatino Linotype', Georgia, serif;
  --font-head: 'Cinzel', 'Trajan Pro', 'Palatino Linotype', Georgia, serif;
  --font-body: 'Cormorant Garamond', 'Palatino Linotype', 'Book Antiqua', Georgia, serif;

  /* gold */
  --gold: #e2b456;
  --gold-light: #f6d98a;
  --gold-pale: #fff4cf;
  --gold-dark: #8d5f1a;
  --gold-ink: #2a1505;
  --gold-edge: linear-gradient(180deg, #fff1b8 0%, #ebc566 22%, #a8752a 52%, #f2d07a 78%, #7a5214 100%);
  --gold-edge-hot: linear-gradient(180deg, #fffbe2 0%, #ffe08a 22%, #cf9a3e 52%, #fff0b0 78%, #a47224 100%);
  --gold-text: linear-gradient(180deg, #fffbe6 0%, #f9e2a0 30%, #e3b45a 55%, #a9752a 72%, #f0cd76 90%, #c8913a 100%);
  --gold-line: rgba(232, 190, 98, 0.5);

  /* velvets and lacquers */
  --crimson-1: #d2333f; --crimson-2: #9e1626; --crimson-3: #6a0b18; --crimson-4: #3e050d;
  --navy-1: #34519f;    --navy-2: #1b2d6a;    --navy-3: #0f1b47;    --navy-4: #070e2b;
  --ebony-1: #3b2a22;   --ebony-2: #22160f;   --ebony-3: #120b07;
  --wine: #2a0a10;

  --ivory: #f6ead0;
  --ivory-2: rgba(246, 234, 208, 0.82);
  --ivory-3: rgba(246, 234, 208, 0.6);
  --well: linear-gradient(180deg, rgba(0, 0, 0, 0.42), rgba(0, 0, 0, 0.24));
  --well-line: inset 0 0 0 1px rgba(232, 190, 98, 0.3), inset 0 2px 8px rgba(0, 0, 0, 0.45);

  --medal: clamp(44px, 6.4vh, 58px);
  --medal-small: clamp(38px, 5.4vh, 46px);
  --medal-big: clamp(56px, 8.4vh, 72px);

  --royal-ease: cubic-bezier(.22, .9, .3, 1);
}

html, body { background: #0d0507; }
html { font-synthesis: none; }
body { color: var(--ivory); font-family: var(--font-body); font-weight: 500; }
::selection { background: rgba(226, 180, 86, 0.4); color: #fff; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
* { scrollbar-width: thin; scrollbar-color: var(--gold-dark) transparent; }

/* ==========================================================================
   Buttons — velvet in a bevelled gold frame
   ========================================================================== */
.btn, .plaque {
  --v1: var(--navy-1); --v2: var(--navy-2); --v3: var(--navy-4);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.55em;
  min-height: clamp(44px, 6.4vh, 56px);
  padding: 0 1.2em;
  border: 3px solid transparent;
  border-image: none;
  border-radius: 10px;
  background:
    radial-gradient(130% 115% at 50% 0%, var(--v1) 0%, var(--v2) 46%, var(--v3) 100%) padding-box,
    var(--gold-edge) border-box;
  box-shadow:
    inset 0 0 0 1px rgba(26, 8, 4, 0.9),
    inset 0 0 0 2.5px rgba(246, 214, 130, 0.5),
    inset 0 16px 20px -14px rgba(255, 230, 210, 0.35),
    inset 0 -16px 22px -12px rgba(0, 0, 0, 0.55),
    0 3px 0 #2a1806,
    0 10px 22px rgba(0, 0, 0, 0.55);
  font-family: var(--font-head);
  font-weight: 700;
  font-size: clamp(14px, 2.15vh, 18px);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-light);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.7), 0 0 14px rgba(0, 0, 0, 0.45);
  filter: none;
  white-space: nowrap;
  transition: transform 0.18s var(--royal-ease), box-shadow 0.2s ease, filter 0.2s ease;
}
/* gold rivets in the four corners */
.btn::after, .plaque::after {
  content: '';
  position: absolute; inset: 3px; border-radius: 6px;
  pointer-events: none;
  --r: radial-gradient(circle, #fff3c4 0 1.1px, #d9a648 1.7px, #6e4710 2.4px, transparent 2.9px);
  background: var(--r) left top / 9px 9px no-repeat, var(--r) right top / 9px 9px no-repeat,
              var(--r) left bottom / 9px 9px no-repeat, var(--r) right bottom / 9px 9px no-repeat;
}
.plaque > * { margin: 0; }
.btn img, .plaque img { width: 1.3em; height: 1.3em; filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.75)); pointer-events: none; flex: none; }
.btn:hover, .plaque:hover, .plaque.active {
  border-image: none;
  transform: translateY(-2px);
  filter: brightness(1.12) saturate(1.05);
  background:
    radial-gradient(130% 115% at 50% 0%, var(--v1) 0%, var(--v2) 46%, var(--v3) 100%) padding-box,
    var(--gold-edge-hot) border-box;
  box-shadow:
    inset 0 0 0 1px rgba(26, 8, 4, 0.9),
    inset 0 0 0 2.5px rgba(255, 228, 150, 0.7),
    inset 0 16px 20px -14px rgba(255, 230, 210, 0.4),
    inset 0 -16px 22px -12px rgba(0, 0, 0, 0.5),
    0 4px 0 #2a1806,
    0 0 18px rgba(246, 200, 100, 0.28),
    0 14px 26px rgba(0, 0, 0, 0.6);
  color: var(--gold-pale);
}
.btn:active, .plaque:active { transform: translateY(2px); filter: brightness(0.96); box-shadow: inset 0 0 0 1px rgba(26, 8, 4, 0.9), inset 0 0 0 2.5px rgba(246, 214, 130, 0.45), inset 0 6px 14px rgba(0, 0, 0, 0.55), 0 1px 0 #2a1806, 0 4px 10px rgba(0, 0, 0, 0.5); }

/* materials */
.btn, .btn.royal, .btn.green, .plaque.primary, .pz-actions .plaque.small.primary { --v1: var(--crimson-1); --v2: var(--crimson-2); --v3: var(--crimson-4); }
.btn.navy, .btn.blue, .btn.yellow, .btn.purple, .plaque { --v1: var(--navy-1); --v2: var(--navy-2); --v3: var(--navy-4); }
.plaque.primary { --v1: var(--crimson-1); --v2: var(--crimson-2); --v3: var(--crimson-4); }
.btn.dark, .plaque.dark { --v1: #5a4234; --v2: var(--ebony-2); --v3: var(--ebony-3); }

.plaque.small, .btn.small {
  min-height: clamp(34px, 5vh, 42px);
  font-size: clamp(11px, 1.75vh, 14px);
  letter-spacing: 0.08em;
  padding: 0 0.85em;
  border-width: 2px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(26, 8, 4, 0.9), inset 0 0 0 2px rgba(246, 214, 130, 0.38), inset 0 -10px 14px -8px rgba(0, 0, 0, 0.5), 0 2px 0 #2a1806, 0 6px 12px rgba(0, 0, 0, 0.45);
}
.plaque.small::after, .btn.small::after { inset: 2px; --r: radial-gradient(circle, #f6d98a 0 1px, #8d5f1a 1.6px, transparent 2.2px); background: var(--r) left top / 7px 7px no-repeat, var(--r) right top / 7px 7px no-repeat, var(--r) left bottom / 7px 7px no-repeat, var(--r) right bottom / 7px 7px no-repeat; }
.plaque.wide, .btn.wide { width: 100%; }
.plaque[disabled], .btn[disabled], .btn:disabled { filter: grayscale(0.7) brightness(0.7); opacity: 0.75; pointer-events: none; }

/* the crown that sits on the frame of the grandest buttons */
.btn-crown {
  position: absolute; left: 50%; top: 0; z-index: 2;
  width: clamp(38px, 5.6vh, 52px); aspect-ratio: 120 / 92;
  transform: translate(-50%, -64%);
  background: url('../assets/images/royal/crown.svg') center / contain no-repeat;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.7));
  pointer-events: none;
}

/* ==========================================================================
   Square icon buttons (title, HUD, corners, toolbars)
   ========================================================================== */
.sq, .medal, .icon-btn {
  --v1: var(--crimson-1); --v2: var(--crimson-2); --v3: var(--crimson-4);
  position: relative;
  width: var(--medal); height: var(--medal);
  flex: none;
  display: inline-grid; place-items: center;
  border: 3px solid transparent;
  border-radius: 10px;
  background:
    radial-gradient(120% 120% at 50% 0%, var(--v1) 0%, var(--v2) 48%, var(--v3) 100%) padding-box,
    var(--gold-edge) border-box;
  box-shadow:
    inset 0 0 0 1px rgba(26, 8, 4, 0.9),
    inset 0 0 0 2.5px rgba(246, 214, 130, 0.45),
    inset 0 -12px 16px -10px rgba(0, 0, 0, 0.55),
    0 3px 0 #2a1806,
    0 8px 16px rgba(0, 0, 0, 0.5);
  filter: none;
  transition: transform 0.18s var(--royal-ease), box-shadow 0.2s ease, filter 0.2s ease;
}
.sq img, .medal img, .icon-btn img { width: 54%; height: 54%; margin: 0; filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.75)); pointer-events: none; }
.sq:hover, .medal:hover, .icon-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.14);
  background:
    radial-gradient(120% 120% at 50% 0%, var(--v1) 0%, var(--v2) 48%, var(--v3) 100%) padding-box,
    var(--gold-edge-hot) border-box;
  box-shadow: inset 0 0 0 1px rgba(26, 8, 4, 0.9), inset 0 0 0 2.5px rgba(255, 228, 150, 0.65), inset 0 -12px 16px -10px rgba(0, 0, 0, 0.5), 0 4px 0 #2a1806, 0 0 16px rgba(246, 200, 100, 0.3), 0 12px 20px rgba(0, 0, 0, 0.55);
}
.sq:active, .medal:active, .icon-btn:active { transform: translateY(2px); filter: brightness(0.95); }
.medal.small, .icon-btn.small, .sq.small { width: var(--medal-small); height: var(--medal-small); border-width: 2px; border-radius: 8px; }
.medal.big { width: var(--medal-big); height: var(--medal-big); border-radius: 12px; }
.medal.wine, .sq.dark { --v1: #5a4234; --v2: var(--ebony-2); --v3: var(--ebony-3); }
.medal.off img, .sq.off img, .icon-btn.off img { opacity: 0.55; }
.sq.off, .icon-btn.off, .medal.off { filter: saturate(0.55) brightness(0.85); }
/* a crest needs the navy field behind it to read */
.sq.avatar-btn { --v1: var(--navy-1); --v2: var(--navy-2); --v3: var(--navy-4); }
.sq.avatar-btn img { width: 74%; height: 74%; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.7)); }

/* labelled squares (title menu): crown on the frame, icon and a small caption */
.sq.labeled {
  width: auto; height: auto; aspect-ratio: 1 / 1.02;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.22em;
  padding: 0.42em 0.1em 0.38em;
  border-radius: 9px;
}
.sq.labeled::before {
  content: ''; position: absolute; left: 50%; top: 0;
  width: 30%; aspect-ratio: 120 / 92;
  transform: translate(-50%, -62%);
  background: url('../assets/images/royal/crown.svg') center / contain no-repeat;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.65));
}
.sq.labeled img { width: 36%; height: auto; aspect-ratio: 1; }
.sq.labeled span {
  font-family: var(--font-head); font-weight: 700;
  font-size: clamp(7px, min(1.1vh, 1.8vw), 10px); letter-spacing: 0.02em; text-transform: uppercase;
  color: var(--gold-light); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.75);
  white-space: nowrap; max-width: 100%; overflow: hidden;
}

/* ==========================================================================
   Focus
   ========================================================================== */
.btn:focus-visible, .plaque:focus-visible, .sq:focus-visible, .medal:focus-visible, .icon-btn:focus-visible,
.mode-card:focus-visible, .diff:focus-visible, .tc-tile:focus-visible, .tc-classic:focus-visible, .color-btn:focus-visible,
.hub-card:focus-visible, .theme-card:focus-visible, .th-swatch:focus-visible, .promo-btn:focus-visible, .tab:focus-visible,
.seg button:focus-visible, .setting:focus-within, .link-btn:focus-visible, .an-move:focus-visible,
.pal-btn:focus-visible, .switch-line input:focus-visible + .switch {
  outline: 2px solid var(--gold-pale);
  outline-offset: 4px;
  box-shadow: 0 0 0 6px rgba(246, 200, 100, 0.22), 0 0 24px rgba(246, 200, 100, 0.35);
}

kbd, .mode-key kbd {
  display: inline-block; min-width: 1.7em;
  padding: 0.08em 0.42em 0.02em; margin: 0 0.1em;
  border: 1px solid #c8913a; border-radius: 5px;
  background: linear-gradient(180deg, #3a2a20, #150d09);
  box-shadow: 0 2px 0 #050302, inset 0 1px 0 rgba(255, 230, 170, 0.25);
  color: var(--gold-light);
  font-family: var(--font-head); font-weight: 700; font-size: 0.8em; line-height: 1.4; text-align: center;
}

/* ==========================================================================
   The royal title (logo)
   ========================================================================== */
.game-logo { margin: 0; line-height: 0; }
.game-logo svg { display: block; width: 100%; height: auto; overflow: visible; }
.lg-word text { font-family: var(--font-display); font-weight: 900; font-size: 124px; }
.lg-depth { fill: #1a0a03; stroke: #1a0a03; stroke-width: 12px; stroke-linejoin: round; opacity: 0.85; }
.lg-edge { fill: none; stroke: #3d2208; stroke-width: 9px; stroke-linejoin: round; }
.lg-face { fill: url(#rc-gold); stroke: #fff2c0; stroke-width: 1.2px; stroke-opacity: 0.55; paint-order: fill stroke; }
.lg-tag { font-family: var(--font-head); font-weight: 700; font-size: 25px; fill: url(#rc-gold-flat); letter-spacing: 3px; }
.game-logo { filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.6)); }

/* ==========================================================================
   Title screen — the throne-room menu
   ========================================================================== */
#screen-title { display: block; }
.title-shade {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 62% 95% at 0% 50%, rgba(28, 4, 9, 0.86), rgba(28, 4, 9, 0.45) 55%, rgba(28, 4, 9, 0) 78%),
    linear-gradient(0deg, rgba(10, 3, 5, 0.65), rgba(10, 3, 5, 0) 24%),
    linear-gradient(180deg, rgba(10, 3, 5, 0.5), rgba(10, 3, 5, 0) 18%);
}
/* v6.2 the throne-room drapes (static SVG art; the curtains sway and the light breathes on the compositor) */
.title-drapes { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.title-drapes i { position: absolute; display: block; }
.td-valance {
  left: 0; right: 0; top: 0; height: clamp(58px, 10.5vh, 118px);
  background: url('../assets/images/royal/valance.svg') center top / auto 100% repeat-x;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.55));
  animation: rcDrop 1.1s 0.1s var(--royal-ease) both;
}
.td-curtain {
  top: -2vh; bottom: -2vh; width: clamp(80px, 11vh, 150px);
  background: url('../assets/images/royal/curtain.svg') right center / 100% 100% no-repeat;
  transform-origin: 50% 0; will-change: transform;
  filter: drop-shadow(-6px 0 12px rgba(0, 0, 0, 0.55));
}
.td-curtain.right { right: 0; animation: rcSway 9s ease-in-out infinite; }
.td-curtain.left { left: 0; width: clamp(56px, 7vh, 96px); transform: scaleX(-1); animation: rcSwayL 10s 1.2s ease-in-out infinite; opacity: 0.85; }
.td-rays {
  left: 34%; right: 4%; top: 0; height: 88%;
  background:
    linear-gradient(104deg, transparent 22%, rgba(255, 222, 160, 0.075) 30%, transparent 37%),
    linear-gradient(97deg, transparent 44%, rgba(255, 222, 160, 0.06) 50%, transparent 56%),
    linear-gradient(86deg, transparent 60%, rgba(255, 222, 160, 0.07) 67%, transparent 74%);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.6) 45%, transparent 95%);
  mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.6) 45%, transparent 95%);
  will-change: opacity; animation: rcRays 7s ease-in-out infinite;
}
@keyframes rcDrop { from { transform: translateY(-100%); } to { transform: none; } }
@keyframes rcSway { 0%, 100% { transform: rotate(0.35deg); } 50% { transform: rotate(-0.25deg); } }
@keyframes rcSwayL { 0%, 100% { transform: scaleX(-1) rotate(0.3deg); } 50% { transform: scaleX(-1) rotate(-0.25deg); } }
@keyframes rcRays { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

.title-col {
  position: absolute;
  left: calc(var(--safe-left) + 4vw);
  top: 0; bottom: 0;
  width: clamp(320px, 28vw, 450px);
  display: flex; flex-direction: column; align-items: stretch; justify-content: center;
  gap: clamp(6px, 1.3vh, 14px);
  padding: calc(var(--safe-top) + 1.2vh) 0 calc(var(--safe-bottom) + 1.2vh);
  max-height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  scrollbar-width: none;
}
.title-col::-webkit-scrollbar { display: none; }
.title-col .game-logo { width: min(100%, 38vh, 340px); align-self: center; animation: rcLogoIn 1.1s var(--royal-ease) both; }
.title-menu-block { display: flex; flex-direction: column; gap: clamp(5px, 1vh, 10px); width: 100%; }

.btn-play {
  width: 100%;
  min-height: clamp(52px, 8.2vh, 76px);
  margin-top: clamp(4px, 0.9vh, 10px);
  border-width: 3.5px;
  border-radius: 12px;
  gap: clamp(10px, 1.4vw, 18px);
  justify-content: flex-start;
  padding: 0 1em;
  animation: rcRise 0.8s 0.35s var(--royal-ease) both;
}
/* the royal glow breathes on its own layer (opacity only: no repaint of the button every frame) */
.btn-play::before {
  content: ''; position: absolute; inset: -5px; border-radius: 17px; pointer-events: none;
  box-shadow: 0 0 0 1px rgba(255, 230, 160, 0.45), 0 0 28px rgba(246, 196, 90, 0.5);
  opacity: 0; will-change: opacity;
  animation: rcGlow 3.4s 1.4s ease-in-out infinite;
}
.btn-play::after { inset: 4px; border-radius: 9px; --r: radial-gradient(circle, #fff3c4 0 1.6px, #d9a648 2.4px, #6e4710 3.2px, transparent 3.8px); background: var(--r) left top / 12px 12px no-repeat, var(--r) right top / 12px 12px no-repeat, var(--r) left bottom / 12px 12px no-repeat, var(--r) right bottom / 12px 12px no-repeat; }
.btn-play > img { width: clamp(26px, 4.2vh, 38px); height: auto; margin-left: 0.3em; }
.btn-stack { display: flex; flex-direction: column; align-items: center; flex: 1; line-height: 1; gap: 0.3em; }
.btn-big {
  font-family: var(--font-head); font-weight: 900;
  font-size: clamp(26px, 4.4vh, 42px); letter-spacing: 0.1em;
  background: linear-gradient(110deg, #b07c2c 0%, #f3d27a 30%, #fff8dc 46%, #f3d27a 60%, #c18b35 100%) 0 0 / 260% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.75)) drop-shadow(0 0 10px rgba(0, 0, 0, 0.35));
  animation: rcShimmer 1.6s 1.2s ease-in-out 1 both;     /* one gold sweep as the menu opens */
  margin-right: 0.6em;
}
.btn-sub { font-family: var(--font-head); font-weight: 700; font-size: clamp(9.5px, 1.4vh, 12px); letter-spacing: 0.14em; color: var(--gold-light); opacity: 0.88; margin-right: 0.9em; }
.btn-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(5px, 0.9vh, 8px); width: 100%; animation: rcRise 0.8s 0.5s var(--royal-ease) both; }
.btn-row2 .btn { min-width: 0; min-height: clamp(38px, 5.4vh, 48px); justify-content: flex-start; padding: 0 0.65em; gap: 0.45em; font-size: clamp(11.5px, 1.6vh, 14px); }
.btn-row2 .btn > img { width: 1.35em; height: 1.35em; }
.btn-row2 .btn-stack { align-items: flex-start; gap: 0.18em; }
.btn-note { font-family: var(--font-body); font-style: italic; font-weight: 600; font-size: clamp(10px, 1.3vh, 12px); letter-spacing: 0.02em; text-transform: none; color: var(--ivory-2); }
.sq-row { display: grid; grid-template-columns: repeat(3, minmax(0, clamp(38px, 5vh, 46px))); justify-content: center; gap: clamp(6px, 1.1vw, 10px); margin-top: clamp(2px, 0.6vh, 6px); animation: rcRise 0.8s 0.65s var(--royal-ease) both; }
.sq-row .sq { width: 100%; }

.key-hint {
  margin: 2px 0 0; text-align: center;
  font-family: var(--font-body); font-style: italic; font-weight: 600;
  font-size: clamp(11px, 1.35vh, 13px); line-height: 1.3;
  color: var(--ivory-3);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  animation: rcFade 1s 1s both;
}
.key-hint b { font-family: var(--font-head); font-style: normal; font-weight: 700; font-size: 0.86em; letter-spacing: 0.06em; color: var(--gold-light); }
.title-corner {
  position: absolute; top: calc(16px + var(--safe-top)); right: calc(18px + var(--safe-right));
  display: flex; gap: 10px; z-index: 5;
  animation: rcFade 0.9s 0.6s both;
}
.title-corner .sq { --medal: clamp(40px, 6vh, 52px); }
.title-version { position: absolute; right: calc(18px + var(--safe-right)); bottom: calc(10px + var(--safe-bottom)); margin: 0; font-family: var(--font-head); font-size: 12px; letter-spacing: 0.14em; color: rgba(246, 217, 138, 0.5); text-shadow: 0 2px 2px rgba(0, 0, 0, 0.7); }
.title-3d-hint {
  position: absolute; left: 66%; bottom: calc(16px + var(--safe-bottom)); transform: translateX(-50%);
  margin: 0; padding: 7px 18px; border-radius: 999px;
  font-family: var(--font-body); font-style: italic; font-weight: 600; font-size: 15px; color: var(--ivory-2);
  background: linear-gradient(180deg, rgba(30, 10, 10, 0.78), rgba(12, 5, 5, 0.82));
  box-shadow: inset 0 0 0 1px var(--gold-line), 0 6px 16px rgba(0, 0, 0, 0.5);
  pointer-events: none; opacity: 0; transition: opacity 0.6s ease; white-space: nowrap;
}
.title-3d-hint.show { opacity: 1; }
body.menu3d #screen-title .key-hint .k3d { display: none; }

@keyframes rcLogoIn { from { opacity: 0; transform: translateY(-18px) scale(0.94); filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0)) brightness(1.6); } to { opacity: 1; transform: none; } }
@keyframes rcRise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes rcFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rcShimmer { 0% { background-position: 100% 0; } 100% { background-position: 0% 0; } }
@keyframes rcGlow { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }

@media (max-height: 780px) and (orientation: landscape) {
  .title-col .game-logo { width: min(100%, 34vh, 290px); }
  .btn-play { min-height: clamp(48px, 7.5vh, 64px); }
  .btn-big { font-size: clamp(24px, 4vh, 34px); }
  .btn-row2 .btn { min-height: clamp(34px, 5vh, 42px); font-size: 11.5px; }
  .sq-row { grid-template-columns: repeat(3, minmax(0, clamp(34px, 4.8vh, 40px))); justify-content: center; }
  .title-menu-block { gap: 5px; }
}
@media (max-height: 600px) and (orientation: landscape) {
  .title-col { gap: 4px; width: clamp(270px, 36vw, 380px); padding-top: calc(var(--safe-top) + 6px); padding-bottom: calc(var(--safe-bottom) + 6px); }
  .title-col .game-logo { width: min(100%, 28vh, 210px); }
  .title-menu-block { gap: 4px; }
  .btn-play { min-height: 42px; margin-top: 4px; border-width: 2.5px; border-radius: 9px; padding: 0 0.7em; }
  .btn-play .btn-crown { width: 24px; }
  .btn-play > img { width: 20px; }
  .btn-big { font-size: 22px; }
  .btn-sub { font-size: 8.5px; }
  .btn-row2 { gap: 4px; }
  .btn-row2 .btn { min-height: 32px; font-size: 10.5px; padding: 0 0.4em; }
  .btn-row2 .btn > img { width: 1.15em; height: 1.15em; }
  .btn-row2 .btn-note { display: none; }
  .sq-row { grid-template-columns: repeat(3, minmax(0, 32px)); gap: 6px; margin-top: 3px; justify-content: center; }
  .sq.labeled { padding: 0.15em; }
  .sq.labeled img { width: 44%; }
  .sq.labeled span { display: none; }
  .key-hint { display: none; }
  .title-corner .sq { --medal: 32px; }
  .td-valance { height: 32px; }
}
@media (orientation: portrait) {
  .title-shade { background: linear-gradient(0deg, rgba(20, 4, 8, 0.94) 0%, rgba(20, 4, 8, 0.78) 44%, rgba(20, 4, 8, 0) 64%), linear-gradient(180deg, rgba(20, 4, 8, 0.6), rgba(20, 4, 8, 0) 28%); }
  .title-col { left: 50%; transform: translateX(-50%); width: min(92vw, 440px); justify-content: space-between; padding-top: calc(var(--safe-top) + 3vh); padding-bottom: calc(var(--safe-bottom) + 2vh); }
  .title-col .game-logo { width: min(80vw, 320px); }
  .title-menu-block { margin-top: auto; }
  .sq-row { grid-template-columns: repeat(3, minmax(0, clamp(40px, 11vw, 50px))); justify-content: center; gap: 8px; }
  .key-hint, .title-version, .title-3d-hint { display: none; }
  .title-drapes .td-rays { display: none; }
  .title-drapes .td-curtain { width: min(14vw, 64px); }
  .title-drapes .td-curtain.left { width: min(11vw, 50px); }
  .td-valance { height: 48px; }
  .btn-row2 .btn { font-size: clamp(12px, 3.8vw, 15px); padding: 0 0.55em; gap: 0.45em; min-height: 42px; }
  .btn-row2 .btn .btn-stack > span:first-child { letter-spacing: 0.05em; }
  .title-corner { top: calc(10px + var(--safe-top)); right: 50%; transform: translateX(50%); gap: 8px; }
  .title-corner .sq { --medal: 38px; }
}
  .key-hint, .title-version, .title-3d-hint { display: none; }
  .title-drapes .td-rays { display: none; }
  .title-drapes .td-curtain { width: min(14vw, 64px); }
  .title-drapes .td-curtain.left { width: min(11vw, 50px); }
  .td-valance { height: 52px; }
  .btn-row2 .btn { font-size: clamp(13px, 4vw, 17px); padding: 0 0.6em; gap: 0.5em; }
  .btn-row2 .btn .btn-stack > span:first-child { letter-spacing: 0.05em; }
  .title-corner { top: calc(10px + var(--safe-top)); right: 50%; transform: translateX(50%); gap: 8px; }
  .title-corner .sq { --medal: 40px; }


/* ==========================================================================
   Loading
   ========================================================================== */
#screen-loading {
  background:
    url('../assets/images/royal/damask.svg') center / 120px,
    radial-gradient(ellipse at 50% 40%, rgba(150, 24, 38, 0.55), rgba(60, 6, 14, 0.4) 45%, rgba(8, 2, 4, 0) 75%),
    radial-gradient(ellipse at 50% 50%, #2a0a10, #0b0306 75%);
}
.loading-inner { gap: 22px; }
.loading-inner .game-logo { width: min(80vw, 470px); animation: rcLogoIn 1.2s var(--royal-ease) both; }
.loading-bar {
  width: min(380px, 74vw); height: 18px; padding: 3px;
  border: 2px solid transparent; border-radius: 999px;
  background: linear-gradient(180deg, #0c0506, #1c0b0d) padding-box, var(--gold-edge) border-box;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.8), 0 6px 16px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.loading-fill {
  border-radius: 999px;
  background: linear-gradient(110deg, #a8752a 0%, #f3d27a 35%, #fff8dc 50%, #f3d27a 65%, #a8752a 100%) 0 0 / 220% 100%;
  box-shadow: 0 0 12px rgba(246, 200, 100, 0.55);
  animation: rcBar 1.8s linear infinite;
}
@keyframes rcBar { to { background-position: -220% 0; } }
.loading-text { font-family: var(--font-body); font-style: italic; font-weight: 600; font-size: clamp(16px, 2.4vh, 21px); letter-spacing: 0.04em; color: var(--ivory-2); opacity: 1; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8); }

/* ==========================================================================
   Screen titles (mode, time, puzzles, themes, board pages)
   ========================================================================== */
.screen-title, .topbar-title, .run-title {
  font-family: var(--font-display);
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: none;
  background: var(--gold-text);
  -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 3px 0 #1a0a03) drop-shadow(0 8px 14px rgba(0, 0, 0, 0.75));
}
.screen-title { position: relative; font-size: clamp(28px, 6vh, 54px); line-height: 1.15; margin-bottom: 22px; }
.screen-title::after {
  content: ''; position: absolute; left: 50%; top: 100%; transform: translateX(-50%);
  width: min(300px, 70vw); height: 20px; margin-top: 2px;
  background: url('../assets/images/royal/divider.svg') center / contain no-repeat;
}
.screen-title .orn { display: inline; font-family: var(--font-body); font-weight: 600; }
.topbar-title { font-size: clamp(18px, 3.2vh, 26px); }
@media (orientation: portrait) { .topbar-title { font-size: clamp(14px, 4.4vw, 20px); letter-spacing: 0; } }
.run-title { font-size: 24px; }
.time-sub { margin: 0 0 6px; }
.hub-rating { margin-top: 2px; }
.time-sub, .mode-stats, .hub-rating { font-family: var(--font-body); font-style: italic; font-weight: 600; color: var(--ivory-2); text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8); }
.hub-rating b { font-family: var(--font-head); font-style: normal; font-weight: 800; color: var(--gold-light); }

/* ==========================================================================
   Cards and dialogs — ebony lacquer, damask, double gold frame, filigree corners
   ========================================================================== */
.modal {
  /* no backdrop-filter: blurring the live 3D canvas behind a dialog cost a full-screen blur every frame */
  background: radial-gradient(ellipse at center, rgba(40, 6, 12, 0.6), rgba(6, 2, 3, 0.9));
}
.panel, .side-panel, .mode-card, .hub-card, .bc-intro-card {
  --corner: 40px;
  border: 3px solid transparent;
  border-image: none;
  border-radius: 14px;
  background:
    url('../assets/images/royal/corner-tl.svg') left 6px top 6px / var(--corner) no-repeat padding-box,
    url('../assets/images/royal/corner-tr.svg') right 6px top 6px / var(--corner) no-repeat padding-box,
    url('../assets/images/royal/corner-bl.svg') left 6px bottom 6px / var(--corner) no-repeat padding-box,
    url('../assets/images/royal/corner-br.svg') right 6px bottom 6px / var(--corner) no-repeat padding-box,
    linear-gradient(90deg, transparent, var(--gold-line) 12%, var(--gold-line) 88%, transparent) center top 10px / calc(100% - 64px) 1px no-repeat padding-box,
    linear-gradient(90deg, transparent, var(--gold-line) 12%, var(--gold-line) 88%, transparent) center bottom 10px / calc(100% - 64px) 1px no-repeat padding-box,
    linear-gradient(180deg, transparent, var(--gold-line) 12%, var(--gold-line) 88%, transparent) left 10px center / 1px calc(100% - 64px) no-repeat padding-box,
    linear-gradient(180deg, transparent, var(--gold-line) 12%, var(--gold-line) 88%, transparent) right 10px center / 1px calc(100% - 64px) no-repeat padding-box,
    url('../assets/images/royal/damask.svg') 0 0 / 96px padding-box,
    radial-gradient(130% 70% at 50% 0%, rgba(140, 18, 34, 0.5), rgba(140, 18, 34, 0) 62%) padding-box,
    linear-gradient(180deg, #23100e 0%, #170a09 55%, #0e0606 100%) padding-box,
    var(--gold-edge) border-box;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.7), inset 0 0 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.6), 0 26px 60px rgba(0, 0, 0, 0.72);
  color: var(--ivory);
}
.panel {
  padding: clamp(16px, 2.8vh, 26px) clamp(14px, 2.8vw, 28px) clamp(14px, 2.2vh, 22px);
  gap: clamp(6px, 1vh, 10px);
  max-height: min(94vh, calc(100vh - 20px));
  box-sizing: border-box;
}
.panel-title, .rc-title {
  margin: 0 0 2px;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(22px, 3.8vh, 36px);
  letter-spacing: 0.04em;
  line-height: 1.1;
  text-transform: none;
  background: var(--gold-text);
  -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 3px 0 #1a0a03) drop-shadow(0 6px 10px rgba(0, 0, 0, 0.7));
}
.panel-title { position: relative; margin-bottom: clamp(10px, 1.8vh, 16px); }
.panel-title::after {
  content: ''; position: absolute; left: 50%; top: 100%; transform: translateX(-50%);
  width: min(200px, 60%); height: 12px; margin-top: 2px;
  background: url('../assets/images/royal/divider.svg') center / contain no-repeat;
}
.panel-title.y, .result-title { background: var(--gold-text); -webkit-background-clip: text; background-clip: text; }
.panel-sub { margin: -2px 0 3px; font-family: var(--font-body); font-style: italic; font-weight: 600; font-size: clamp(13px, 1.9vh, 16px); color: var(--ivory-2); }
.stack { gap: clamp(8px, 1.4vh, 12px); }
.panel-actions { gap: clamp(10px, 1.6vw, 18px); }
.medal.modal-close { position: absolute; top: 12px; right: 12px; z-index: 2; }

/* inset wells: rows, chips and lists inside cards */
.setting, .seg-row, .custom-row, .rt-row, .run-stats div, .pz-head, .an-engine, .ed-castle, .run-rival.show, .th-swatch, .pz-meta .chip, .an-moves, .vs-strip {
  background: var(--well);
  border-radius: 9px;
  box-shadow: var(--well-line);
}

/* ==========================================================================
   Pause, confirm, coat-of-arms picker
   ========================================================================== */
.pause-card {
  width: min(440px, 92vw);
  max-height: min(95vh, calc(100vh - 16px));
  padding: clamp(22px, 3.2vh, 30px) clamp(14px, 3vw, 22px) clamp(12px, 1.8vh, 16px);
  gap: clamp(3px, 0.7vh, 6px);
  overflow: visible;
  align-items: stretch;
  box-sizing: border-box;
}
.pause-card .card-badge {
  position: absolute; left: 50%; top: 0; z-index: 2;
  width: clamp(48px, 6.5vh, 64px); aspect-ratio: 120 / 92;
  transform: translate(-50%, -60%);
  background: url('../assets/images/royal/crown.svg') center / contain no-repeat;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.7));
  border: 0; box-shadow: none; rotate: 0deg;
  pointer-events: none;
}
.pause-card .panel-title {
  text-align: center;
  font-size: clamp(18px, 2.7vh, 23px);
  margin: 0 0 5px;
  line-height: 1.1;
}
.pause-card .panel-title::after {
  height: 8px;
  width: min(150px, 50%);
  margin-top: 1px;
}
.pause-card .panel-sub {
  text-align: center;
  margin: -3px 0 1px;
  font-size: clamp(11px, 1.4vh, 12.5px);
}
.pause-card .vs-strip {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 3px 8px;
  border-radius: 7px;
  font-family: var(--font-head); font-weight: 700; font-size: clamp(11px, 1.4vh, 12.5px);
  letter-spacing: 0.05em; color: var(--ivory); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.7);
}
.pause-card .vs-strip img { width: 22px; height: 22px; border: 0; border-radius: 0; background: none; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.6)); }
.pause-card .vs-strip .vs-name { min-width: 0; white-space: normal; line-height: 1.15; text-align: center; }
.pause-card .vs-strip b { font-family: var(--font-display); font-weight: 900; font-size: 1.15em; color: #e0505c; text-shadow: 0 2px 0 #2a0206, 0 0 10px rgba(220, 40, 50, 0.5); }
.pause-card .pause-meta { margin: -2px 0 1px; text-align: center; font-family: var(--font-body); font-style: italic; font-weight: 600; font-size: clamp(10px, 1.3vh, 11.5px); color: var(--ivory-3); }

.pause-card .btn-resume {
  width: 100%;
  min-height: clamp(34px, 4.6vh, 42px);
  margin-top: 2px;
  font-size: clamp(14px, 2vh, 17px);
  letter-spacing: 0.12em;
  border-width: 2.5px;
  border-radius: 8px;
  padding: 0 0.8em;
  gap: 8px;
}
.pause-card .btn-resume .btn-crown { width: clamp(20px, 2.8vh, 26px); }
.pause-card .btn-resume > img { width: 13px; height: 13px; }

.pause-card .btn-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; width: 100%; }
.pause-card .btn-grid2 .btn {
  min-height: clamp(28px, 3.8vh, 34px);
  padding: 0 0.5em;
  font-size: clamp(10px, 1.3vh, 12px);
  border-radius: 6px;
  border-width: 2px;
  gap: 4px;
}
.pause-card .btn-grid2 .btn img { width: 13px; height: 13px; }
.pause-card .btn .lock {
  display: none; position: absolute; right: -5px; top: -6px;
  width: 18px; height: 18px; padding: 2.5px;
  border: 1.5px solid #c8913a; border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, #5a1520, #2a050c); filter: none; z-index: 2;
}
.btn:disabled .lock, .btn[disabled] .lock { display: block; }
.pause-card .btn-grid2 .btn:disabled { opacity: 1; filter: grayscale(0.85) brightness(0.62); pointer-events: auto; cursor: not-allowed; }

.pause-card .btn.dark.wide {
  min-height: clamp(28px, 3.8vh, 34px);
  font-size: clamp(10px, 1.3vh, 12px);
  padding: 0 0.5em;
  border-radius: 6px;
  border-width: 2px;
  gap: 4px;
}
.pause-card .btn.dark.wide img { width: 13px; height: 13px; }

.pause-card .pause-audio { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; width: 100%; }
.pause-card .pause-audio .setting {
  padding: 3px 7px;
  gap: 5px;
  font-size: clamp(9.5px, 1.2vh, 11px);
  border-radius: 6px;
}
.pause-card .pause-audio .setting > img { width: 14px; height: 14px; }
.pause-card .pause-audio .switch { width: 34px; height: 18px; border-radius: 10px; }
.pause-card .pause-audio .switch::after { width: 12px; height: 12px; top: 3px; left: 3px; }
.pause-card .pause-audio .setting input:checked + .switch::after { transform: translateX(16px); }

.pause-card .card-icons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  margin-bottom: 0;
  width: 100%;
}
.pause-card .card-icons .sq {
  --medal: clamp(26px, 3.5vh, 32px);
  border-radius: 6px;
  border-width: 2px;
}
.pause-card .card-icons .sq img { width: 14px; height: 14px; }

.confirm-card { width: min(420px, 92vw); padding: clamp(20px, 3vh, 28px) clamp(16px, 3vw, 24px); }
.confirm-card .panel-sub { text-align: center; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-top: 6px; }
.confirm-actions .btn { min-height: clamp(34px, 4.8vh, 42px); font-size: clamp(12px, 1.6vh, 14px); }

/* ---- v6.2 the Royal Wardrobe: coats of arms, piece sets, boards ---- */
.wardrobe-card { width: min(880px, 95vw); }
.wd-tabs { display: flex; width: 100%; max-width: 580px; }
.wd-tabs button { flex: 1; }
.wd-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(152px, 1fr)); gap: 12px;
  width: 100%; max-height: min(50vh, 520px); overflow: auto; padding: 6px 4px;
  scrollbar-width: thin; scrollbar-color: var(--gold-dark) transparent;
}
.wd-grid.arms { grid-template-columns: repeat(4, 1fr); }
.wd-grid.pieces { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.wd-item {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 8px 11px; text-align: center;
  border: 2px solid transparent; border-radius: 12px;
  background: linear-gradient(180deg, #2a1a14, #120a07) padding-box, linear-gradient(180deg, rgba(232, 190, 98, 0.65), rgba(141, 95, 26, 0.5)) border-box;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.6), 0 6px 12px rgba(0, 0, 0, 0.45);
  transition: transform 0.18s var(--royal-ease), box-shadow 0.2s ease;
}
.wd-item:hover { transform: translateY(-3px); box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.5), 0 0 16px rgba(246, 200, 100, 0.25), 0 10px 16px rgba(0, 0, 0, 0.5); }
.wd-item:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 2px; }
.wd-item.worn {
  background: radial-gradient(120% 110% at 50% 0%, var(--crimson-1), var(--crimson-2) 48%, var(--crimson-4)) padding-box, var(--gold-edge-hot) border-box;
  box-shadow: inset 0 0 0 1px rgba(26, 8, 4, 0.9), 0 0 0 2px rgba(246, 214, 130, 0.25), 0 0 20px rgba(246, 200, 100, 0.4), 0 8px 14px rgba(0, 0, 0, 0.5);
}
.wd-item.worn::after {
  content: '♛'; position: absolute; left: 9px; top: 6px;
  font-size: 17px; line-height: 1; color: var(--gold-pale); text-shadow: 0 0 8px rgba(255, 210, 120, 0.8), 0 2px 0 #000;
}
.wd-art { display: flex; align-items: flex-end; justify-content: center; gap: 2px; width: 100%; height: 96px; }
.wd-art img { width: 88px; height: 88px; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.6)); }
.wd-art canvas { width: 90px; height: 90px; align-self: center; border-radius: 6px; box-shadow: 0 0 0 2px rgba(232, 190, 98, 0.6), 0 6px 12px rgba(0, 0, 0, 0.6); }
.wd-item b { font-family: var(--font-head); font-weight: 700; font-size: 13.5px; letter-spacing: 0.04em; color: var(--gold-light); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.7); }
.wd-item small { font-family: var(--font-body); font-style: italic; font-weight: 600; font-size: 13.5px; line-height: 1.15; color: rgba(247, 238, 215, 0.8); }
.wd-item.worn small { color: var(--gold-pale); font-style: normal; font-family: var(--font-head); font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; }
.wd-item.locked .wd-art { filter: grayscale(0.8) brightness(0.48); }
.wd-grid.pieces .wd-art { filter: drop-shadow(0 0 1.5px rgba(255, 222, 160, 0.55)) drop-shadow(0 4px 4px rgba(0, 0, 0, 0.6)); }
.wd-grid.pieces .wd-item.locked .wd-art { filter: grayscale(0.8) brightness(0.5) drop-shadow(0 0 1.5px rgba(255, 222, 160, 0.5)); }
.wd-item.locked b { color: rgba(232, 214, 170, 0.72); }
.wd-item.locked::before, .th-swatch.locked::before {
  content: ''; position: absolute; right: 8px; top: 8px; width: 26px; height: 26px; border-radius: 50%; z-index: 1;
  background: url(../assets/images/icons/royal/lock.svg) center / 15px no-repeat, radial-gradient(circle at 40% 35%, #5a1a1c, #1a070a);
  box-shadow: 0 0 0 1.5px rgba(232, 190, 98, 0.75), 0 3px 6px rgba(0, 0, 0, 0.6);
}
.wd-item .wd-req { font-style: normal; font-family: var(--font-head); font-weight: 700; font-size: 11.5px; letter-spacing: 0.02em; color: #f0c98a; }
.wd-item .wd-prog { font-style: normal; font-family: var(--font-head); font-size: 10.5px; color: rgba(240, 201, 138, 0.75); }
.wd-bar { width: 78%; height: 5px; margin-top: 3px; border-radius: 3px; overflow: hidden; background: rgba(0, 0, 0, 0.55); box-shadow: inset 0 0 0 1px rgba(232, 190, 98, 0.35); }
.wd-bar i { display: block; height: 100%; transform-origin: left center; background: linear-gradient(90deg, #b07a26, #f4d27a); }
.wd-foot { margin: 0; text-align: center; font-family: var(--font-body); font-style: italic; font-size: 14.5px; color: rgba(247, 238, 215, 0.72); }

/* a king carved in each material: the 2D king as a mask over the material, its engraving multiplied on top */
.wd-king {
  position: relative; display: block; width: 62px; height: 78px;
  -webkit-mask: url(../assets/images/pieces/w_k.png) center bottom / contain no-repeat;
  mask: url(../assets/images/pieces/w_k.png) center bottom / contain no-repeat;
  background: var(--mat, #ddd);
}
.wd-king::after {
  content: ''; position: absolute; inset: 0;
  background: url(../assets/images/pieces/w_k.png) center bottom / contain no-repeat;
  mix-blend-mode: multiply; opacity: 0.5;
}
.wd-king.b { width: 56px; height: 70px; }
.wd-king.b::after { opacity: 0.22; }
.wd-king.w.marble { --mat: linear-gradient(140deg, #fffefb 10%, #e2dfda 42%, #b8b5b1 64%, #f4f2ee 88%); }
.wd-king.b.marble { --mat: linear-gradient(140deg, #4a5059 8%, #15181d 46%, #08090b 70%, #2a2f36 94%); }
.wd-king.w.wood { --mat: linear-gradient(140deg, #f6dfaa 8%, #d9b06c 46%, #b88443 72%, #ecc98a 94%); }
.wd-king.b.wood, .wd-king.b.gold { --mat: linear-gradient(140deg, #4b3527 8%, #1b110b 46%, #0b0705 70%, #33241a 94%); }
.wd-king.w.gold { --mat: linear-gradient(140deg, #fff4c4 6%, #f3c95c 36%, #a8731e 66%, #ffe39c 90%); }
.wd-king.w.ruby { --mat: linear-gradient(140deg, #fffaf0 8%, #efe2c4 44%, #cdb68a 70%, #f8eedb 94%); }
.wd-king.b.ruby { --mat: linear-gradient(140deg, #ff6a7d 4%, #c4142f 30%, #6a0614 64%, #a01028 92%); }
.wd-king.w.silver { --mat: linear-gradient(140deg, #ffffff 6%, #d3d8df 34%, #858c97 62%, #eef2f6 88%); }
.wd-king.b.silver { --mat: linear-gradient(140deg, #7aa6ff 4%, #2350c0 30%, #0a1b5a 64%, #1d3f9c 92%); }

/* Settings: boards and piece sets still to be earned */
.th-swatch { position: relative; }
.th-swatch.locked canvas { filter: grayscale(0.8) brightness(0.5); }
.th-swatch.locked::before { right: 6px; top: 6px; width: 22px; height: 22px; background-size: 12px auto, auto; }
.seg button.locked { opacity: 0.55; }
.seg button.locked::before { content: '🔒︎'; margin-right: 4px; font-size: 0.85em; filter: grayscale(1); }

/* ==========================================================================
   Mode select, time control
   ========================================================================== */
.mode-card { --corner: 34px; width: clamp(270px, 40vmin, 380px); padding: clamp(18px, 3vmin, 28px) 18px clamp(18px, 2.8vmin, 26px); transition: transform 0.25s var(--royal-ease), box-shadow 0.25s ease, filter 0.25s ease; }
.mode-card:hover {
  filter: brightness(1.08); transform: translateY(-6px);
  background-image:
    url('../assets/images/royal/corner-tl.svg'), url('../assets/images/royal/corner-tr.svg'), url('../assets/images/royal/corner-bl.svg'), url('../assets/images/royal/corner-br.svg'),
    linear-gradient(90deg, transparent, var(--gold-line) 12%, var(--gold-line) 88%, transparent), linear-gradient(90deg, transparent, var(--gold-line) 12%, var(--gold-line) 88%, transparent),
    linear-gradient(180deg, transparent, var(--gold-line) 12%, var(--gold-line) 88%, transparent), linear-gradient(180deg, transparent, var(--gold-line) 12%, var(--gold-line) 88%, transparent),
    url('../assets/images/royal/damask.svg'),
    radial-gradient(130% 70% at 50% 0%, rgba(190, 30, 46, 0.6), rgba(140, 18, 34, 0) 62%),
    linear-gradient(180deg, #2a1311 0%, #1a0b0a 55%, #100707 100%),
    var(--gold-edge-hot);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.7), inset 0 0 40px rgba(0, 0, 0, 0.45), 0 0 30px rgba(246, 200, 100, 0.22), 0 30px 60px rgba(0, 0, 0, 0.75);
}
.mode-art img { filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.75)); }
.vs { font-family: var(--font-display); font-weight: 900; font-size: clamp(24px, 4.2vh, 38px); color: #e0505c; text-transform: none; text-shadow: 0 2px 0 #2a0206, 0 0 16px rgba(220, 40, 50, 0.55); }
.mode-name { white-space: nowrap; font-family: var(--font-head); font-weight: 800; font-size: clamp(16px, 2.8vh, 24px); letter-spacing: 0.1em; color: var(--gold-light); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.8); }
.mode-name img { filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.7)); }
.mode-desc { font-family: var(--font-body); font-style: italic; font-weight: 600; color: var(--ivory-2); }
.difficulty {
  padding: 8px; gap: 8px; border-radius: 12px;
  border: 2px solid transparent;
  background: linear-gradient(180deg, #1c0d0c, #0e0606) padding-box, var(--gold-edge) border-box;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.55);
}
.diff, .seg button, .tab {
  border: 2px solid transparent;
  background: radial-gradient(120% 120% at 50% 0%, var(--navy-1), var(--navy-2) 50%, var(--navy-4)) padding-box, linear-gradient(180deg, rgba(232, 190, 98, 0.75), rgba(141, 95, 26, 0.7)) border-box;
  box-shadow: inset 0 -8px 12px -8px rgba(0, 0, 0, 0.55), 0 3px 8px rgba(0, 0, 0, 0.45);
  color: var(--ivory-2);
  transition: transform 0.18s var(--royal-ease), filter 0.2s ease, box-shadow 0.2s ease;
}
.diff { border-radius: 9px; }
.diff .stars { color: var(--gold-light); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.7); }
.diff .diff-name { font-family: var(--font-head); font-weight: 700; font-size: clamp(11px, 1.8vh, 14px); letter-spacing: 0.1em; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.7); }
.diff:hover, .seg button:hover, .tab:hover { transform: translateY(-2px); filter: brightness(1.15); color: var(--ivory); }
.diff.selected, .seg button.selected, .tab.active {
  background: radial-gradient(120% 120% at 50% 0%, var(--crimson-1), var(--crimson-2) 50%, var(--crimson-4)) padding-box, var(--gold-edge-hot) border-box;
  box-shadow: inset 0 0 0 1px rgba(26, 8, 4, 0.8), 0 0 14px rgba(246, 200, 100, 0.35), 0 3px 8px rgba(0, 0, 0, 0.45);
  color: var(--gold-pale);
}
.diff.selected .stars { color: var(--gold-pale); text-shadow: 0 0 10px rgba(255, 220, 140, 0.6), 0 2px 0 rgba(0, 0, 0, 0.7); }

.tc-classic, .tc-tile {
  border: 2px solid transparent; border-radius: 12px;
  background: radial-gradient(120% 110% at 50% 0%, var(--navy-1), var(--navy-2) 45%, var(--navy-4)) padding-box, var(--gold-edge) border-box;
  box-shadow: inset 0 0 0 1px rgba(10, 6, 20, 0.8), inset 0 -14px 18px -10px rgba(0, 0, 0, 0.55), 0 8px 16px rgba(0, 0, 0, 0.5);
}
.tc-main { font-family: var(--font-head); font-weight: 800; color: var(--gold-light); letter-spacing: 0.06em; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.8); }
.tc-cat { font-family: var(--font-body); font-style: italic; font-weight: 600; color: var(--ivory-2); }
.tc-tile:hover, .tc-classic:hover { transform: translateY(-3px); filter: brightness(1.15); box-shadow: inset 0 0 0 1px rgba(10, 6, 20, 0.8), 0 0 16px rgba(246, 200, 100, 0.3), 0 12px 20px rgba(0, 0, 0, 0.55); }
.tc-tile.selected, .tc-classic.selected {
  background: radial-gradient(120% 110% at 50% 0%, var(--crimson-1), var(--crimson-2) 45%, var(--crimson-4)) padding-box, var(--gold-edge-hot) border-box;
  box-shadow: inset 0 0 0 1px rgba(26, 8, 4, 0.8), 0 0 22px rgba(246, 200, 100, 0.4), 0 8px 16px rgba(0, 0, 0, 0.5);
}
.tc-tile.selected .tc-cat, .tc-classic.selected .tc-cat { color: var(--gold-pale); }
.color-pick {
  border: 2px solid transparent; border-radius: 999px;
  background: linear-gradient(180deg, #1c0d0c, #0e0606) padding-box, var(--gold-edge) border-box;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.55);
}
.color-label { font-family: var(--font-head); font-weight: 700; font-size: 14px; letter-spacing: 0.12em; color: var(--gold-light); }
.color-btn {
  border: 2px solid transparent;
  background: radial-gradient(circle at 50% 30%, var(--navy-1), var(--navy-4)) padding-box, linear-gradient(180deg, rgba(232, 190, 98, 0.8), rgba(141, 95, 26, 0.7)) border-box;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}
.color-btn.selected {
  background: radial-gradient(circle at 50% 30%, var(--crimson-1), var(--crimson-4)) padding-box, var(--gold-edge-hot) border-box;
  box-shadow: 0 0 16px rgba(246, 200, 100, 0.5), 0 4px 10px rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   Puzzle hub + theme list
   ========================================================================== */
.hub-card { --corner: 30px; color: var(--ivory); transition: transform 0.22s var(--royal-ease), filter 0.22s ease, box-shadow 0.22s ease; }
button.hub-card:hover { transform: translateY(-4px); filter: brightness(1.1); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.7), inset 0 0 40px rgba(0, 0, 0, 0.45), 0 0 24px rgba(246, 200, 100, 0.2), 0 22px 40px rgba(0, 0, 0, 0.65); }
.hub-card > img { filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.7)); }
.hub-card.big {
  background:
    url('../assets/images/royal/corner-tl.svg') left 6px top 6px / 40px no-repeat padding-box,
    url('../assets/images/royal/corner-tr.svg') right 6px top 6px / 40px no-repeat padding-box,
    url('../assets/images/royal/corner-bl.svg') left 6px bottom 6px / 40px no-repeat padding-box,
    url('../assets/images/royal/corner-br.svg') right 6px bottom 6px / 40px no-repeat padding-box,
    url('../assets/images/royal/damask.svg') 0 0 / 96px padding-box,
    radial-gradient(120% 90% at 50% 0%, var(--crimson-1), var(--crimson-2) 45%, var(--crimson-4)) padding-box,
    var(--gold-edge) border-box;
}
.hub-card.big .hub-desc { color: var(--ivory); }
.hub-name, .theme-card b { font-family: var(--font-head); font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold-light); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.8); }
.hub-desc, .theme-card span { font-family: var(--font-body); font-style: italic; font-weight: 600; color: var(--ivory-2); }
.hub-stat, .theme-card small { font-family: var(--font-head); font-weight: 700; letter-spacing: 0.1em; color: var(--gold); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.7); }
.theme-cat h3 { font-family: var(--font-head); font-weight: 800; font-size: 16px; letter-spacing: 0.18em; color: var(--gold); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.8); }
.theme-card {
  border: 2px solid transparent; border-radius: 10px;
  background: radial-gradient(120% 120% at 50% 0%, var(--navy-2), var(--navy-3) 55%, var(--navy-4)) padding-box, linear-gradient(180deg, rgba(232, 190, 98, 0.7), rgba(141, 95, 26, 0.6)) border-box;
  box-shadow: inset 0 -10px 16px -10px rgba(0, 0, 0, 0.6), 0 6px 14px rgba(0, 0, 0, 0.45);
  color: var(--ivory);
}
.theme-card:hover { transform: translateY(-3px); filter: brightness(1.15); box-shadow: 0 0 16px rgba(246, 200, 100, 0.25), 0 10px 18px rgba(0, 0, 0, 0.5); }

/* ==========================================================================
   Settings
   ========================================================================== */
.tabs { gap: 8px; margin: 2px 0 6px; }
.tab { padding: 8px 16px; border-radius: 8px; font-family: var(--font-head); font-weight: 700; font-size: clamp(12px, 1.9vh, 14px); letter-spacing: 0.12em; text-transform: uppercase; }
.theme-grid { gap: 10px; }
.th-swatch { color: var(--ivory-2); font-family: var(--font-head); font-weight: 700; font-size: 10.5px; letter-spacing: 0.06em; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.7); padding: 7px; }
.th-swatch canvas { border-radius: 4px; border: 1px solid rgba(232, 190, 98, 0.55); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.55); }
.th-swatch.selected { background: linear-gradient(180deg, rgba(160, 24, 40, 0.55), rgba(70, 8, 16, 0.6)); box-shadow: inset 0 0 0 2px var(--gold-light), 0 0 16px rgba(246, 200, 100, 0.35); color: var(--gold-pale); }
.seg-label, .setting, .custom-row, .switch-line, .ed-label, .an-field {
  font-family: var(--font-head); font-weight: 600; letter-spacing: 0.05em; text-transform: none; color: var(--ivory); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6);
}
.setting { font-size: clamp(14px, 2.1vh, 16px); padding: 10px 14px; }
.setting > img { width: 26px; height: 26px; filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.7)); }
.setting:hover { box-shadow: inset 0 0 0 1px var(--gold-light), inset 0 2px 8px rgba(0, 0, 0, 0.4); }
.seg-label { font-size: clamp(14px, 2.1vh, 16px); }
.seg { gap: 6px; }
.seg button { padding: 6px 12px; border-radius: 7px; font-family: var(--font-head); font-weight: 700; font-size: 12.5px; letter-spacing: 0.06em; }
.switch {
  width: 58px; height: 30px; border-radius: 999px;
  border: 2px solid transparent;
  background: linear-gradient(180deg, #070b22, #141d48) padding-box, linear-gradient(180deg, #e6bb5c, #8d5f1a) border-box;
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.7);
}
.switch::after {
  top: 1px; left: 1px; width: 24px; height: 24px; border: 0;
  background: radial-gradient(circle at 35% 30%, #fff8dc, #f0c862 45%, #9a6a1e 100%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.7), inset 0 -2px 3px rgba(0, 0, 0, 0.25);
}
.setting input:checked + .switch, .switch-line input:checked + .switch { background: linear-gradient(180deg, #5c0a16, #b01d2c) padding-box, linear-gradient(180deg, #fff1b8, #b07a26) border-box; }
.setting input:checked + .switch::after, .switch-line input:checked + .switch::after { transform: translateX(28px); }
.settings-note, .ed-status { font-family: var(--font-body); font-style: italic; font-weight: 600; }
input[type=range] { accent-color: #c4313c; }
.custom-row b { color: var(--gold-light); }

/* ==========================================================================
   Promotion, results, runs, help, credits, achievements
   ========================================================================== */
.promo-btn {
  border: 2px solid transparent; border-radius: 12px;
  background: radial-gradient(120% 100% at 50% 20%, var(--navy-1), var(--navy-3) 60%, var(--navy-4)) padding-box, var(--gold-edge) border-box;
  box-shadow: inset 0 -12px 18px -10px rgba(0, 0, 0, 0.6), 0 8px 16px rgba(0, 0, 0, 0.5);
}
.promo-btn span { font-family: var(--font-head); font-weight: 800; font-size: 13px; letter-spacing: 0.12em; color: var(--gold-light); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.8); }
.promo-btn:hover {
  transform: translateY(-4px);
  background: radial-gradient(120% 100% at 50% 20%, var(--crimson-1), var(--crimson-2) 55%, var(--crimson-4)) padding-box, var(--gold-edge-hot) border-box;
  box-shadow: 0 0 22px rgba(246, 200, 100, 0.4), 0 12px 20px rgba(0, 0, 0, 0.55);
}
.result-emblem {
  width: clamp(68px, 9vh, 88px); height: clamp(68px, 9vh, 88px); margin: clamp(-54px, -7.5vh, -42px) 0 2px;
  display: grid; place-items: center;
  border: 3.5px solid transparent; border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, var(--crimson-1), var(--crimson-2) 50%, var(--crimson-4)) padding-box, var(--gold-edge) border-box;
  box-shadow: inset 0 0 0 1px rgba(26, 8, 4, 0.9), inset 0 0 0 4px rgba(246, 214, 130, 0.35), 0 0 26px rgba(246, 200, 100, 0.35), 0 10px 20px rgba(0, 0, 0, 0.6);
  rotate: 0deg;
}
.result-emblem img { width: 54%; height: 54%; animation: none; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.7)); }
.panel-result, .modal#modal-run .panel {
  width: min(440px, 92vw);
  max-height: min(94vh, calc(100vh - 20px));
  overflow-y: auto;
  overflow-x: hidden;
  padding: clamp(34px, 5vh, 46px) clamp(16px, 3.2vw, 24px) clamp(14px, 2.2vh, 20px);
  gap: clamp(5px, 1vh, 9px);
  box-sizing: border-box;
}
.panel-result .result-title, .modal#modal-run .result-title {
  font-size: clamp(20px, 3.2vh, 28px);
  margin-bottom: clamp(6px, 1.2vh, 12px);
}
.panel-result .result-sub {
  margin-top: -6px;
  font-size: clamp(12px, 1.7vh, 14.5px);
}
.rt-row {
  padding: clamp(3px, 0.6vh, 6px) clamp(8px, 1.6vw, 14px);
  gap: 8px;
}
.rt-row img { height: clamp(28px, 4.4vh, 40px); margin: 1px 0; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.6)); }
.rt-name, .rt-time, .run-stats b, .result-score, .run-stats span { font-family: var(--font-head); color: var(--ivory); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.7); letter-spacing: 0.06em; }
.rt-name { color: var(--gold-light); font-weight: 700; font-size: clamp(12px, 1.7vh, 15px); }
.rt-time { font-weight: 800; font-size: clamp(16px, 2.4vh, 22px); }
.rt-row.winner { box-shadow: inset 0 0 0 2px var(--gold-light), 0 0 18px rgba(246, 200, 100, 0.3); background: linear-gradient(180deg, rgba(150, 22, 36, 0.45), rgba(60, 6, 14, 0.5)); }
.result-score { font-weight: 800; font-size: clamp(15px, 2.2vh, 20px); color: var(--gold-light); }
.result-score small { font-family: var(--font-body); font-style: italic; color: var(--ivory-2); text-shadow: none; }
.result-score .new-best { color: var(--gold-pale); font-family: var(--font-head); font-style: normal; text-shadow: 0 0 10px rgba(255, 220, 140, 0.6); }
.result-acc { font-family: var(--font-head); color: var(--gold-light); font-size: 12px; }
.panel-result .panel-actions {
  gap: clamp(8px, 1.6vw, 16px);
  margin-top: clamp(4px, 0.8vh, 8px);
}
.panel-result .panel-actions .medal.big {
  --medal-big: clamp(44px, 6.4vh, 62px);
}
.link-btn { font-family: var(--font-head); font-weight: 700; font-size: clamp(11px, 1.4vh, 12.5px); letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold-light); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.7); }
.link-btn img { filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.7)); }
.run-stats .best b { color: var(--gold-pale); }
.help-body { font-family: var(--font-body); font-weight: 500; font-size: clamp(15px, 2.2vh, 18px); }
.help-body h3 { font-family: var(--font-head); font-weight: 800; font-size: 0.95em; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold-light); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.8); border-bottom: 1px solid rgba(232, 190, 98, 0.25); padding-bottom: 3px; }
.help-body p { color: var(--ivory-2); }
.help-body b { color: var(--gold-light); font-weight: 700; }
.help-art { float: right; width: 108px; height: auto; margin: 2px 0 4px 12px; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.6)); }
.help-art.touch { display: none; }
@media (pointer: coarse) { .help-art.keys { display: none; } .help-art.touch { display: block; } }
.credits-crest { height: 84px; filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.6)); }
.credits-text { font-family: var(--font-body); font-weight: 500; font-size: 17px; color: var(--ivory-2); }
.credits-version { font-family: var(--font-head); color: var(--gold); letter-spacing: 0.2em; }
.pgn-text, .an-field input, .ed-row select { background: rgba(6, 3, 3, 0.75); color: var(--ivory); border: 1px solid rgba(232, 190, 98, 0.45); box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6); }
.ed-row select { font-family: var(--font-head); }
.ach-card { border: 1px solid rgba(232, 190, 98, 0.35); border-radius: 9px; background: var(--well); box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4); }
.ach-card.fresh { border-color: var(--gold-light); box-shadow: 0 0 16px rgba(255, 220, 140, 0.35); }
.ach-text b { font-family: var(--font-head); font-weight: 800; color: var(--gold-light); }
.ach-text small { font-family: var(--font-head); font-weight: 700; color: var(--gold); }
.ach-text span { font-family: var(--font-body); font-style: italic; color: var(--ivory-2); }
.ach-medal { background: radial-gradient(circle at 35% 30%, #fff6d4, #f0c862 45%, #9a6a1e 100%); box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.35), 0 0 0 2px #5a3a0e, 0 0 14px rgba(255, 210, 110, 0.45); }
.ach-toast {
  border: 2px solid transparent; border-radius: 12px;
  background: url('../assets/images/royal/damask.svg') 0 0 / 96px padding-box, linear-gradient(180deg, #2a1210, #120707) padding-box, var(--gold-edge) border-box;
}

/* ==========================================================================
   In-game HUD: player plates, buttons, camera bar, toasts
   ========================================================================== */
.hud-plate {
  border: 2px solid transparent;
  border-image: none;
  border-radius: 12px;
  background:
    url('../assets/images/royal/damask.svg') 0 0 / 80px padding-box,
    radial-gradient(120% 90% at 50% 0%, rgba(130, 18, 32, 0.45), rgba(130, 18, 32, 0) 70%) padding-box,
    linear-gradient(180deg, rgba(34, 16, 14, 0.95), rgba(14, 7, 6, 0.96)) padding-box,
    var(--gold-edge) border-box;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.7), inset 0 0 0 3px rgba(232, 190, 98, 0.18), 0 10px 22px rgba(0, 0, 0, 0.55);
  filter: none;
  padding: 0 12px 0 8px;
}
.hud-plate > * { margin: 0; }
.hud-king { width: clamp(42px, 6.6vh, 56px); align-self: center; height: clamp(42px, 6.6vh, 56px); }
.hud-king img { bottom: 0; }
.hud-king.avatar img { position: static; width: 100%; height: 100%; transform: none; border-radius: 0; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.65)); }
.hud-player[data-side="w"] .hud-king.avatar, .hud-player[data-side="b"] .hud-king.avatar { border-radius: 0; box-shadow: none; }
.hud-name { font-family: var(--font-head); font-weight: 800; letter-spacing: 0.1em; color: var(--gold-light); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.8); }
.hud-time .time { font-family: var(--font-head); font-weight: 700; color: var(--ivory); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.8); }
.hud-time img { filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.7)); }
.hud-turn { width: 14px; height: 14px; border: 1px solid #8d5f1a; background: radial-gradient(circle at 35% 30%, #4a3a30, #120a07); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.8); }
.hud-player.active .hud-plate {
  transform: scale(1.03);
  background:
    url('../assets/images/royal/damask.svg') 0 0 / 80px padding-box,
    radial-gradient(120% 90% at 50% 0%, rgba(190, 28, 44, 0.6), rgba(130, 18, 32, 0) 72%) padding-box,
    linear-gradient(180deg, rgba(44, 18, 16, 0.96), rgba(16, 7, 6, 0.97)) padding-box,
    var(--gold-edge-hot) border-box;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.7), inset 0 0 0 3px rgba(255, 220, 140, 0.3), 0 0 0 2px rgba(246, 214, 130, 0.25), 0 0 26px rgba(246, 196, 90, 0.45), 0 10px 22px rgba(0, 0, 0, 0.55);
}
.hud-player.active .hud-turn { background: radial-gradient(circle at 35% 30%, #fff8dc, #f0c862 45%, #9a6a1e 100%); box-shadow: 0 0 10px rgba(255, 210, 110, 0.9); }
.hud-player.in-check .hud-plate { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.7), 0 0 0 2px rgba(255, 70, 60, 0.55), 0 0 30px rgba(230, 30, 30, 0.6), 0 10px 22px rgba(0, 0, 0, 0.55); }
.hud-player.low-time .hud-time::after { content: ''; width: 10px; height: 10px; margin-left: 4px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffb3a8, #d8352a 60%, #7a120c); box-shadow: 0 0 10px rgba(255, 60, 40, 0.9); animation: rcLow 0.6s ease-in-out infinite alternate; }
@keyframes rcLow { to { transform: scale(1.4); opacity: 0.6; } }
.hud-score {
  border: 1px solid #b9842f;
  background: linear-gradient(180deg, rgba(34, 16, 14, 0.95), rgba(14, 7, 6, 0.95));
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  font-family: var(--font-head); font-weight: 800; color: var(--gold-light); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.8);
}
.hud-score img { filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.7)); }
.hud-captured { border: 1px solid rgba(232, 190, 98, 0.4); background: rgba(14, 7, 6, 0.75); }
.hud-captured .adv { font-family: var(--font-head); font-weight: 800; color: var(--gold-light); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.8); }
.hud-buttons { gap: 9px; }
.cam-controls, .view-bar, .palette {
  border: 2px solid transparent;
  background: linear-gradient(180deg, rgba(34, 16, 14, 0.94), rgba(12, 6, 5, 0.95)) padding-box, var(--gold-edge) border-box;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.55);
}
.cam-controls { gap: 8px; padding: 7px 12px; border-radius: 14px; }
.view-bar { border-radius: 14px; }
.view-label { font-family: var(--font-head); font-weight: 800; letter-spacing: 0.1em; color: var(--gold-light); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.8); }
.view-label img { filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.7)); }

/* toasts: a velvet banner in a gold frame */
.toast {
  border: 3px solid transparent;
  border-radius: 12px;
  padding: 12px 38px 14px;
  background:
    radial-gradient(130% 120% at 50% 0%, var(--crimson-1), var(--crimson-2) 48%, var(--crimson-4)) padding-box,
    var(--gold-edge) border-box;
  box-shadow: inset 0 0 0 1px rgba(26, 8, 4, 0.9), inset 0 0 0 3px rgba(246, 214, 130, 0.4), 0 0 30px rgba(220, 40, 50, 0.35), 0 16px 34px rgba(0, 0, 0, 0.6);
  font-family: var(--font-display);
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: none;
  color: var(--gold-pale);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.7), 0 0 16px rgba(255, 200, 120, 0.45);
  display: flex; align-items: center; gap: 0.4em;
}
.toast.gold, .toast.blue {
  background:
    radial-gradient(130% 120% at 50% 0%, var(--navy-1), var(--navy-2) 48%, var(--navy-4)) padding-box,
    var(--gold-edge) border-box;
  box-shadow: inset 0 0 0 1px rgba(10, 6, 20, 0.9), inset 0 0 0 3px rgba(246, 214, 130, 0.4), 0 0 26px rgba(246, 200, 100, 0.25), 0 16px 34px rgba(0, 0, 0, 0.6);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.7), 0 0 16px rgba(255, 220, 150, 0.4);
}
.toast.small { border-width: 2px; padding: 8px 22px 9px; font-family: var(--font-head); font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }

/* ==========================================================================
   Board pages (puzzles, runs, analysis, editor)
   ========================================================================== */
.topbar { background: linear-gradient(rgba(26, 6, 10, 0.94), rgba(26, 6, 10, 0.65) 70%, rgba(26, 6, 10, 0)); }
.side-panel { --corner: 34px; padding: 16px; }
.pz-title, .run-score-n, .run-clock, .an-score, .pz-streak, .rv-score { font-family: var(--font-head); font-weight: 800; color: var(--ivory); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.8); }
.pz-title { color: var(--gold-light); }
.run-score-n { color: var(--gold-light); }
.pz-sub, .pz-meta, .run-status, .an-line, .an-moves, .an-var { font-family: var(--font-body); font-weight: 600; }
.pz-sub, .run-status { font-style: italic; }
.pz-head.good { background: linear-gradient(180deg, rgba(30, 110, 60, 0.7), rgba(10, 56, 30, 0.75)); box-shadow: inset 0 0 0 1px var(--gold-light); }
.pz-head.bad { background: linear-gradient(180deg, rgba(160, 24, 36, 0.75), rgba(70, 8, 14, 0.8)); box-shadow: inset 0 0 0 1px var(--gold-light); }
.pz-meta .chip { font-family: var(--font-head); font-weight: 700; }
.pz-meta .chip b { color: var(--gold-light); }
.combo-marks, .combo-n, .run-score-l, .an-depth { font-family: var(--font-head); font-weight: 700; }
.combo-bar { height: 14px; border: 1px solid #b9842f; background: rgba(6, 3, 3, 0.8); box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.7); }
.combo-fill { background: linear-gradient(90deg, #a8752a, #f3d27a 60%, #fff8dc); box-shadow: 0 0 10px rgba(246, 200, 100, 0.5); }
.combo-marks span.hit { color: var(--gold-light); }
.pz-history .win, .run-log .win { background: linear-gradient(180deg, #f3d27a, #c8913a); color: #2a1505; }
.pz-history .loss, .run-log .loss { background: linear-gradient(180deg, #d8404c, #8e1420); color: #fff2e6; }
.an-line { background: rgba(0, 0, 0, 0.3); }
.an-line:hover { background: rgba(150, 22, 36, 0.4); }
.an-line b { font-family: var(--font-head); font-weight: 800; color: var(--gold-light); }
.an-move { font-family: var(--font-body); font-weight: 700; }
.an-move:hover { background: rgba(246, 217, 138, 0.18); }
.an-move.current { background: linear-gradient(180deg, #f6d98a, #c8913a); color: #2a1505; }
.an-comment { color: var(--gold-light); }
.an-var { border-left-color: rgba(232, 190, 98, 0.45); }
.pal-btn { background: rgba(246, 217, 138, 0.06); }
.pal-btn:hover { background: rgba(246, 217, 138, 0.16); }
.pal-btn.selected { background: radial-gradient(circle at 50% 30%, var(--crimson-1), var(--crimson-4)); box-shadow: inset 0 0 0 2px var(--gold-light); }
.palette { border-radius: 12px; }
.evalbar { box-shadow: 0 0 0 2px #b9842f, 0 0 0 3px #2a1505, 0 6px 14px rgba(0, 0, 0, 0.6); }
.eval-text { font-family: var(--font-head); font-weight: 800; }
.ed-castle input { accent-color: #c4313c; }
.ed-status { color: var(--gold-light); }
.ed-status.bad { color: #ff8f82; }
.run-strikes .strike { box-shadow: inset 0 0 0 2px rgba(232, 190, 98, 0.5); }
.rush-btns .plaque.small { font-size: 11px; }

/* ==========================================================================
   Opening ceremony: the herald's card
   ========================================================================== */
.bc-intro { background: radial-gradient(ellipse at center, rgba(40, 6, 12, 0.72), rgba(4, 1, 2, 0.94)); }
.bc-intro-card {
  --corner: 46px;
  position: relative;
  padding: clamp(48px, 7vh, 64px) clamp(28px, 5vw, 64px) clamp(22px, 3.4vh, 30px);
  gap: 10px;
  overflow: visible;
  animation: rcRise 0.8s var(--royal-ease) both;
}
.bc-intro-crown {
  position: absolute; left: 50%; top: 0;
  width: clamp(84px, 13vh, 116px); aspect-ratio: 120 / 92;
  transform: translate(-50%, -62%);
  background: url('../assets/images/royal/crown.svg') center / contain no-repeat;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.7));
}
.bc-intro-event {
  font-family: var(--font-display); font-weight: 900; font-size: clamp(22px, 4.2vh, 42px); letter-spacing: 0.04em;
  background: var(--gold-text); -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: none; filter: drop-shadow(0 3px 0 #1a0a03) drop-shadow(0 0 18px rgba(246, 200, 100, 0.35));
}
.bc-intro-round { font-family: var(--font-head); font-weight: 700; letter-spacing: 0.3em; color: var(--gold); }
.bc-intro-round::after { content: ''; display: block; width: 240px; max-width: 70vw; height: 16px; margin: 10px auto 0; background: url('../assets/images/royal/divider.svg') center / contain no-repeat; }
.bc-intro-player img { height: clamp(84px, 16vh, 150px); filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.7)); }
.bc-intro-player b { font-family: var(--font-head); font-weight: 800; letter-spacing: 0.08em; color: var(--ivory); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.8); margin-top: 6px; }
.bc-intro-player small { font-family: var(--font-body); font-style: italic; font-weight: 600; color: var(--ivory-2); }
.bc-intro-player em { font-family: var(--font-head); font-weight: 700; color: var(--gold-light); border-radius: 999px; box-shadow: inset 0 0 0 1px rgba(232, 190, 98, 0.55); padding: 2px 10px; }
.bc-intro-vs { font-family: var(--font-display); font-weight: 900; color: #e0505c; text-shadow: 0 0 20px rgba(220, 40, 50, 0.6), 0 3px 0 #2a0206; }
.bc-intro-call { font-family: var(--font-head); font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold-light); }
.bc-intro-skip { font-family: var(--font-body); font-style: italic; color: var(--ivory-3); }

/* move-quality badges and chips keep their verdict colours but take the royal type */
.bc-badge span { font-family: var(--font-head); font-weight: 800; background: rgba(14, 7, 6, 0.9); }
.bc-badge b { font-family: var(--font-head); }
.cine-chip { font-family: var(--font-head); font-weight: 800; background: linear-gradient(180deg, rgba(34, 16, 14, 0.95), rgba(12, 6, 5, 0.94)); }
.co-kicker { font-family: var(--font-head); }
.co-sub { font-family: var(--font-body); font-weight: 600; }
.cine-phase b { font-family: var(--font-display); letter-spacing: 0.1em; text-transform: none; }

/* ==========================================================================
   Frame-rate meter (Settings → Graphics → Show frame rate)
   ========================================================================== */
.fps-meter {
  position: absolute; z-index: 70; left: 50%; top: calc(6px + var(--safe-top)); transform: translateX(-50%);
  display: none; padding: 3px 12px 2px; border-radius: 999px;
  background: rgba(10, 4, 4, 0.78); box-shadow: inset 0 0 0 1px var(--gold-line);
  font-family: var(--font-head); font-weight: 700; font-size: 12px; letter-spacing: 0.08em; color: var(--gold-light);
  font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none;
}
.fps-meter.show { display: block; }
.fps-meter.low { color: #ff9b8c; }

/* Responsive adjustments for different screen sizes and aspect ratios */
@media (max-height: 640px) {
  .modal {
    padding: clamp(12px, 2vh, 20px) 10px 10px;
  }
  .panel {
    padding: 18px 16px 14px;
    gap: 6px;
    --corner: 28px;
  }
  .pause-card {
    padding: clamp(18px, 3vh, 24px) 14px 10px;
    gap: 3px;
    max-height: 98vh;
  }
  .pause-card .card-badge {
    width: clamp(40px, 6.5vh, 48px);
    transform: translate(-50%, -55%);
  }
  .pause-card .panel-title {
    font-size: 16px;
    margin: 0 0 3px;
  }
  .pause-card .panel-title::after {
    height: 6px;
  }
  .pause-card .panel-sub {
    font-size: 10px;
    margin: -2px 0 1px;
  }
  .pause-card .vs-strip {
    padding: 2px 6px;
    gap: 6px;
    font-size: 10.5px;
  }
  .pause-card .vs-strip img {
    width: 20px;
    height: 20px;
  }
  .pause-card .pause-meta {
    font-size: 9.5px;
  }
  .pause-card .btn-resume {
    min-height: 30px;
    font-size: 13px;
    margin-top: 1px;
    border-radius: 6px;
  }
  .pause-card .btn-resume .btn-crown {
    width: 18px;
  }
  .pause-card .btn-grid2 {
    gap: 3px;
  }
  .pause-card .btn-grid2 .btn,
  .pause-card .btn.dark.wide {
    min-height: 26px;
    font-size: 9.5px;
    border-radius: 5px;
  }
  .pause-card .pause-audio {
    gap: 3px;
  }
  .pause-card .pause-audio .setting {
    padding: 2px 5px;
    font-size: 9px;
  }
  .pause-card .pause-audio .switch {
    width: 30px;
    height: 16px;
  }
  .pause-card .pause-audio .switch::after {
    width: 10px;
    height: 10px;
  }
  .pause-card .pause-audio .setting input:checked + .switch::after {
    transform: translateX(14px);
  }
  .pause-card .card-icons {
    gap: 4px;
    margin-top: 2px;
  }
  .pause-card .card-icons .sq {
    --medal: 24px;
    border-radius: 5px;
  }
  .pause-card .card-icons .sq img {
    width: 12px;
    height: 12px;
  }
  .panel-result {
    padding-top: 28px;
    padding-bottom: 10px;
  }
  .panel-result .result-emblem {
    width: 52px;
    height: 52px;
    margin: -38px 0 1px;
  }
  .panel-result .result-title {
    font-size: 18px;
  }
}

@media (max-height: 480px) {
  .pause-card {
    padding: 12px 10px 6px;
    gap: 2px;
  }
  .pause-card .card-badge {
    display: none;
  }
  .pause-card .panel-sub,
  .pause-card .pause-meta {
    display: none;
  }
  .pause-card .btn-resume {
    min-height: 26px;
    font-size: 11.5px;
  }
  .pause-card .btn-grid2 .btn,
  .pause-card .btn.dark.wide {
    min-height: 23px;
    font-size: 9px;
  }
  .pause-card .card-icons .sq {
    --medal: 20px;
  }
  .pause-card .card-icons .sq img {
    width: 10px;
    height: 10px;
  }
}

/* narrow phones */
@media (max-width: 420px) {
  .pause-audio .setting { padding: 4px 6px; font-size: 10px; }
  .pause-audio .setting > img { width: 13px; height: 13px; }
  .vs-strip { gap: 6px; font-size: 11px; letter-spacing: 0.02em; }
  .vs-strip img { width: 20px; height: 20px; }
  .pause-card { padding-left: 12px; padding-right: 12px; }
  .card-icons { gap: 4px; }
  .card-icons .sq { --medal: 26px; border-width: 1.5px; border-radius: 6px; }
  .btn-grid2 .btn { font-size: 10px; letter-spacing: 0.03em; }
  .wd-grid, .wd-grid.arms { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .wd-item { padding: 9px 5px 8px; }
  .wd-tabs button { padding-left: 6px; padding-right: 6px; font-size: 11px; }
  .wardrobe-card .panel-title { padding: 0 30px; }
  .panel, .side-panel, .mode-card, .hub-card { --corner: 26px; }
}
