/* Balatrodle on games.aong.dev, in the site's look (css/hub.css is loaded first: panels, buttons, top bar,
   footer, both themes). Behind it runs the Balatro paint swirl from mods.aong.dev (js/swirl.js, copied in by
   the build). Clue colours: --hit / --near / --miss, swapped for blue and orange by "Colour-blind colours". */
:root {
  --hit: #3fae5e; --hit-ink: #07160c;
  --near: #e2a72e; --near-ink: #1d1404;
  --miss: #5d6678; --miss-ink: #f3f5f9;
  --mult: #e0506a; --chips: #3a8ee6; --money: #e0a21f; --attention: #f08a2c;
  --t-green: #3fae5e; --t-purple: #8e5bd0; --t-teal: #2aa3a0; --t-dim: #6b7486;
  --card-w: 71px; --card-h: 95px;
}
html[data-theme="dark"] { --miss: #4a5264; --t-dim: #98a1b3; }
html.bd-cb { --hit: #2f86d9; --hit-ink: #fff; --near: #f08a2c; --near-ink: #1a0d02; }

/* ---------- the swirl ---------- */
#swirl {
  position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: -1;
  image-rendering: pixelated; pointer-events: none;
  background: radial-gradient(circle at 50% 40%, #2a6b50, #0e271f);
  view-transition-name: swirl;
}
html[data-theme="light"] #swirl { background: radial-gradient(circle at 50% 40%, #5aa58d, #2a6b50); }
.on-swirl body { background: #0e271f; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- page ---------- */
.bd-page { max-width: 1180px; margin: 0 auto; padding: calc(var(--bar) + 8px) 20px 0; display: grid; gap: 20px; }
.page-back { justify-self: start; color: #fff; text-decoration: none; font: 600 1.05rem/1 var(--f-head); text-shadow: 0 2px 0 rgba(0,0,0,.5); padding: 6px 0; }
.page-back:hover { color: var(--sun); }
.bd-page .panel { padding: 22px 24px; }
.bd-page h2 { font-size: 1.6rem; }

/* top: name, what to guess, mode, options */
.bd-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px 24px; align-items: center; }
.bd-brand h1 {
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  color: #fff; text-shadow: 0 3px 0 var(--mult), 0 6px 0 rgba(0,0,0,.35);
  -webkit-text-stroke: 1px rgba(0,0,0,.25);
}
.bd-brand p { color: var(--ink-dim); margin-top: 6px; }
.bd-controls { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.seg { display: inline-flex; padding: 4px; gap: 4px; border-radius: 12px; background: var(--panel-sub); box-shadow: inset 0 0 0 2px var(--line); }
.seg button {
  border: 0; border-radius: 8px; padding: 9px 13px 8px; cursor: pointer;
  font: 600 1rem/1 var(--f-head); color: var(--ink); background: transparent;
}
.seg button:hover { background: var(--panel-sub); }
.seg button[aria-pressed="true"] { background: var(--mult); color: #fff; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
#bd-modes button[aria-pressed="true"] { background: var(--chips); }
.bd-options { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; font-size: .95rem; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--leaf-deep); margin: 0; }
.check small { color: var(--ink-dim); font-size: .85em; }
.check-group { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; border: 0; padding: 6px 12px; margin: 0; border-radius: 10px; background: var(--panel-sub); }
.check-group legend { float: left; font: 400 .8rem/1 var(--f-label); letter-spacing: .05em; text-transform: uppercase; color: var(--ink-dim); padding: 0; margin-right: 4px; }

/* the hidden card and the guess box */
.bd-play { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 22px; align-items: center; }
.bd-play.is-loading { opacity: .7; }
.bd-mystery { width: calc(var(--card-w) * 1.6); height: calc(var(--card-h) * 1.6); }
.mystery-img { width: 100%; height: 100%; image-rendering: pixelated; filter: drop-shadow(0 6px 0 rgba(0,0,0,.3)); animation: bob 3.2s ease-in-out infinite; }
.mystery-img.is-found { animation: found .7s ease-out both, bob 3.2s ease-in-out .7s infinite; }
@keyframes bob { 50% { transform: translateY(-5px) rotate(-1.5deg); } }
@keyframes found { from { transform: rotateY(90deg) scale(.9); } to { transform: none; } }
.bd-ask { display: grid; gap: 8px; min-width: 0; }
.bd-count { font-size: 1rem; }
.bd-count b { font: 600 1.3rem/1 var(--f-head); color: var(--mult); }
.bd-hint { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--panel-sub); box-shadow: inset 0 0 0 2px dashed var(--line); }
.bd-hint b { font: 600 1.3rem/1.2 var(--f-head); letter-spacing: .18em; }
.bd-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 4px; }
.combo { position: relative; flex: 1 1 260px; min-width: 0; }
#bd-input {
  width: 100%; box-sizing: border-box; padding: 12px 14px; border-radius: 10px; border: 0;
  font: 400 1.05rem/1.2 var(--f-body); color: var(--ink); background: var(--panel-solid);
  box-shadow: inset 0 0 0 2px var(--line);
}
#bd-input:focus { outline: none; box-shadow: inset 0 0 0 3px var(--chips); }
#bd-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 5; margin: 0; padding: 6px; list-style: none;
  border-radius: 12px; max-height: 360px; overflow-y: auto;
}
#bd-list li { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 8px; cursor: pointer; }
#bd-list li[aria-selected="true"], #bd-list li:hover { background: var(--panel-sub); box-shadow: inset 0 0 0 2px var(--chips); }
#bd-list li.none { cursor: default; color: var(--ink-dim); box-shadow: none; background: none; }
.opt-img { width: 32px; height: 43px; image-rendering: pixelated; flex: none; }
.src { font: 400 .72rem/1 var(--f-label); letter-spacing: .05em; text-transform: uppercase; color: var(--ink-dim); padding: 3px 6px; border-radius: 6px; background: var(--panel-sub); margin-left: auto; }

