/* Presentation polish: hover/press states, panel entrances, overlays, settings, roster popover, sound board. */

/* ---------- buttons and tiles ---------- */
.big, .row button, .seg button, .invite-box button, .tile, .mini, .btn { transition: transform .08s, box-shadow .08s, filter .12s, background-color .12s; }
@media (hover: hover) {
  .big:hover:not(:disabled), .row button:hover, .seg button:hover, .invite-box button:hover {
    transform: translateY(-2px); box-shadow: 0 6px 0 var(--ink); filter: brightness(1.05);
  }
  .tile:hover:not(:disabled) { transform: translateY(-3px) rotate(-1deg); box-shadow: 0 6px 0 var(--ink); filter: brightness(1.04); }
  .mini:hover, .btn:hover { filter: brightness(1.08); }
  .link:hover { color: #b0571a; }
}
.big:active:not(:disabled), .row button:active, .seg button:active, .invite-box button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); filter: brightness(.96); }
.tile:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.mini:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.big:focus-visible, .tile:focus-visible, .btn:focus-visible, .mini:focus-visible, .link:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.tile.on canvas { animation: tile-bob 1.6s ease-in-out infinite; }
@keyframes tile-bob { 50% { transform: translateY(-3px); } }

.links { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.no-hotkeys .btn .key { display: none; }

/* ---------- panels fade in ---------- */
.screen:not([hidden]) { animation: screen-in .22s ease-out both; }
.screen:not([hidden]) > .panel { animation: panel-in .32s cubic-bezier(.2, 1.35, .45, 1) both; }
@keyframes screen-in { from { background-color: rgba(30, 18, 8, 0); } }
@keyframes panel-in { from { opacity: 0; transform: translateY(18px) scale(.96); } }

/* ---------- countdown ---------- */
#countdown { position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 25; }
#countdown span { font-family: var(--font); font-size: clamp(64px, 16vw, 140px); color: #fff; -webkit-text-stroke: 3px var(--ink);
  text-shadow: 0 6px 0 var(--ink), 0 10px 18px rgba(0,0,0,.3); animation: count-pop .45s cubic-bezier(.2, 1.6, .4, 1) both; }
#countdown span.go { color: #ffcf33; animation: count-go .9s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes count-pop { from { transform: scale(2.2); opacity: 0; } 60% { opacity: 1; } to { transform: scale(1); } }
@keyframes count-go { 0% { transform: scale(.3) rotate(-8deg); opacity: 0; } 30% { transform: scale(1.15) rotate(3deg); opacity: 1; } 75% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.4); opacity: 0; } }

