/* ===============================================
   KNIGHT TALE
   - Knight-Tale.html : the guide + entry page (.tl-intro)
   - Tale-Play.html   : the game page (.tl-game): left = what to do now, centre = the board (49 spaces in a 7 x 7 snake,
                        gate at the start, castle on top), right = the 12 dice, the 15 cards, the seeds.
   Game colour: orange (--ga). The brand green stays for what you do and what you win.
   =============================================== */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; min-width: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overscroll-behavior: contain; height: 100%; }
body { font-family: 'JetBrains Mono', monospace; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1, h2, h3, p { font-size: inherit; font-weight: inherit; line-height: 1.25; overflow-wrap: break-word; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
ul, ol { list-style: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

@font-face { font-family: 'JetBrains Mono'; src: url('../Source/Font/JetBrainsMono-2.304/fonts/webfonts/JetBrainsMono-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('../Source/Font/JetBrainsMono-2.304/fonts/webfonts/JetBrainsMono-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('../Source/Font/JetBrainsMono-2.304/fonts/webfonts/JetBrainsMono-Thin.woff2') format('woff2'); font-weight: 100; font-style: normal; font-display: swap; }

body[data-game="tale"] { --ga: #ff6a00; --ga-rgb: 255, 106, 0; }

.header-d-wrap, .header-p-wrap, .footer-d-wrap, .footer-p-wrap { width: 100%; flex-shrink: 0; }
.header-p-wrap, .footer-p-wrap { display: none; }
.headerc-d-logo img, .headerc-p-logo img { max-width: none; height: 148%; }

body {
  background: #090909;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100vh;
  height: 100svh;
}

/* ===== page ===== */

/* Same page frame as the other game pages: the side space is --kd-pad-x (Polish-Fluid.css: 150px, shrinking
   in a smaller window), the top space and the title come from Polish-Game.css. */
.tl-body {
  --tl-h: max(440px, calc(100svh - 306px));   /* what is left of the window under the header, title and footer */
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: 100%;
  padding: 36px var(--kd-pad-x, 150px) 20px;
  overflow-y: auto;   /* a short window scrolls the page instead of cutting the board */
  overflow-x: hidden;
}

.tl-title {
  flex-shrink: 0;
  font-weight: 700;
  font-size: 40px;
  color: #3d0018;
  text-shadow: 0 1px 1px rgba(0, 255, 146, 0.5);
}

.tl-label { font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(var(--ga-rgb), 0.9); }

.tl-box {
  background: rgba(6, 6, 6, 0.72);
  border-radius: 12px;
  border-top: 1px solid rgba(var(--ga-rgb), 0.55);   /* the game colour, like the boxes of the other games */
  box-shadow: inset 0 4px 30px 5px rgba(205, 205, 205, 0.05);   /* inside only: an outer glow would be cut by the scrolling column */
  padding: 18px 18px;
}

/* ===============================================
   GAME PAGE
   =============================================== */

.tl-topbar { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.tl-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.tl-chips div { display: flex; flex-direction: column; gap: 2px; min-width: 92px; padding: 8px 14px; border-radius: 10px; background: rgba(6, 6, 6, 0.7); outline: 1px solid rgba(205, 205, 205, 0.14); outline-offset: -1px; border-left: 2px solid rgba(var(--ga-rgb), 0.65); }
.tl-chips span { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(205, 205, 205, 0.5); }
.tl-chips b { font-size: 15px; color: #00ff92; text-shadow: 0 0 8px rgba(0, 255, 146, 0.3); }

.tl-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) calc(var(--tl-h) * 0.6154) minmax(280px, 1fr);
  column-gap: 24px;
  align-items: start;
  justify-content: center;
}

.tl-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: var(--tl-h);
  overflow-y: auto;
  scrollbar-gutter: stable;   /* the bar always has its room, so the boxes always end at the same place */
  padding: 4px 8px 8px 2px;   /* (the scroll bar is the site scroll bar: Polish-Scroll.css, 6px wide) */
}

/* Desktop: the five numbers sit exactly over the right column: the same left and right edge as the boxes under them. */
@media (min-width: 1181px) {
  .tl-topbar { display: grid; grid-template-columns: minmax(280px, 1fr) calc(var(--tl-h) * 0.6154) minmax(280px, 1fr); column-gap: 24px; align-items: center; justify-content: center; }
  .tl-title { grid-column: 1 / 3; }
  .tl-chips { grid-column: 3; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 0 14px 0 2px; }
  .tl-chips div { min-width: 0; padding: 8px clamp(6px, 0.7vw, 12px); overflow: hidden; }
  .tl-chips span { white-space: nowrap; font-size: clamp(8px, 0.62vw, 10px); letter-spacing: 0.04em; }
  .tl-chips b { white-space: nowrap; font-size: clamp(12px, 0.95vw, 15px); }
}

.tl-hud { display: flex; flex-direction: column; gap: 14px; }

/* ===== status ===== */

.tl-status { font-weight: 700; font-size: 22px; color: #ececec; }
.tl-sub { margin-top: 6px; font-size: 14px; line-height: 1.4; color: rgba(205, 205, 205, 0.62); min-height: 20px; }

/* ===== buttons ===== */

.tl-btn {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.12em;
  text-align: center;
  transition: transform 0.12s, filter 0.12s, opacity 0.12s;
}
.tl-btn:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
.tl-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.tl-btn-big { min-height: var(--tl-act-h, 68px); font-size: 24px; }
.tl-btn-main {
  color: #04140c;
  background: linear-gradient(180deg, #4dffb5, #00d676);
  box-shadow: 0 0 18px rgba(0, 255, 146, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.tl-btn-main:hover:not(:disabled) { filter: brightness(1.08); }
.tl-btn-skip { color: #cdcdcd; background: #1a0009; outline: 1px solid rgba(205, 205, 205, 0.4); outline-offset: -1px; }
.tl-btn-coin { color: var(--ga); background: rgba(var(--ga-rgb), 0.1); outline: 1px solid rgba(var(--ga-rgb), 0.7); outline-offset: -1px; box-shadow: 0 0 14px rgba(var(--ga-rgb), 0.25); }

/* the 10-second bar: the system rolls (or flips) when it runs out */
.tl-timer { height: 5px; border-radius: 3px; background: rgba(205, 205, 205, 0.1); overflow: hidden; margin-bottom: 12px; }
/* in the bet state the bar is not needed: it keeps its place (so the box does not change height) but is not drawn */
.tl-controls:has(.tl-bet-panel:not([hidden])) .tl-timer,
.tl-controls:has(.tl-pick-note:not([hidden])) .tl-timer { visibility: hidden; }
.tl-timer i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #00ff92, var(--ga)); }

.tl-controls { display: flex; flex-direction: column; }
.tl-act { display: grid; grid-template-columns: 1.5fr 1fr; gap: 10px; }
.tl-act .tl-btn-coin { min-height: var(--tl-act-h, 68px); font-size: 15px; }
/* The bet panel is exactly as high as the ROLL / FLIP COIN row, so the page never jumps when a card asks for a bet:
   the slip sits where ROLL is, BET and SKIP are stacked where FLIP COIN is. */
.tl-controls { --tl-act-h: 68px; }
.tl-bet-panel { display: grid; grid-template-columns: 1.5fr 1fr; gap: 10px; height: var(--tl-act-h); }
.tl-bet-panel .tl-slip { min-width: 0; }
.tl-bet-title { font-size: 15px; color: #cdcdcd; }
.tl-bet-title span { color: var(--ga); font-weight: 700; }
.tl-bet-row { display: flex; flex-direction: column; gap: 4px; align-items: stretch; min-width: 0; }
.tl-bet-row .tl-btn { flex: 1 1 0; min-height: 0; padding: 0 6px; font-size: 14px; letter-spacing: 0.08em; border-radius: 9px; }

/* The bet slip: the slip of the Dice, Coin and Card bet pages (built by Bet-Slip.js), in the colour of this game. */
.tl-slip .db-card-p {
  position: relative;
  width: 100%;
  height: var(--tl-act-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 1px;
  padding: 5px 10px 4px;
  font-family: 'JetBrains Mono', monospace;
  box-sizing: border-box;
  border: 1px solid rgba(var(--ga-rgb), 0.45);
  border-top: 2px solid rgba(var(--ga-rgb), 0.85);
  border-radius: 10px;
  background:
    radial-gradient(ellipse 85% 38% at 50% 0%, rgba(120, 0, 48, 0.5), rgba(0, 0, 0, 0) 72%),
    linear-gradient(180deg, rgba(18, 18, 18, 0.94), rgba(6, 6, 6, 0.94));
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55), 0 0 18px rgba(var(--ga-rgb), 0.2), inset 0 0 22px rgba(205, 205, 205, 0.03);
}
.tl-slip .db-row-head-p { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tl-slip .db-card-types { display: flex; align-items: center; justify-content: flex-start; font-size: 13px; white-space: nowrap; }
.tl-slip .db-type-btn { color: #fff; font-weight: 700; font-size: inherit; letter-spacing: 0.02em; }
.tl-slip .db-card-mult {
  display: inline-block;
  padding: 0 9px;
  border: 1px solid rgba(var(--ga-rgb), 0.4);
  border-radius: 7px;
  background: rgba(var(--ga-rgb), 0.09);
  color: var(--ga);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.35;
  white-space: nowrap;
  text-shadow: 0 0 10px rgba(var(--ga-rgb), 0.5);
}
.tl-slip .db-row-indicator-p { width: 100%; display: flex; align-items: center; justify-content: center; gap: 12px; }
.tl-slip .db-amount-value { font-size: 20px; font-weight: 700; line-height: 1.1; color: #fff; opacity: 0.55; text-shadow: none; }
.tl-slip .db-amount-value.db-active { opacity: 1; text-shadow: 0 0 14px rgba(var(--ga-rgb), 0.45); }
.tl-slip .db-sign {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(205, 205, 205, 0.3);
  border-radius: 7px;
  background: rgba(205, 205, 205, 0.05);
  font-size: 19px; line-height: 1; color: #e6e6e6;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
  transition: border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, transform 0.15s ease;
}
.tl-slip .db-sign:hover { border-color: var(--ga); color: var(--ga); background: rgba(var(--ga-rgb), 0.1); box-shadow: 0 0 12px rgba(var(--ga-rgb), 0.35); }
.tl-slip .db-sign:active { transform: scale(0.92); }
.tl-slip .db-mbet-p { width: 100%; text-align: center; font-size: 9px; line-height: 1.1; color: rgba(205, 205, 205, 0.6); white-space: nowrap; }
.tl-slip .db-mbet-sep { opacity: 0.6; }
/* Desktop: the minus, the amount and the plus sit exactly in the middle of the slip; the card name + multiplier stay on top, Min / Max at the bottom */
@media (min-width: 769px) {
  .tl-slip .db-card-p { justify-content: center; }
  .tl-slip .db-row-head-p { position: absolute; top: 6px; left: 12px; right: 12px; width: auto; }
  .tl-slip .db-row-indicator-p { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); width: auto; gap: 14px; }
  .tl-slip .db-mbet-p { position: absolute; left: 0; right: 0; bottom: 5px; width: auto; }
}
.tl-pick-note { font-size: 13px; line-height: 1.3; color: var(--ga); display: grid; grid-template-columns: 1.5fr 1fr; gap: 10px; align-items: center; min-height: var(--tl-act-h); }
.tl-pick-note p { margin: 0; }
.tl-pick-note .tl-btn { min-height: var(--tl-act-h); font-size: 13px; padding: 0 6px; }

/* ===== die, coin (the real dice and coin clips of the other games) ===== */

.tl-dice-box { display: flex; flex-direction: column; gap: 14px; }
.tl-die-row { display: flex; align-items: center; gap: 16px; }
.tl-die, .tl-coin-box {
  position: relative;
  flex: 0 0 auto;
  width: 124px;
  height: 124px;
  border-radius: 14px;
  background: rgba(6, 6, 6, 0.7);
  box-shadow: inset 0 0 20px 0 rgba(205, 205, 205, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  outline: 1px solid rgba(205, 205, 205, 0.2);
  outline-offset: -1px;
  transition: box-shadow 0.3s ease, outline-color 0.3s ease;
}
.tl-die img, .tl-coin-box img, .tl-clip { width: 88%; height: 88%; object-fit: contain; opacity: 1; transition: opacity 0.4s ease; }
.tl-clip-fade { opacity: 0; }
.tl-die.is-rolling, .tl-coin-box.is-flipping { outline-color: rgba(var(--ga-rgb), 0.8); box-shadow: inset 0 0 20px 0 rgba(205, 205, 205, 0.05), 0 0 22px rgba(var(--ga-rgb), 0.5); }
.tl-die { border-top: 1px solid rgba(var(--ga-rgb), 0.55); }
.tl-coin-box { border-radius: 50%; }
.tl-coin-box.is-ready { outline-color: rgba(0, 255, 146, 0.7); box-shadow: 0 0 16px rgba(0, 255, 146, 0.35); }
.tl-coin-box.is-used { opacity: 0.55; filter: grayscale(0.6); }
.tl-die-text { flex: 1 1 auto; display: flex; flex-direction: column; gap: 6px; }
.tl-die-note { font-size: 14px; font-weight: 700; color: #cdcdcd; min-height: 18px; }
.tl-dice-left { font-size: 12px; color: rgba(205, 205, 205, 0.55); }
.tl-knights { font-size: 11px; color: rgba(205, 205, 205, 0.45); }
/* the Knight counter: three little knights (the new horse design), lit one by one */
.tl-pips { display: flex; gap: 8px; }
.tl-pip {
  width: 22px; height: 26px;
  background: rgba(205, 205, 205, 0.2);
  -webkit-mask: url('../Source/Knight-Tale/pawn-idle.webp?v=5') center / contain no-repeat;
  mask: url('../Source/Knight-Tale/pawn-idle.webp?v=5') center / contain no-repeat;
  transition: background 0.25s ease;
}
.tl-pip.is-on { background: var(--ga); }

/* ===== the 12 dice ===== */

/* Each place is a small copy of the big die frame (.tl-die): the same dark box, the same die picture.
   Waiting = the "?" die, dim. Now = the "?" die with a soft orange glow that fades out. Rolled = the real die face. */
.tl-tray-box { display: flex; flex-direction: column; gap: 14px; padding: 18px; }
.tl-tray { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.tl-slot {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(6, 6, 6, 0.7);
  box-shadow: inset 0 0 20px 0 rgba(205, 205, 205, 0.05);
  outline: 1px solid rgba(205, 205, 205, 0.2);
  outline-offset: -1px;
  transition: box-shadow 0.3s ease, outline-color 0.3s ease;
}
.tl-slot > img { width: 88%; height: 88%; object-fit: contain; transition: opacity 0.3s ease; }
.tl-slot.is-waiting > img { opacity: 0.3; }
.tl-slot.is-current { outline-color: rgba(var(--ga-rgb), 0.8); box-shadow: inset 0 0 20px 0 rgba(205, 205, 205, 0.05), 0 0 18px 2px rgba(var(--ga-rgb), 0.35); }
.tl-slot.is-lost > img { opacity: 0.45; }
.tl-slot.is-lost::after { content: '\2713'; position: absolute; font-size: 22px; font-weight: 700; line-height: 1; color: #00ff92; text-shadow: 0 0 8px rgba(0, 255, 146, 0.6); }

/* ===== the 15 cards (small) ===== */

.tl-cards-box { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; }
.tl-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px 4px; }
.tl-mini { position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; border-radius: 8px; padding: 2px; }
.tl-mini-face { position: relative; display: block; width: 100%; aspect-ratio: 1; container-type: inline-size; }
.tl-mini-face > img { width: 100%; height: 100%; object-fit: contain; }
.tl-mini em { font-style: normal; font-size: 10px; color: rgba(205, 205, 205, 0.5); }
.tl-mini.is-dim .tl-mini-face { opacity: 0.45; }
.tl-mini.is-behind:not(.is-pick) .tl-mini-face, .tl-mini.is-behind:not(.is-pick) em { opacity: 0.5; }   /* a card the knight has passed */
.tl-mini.is-sel { outline: 2px solid var(--ga) !important; box-shadow: 0 0 16px rgba(var(--ga-rgb), 0.75) !important; animation: none !important; }
.tl-mini.is-pick { cursor: pointer; outline: 2px solid #00ff92; outline-offset: -2px; box-shadow: 0 0 14px rgba(0, 255, 146, 0.55); animation: tl-pulse 1s ease-in-out infinite; }
@keyframes tl-pulse { 50% { box-shadow: 0 0 4px rgba(0, 255, 146, 0.2); } }
.tl-legend { font-size: 11px; color: rgba(205, 205, 205, 0.55); }
.tl-legend .g { color: #4dffb5; }
.tl-legend .r { color: #ff5a6e; }
.tl-legend .m { color: #00ff92; }

.tl-ft { position: absolute; display: flex; align-items: center; justify-content: center; font-weight: 700; line-height: 1; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8); }
.tl-ft-mult { font-size: 17cqw; color: #00ff92; text-shadow: 0 0 6px rgba(0, 255, 146, 0.5); }
.tl-ft-fwd { font-size: 17cqw; color: #4dffb5; }
.tl-ft-back { font-size: 17cqw; color: #ff5a6e; text-shadow: 0 0 6px rgba(255, 90, 110, 0.5); }

/* ===== the seeds ===== */

.tl-trust { display: flex; justify-content: center; }
.tl-trust .tb-trust-box { width: 100%; padding: 6px; gap: 6px; }
.tl-trust .tb-trust-box .tb-seed-cell { flex: 1 1 0; width: auto; padding: 0 6px; gap: 6px; }
.tl-trust .tb-start-btn { display: none; }
.tl-trust .tb-trust-box-p { grid-template-rows: 26px; }

/* ===== board ===== */

.tl-board-col { position: relative; height: var(--tl-h); }

.tl-board {
  position: relative;
  height: 100%;
  aspect-ratio: 960 / 1560;
  container-type: inline-size;
  background: #0c0309 url('../Source/Knight-Tale/board-bg.webp?v=9') center / 100% 100% no-repeat;
  border-radius: 12px;
  outline: 1px solid rgba(var(--ga-rgb), 0.35);
  box-shadow: 0 0 34px rgba(var(--ga-rgb), 0.12);
  overflow: hidden;
}

.tl-castle { position: absolute; left: 22.9167%; top: 1.282%; width: 54.1667%; pointer-events: none; }
.tl-gate { position: absolute; left: 50%; bottom: 0; width: 35.83%; transform: translateX(-50%); pointer-events: none; }

.tl-tile { position: absolute; width: 12.29%; aspect-ratio: 1; transform: translate(-50%, -50%); display: flex; align-items: center; justify-content: center; }
.tl-tile > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.tl-tile > b { position: relative; font-size: 4.7cqw; font-weight: 700; color: #f4eef1; text-shadow: 0 1px 3px #000, 0 0 8px rgba(0, 0, 0, 0.55); margin-top: -0.4cqw; letter-spacing: -0.02em; }
.tl-tile.is-card > b { margin-top: -0.9cqw; margin-right: 0.5cqw; }
.tl-tile > i { position: absolute; left: 0; right: 0; bottom: 14%; text-align: center; font-style: normal; font-weight: 700; font-size: 2.2cqw; color: #00ff92; text-shadow: 0 1px 2px #000; white-space: nowrap; }
.tl-tile.is-card.is-passed > b { color: var(--ga); }
.tl-tile.is-behind > img, .tl-tile.is-behind > b, .tl-tile.is-behind > i { opacity: 0.5; }   /* a card the knight has passed */

/* the knight (a chess knight piece): the picture faces right; .is-left mirrors it on the rows that run left */
.tl-pawn {
  position: absolute;
  width: 15%;
  transform: translate(-50%, -100%);
  transition: left var(--hop-ms, 210ms) linear, top var(--hop-ms, 210ms) linear;
  pointer-events: none;
  z-index: 4;
  filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.55));
}
.tl-pawn img { transition: transform 0.12s ease-out; transform-origin: 50% 100%; }
.tl-pawn.is-left img { transform: scaleX(-1); }
.tl-pawn.is-hop img { transform: translateY(-9%); }
.tl-pawn.is-left.is-hop img { transform: scaleX(-1) translateY(-9%); }
.tl-pawn.is-back { filter: drop-shadow(0 0 0.8cqw rgba(255, 74, 94, 0.9)) drop-shadow(0 6px 6px rgba(0, 0, 0, 0.55)); }
.tl-pawn.is-win { z-index: 6; }
.tl-pawn.is-win img { animation: tl-rear 1.3s ease-in-out infinite; }
@keyframes tl-rear { 0%, 100% { transform: translateY(0) scale(1.15); } 50% { transform: translateY(-7%) scale(1.22); } }

/* ===== the win: castle lights, rays, glow, banner, fireworks, confetti ===== */
.tl-win-rays, .tl-win-glow { position: absolute; left: 50%; top: 14.6%; pointer-events: none; opacity: 0; transition: opacity 0.9s ease; }
.tl-win-rays {
  width: 170%; aspect-ratio: 1; transform: translate(-50%, -50%);
  background: repeating-conic-gradient(from 0deg, rgba(0, 255, 146, 0.3) 0deg 7deg, rgba(0, 255, 146, 0) 7deg 22deg);
  -webkit-mask-image: radial-gradient(circle, #000 4%, transparent 60%); mask-image: radial-gradient(circle, #000 4%, transparent 60%);
}
.tl-win-glow { width: 120%; aspect-ratio: 1; transform: translate(-50%, -50%); background: radial-gradient(circle, rgba(0, 255, 146, 0.5), rgba(0, 255, 146, 0) 62%); }
.tl-board.is-win .tl-win-rays { opacity: 1; animation: tl-spin 16s linear infinite; }
.tl-board.is-win .tl-win-glow { opacity: 1; animation: tl-glow 1.8s ease-in-out infinite; }
@keyframes tl-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes tl-glow { 50% { opacity: 0.55; } }
.tl-castle.is-lit { animation: tl-castle-pop 1s ease-out; filter: drop-shadow(0 0 2.4cqw rgba(0, 255, 146, 0.6)); }
@keyframes tl-castle-pop { 0% { transform: scale(1); filter: brightness(1); } 30% { transform: scale(1.07); filter: brightness(1.5) drop-shadow(0 0 3cqw rgba(0, 255, 146, 0.9)); } 100% { transform: scale(1); filter: brightness(1) drop-shadow(0 0 2.4cqw rgba(0, 255, 146, 0.6)); } }
.tl-castle { transform-origin: 50% 80%; }
.tl-fx { position: absolute; inset: 0; z-index: 7; pointer-events: none; overflow: hidden; }
.tl-fw { position: absolute; width: 1.2cqw; height: 1.2cqw; border-radius: 50%; background: var(--c); box-shadow: 0 0 1.8cqw var(--c); transform: translate(-50%, -50%); animation: tl-fw 1.15s ease-out forwards; }
@keyframes tl-fw { 0% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(calc(-50% + var(--dx) * 1cqw), calc(-50% + var(--dy) * 1cqw + 3cqw)) scale(0.3); } }
.tl-cf { position: absolute; top: -4%; left: var(--x); width: 1.6cqw; height: 2.6cqw; background: var(--c); border-radius: 2px; opacity: 0.92; animation: tl-cf 2.6s linear var(--d) forwards; }
@keyframes tl-cf { 0% { transform: translate(0, 0) rotate(0); } 100% { top: 106%; transform: translate(var(--sx), 0) rotate(720deg); } }
.tl-win-banner {
  position: absolute; left: 50%; top: 38%; z-index: 9; transform: translate(-50%, -50%) scale(0.4); opacity: 0; pointer-events: none;
  padding: 1.5cqw 3.6cqw; border-radius: 1.4cqw; background: rgba(6, 6, 6, 0.85); border: 2px solid #00ff92;
  color: #00ff92; font-weight: 700; font-size: 4.4cqw; letter-spacing: 0.14em; white-space: nowrap;
  text-shadow: 0 0 12px rgba(0, 255, 146, 0.7); box-shadow: 0 0 34px rgba(0, 255, 146, 0.5);
}
.tl-win-banner.is-on { animation: tl-banner 3.2s ease-out forwards; }
@keyframes tl-banner { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); } 12% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); } 20% { transform: translate(-50%, -50%) scale(1); } 88% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -58%) scale(1); } }

.tl-burst { position: absolute; width: 22%; aspect-ratio: 1; transform: translate(-50%, -50%) scale(0.2); opacity: 0; pointer-events: none; z-index: 5; display: flex; align-items: center; justify-content: center; }
.tl-burst img { position: absolute; inset: 0; width: 100%; height: 100%; }
.tl-burst span { position: relative; font-size: 7cqw; font-weight: 700; color: #fff; text-shadow: 0 2px 6px #000; }
.tl-burst.is-on { animation: tl-burst 1s ease-out forwards; }
@keyframes tl-burst { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.2); } 25% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -80%) scale(1); } }

/* ===== the card that was just turned over (on top of the board) ===== */

.tl-reveal-wrap { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); z-index: 8; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: 62%; }
.tl-reveal { width: 70%; aspect-ratio: 1; perspective: 900px; filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.7)); }
.tl-flip { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 0.55s ease-in-out; }
.tl-reveal.is-flipped .tl-flip { transform: rotateY(180deg); }
.tl-flip-back, .tl-flip-front { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; container-type: inline-size; }
.tl-flip-back img, .tl-flip-front > img { width: 100%; height: 100%; object-fit: contain; }
.tl-flip-front { transform: rotateY(180deg); }
.tl-reveal-note { font-size: 14px; font-weight: 700; text-align: center; color: #00ff92; text-shadow: 0 1px 4px #000, 0 0 10px rgba(0, 0, 0, 0.9); background: rgba(6, 6, 6, 0.75); border-radius: 8px; padding: 2px 8px; }
.tl-reveal-note:empty { display: none; }

/* ===== end of the round ===== */

.tl-modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(0, 0, 0, 0.62); }
.tl-modal-box { width: min(440px, 100%); padding: 24px 22px; text-align: center; border-radius: 14px; background: #0b0307; border-top: 2px solid rgba(var(--ga-rgb), 0.8); box-shadow: 0 0 50px rgba(120, 0, 48, 0.55); display: flex; flex-direction: column; gap: 14px; }
.tl-modal.is-win .tl-modal-box { border-top-color: #00ff92; box-shadow: 0 0 60px rgba(0, 255, 146, 0.3); }
.tl-modal-title { font-size: 22px; font-weight: 700; color: #cdcdcd; }
.tl-modal.is-win .tl-modal-title { color: #00ff92; text-shadow: 0 0 10px rgba(0, 255, 146, 0.5); }
.tl-modal-body { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: rgba(205, 205, 205, 0.8); }
.tl-modal-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tl-modal-btns #tl-modal-again { grid-column: 1 / -1; }

/* ===============================================
   GUIDE + ENTRY PAGE
   =============================================== */

/* The page keeps its height (like the other game pages): the title and the entry stay, only the "how to play" list scrolls inside its box.
   Same side space as the other pages: the intro fills the width of the body (the body has --kd-pad-x on both sides). */
.tl-intro-body { overflow-y: auto; overflow-x: hidden; padding-bottom: 20px; }
.tl-intro { flex: 1 1 auto; min-height: 0; width: 100%; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); grid-template-rows: auto minmax(240px, 1fr); gap: 16px 32px; align-items: start; }
.tl-intro-head { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 16px; }
.tl-lead { font-size: 16px; color: rgba(205, 205, 205, 0.75); }

.tl-steps { display: flex; flex-direction: column; gap: 10px; height: 100%; min-height: 0; }
.tl-steps .tl-label { margin-bottom: 2px; }
.tl-steps-list { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; overflow-x: hidden; padding: 2px 10px 6px 0; }
.tl-steps-list > .tl-step { flex-shrink: 0; }
.tl-step { display: grid; grid-template-columns: 56px 1fr; gap: 16px; align-items: center; padding: 12px 16px; }
.tl-step img { width: 56px; height: 56px; object-fit: contain; }
.tl-step p { font-size: 14px; line-height: 1.45; color: rgba(205, 205, 205, 0.8); }
.tl-step b { color: #ececec; }
.tl-offer { display: flex; flex-direction: column; gap: 12px; }
.tl-offer-box { display: flex; flex-direction: column; gap: 14px; padding: 18px; border-top-color: rgba(var(--ga-rgb), 0.8); box-shadow: inset 0 4px 30px 5px rgba(205, 205, 205, 0.05), 0 0 30px rgba(var(--ga-rgb), 0.14); }
.tl-offer-rows { display: flex; flex-direction: column; }
.tl-offer-rows div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 0; border-bottom: 1px solid rgba(205, 205, 205, 0.1); font-size: 14px; }
.tl-offer-rows span { color: rgba(205, 205, 205, 0.6); }
.tl-offer-rows b { color: var(--ga); text-align: right; text-shadow: 0 0 8px rgba(var(--ga-rgb), 0.35); }
.tl-offer-rows div:first-child b { font-size: 20px; }
.tl-offer-note { font-size: 13px; line-height: 1.4; text-align: center; color: rgba(205, 205, 205, 0.6); min-height: 18px; }

/* smaller screens: a smaller die and coin, so the text beside them (and the three knights) always fits */
@media (max-width: 1400px) {
  .tl-die, .tl-coin-box { width: 104px; height: 104px; }
  .tl-die-row { gap: 12px; }
  .tl-pips { flex-wrap: wrap; gap: 6px; }
  .tl-pip { width: 20px; height: 24px; }
}

/* ===== tablet / narrow desktop: the page scrolls. The board stays in view on the right, the controls,
   the dice, the cards and the seeds run down the left. ===== */

@media (min-width: 769px) and (max-width: 1180px) {
  /* board width: 42% of the window, but never taller than the window (and between 300 and 440px) */
  .tl-body { --tl-bw: clamp(300px, min(42vw, calc((100svh - 250px) * 0.6154)), 440px); }
  .tl-stage { flex: 0 0 auto; grid-template-columns: minmax(0, 1fr) var(--tl-bw); row-gap: 14px; column-gap: 20px; align-items: start; justify-content: stretch; padding-bottom: 8px; }
  .tl-col { display: contents; }
  .tl-hud, .tl-dice-box, .tl-tray-box, .tl-cards-box, .tl-trust { grid-column: 1; }
  .tl-board-col { grid-column: 2; grid-row: 1 / span 5; position: sticky; top: 0; align-self: start; height: auto; width: 100%; }
  .tl-board { height: auto; width: 100%; }
  .tl-intro { grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); gap: 16px 20px; }
}

/* ===============================================
   PHONE (768px and less): one column, the board under the controls; the controls stay on top while you scroll
   =============================================== */
@media (max-width: 768px) {
  .header-d-wrap, .footer-d-wrap { display: none; }
  .header-p-wrap, .footer-p-wrap { display: block; }

  .tl-body {
    gap: 14px;
    padding: 16px 20px 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
  .tl-title { font-size: 30px; }

  .tl-topbar { gap: 8px; }
  .tl-chips { gap: 6px; width: 100%; display: grid; grid-template-columns: repeat(5, 1fr); }
  .tl-chips div { min-width: 0; padding: 5px 6px; }
  .tl-chips span { font-size: 9px; letter-spacing: 0.04em; }
  .tl-chips b { font-size: 12px; }

  .tl-stage { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 14px; flex: 0 0 auto; }
  .tl-col { display: contents; }
  .tl-hud { order: 1; position: sticky; top: -1px; z-index: 20; padding: 6px 0 4px; }
  .tl-board-col { order: 2; height: auto; width: 100%; max-width: 440px; align-self: center; }
  .tl-board { height: auto; width: 100%; }
  .tl-dice-box { order: 3; }
  .tl-tray-box { order: 4; }
  .tl-cards-box { order: 5; }
  .tl-trust { order: 6; padding-bottom: 12px; }

  /* the top (sticky) part is low on a phone: the report box, then the roll / bet row */
  .tl-hud { gap: 8px; }
  /* While you scroll, the two boxes stay on top as two separate boxes: a thin orange line, round corners, a small gap between them */
  .tl-hud .tl-box { border: 1px solid rgba(var(--ga-rgb), 0.6); border-radius: 12px; background: rgba(9, 9, 9, 0.96); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
  .tl-msg.tl-box { padding: 8px 12px; }
  .tl-status { font-size: 15px; line-height: 1.2; }
  .tl-sub { font-size: 11px; line-height: 1.35; margin-top: 2px; min-height: 30px; }
  .tl-btn { min-height: 44px; font-size: 15px; }
  .tl-controls.tl-box { padding: 12px 12px; }
  .tl-controls { --tl-act-h: 40px; }
  .tl-timer { height: 4px; margin-bottom: 10px; }
  .tl-btn-big, .tl-act .tl-btn-coin, .tl-pick-note .tl-btn { min-height: var(--tl-act-h); }
  .tl-act .tl-btn-coin { font-size: 13px; }
  /* The bet row on a phone: SKIP on the left, the slip in the middle, BET on the right.
     The slip is ONE line: "Card 10", minus, the amount, plus, the multiplier. (The Min / Max line is in the report box above.) */
  .tl-bet-panel { grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px; align-items: stretch; }
  .tl-bet-row { display: contents; }
  .tl-bet-row .tl-btn { flex: none; min-height: 0; height: var(--tl-act-h); min-width: 54px; padding: 0 6px; font-size: 13px; letter-spacing: 0.06em; }
  #tl-skip-btn { order: 1; }
  .tl-bet-panel .tl-slip { order: 2; }
  #tl-bet-btn { order: 3; }
  .tl-slip .db-card-p { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto auto; align-items: center; column-gap: 4px; padding: 0 6px; }
  .tl-slip .db-row-head-p, .tl-slip .db-row-indicator-p { display: contents; }
  .tl-slip .db-card-types { grid-row: 1; grid-column: 1; font-size: 11px; }
  .tl-slip .db-sign:first-child { grid-row: 1; grid-column: 2; }
  .tl-slip .db-amount-value { grid-row: 1; grid-column: 3; font-size: 17px; text-align: center; }
  .tl-slip .db-sign:last-of-type { grid-row: 1; grid-column: 4; }
  .tl-slip .db-card-mult { grid-row: 1; grid-column: 5; font-size: 11px; line-height: 1.25; padding: 0 4px; }
  .tl-slip .db-sign { width: 22px; height: 22px; font-size: 16px; }
  .tl-slip .db-mbet-p { display: none; }
  .tl-btn-big { font-size: 17px; }
  .tl-box { padding: 12px 14px; }
  .tl-die, .tl-coin-box { width: 72px; height: 72px; }
  .tl-die-row { gap: 12px; }
  .tl-dice-box { gap: 8px; }
  .tl-reveal-wrap { width: 76%; }
  .tl-modal-btns { grid-template-columns: 1fr 1fr; }
  /* the 12 dice that landed: two rows of six, so each one is big enough to read */
  .tl-tray-box { padding: 12px 14px; gap: 10px; }
  .tl-tray { grid-template-columns: repeat(6, 1fr); gap: 8px; }

  .tl-intro-body { padding-top: 14px; }
  .tl-intro { flex: none; grid-template-columns: 1fr; grid-template-rows: auto; gap: 12px; }
  .tl-steps { height: auto; }
  .tl-steps-list { overflow: visible; padding: 0; }
  .tl-offer { order: -1; }
  .tl-intro-head { order: -2; }
  .tl-step { grid-template-columns: 44px 1fr; gap: 12px; }
  .tl-step img { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .tl-pawn, .tl-pawn img, .tl-flip { transition: none; }
  .tl-mini.is-pick, .tl-burst.is-on, .tl-pawn.is-win img, .tl-board.is-win .tl-win-rays, .tl-board.is-win .tl-win-glow, .tl-castle.is-lit { animation: none; }
  .tl-fx { display: none; }
  .tl-win-banner.is-on { animation: none; opacity: 1; transform: translate(-50%, -50%); }
}