/* ---------- the board ---------- */
.bd-board { display: grid; gap: 8px; min-width: 0; }
.bd-empty { text-align: center; color: var(--ink-dim); }
.bd-scroll { overflow-x: auto; padding-bottom: 4px; }
.row {
  display: grid; gap: 6px; align-items: stretch;
  grid-template-columns: minmax(190px, 1.7fr) repeat(var(--cols, 5), minmax(92px, 1fr));
  min-width: calc(190px + var(--cols, 5) * 98px);
}
.row-head { padding: 0 2px 2px; }
.row-head span { font: 400 .78rem/1 var(--f-label); letter-spacing: .06em; text-transform: uppercase; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.5); text-align: center; }
.row-head .h-card { text-align: left; padding-left: 8px; }
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cell {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 60px; padding: 6px 8px; border-radius: 10px; text-align: center;
  font: 600 1rem/1.1 var(--f-head);
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.22);
}
.cell.hit { background: var(--hit); color: var(--hit-ink); }
.cell.near { background: var(--near); color: var(--near-ink); }
.cell.miss { background: var(--miss); color: var(--miss-ink); }
.cell-arrow { font-size: .9rem; }
.cell.name {
  justify-content: flex-start; text-align: left; gap: 10px; background: var(--glass); color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--glass-edge), 0 6px 18px rgba(0,0,0,.15);
  -webkit-backdrop-filter: blur(14px) saturate(160%); backdrop-filter: blur(14px) saturate(160%);
}
.row.is-win .cell.name { box-shadow: inset 0 0 0 3px var(--hit), 0 6px 18px rgba(0,0,0,.15); }
.name-t { display: grid; gap: 4px; min-width: 0; }
.name-t .src { margin-left: 0; justify-self: start; }
.row-img { width: 36px; height: 48px; image-rendering: pixelated; flex: none; }
/* rarity cells keep the clue colour, with a stripe in the rarity's colour */
.cell[class*=" r-"]::before { content: ""; position: absolute; left: 6px; top: 8px; bottom: 10px; width: 4px; border-radius: 2px; background: var(--r); }
.r-common { --r: #3a8ee6; } .r-uncommon { --r: #2fbf71; } .r-rare { --r: #e0506a; } .r-legendary { --r: #a46ce0; }
.r-epic { --r: #ef6aa0; } .r-exotic { --r: #6e5cff; } .r-candy { --r: #ff9fd1; } .r-cursed { --r: #2b2b2b; }
/* a fresh row's clues flip over one by one */
.row.is-new .cell:not(.name) { animation: flip .5s ease-out both; animation-delay: var(--d, 0ms); }
.row.is-new .cell.name { animation: slide .35s ease-out both; }
@keyframes flip { from { transform: rotateX(90deg); filter: brightness(1.6); } to { transform: none; } }
@keyframes slide { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- the result ---------- */
.bd-end { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 24px; align-items: start; scroll-margin-top: calc(var(--bar) + 16px); }
.end-img { width: calc(var(--card-w) * 2.2); height: calc(var(--card-h) * 2.2); image-rendering: pixelated; filter: drop-shadow(0 8px 0 rgba(0,0,0,.3)); }
.end-main { display: grid; gap: 10px; min-width: 0; }
.end-main h2 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
.end-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-block; font: 600 .9rem/1 var(--f-head); padding: 5px 8px 4px; border-radius: 8px; background: var(--panel-sub); box-shadow: inset 0 0 0 2px var(--line); }
.tag[class*=" r-"] { background: var(--r); color: #fff; box-shadow: none; }
.tag.ty-tarot { background: var(--t-purple); color: #fff; box-shadow: none; }
.tag.ty-planet { background: var(--t-teal); color: #fff; box-shadow: none; }
.tag.ty-spectral { background: var(--chips); color: #fff; box-shadow: none; }
.tag.tag-cost { background: var(--money); color: #1d1404; box-shadow: none; }
.end-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 4px; }
.next-in b { font: 600 1.2rem/1 var(--f-head); font-variant-numeric: tabular-nums; }
.copied { min-height: 1.2em; color: var(--ink-dim); font-size: .92rem; }
.share-text { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--panel-sub); white-space: pre-wrap; user-select: all; font-size: .95rem; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 4px 0 0; }
.stats div { padding: 10px; border-radius: 10px; background: var(--panel-sub); text-align: center; }
.stats dt { font: 400 .74rem/1 var(--f-label); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-dim); }
.stats dd { margin: 6px 0 0; font: 600 1.5rem/1 var(--f-head); }
.dist { display: grid; gap: 3px; }
.dist-row { display: grid; grid-template-columns: 2.4em 1fr; gap: 8px; align-items: center; font-size: .85rem; }
.dist-bar { display: block; height: 18px; border-radius: 5px; background: var(--panel-sub); position: relative; }
.dist-bar::before { content: ""; position: absolute; inset: 0 auto 0 0; width: max(22px, calc(var(--w) * 100%)); border-radius: 5px; background: var(--miss); }
.dist-row.is-mine .dist-bar::before { background: var(--hit); }
.dist-bar b { position: relative; padding-left: 6px; font: 600 .8rem/18px var(--f-head); color: #fff; }

/* card text in Balatro's colours */
.card-text { display: grid; gap: 2px; padding: 12px 14px; border-radius: 12px; background: var(--panel-solid); box-shadow: inset 0 0 0 2px var(--line); font-size: .98rem; max-width: 52ch; }
.card-text:empty { display: none; }
.t-line { display: block; }
.t-mult, .t-red { color: var(--mult); } .t-chips, .t-blue { color: var(--chips); }
.t-money, .t-gold { color: var(--money); } .t-attention, .t-orange { color: var(--attention); }
.t-green { color: var(--t-green); } .t-inactive { color: var(--t-dim); }
.t-tarot, .t-purple, .t-dark_edition { color: var(--t-purple); } .t-planet { color: var(--t-teal); }
.t-spectral { color: var(--chips); } .t-legendary { color: #a46ce0; }
.t-white { color: #fff; }
.t-bg { padding: 0 4px; border-radius: 4px; }
.t-bg-mult, .t-bg-red { background: var(--mult); color: #fff; } .t-bg-chips, .t-bg-blue { background: var(--chips); color: #fff; }
.t-bg-attention { background: var(--attention); color: #fff; } .t-bg-money { background: var(--money); }
.t-bg-dark_edition { background: var(--t-purple); color: #fff; }
.t-small { font-size: .9em; }

/* ---------- how to play, credits ---------- */
.bd-how, .bd-credits { display: grid; gap: 12px; }
.bd-how p, .bd-credits p { color: var(--ink-dim); max-width: 75ch; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.legend li { display: flex; align-items: center; gap: 10px; }
.legend .cell { min-height: 0; padding: 6px 10px 8px; min-width: 64px; }
.how-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; }
.how-cols div { padding: 12px 14px; border-radius: 12px; background: var(--panel-sub); box-shadow: inset 0 0 0 2px var(--line); }
.how-cols dt { font: 600 1.1rem/1.2 var(--f-head); margin-bottom: 6px; }
.how-cols dd { margin: 0; color: var(--ink-dim); font-size: .95rem; }

@media (max-width: 820px) {
  .bd-top { grid-template-columns: 1fr; }
  .bd-controls { justify-content: flex-start; }
  .how-cols { grid-template-columns: 1fr; }
  .bd-end { grid-template-columns: 1fr; justify-items: start; }
}
/* on phones each guess is a small block: the card's name on top, its clues in a row under it */
@media (max-width: 640px) {
  .row { grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr)); min-width: 0; gap: 4px; }
  .rows { gap: 10px; }
  .cell.name { grid-column: 1 / -1; min-height: 0; padding: 6px 8px; flex-direction: row; font-size: .95rem; }
  .name-t { grid-auto-flow: column; align-items: center; gap: 8px; }
  .row-img { width: 27px; height: 36px; }
  .row-head .h-card { display: none; }
  .row-head span { font-size: .66rem; letter-spacing: .02em; }
  .cell { min-height: 48px; padding: 4px 3px 7px; font-size: .78rem; flex-direction: column; gap: 2px; word-break: break-word; }
  .cell[class*=" r-"]::before { left: 3px; top: 6px; bottom: 8px; width: 3px; }
  .cell-arrow { font-size: .7rem; }
}
@media (max-width: 560px) {
  .bd-page { padding-left: 12px; padding-right: 12px; }
  .bd-page .panel { padding: 18px 16px; }
  .bd-play { grid-template-columns: 1fr; justify-items: start; }
  .bd-mystery { width: calc(var(--card-w) * 1.2); height: calc(var(--card-h) * 1.2); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .seg button { padding: 8px 10px 7px; font-size: .95rem; }
}
@media (prefers-reduced-motion: reduce) {
  .mystery-img, .mystery-img.is-found, .row.is-new .cell, .row.is-new .cell.name { animation: none !important; }
}