/* ---------- victory / defeat ---------- */
#over { overflow: hidden; }
#over.win .panel { animation: over-win .7s cubic-bezier(.2, 1.4, .4, 1) both; }
#over.lose .panel { animation: over-lose .9s cubic-bezier(.3, 1.2, .5, 1) both; }
#over.win #over-title { animation: title-bounce 1.2s cubic-bezier(.2, 1.6, .4, 1) both, title-glow 2.4s 1.2s ease-in-out infinite; }
#over.lose #over-title { color: #9fb3c8; animation: title-droop 1.4s ease-out both; }
@keyframes over-win { from { opacity: 0; transform: scale(.6) rotate(-3deg); } }
@keyframes over-lose { from { opacity: 0; transform: translateY(-40px); } 60% { transform: translateY(6px); } }
@keyframes title-bounce { 0% { transform: scale(.2); } 50% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes title-glow { 50% { transform: scale(1.04); filter: brightness(1.15); } }
@keyframes title-droop { 0% { transform: translateY(-20px); opacity: 0; } 50% { transform: none; opacity: 1; } 70% { transform: rotate(2deg); } 100% { transform: rotate(-1.5deg) translateY(2px); } }
.ov-stats { display: grid; gap: 3px; background: #fff7e2; border: 3px solid var(--ink); border-radius: 14px; padding: 8px 12px; font-weight: 800; }
.ov-stats > div { display: grid; grid-template-columns: 1fr 72px 72px; align-items: center; gap: 6px; animation: row-in .35s calc(.25s + var(--i, 0) * .09s) both; }
.ov-stats > div b { font-family: var(--font); font-weight: 700; font-size: 19px; text-align: right; font-variant-numeric: tabular-nums; }
.ov-stats .hd { border-bottom: 2px solid var(--parch-d); padding-bottom: 3px; animation: none; }
.ov-stats .hd b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-stats .hd b:nth-child(2) { color: var(--p0); }
.ov-stats .hd b:nth-child(3) { color: var(--p1); }
.ov-stats .time { grid-template-columns: 1fr auto; border-top: 2px solid var(--parch-d); padding-top: 3px; }
.ov-stats span { font-size: 14px; color: #7a5a3a; }
@keyframes row-in { from { opacity: 0; transform: translateX(-10px); } }
.ov-fx { position: absolute; inset: 0; pointer-events: none; }
.ov-fx i { position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px; opacity: 0; animation: confetti linear both; }
#over.lose .ov-fx i { width: 2px; height: 16px; border-radius: 1px; animation-name: drizzle; animation-iteration-count: infinite; }
@keyframes confetti { 0% { opacity: 1; transform: translate(0, 0) rotate(0); } 100% { opacity: .9; transform: translate(var(--dx), 105vh) rotate(var(--r)); } }
@keyframes drizzle { 0% { opacity: .5; transform: translateY(0); } 100% { opacity: .2; transform: translateY(105vh); } }

/* ---------- roster popover ---------- */
#roster { position: fixed; z-index: 40; background: var(--parch); border: 3px solid var(--ink); border-radius: 14px; padding: 8px 10px; pointer-events: none;
  box-shadow: 0 5px 0 rgba(42, 27, 16, .5); animation: panel-in .2s ease-out both; }
#roster b { font-family: var(--font); font-weight: 700; font-size: 17px; display: block; margin-bottom: 4px; }
#roster .grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px 2px; }
#roster .grid > div { display: flex; flex-direction: column; align-items: center; min-width: 0; }
#roster .grid > div.spell canvas { background: linear-gradient(#e9f6ff, #b9dcf5); border-radius: 8px; }
#roster canvas { width: 40px; height: 40px; }
#roster small { font-size: 10px; font-weight: 800; line-height: 1.1; text-align: center; color: #5a3a1a; overflow: hidden; text-overflow: ellipsis; max-width: 100%; white-space: nowrap; }

/* ---------- settings ---------- */
.settings .slider { display: grid; grid-template-columns: 1fr 52px; align-items: center; gap: 2px 10px; font-weight: 800; font-size: 15px; }
.settings .slider span { grid-column: 1 / -1; }
.settings .slider output { font-family: var(--font); font-size: 16px; text-align: right; }
.settings input[type=range] { padding: 0; border: 0; background: none; width: 100%; height: 28px; accent-color: #f2a91f; min-width: 0; }
.settings .check { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 15px; cursor: pointer; }
.settings input[type=checkbox] { width: 22px; height: 22px; padding: 0; accent-color: #f2a91f; flex: none; }
.settings .row.end { align-items: center; justify-content: space-between; }

/* ---------- sound board ---------- */
.sb-screen { position: fixed; inset: 0; z-index: 45; overflow-y: auto; padding: 16px; background: rgba(30, 18, 8, .55); }
.sb-screen[hidden] { display: none; }
.sb { width: min(980px, 100%); }
.sb-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sb h4 { margin: 8px 0 2px; font-family: var(--font); font-weight: 700; font-size: 16px; color: #7a4a20; }
.sb-row { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; padding: 2px 0; }
.sb-row > b { width: 150px; font-family: var(--font); font-weight: 700; font-size: 15px; }
.sb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 5px; }
.sb-btn { display: flex; flex-direction: column; align-items: flex-start; border: 2px solid var(--ink); border-radius: 10px; background: #fff3d6; padding: 4px 9px;
  box-shadow: 0 2px 0 var(--ink); font-weight: 800; font-size: 13px; text-align: left; }
.sb-btn small { font-size: 10px; color: #8a6a4a; font-weight: 700; }
.sb-btn.on { background: linear-gradient(#ffe48a, #ffc23a); }
.sb-btn.hit { animation: sb-hit .25s ease-out; }
@keyframes sb-hit { 0% { background: #ffd23f; transform: scale(.95); } }
.sb-int { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 13px; }
.sb-int input { padding: 0; border: 0; background: none; accent-color: #f2a91f; }

@media (max-width: 420px) {
  .panel { padding: 16px 14px 14px; }
  .ov-stats > div { grid-template-columns: 1fr 56px 56px; }
  #roster .grid { grid-template-columns: repeat(4, 1fr); }
  .sb-row > b { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .screen:not([hidden]), .screen:not([hidden]) > .panel, #over .panel, #over-title, .ov-stats > div, .tile.on canvas, #countdown span { animation: none !important; }
}
body.reduce-motion .screen:not([hidden]), body.reduce-motion .screen:not([hidden]) > .panel, body.reduce-motion #over .panel, body.reduce-motion #over-title,
body.reduce-motion .ov-stats > div, body.reduce-motion .tile.on canvas, body.reduce-motion #countdown span { animation: none !important; }
html.cb-sim { filter: url(#deuteranopia); }
/* Settings → About: the version and the build (for bug reports) */
.settings .about { border-top: 2px dashed #c9a46a; padding-top: 8px; }
.settings .about h3 { margin: 0 0 4px; }
.settings .about p { margin: 2px 0; font-weight: 700; font-size: 16px; }
.settings .about code { font-size: 15px; background: #fff7e2; border: 2px solid var(--ink); border-radius: 6px; padding: 0 6px; user-select: all; }
.settings .about .links { display: flex; flex-wrap: wrap; gap: 0 14px; }
.settings .about .links a, .settings .about .links .link { min-height: 44px; display: inline-flex; align-items: center; font-size: 16px; }
/* blind pick: an opponent's face before the start */
.pcard .qface { width: 56px; height: 56px; flex: none; display: grid; place-items: center; border: 3px dashed #a8692f; border-radius: 50%;
  font: 700 30px var(--font); color: #a8692f; background: #fff3d6; }
/* the VS screen between Ready and the first tick: both sides' crests, players and factions, and the map */
#reveal { position: fixed; inset: 0; z-index: 26; display: grid; grid-template-columns: 1fr auto 1fr; grid-template-rows: 1fr auto; align-items: center;
  gap: 8px 24px; padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at center, rgba(42, 27, 16, .72), rgba(42, 27, 16, .94)); color: #fff7e2; font-family: var(--font);
  transition: opacity .25s; }
#reveal[hidden] { display: none; }
#reveal.out { opacity: 0; }
#reveal .rv-side { display: flex; flex-direction: column; gap: 14px; align-items: center; animation: rv-in-l .45s cubic-bezier(.2, 1.3, .4, 1) both; }
#reveal .rv-side.t1 { animation-name: rv-in-r; }
#reveal .rv-p { display: grid; justify-items: center; gap: 2px; text-align: center; }
#reveal .rv-p canvas { width: clamp(88px, 16vw, 160px); height: clamp(88px, 16vw, 160px); filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .45)); }
#reveal .rv-p b { font-size: clamp(22px, 3.4vw, 36px); font-weight: 700; -webkit-text-stroke: 1px var(--ink); paint-order: stroke; text-shadow: 0 3px 0 var(--ink); }
#reveal .rv-p span { font-size: clamp(16px, 2vw, 20px); font-weight: 600; opacity: .9; }
#reveal .t0 .rv-p b { color: #9cc6ff; } #reveal .t1 .rv-p b { color: #ffb0a6; }
#reveal .rv-vs { justify-self: center; font-size: clamp(48px, 9vw, 110px); font-weight: 700; color: #ffcf33; -webkit-text-stroke: 3px var(--ink); paint-order: stroke;
  text-shadow: 0 6px 0 var(--ink); animation: rv-vs .5s .15s cubic-bezier(.2, 1.6, .4, 1) both; }
#reveal .rv-map { grid-column: 1 / -1; justify-self: center; font-size: 20px; font-weight: 600; padding: 6px 18px; border: 3px solid var(--ink);
  border-radius: 999px; background: var(--parch); color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
#reveal .rv-map::before { content: '⚑ '; }
@keyframes rv-in-l { from { transform: translateX(-40vw); opacity: 0; } }
@keyframes rv-in-r { from { transform: translateX(40vw); opacity: 0; } }
@keyframes rv-vs { from { transform: scale(2.4); opacity: 0; } }
body.reduce-motion #reveal * { animation: none !important; }
@media (max-width: 600px) and (orientation: portrait) {
  #reveal { grid-template-columns: 1fr; grid-template-rows: 1fr auto 1fr auto; gap: 6px; justify-items: center; }
  #reveal .rv-side.t0 { align-self: end; } #reveal .rv-side.t1 { align-self: start; }
  #reveal .rv-side { flex-direction: row; justify-content: center; gap: 18px; }
  #reveal .rv-map { grid-column: 1; }
}
/* the VS screen: a Greek player's patron god under its faction (announced here, blind until now) */
#reveal .rv-p .rv-god { display: flex; align-items: center; gap: 6px; margin: 2px 0; }
#reveal .rv-p .rv-god canvas { width: clamp(40px, 6vw, 64px); height: clamp(40px, 6vw, 64px); }
#reveal .rv-p .rv-god span { font-size: clamp(15px, 1.9vw, 20px); font-weight: 700; color: #ffe08a; }
