/* Palette and printed-card treatment from the supplied design. */
:root {
  --bg: #122b55;
  --surface: #193862;
  --surface2: #234775;
  --surface3: #365b87;
  --accent: #ffab57;
  --accent-hover: #ffbc7a;
  --success: #87df9c;
  --danger: #ff8c95;
  --warn: #ffd16b;
  --info: #afe2ef;
  --text: #fffdf6;
  --muted: #bfd0e4;
  --radius: 14px;
}
body { background: radial-gradient(ellipse at 50% 0, #234b7c, transparent 65%), var(--bg); }
body::before { background-image: radial-gradient(#b4dfed26 1px, transparent 1px); background-size: 24px 24px; }
.ambient-grid::before, .ambient-grid::after { border-color: #b4dfed33; box-shadow: none; }
.card-panel { background: #17345c; border: 1px solid #54759a; box-shadow: 0 14px 35px #081b3438; backdrop-filter: none; }
.card-panel::before { background: #f47b20; height: 4px; opacity: 1; }
#screen-home .card-panel { max-width: 590px; margin: 12px auto; padding: 28px 42px; overflow: visible; }
#screen-home .card-panel::before { display: none; }
.eyebrow { margin: 0 0 25px; color: #c5e6ef; font-size: .65rem; }
.game-owners { width: fit-content; max-width: 100%; margin: 0 auto 20px; padding: 8px 14px; border-radius: 8px; background: #fffdf6; }
.game-owner-logos { display: flex; align-items: center; justify-content: center; gap: 16px; }
.game-owner-logos img { display: block; object-fit: contain; height: auto; }
.owner-leg, .owner-sbm { width: clamp(95px, 24vw, 125px); }
.owner-kppu { width: clamp(125px,28vw,160px); flex-shrink: 0; }
.subtitle { margin: 16px auto; font-size: .9rem; }
.reference-decks { display: flex; align-items: center; justify-content: center; gap: 15px; height: 157px; margin: 22px 0; }
.reference-decks img { width: 86px; height: auto; border-radius: 5px; box-shadow: 0 8px 12px #081b3455; }
.reference-decks img:first-child { transform: rotate(-10deg) translateY(5px); }
.reference-decks img:nth-child(2) { width: 96px; z-index: 1; }
.reference-decks img:last-child { transform: rotate(10deg) translateY(5px); }
.feature-strip { margin-bottom: 22px; }
.feature-strip span { color: #d3eaf2; background: #234775; border-color: #54759a; }
.top-bar { background: #193862; border-color: #54759a; }
input[type="text"], input[type="number"], select { background: #102b50; border: 1px solid #7290b0; color: var(--text); border-radius: 10px; padding: 12px 14px; font: inherit; width: 100%; outline: none; }
input::placeholder { color: #afc2da; opacity: 1; }
input:focus, select:focus { border-color: #ffab57; box-shadow: 0 0 0 3px #ffab5733; }
select option { color: #fff; background: #102b50; }
button:focus-visible, .action-card:focus-visible { outline: 3px solid #afe2ef; outline-offset: 4px; }
.btn-primary, .btn-join-quick { background: #f47b20; color: #192c49; font-weight: 800; box-shadow: 0 4px 0 #b95311; }
.btn-primary:hover, .btn-join-quick:hover { background: #ffab57; box-shadow: 0 4px 0 #b95311; }
.btn-secondary, .btn-num { background: #2c5180; border-color: #7290b0; }
.btn-secondary:hover, .btn-num:hover { background: #3c6698; }
.room-code-display { background: #102b50; border-color: #9abacf; }
.demand-badge { background: #f47b20; color: #192c49; font-weight: 850; border-color: #ffc189; }
.action-card, .action-card.kppu-card { background: #145322; border: 5px solid #fffdf3; border-radius: 9px; padding: 18px 14px; box-shadow: inset 0 0 0 2px #145322, inset 0 0 0 4px #c2dfb4, 0 8px 16px #071b3340; }
.action-card::after { content: 'KPPU'; transform: none; right: 12px; bottom: 7px; font-size: .5rem; letter-spacing: .12em; color: #d3eac4; }
.action-card .card-label { font-family: inherit; color: #fffdf3; font-weight: 800; }
.action-card .card-type { color: #d9edb4; }
.action-card .card-desc { color: #174323; background: #fffdf3; border: 0; padding: 10px; border-radius: 5px; margin-bottom: 12px; }
.action-card:hover, .action-card.selected, .action-card.kppu-card:hover, .action-card.kppu-card.selected { background: #216632; border-color: #ffd16b; box-shadow: 0 0 0 3px #f47b20, 0 12px 24px #071b3355; }
.action-card.kppu-card { background: #24548b; }
.demand-card-big { background: #f47b20; border: 6px solid #fffdf3; border-radius: 9px; box-shadow: inset 0 0 0 3px #ffd095, 0 16px 30px #071b3355; }
.demand-card-big::before { content: 'KARTU PERMINTAAN'; color: #fffdf3; }
.demand-card-big .demand-num { color: #17345c; text-shadow: none; background: #ffd16b; border: 3px dashed #fff0bf; border-radius: 50%; width: 110px; height: 110px; display: grid; place-items: center; margin: 0 auto 14px; }
.demand-sub { color: #172d4b; font-weight: 750; }
.table-felt { --board-tilt-x: 0deg; --board-tilt-y: 0deg; --board-light-x: 50%; --board-light-y: 50%; background: repeating-linear-gradient(3deg, #61391512 0 2px, transparent 2px 13px), repeating-linear-gradient(90deg, transparent 0 119px, #4c2c1926 120px 122px), linear-gradient(115deg, #b78450, #956337 55%, #ad7b47); border: 8px solid #634025; border-radius: 20px; box-shadow: inset 0 0 0 3px #d9ad76, inset 0 0 60px #4d2e1940, 0 15px 30px #081b3455; transform: rotateX(calc(2deg + var(--board-tilt-y))) rotateY(var(--board-tilt-x)); transition: transform .18s ease-out, box-shadow .25s ease; }
.table-felt::before { content: ''; position: absolute; z-index: 1; inset: 0; pointer-events: none; border-radius: inherit; opacity: .42; background: radial-gradient(circle 180px at var(--board-light-x) var(--board-light-y), #fff4d540, transparent 75%); transition: opacity .25s ease; }
.table-felt:hover { box-shadow: inset 0 0 0 3px #e8bd86, inset 0 0 60px #4d2e1940, 0 22px 42px #081b3470; }
.table-felt::after { border: 1px dashed #ffe2b588; border-radius: 8px; z-index: 2; }
.table-center-card { background: #fff9e9; border-color: #f47b20; border-radius: 5px; color: #122b55; }
.table-center-card span { color: #924309; }
.table-center-card strong { font-family: inherit; }
.table-center-card b { color: #145322; }
.table-center-card { animation: phaseCardDeal .52s cubic-bezier(.2,.9,.25,1.25) both; transition: transform .2s ease, box-shadow .2s ease; }
.table-seat { z-index: 3; cursor: pointer; transition: transform .18s ease, filter .2s ease; animation: seatDeal .42s cubic-bezier(.2,.8,.3,1.15) both; animation-delay: calc(var(--seat-index) * 70ms); }
.table-seat:hover { z-index: 8; filter: drop-shadow(0 7px 9px #3b210d80); }
.table-seat:hover:not(.seat-active), .table-seat.seat-tapped:not(.seat-active) { transform: translate(-50%,-50%) scale(1.08); }
.table-seat:hover .seat-avatar, .table-seat.seat-tapped .seat-avatar { box-shadow: 0 0 0 4px #ffffff35, 0 5px 15px #2e190d99; }
.table-seat.seat-tapped .seat-info { background: #153466; }
.seat-cards i { transition: transform .2s ease; }
.table-seat:hover .seat-cards i:nth-child(odd) { transform: translateY(-4px) rotate(-4deg); }
.table-seat:hover .seat-cards i:nth-child(even) { transform: translateY(-6px) rotate(4deg); }
.table-center-card:hover { transform: translate(-50%,-54%) rotate(1deg) scale(1.03); box-shadow: 0 17px 28px #3b210d70; }
@keyframes phaseCardDeal { from { opacity: 0; transform: translate(-50%,-70%) rotate(-9deg) scale(.82); } }
@keyframes seatDeal { from { opacity: 0; transform: translate(-50%,-50%) scale(.7); } }
.seat-avatar, .seat-me .seat-avatar { background: var(--player-color); }
.seat-info { background: #0c2144; border-bottom: 3px solid var(--player-color); }
.seat-info span { color: #c4dbee; }
.seat-me .seat-info { outline-color: #b4dfed; }
.seat-cards i { background: #145322 url('assets/action-card.png') center / cover; border-color: #fffdf3; }
.product-card { background: var(--player-color); border-color: #fffdf3; }
.production-warehouse { background: #102b50; border-color: #54759a; }
.product-box { background: #24548b; border-color: #afe2ef; }
.product-number, .warehouse-hint { color: #c4dbee; }
.last-card-panel { background: #174b2c; border-color: #87b78a; }
.last-card-panel.kppu { background: #24548b; }
.last-card-panel p { color: #e1ecdf; }
.effect-card { background: #145322; border: 6px solid #fffdf3; border-radius: 10px; }
.effect-kppu .effect-card { background: #24548b; border-color: #b4dfed; }
.effect-danger .effect-card { background: #145322; border-color: #ff8c95; }
.effect-description {
  width: 100%;
  max-height: 125px;
  margin: 16px 0 0;
  padding: 12px 14px;
  overflow-y: auto;
  border-radius: 10px;
  color: #17345c;
  background: #fffdf3;
  font-size: clamp(.82rem,2.8vw,1rem);
  font-weight: 650;
  line-height: 1.45;
  text-align: left;
}
.last-card-panel p b { color: #ffe28a; }
.seat-products .product-count-badge {
  right: -8px;
  bottom: -8px;
  min-width: 29px;
  min-height: 29px;
  padding: 4px 7px;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
  color: #102b55;
  background: #ffd43b;
  font-size: .75rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 4px 10px #27150570;
}

/* High-contrast round-result values. */
.round-reward.reward-positive .reward-value,
html[data-theme="light"] .round-reward.reward-positive .reward-value {
  color: #59ff9b;
  text-shadow: 0 3px 0 #075c35,0 0 18px #38ef8aaa,0 0 42px #38ef8a70;
}
.round-reward .reward-balance,
html[data-theme="light"] .round-reward .reward-balance {
  border-color: #b9dcf099;
  background: #082a506e;
  box-shadow: inset 0 1px #ffffff24;
}
.round-reward .reward-balance span,
html[data-theme="light"] .round-reward .reward-balance span { color: #e4f5ff; }
.round-reward .reward-balance strong,
html[data-theme="light"] .round-reward .reward-balance strong { color: #fff; text-shadow: 0 2px 7px #06172d; }
.round-reward > .reward-content > p,
html[data-theme="light"] .round-reward > .reward-content > p { color: #dcefff; }
.round-reward, .profit-calculation, .production-reveal { background: radial-gradient(circle at center, #24548b, #122b55 75%); }
#results-table { overflow-x: auto; }
.join-row .code-input { min-width: 0; }
.mobile-game-nav { display: none; }
@media (min-width: 681px) {
  #screen-production .number-row { width: 100%; flex-wrap: nowrap; }
  #screen-production .number-row input {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
  }
  #screen-production .btn-num {
    flex: 0 0 48px;
    min-width: 48px;
  }
}
.event-layout { width: min(980px, 100%); min-height: calc(100svh - 72px); margin: 0 auto; display: grid; grid-template-columns: minmax(300px, .9fr) minmax(320px, 1.1fr); align-items: center; gap: 28px; }
.event-stage { position: relative; padding: 26px; text-align: center; border: 1px solid #54759a; border-radius: 20px; background: radial-gradient(circle at 50% 30%, #315d92, #132f57 72%); box-shadow: 0 25px 60px #07192f70; overflow: hidden; }
.event-stage::before { content: ''; position: absolute; inset: -35%; pointer-events: none; background: repeating-conic-gradient(#fff1 0 5deg, transparent 5deg 16deg); animation: eventRays 24s linear infinite; }
.event-kicker { position: relative; z-index: 1; margin-bottom: 14px; color: #afe2ef; font-size: .68rem; font-weight: 900; letter-spacing: .2em; }
.event-card { position: relative; z-index: 1; width: min(320px, 78vw, calc(62svh * 991 / 1548)); aspect-ratio: 991 / 1548; margin: 0 auto; container-type: inline-size; perspective: 1200px; filter: drop-shadow(0 18px 22px #07182d99); }
.event-card-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; }
.event-card-face { position: absolute; inset: 0; border-radius: 4.5%; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; }
.event-card-face img { display: block; width: 100%; height: 100%; object-fit: contain; }
.event-card-front { transform: rotateY(180deg); background: #fff; }
.event-card-back { background: #fff; }
.event-card-revealed .event-card-inner { transform: rotateY(180deg); }
/* Keep the copy inside the blank area above the printed event illustration. */
.event-card .event-copy { position: absolute; top: 12%; left: 8%; right: 23%; bottom: 54%; display: flex; flex-direction: column; justify-content: center; text-align: left; }
.event-card .event-copy h2 { margin: 0; color: #203b79; font-size: 6.3cqi; font-weight: 900; line-height: 1.18; text-wrap: balance; }
.event-card .event-copy p { margin: 3.5cqi 0 0; color: #344666; font-size: 4.5cqi; line-height: 1.4; }
.event-ready-panel { margin: 0; }
.event-ready-panel h3 { color: var(--text); font-size: 1rem; }
#btn-ready-event { width: 100%; margin-top: 14px; }
#event-ready-hint { margin-top: 12px; text-align: center; }
.event-rule-chip { margin: 10px 0 4px; padding: 9px 11px; border: 1px solid #ffb66c77; border-radius: 8px; color: #ffe5bd; background: #f47b2018; font-size: .76rem; line-height: 1.4; }
@keyframes eventRays { to { transform: rotate(360deg); } }
.event-effect { position: fixed; inset: 0; z-index: 1450; display: grid; place-items: center; visibility: hidden; overflow: hidden; pointer-events: none; opacity: 0; }
.event-effect.active { visibility: visible; pointer-events: auto; animation: eventEffectIn .25s ease forwards; }
.event-effect.leaving { pointer-events: none; animation: eventEffectOut .38s ease forwards; }
.event-effect-backdrop { position: absolute; inset: 0; background: radial-gradient(circle at 50% 42%, #32669a, #0a1e3c 68%); }
.event-effect-backdrop::after { content: ''; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 35%, #ffffff14 50%, transparent 65%); animation: eventBackdropShine 2s ease-out both; }
.event-effect-rays { position: absolute; width: min(125vw, 920px); aspect-ratio: 1; border-radius: 50%; background: repeating-conic-gradient(#afe2ef24 0 5deg, transparent 5deg 15deg); mask-image: radial-gradient(circle, black 0 18%, transparent 70%); animation: eventEffectRays 12s linear infinite; }
.event-effect-content { position: relative; z-index: 2; width: min(90vw, 560px); padding: 22px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.event-effect-kicker { color: #afe2ef; font-size: .72rem; font-weight: 900; letter-spacing: .28em; text-shadow: 0 0 18px #afe2ef88; }
.event-effect-card { width: min(360px, 78vw, calc((100svh - 130px) * 991 / 1548)); margin: 18px 0 0; filter: drop-shadow(0 24px 30px #020b18bb); }
.event-effect.active .event-card-inner { animation: eventCardFlip 1.65s cubic-bezier(.45, 0, .2, 1) both; }
.event-effect-progress { width: min(70vw, 360px); height: 5px; margin-top: 22px; overflow: hidden; border-radius: 99px; background: #ffffff22; }
.event-effect-progress span { display: block; width: 100%; height: 100%; transform-origin: left; background: linear-gradient(90deg, #afe2ef, #f47b20); animation: eventEffectProgress 3s linear forwards; }
@keyframes eventEffectIn { to { opacity: 1; } }
@keyframes eventEffectOut { to { opacity: 0; transform: scale(1.04); } }
@keyframes eventEffectRays { to { transform: rotate(360deg); } }
@keyframes eventBackdropShine { from { transform: translateX(-80%); } to { transform: translateX(80%); } }
@keyframes eventCardFlip {
  0% { transform: translateY(-45px) rotateY(0deg) rotateZ(-5deg) scale(.9); }
  25%, 50% { transform: translateY(0) rotateY(0deg) rotateZ(0deg) scale(1); }
  100% { transform: translateY(0) rotateY(180deg) rotateZ(0deg) scale(1); }
}
@keyframes eventEffectProgress { to { transform: scaleX(0); } }
.sales-reveal { position: fixed; inset: 0; z-index: 1375; display: grid; place-items: center; visibility: hidden; opacity: 0; overflow: auto; color: #fff; background: radial-gradient(circle at 50% 42%, #315b87, #0a1e3c 72%); }
.sales-reveal.active { visibility: visible; animation: salesRevealIn .3s ease forwards; }
.sales-reveal.leaving { animation: salesRevealOut .4s ease forwards; }
.sales-reveal-content { width: min(92vw, 900px); padding: 28px 16px; text-align: center; }
.sales-reveal-kicker { color: #afe2ef; font-size: .68rem; font-weight: 900; letter-spacing: .24em; }
.sales-reveal-content h2 { margin: 8px 0 3px; font-size: clamp(1.7rem, 5vw, 2.7rem); }
.sales-reveal-content > p { color: #bfd5e8; font-size: .82rem; }
.sales-reveal-players { margin-top: 24px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.sales-player-lane { position: relative; min-height: 104px; padding: 13px 104px 13px 14px; overflow: hidden; border: 1px solid #ffffff24; border-radius: 14px; text-align: left; background: #ffffff0b; }
.sales-player-target { position: absolute; z-index: 4; top: 12px; right: 12px; width: 82px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.sales-player-avatar { width: 43px; height: 43px; display: grid; place-items: center; border: 3px solid #fff; border-radius: 50%; color: #fff; font-weight: 900; background: var(--player-color); box-shadow: 0 0 22px color-mix(in srgb, var(--player-color) 55%, transparent); }
.sales-player-target strong { max-width: 82px; overflow: hidden; color: #fff; font-size: .7rem; white-space: nowrap; text-overflow: ellipsis; }
.sales-goods-track { position: relative; height: 48px; }
.sale-good { position: absolute; left: 0; top: 5px; width: 29px; height: 39px; display: grid; place-items: center; border: 2px solid #fff8df; border-radius: 5px; color: #56340e; background: linear-gradient(145deg,#fff2bb,#e6a744); box-shadow: 0 5px 10px #07172b88; opacity: 0; animation: soldGoodFly 1s cubic-bezier(.2,.8,.3,1.15) forwards; animation-delay: calc(var(--lane-index) * 150ms + var(--good-index) * 110ms + 350ms); }
.sale-good span { font-size: .83rem; }
.sold-overflow { position: absolute; left: 55%; top: 13px; color: #ffe6a0; font-weight: 900; opacity: 0; animation: salesTextIn .35s 1.5s ease forwards; }
.sales-counts { position: relative; z-index: 3; display: flex; gap: 7px; flex-wrap: wrap; margin-top: 5px; }
.sales-sold, .sales-unsold { padding: 4px 7px; border-radius: 999px; font-size: .65rem; font-weight: 800; opacity: 0; animation: salesTextIn .35s 1.55s ease forwards; }
.sales-sold { color: #a9f5ca; background: #16935d2b; border: 1px solid #55d99a55; }
.sales-unsold { color: #ffc1c6; background: #d944542b; border: 1px solid #ff8c9555; }
.sales-reveal-progress { width: min(70vw, 430px); height: 5px; margin: 24px auto 0; overflow: hidden; border-radius: 99px; background: #ffffff20; }
.sales-reveal-progress span { display: block; width: 100%; height: 100%; transform-origin: left; background: linear-gradient(90deg,#afe2ef,#f47b20); animation: salesProgress 4s linear forwards; }
@keyframes soldGoodFly { 0% { opacity: 0; transform: translate(-45px,-25px) rotate(-20deg) scale(1.35); } 30% { opacity: 1; } 100% { opacity: 1; left: calc(100% - 112px); transform: translateX(calc(var(--good-index) * -8px)) rotate(calc((var(--good-index) - 3) * 3deg)); } }
@keyframes salesTextIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; } }
@keyframes salesRevealIn { to { opacity: 1; } }
@keyframes salesRevealOut { to { opacity: 0; transform: scale(1.03); } }
@keyframes salesProgress { to { transform: scaleX(0); } }
button { position: relative; overflow: hidden; touch-action: manipulation; }
.button-ripple { position: absolute; z-index: 5; width: 14px; height: 14px; margin: -7px; pointer-events: none; border-radius: 50%; background: #fff9; animation: buttonRipple .48s ease-out forwards; }
.mobile-game-nav button { transition: background .2s ease, color .2s ease, transform .16s ease; }
.money-chip { animation: balanceGlow 2.4s ease-in-out infinite; }
.factory-status.running { animation: statusBreathe 1.5s ease-in-out infinite; }
@keyframes buttonRipple { to { opacity: 0; transform: scale(18); } }
@keyframes balanceGlow { 50% { box-shadow: 0 0 15px #87df9c28; border-color: #87df9c66; } }
@keyframes statusBreathe { 50% { box-shadow: 0 0 16px #87df9c28; } }

html[data-theme="light"] {
  --bg: #eef7fb; --surface: #ffffff; --surface2: #e4f1f8; --surface3: #c9e1ef;
  --accent: #f47b20; --accent-hover: #ff9854; --success: #187747; --danger: #c83548;
  --warn: #d36a15; --info: #176da9; --text: #17345c; --muted: #58708a;
}
html[data-theme="light"] body { background: radial-gradient(circle at 88% 5%, #c9e7f6 0, transparent 29rem), linear-gradient(145deg, #f7fcfe, #e8f4f9); }
html[data-theme="light"] body::before { background-image: radial-gradient(#4c90c522 1.25px, transparent 1.25px); opacity: .8; }
html[data-theme="light"] .ambient-grid::before, html[data-theme="light"] .ambient-grid::after { border-color: #4c90c540; }
html[data-theme="light"] .card-panel { background: #fffffff2; border-color: #b4d4e4; box-shadow: 0 14px 35px #315b7920; }
html[data-theme="light"] .card-panel::before { background: linear-gradient(90deg, #4c90c5, #f47b20, #f7c928); }
html[data-theme="light"] .top-bar { color: #17345c; background: #fffffff0; border-color: #b4d4e4; box-shadow: 0 7px 20px #315b7917; }
html[data-theme="light"] .room-chip, html[data-theme="light"] .money-chip { background: #e4f1f8; border-color: #b4d4e4; }
html[data-theme="light"] input[type="text"], html[data-theme="light"] input[type="number"], html[data-theme="light"] select { color: #17345c; background: #f8fcfe; border-color: #9abfd3; }
html[data-theme="light"] input::placeholder { color: #71879b; }
html[data-theme="light"] select option { color: #17345c; background: #fff; }
html[data-theme="light"] .btn-secondary, html[data-theme="light"] .btn-num { color: #17345c; background: #d9ebf5; border-color: #9abfd3; }
html[data-theme="light"] .btn-secondary:hover, html[data-theme="light"] .btn-num:hover { background: #c6e1ef; }
html[data-theme="light"] .btn-ghost { color: #4e6982; border-color: #9abfd3; }
html[data-theme="light"] .btn-ghost:hover { color: #17345c; background: #e4f1f8; }
html[data-theme="light"] .feature-strip span, html[data-theme="light"] .room-list-item, html[data-theme="light"] .player-row, html[data-theme="light"] .score-row, html[data-theme="light"] .cost-preview, html[data-theme="light"] .turn-indicator { color: #355875; background: #e7f3f8; border-color: #bad7e5; }
html[data-theme="light"] .player-row .pname, html[data-theme="light"] .score-name { color: #17345c; }
html[data-theme="light"] .room-code-display, html[data-theme="light"] .production-warehouse { color: #17345c; background: #e5f2f8; border-color: #a9cddd; }
html[data-theme="light"] .event-stage { background: radial-gradient(circle at 50% 25%, #dff3fb, #b8dcef 72%); border-color: #8dbbd3; box-shadow: 0 20px 45px #315b7925; }
html[data-theme="light"] .event-kicker { color: #174f8f; }
html[data-theme="light"] .event-rule-chip { color: #93430b; background: #fff1e5; border-color: #f6b17b; }
html[data-theme="light"] .kppu-banner { color: #85420c; background: #fff5dc; border-color: #e6b74d; }
html[data-theme="light"] th { color: #58708a; border-color: #c6dde8; }
html[data-theme="light"] td { border-color: #d8e8ef; }
html[data-theme="light"] .mobile-game-nav button { color: #4d6982; background: #fff; border-color: #9abfd3; }
html[data-theme="light"] .mobile-game-nav button[aria-pressed="true"] { color: #17345c; background: #f7c928; border-color: #e1aa16; }
html[data-theme="light"] .splash-screen { color: #17345c; background: linear-gradient(#f5fbfee8,#e8f5faee), radial-gradient(circle at 50% 28%,#bfe6f7,#eef8fc 68%); }
html[data-theme="light"] .splash-screen::before { background-image: radial-gradient(#4c90c52e 1.25px,transparent 1.25px); background-size: 28px 28px; mask-image: none; }
html[data-theme="light"] .splash-screen::after { border-color: #4c90c548; box-shadow: 0 0 90px #4c90c522,inset 0 0 90px #4c90c51a; }
html[data-theme="light"] .splash-logo-divider { background: #174f8f40; }
html[data-theme="light"] .splash-hero-image { filter: drop-shadow(0 20px 35px #315b7935); }
html[data-theme="light"] .splash-loader { background: #4c90c52e; }
html[data-theme="light"] .splash-skip { color: #4f6d86; }
html[data-theme="light"] .splash-skip:hover, html[data-theme="light"] .splash-skip:focus-visible { color: #17345c; }
html[data-theme="light"] .splash-landscape { color: #17345c; background: linear-gradient(135deg,#ffd65d,#f7b928); border-color: #e6a512; box-shadow: 0 9px 28px #c47b1c2e; }
html[data-theme="light"] .landscape-hint { color: #607d93; }
html[data-theme="light"] .landscape-hint-warning { color: #a84d0d; }
@media (max-width: 680px), (orientation: landscape) {
  #screen-home .card-panel { margin: 8px auto; padding: 25px 20px; }
  .event-layout { min-height: calc(100svh - 20px); display: flex; flex-direction: column; justify-content: center; gap: 10px; }
  .event-stage { width: 100%; padding: 13px; border-radius: 14px; }
  .event-kicker { margin-bottom: 7px; }
  .event-stage .event-card { width: min(250px, 70vw, calc(60svh * 991 / 1548)); }
  .event-ready-panel { width: 100%; padding: 13px !important; }
  .event-ready-panel .player-row { padding: 5px 8px; }
  .event-ready-panel .pmeta { display: none; }
  #btn-ready-event { min-height: 42px; margin-top: 8px; }
  #event-ready-hint { margin-top: 7px; font-size: .68rem; }
  .event-effect-content { padding: 12px; }
  .event-effect-card { margin-top: 12px; }
  .event-effect-progress { margin-top: 14px; }
  .sales-reveal-content { width: 100%; padding: 18px 10px; }
  .sales-reveal-players { margin-top: 13px; grid-template-columns: 1fr; gap: 7px; }
  .sales-player-lane { min-height: 82px; padding: 8px 88px 8px 9px; border-radius: 10px; }
  .sales-player-target { top: 7px; right: 7px; width: 72px; }
  .sales-player-avatar { width: 36px; height: 36px; font-size: .72rem; }
  .sales-goods-track { height: 39px; }
  .sale-good { width: 24px; height: 33px; top: 2px; }
  .sales-counts { margin-top: 2px; }
  .sales-sold, .sales-unsold { font-size: .58rem; }
  .sales-reveal-progress { margin-top: 14px; }
  /* Keep the board visible in a compact mobile format. */
  .screen > .game-table { display: block; margin-bottom: 10px; }
  .production-warehouse { display: none; }
  .screen > .game-table .table-felt { min-height: 255px; border-width: 6px; border-radius: 16px; }
  .screen > .game-table .table-felt::after { inset: 8px; }
  .screen > .game-table .table-seat { width: 92px; grid-template-columns: 28px 1fr; gap: 3px; }
  .screen > .game-table .seat-avatar { width: 28px; height: 28px; border-width: 2px; font-size: .62rem; }
  .screen > .game-table .seat-info { padding: 4px 5px; }
  .screen > .game-table .seat-info strong { font-size: .55rem; }
  .screen > .game-table .seat-cards { bottom: 32px; }
  .screen > .game-table .seat-lower .seat-cards { top: 32px; bottom: auto; }
  .screen > .game-table .seat-cards i { width: 17px; height: 24px; margin-left: -10px; }
  .screen > .game-table .seat-products { top: 32px; }
  .screen > .game-table .seat-lower .seat-products { top: auto; bottom: 32px; }
  .screen > .game-table .product-card { width: 20px; height: 28px; margin-left: -12px; }
  .screen > .game-table .table-center-card { width: 102px; min-height: 76px; padding: 7px; }
  .screen > .game-table .table-center-card strong { font-size: .9rem; }
  .screen > .game-table .table-center-card small { font-size: .62rem; }
  .screen > .game-table .table-felt { transform: none; transition: box-shadow .2s ease; }
  .screen > .game-table .table-felt::before { opacity: .22; }
  .screen { padding: 10px; min-height: 100svh; }
  .top-bar { gap: 6px; padding: 9px 11px; margin-bottom: 8px; }
  .top-bar::before { font-size: .85rem; padding-bottom: 0; }
  .round-label { font-size: .78rem; }
  .room-chip, .money-chip, .demand-badge { padding: 5px 8px; font-size: .72rem; }
  .mobile-game-nav { display: flex; gap: 6px; margin-bottom: 10px; }
  .mobile-game-nav button { flex: 1; min-height: 40px; padding: 8px; border: 1px solid #54759a; border-radius: 8px; background: #17345c; color: var(--muted); font-weight: 700; }
  .mobile-game-nav button[aria-pressed="true"] { background: #f47b20; border-color: #f47b20; color: #192c49; }
  .main-layout { gap: 0; }
  .main-layout > .card-panel { padding: 16px; margin-bottom: 0; min-width: 0; }
  .main-layout > .card-panel:nth-child(2) { display: none; }
  .mobile-show-status .main-layout > .card-panel:first-child { display: none; }
  .mobile-show-status .main-layout > .card-panel:nth-child(2) { display: block; }
  .main-layout > .card-panel { animation: mobilePanelIn .24s ease both; }
  .card-panel h2 { font-size: 1.2rem; margin-bottom: 10px; }
  .number-row { flex-wrap: nowrap; gap: 5px; }
  .number-row input { min-width: 0; width: 64px; }
  .btn-num { min-height: 44px; flex: 1; padding: 7px; }
  .cost-preview { font-size: .8rem; line-height: 1.5; }
  #btn-ready-prod, #btn-ready-offer { width: 100%; min-height: 44px; }
  .hand-display { margin-bottom: 0; padding-bottom: 10px; }
  .action-card { flex-basis: 190px; min-height: 150px; padding: 12px; }
  .action-card .card-label { font-size: .95rem; }
  .action-card .card-desc { padding: 8px; }
  .player-row { padding: 8px 10px; }
  .turn-indicator { padding: 9px; margin-bottom: 10px; font-size: .8rem; }
  .card-panel.center { margin: 12px auto; padding: 20px; }
  @keyframes mobilePanelIn { from { opacity: 0; transform: translateY(7px); } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Compact game board based on the supplied Modern Clean UI reference. */
.phase-illustration { display: block; margin: 5px 0 1px; font-style: normal; font-size: 2.5rem; line-height: 1; filter: drop-shadow(0 4px 3px #17345c24); }

@media (max-width: 680px), (orientation: landscape) {
  #screen-production, #screen-action_cards, #screen-offering { padding: 6px 0 0; background: #f3ead8; }
  #screen-production .top-bar, #screen-action_cards .top-bar, #screen-offering .top-bar {
    position: relative; z-index: 20; margin: 0 0 5px; padding: 8px 14px; gap: 8px; border: 1px solid #d8d5cc;
    border-radius: 0 0 18px 18px; color: #102b55; background: #fff; box-shadow: 0 3px 10px #46301b24;
  }
  .top-bar > :last-child { margin-left: 0; }
  .round-label { color: #102b55; font-size: .88rem; font-weight: 900; }
  .room-chip, .money-chip { padding: 6px 10px; border: 1px solid #bfd1e1; color: #315b82; background: #eaf4fb; }
  .money-chip { margin-left: auto !important; color: #155c3d; border-color: #9ed9bd; background: #ddf8e9; }
  .mobile-game-nav { margin: 0 10px 5px; gap: 5px; }
  .mobile-game-nav button { min-height: 39px; padding: 7px 5px; border: 0; border-radius: 11px; color: #102b55; background: #fffdf8; box-shadow: 0 2px 5px #4f321c24; }
  .mobile-game-nav button:first-child::before { content: '🎴'; margin-right: 6px; }
  .mobile-game-nav button:last-child::before { content: '♟'; margin-right: 6px; }
  .mobile-game-nav button[aria-pressed="true"] { color: #142b51; background: linear-gradient(#ffd35a,#ffb72e); box-shadow: inset 0 0 0 1px #ed9b13,0 3px 6px #6d43052b; }
  .screen > .game-table { margin: 0; padding: 0; }
  .screen > .game-table .table-felt {
    min-height: 292px; border: 0; border-radius: 0;
    background: radial-gradient(circle at 58% 42%,#b9662e22,transparent 35%), repeating-linear-gradient(0deg,#ffffff08 0 1px,transparent 1px 7px), repeating-linear-gradient(91deg,transparent 0 76px,#4a1d0e22 78px 80px), linear-gradient(105deg,#8e431f,#5f2915 58%,#8c421e);
    box-shadow: inset 0 9px 18px #35150866,inset 0 -8px 14px #35150844;
  }
  .screen > .game-table .table-felt::before { inset: 0; border: 0; border-radius: 0; opacity: .65; background: linear-gradient(90deg,#ffffff0d,transparent 22%,#ffffff0b 52%,transparent 75%); }
  .screen > .game-table .table-felt::after { display: none; }
  .board-leaves { top: -12px; left: -14px; font-size: 3.6rem; }
  .board-cup { top: 5px; right: 5px; font-size: 3.2rem; }
  .board-pencil { right: -2px; bottom: -8px; left: auto; font-size: 2.7rem; }
  .board-note { display: none; }
  .screen > .game-table .table-center-card {
    top: 50%; width: 142px; min-height: 164px; padding: 13px 9px 10px; border: 1px solid #ead8ad; border-radius: 12px;
    color: #102b55; background: linear-gradient(90deg,#fff9e7,#fffdf6 48%,#fff6dd); box-shadow: 0 5px 0 #dec78f,0 10px 19px #32160970;
  }
  .screen > .game-table .table-center-card::before, .screen > .game-table .table-center-card::after { width: 30px; height: 13px; background: #fff9e7; }
  .screen > .game-table .table-center-card span { color: #d12734; font-size: .7rem; letter-spacing: .04em; }
  .screen > .game-table .table-center-card strong { margin: 3px 0; color: #102b55; font-size: 1.13rem; }
  .screen > .game-table .table-center-card small { width: calc(100% + 18px); margin: 2px -9px -8px; padding: 5px; color: #17345c; background: #fff3ce; }
  .screen > .game-table .table-center-card b { font-size: 1.65rem; }
  .phase-illustration { margin: 7px 0 3px; font-size: 2.6rem; }
  .screen > .game-table .table-seat { width: 132px; grid-template-columns: 33px 1fr; }
  .screen > .game-table .seat-avatar { width: 35px; height: 35px; font-size: .7rem; border-color: #fff; }
  .screen > .game-table .seat-info { padding: 6px 7px 6px 10px; border: 2px solid var(--player-color); border-radius: 7px 13px 13px 7px; background: #0d2d58; }
  .screen > .game-table .seat-info strong { font-size: .65rem; }
  .screen > .game-table .seat-me .seat-info { outline: 2px solid #ffd34d; }
  .screen > .game-table .board-discard { left: 83%; width: 46px; height: 65px; }
  .screen > .game-table .board-card-pile small { top: 70px; color: #fff6e7; }
  .main-layout > .card-panel { border: 0; border-radius: 20px 20px 0 0; color: #17345c; background: #fffdf8; box-shadow: 0 -4px 16px #4827122c; }
  .main-layout > .card-panel::before { display: none; }
  #screen-production .main-layout > .card-panel:first-child h2::before { content: '🏭'; margin-right: 10px; }
  .main-layout > .card-panel h2 { color: #102b55; font-size: 1.25rem; }
  .main-layout > .card-panel p, .main-layout > .card-panel label { color: #315273; }
  .event-rule-chip { color: #c63822; background: #fff0e8; border-color: #ff9a7b; }
  .number-row { justify-content: center; }
  .number-row input { height: 46px; border: 1px solid #9fc4dc; color: #102b55; background: #fff; font-size: 1.35rem; font-weight: 900; }
  .btn-num { max-width: 58px; height: 43px; border: 1px solid #e9a21d; color: #102b55; background: linear-gradient(#ffd459,#ffb72e); box-shadow: 0 3px 0 #df8d10; font-size: 1.35rem; font-weight: 900; }
  .cost-preview { color: #28527c; background: transparent; text-align: center; }
  #btn-ready-prod, #btn-ready-offer { min-height: 54px; border-radius: 12px; color: #fff; background: linear-gradient(135deg,#ff7422,#ff5417); box-shadow: 0 4px 0 #c73b0b; font-size: 1.15rem; font-weight: 900; }
  #btn-ready-prod::before { content: '🏭'; margin-right: 9px; }
  html[data-theme="dark"] #screen-production, html[data-theme="dark"] #screen-action_cards, html[data-theme="dark"] #screen-offering { color: #17345c; }
}

@media (orientation: landscape) {
  #screen-production.active, #screen-action_cards.active, #screen-offering.active {
    position: relative; display: grid; grid-template-columns: minmax(315px,.95fr) minmax(300px,1.05fr) 54px; grid-template-rows: 62px 1fr auto;
    min-height: 100svh; height: 100svh; padding: 0; overflow: hidden; background: #713416;
  }
  #screen-production .top-bar, #screen-action_cards .top-bar, #screen-offering .top-bar {
    grid-column: 1; grid-row: 1; align-self: start; width: calc(100% - 14px); margin: 8px 7px 0 12px; padding: 8px 12px; border-radius: 15px;
  }
  #screen-production .mobile-game-nav, #screen-action_cards .mobile-game-nav, #screen-offering .mobile-game-nav {
    position: relative; z-index: 20; grid-column: 2; grid-row: 1; align-self: start; width: calc(100% - 8px); margin: 7px 4px 0; gap: 5px;
  }
  .mobile-game-nav button { min-height: 45px; font-size: .82rem; }
  #screen-production > .game-table, #screen-action_cards > .game-table, #screen-offering > .game-table { grid-column: 1 / -1; grid-row: 1 / -1; width: 100%; height: 100%; }
  #screen-production .table-felt, #screen-action_cards .table-felt, #screen-offering .table-felt { height: 100%; min-height: 0; }
  #screen-production > .main-layout, #screen-action_cards > .main-layout, #screen-offering > .main-layout {
    position: relative; z-index: 18; grid-column: 1 / -1; grid-row: 3; width: calc(100% - 12px); max-width: none; height: auto; margin: 0 6px 6px; overflow: visible; background: transparent;
    grid-template-columns: 1fr;
  }
  .main-layout > .card-panel:nth-child(2) { display: none; }
  .mobile-show-status .main-layout > .card-panel:first-child { display: none; }
  .mobile-show-status .main-layout > .card-panel:nth-child(2) { display: block; }
  .main-layout > .card-panel { min-height: 0; margin: 0; padding: 13px 18px; border: 2px solid #e3d1ae; border-radius: 20px; box-shadow: 0 -4px 14px #37150645; }
  #screen-production .main-layout > .card-panel:first-child {
    display: grid; grid-template-columns: minmax(270px,1fr) minmax(255px,.72fr) minmax(170px,.42fr); grid-template-rows: auto auto auto; column-gap: 20px; align-items: center;
  }
  #screen-production .main-layout > .card-panel:first-child h2 { grid-column: 1; grid-row: 1; margin: 0; font-size: 1.13rem; }
  #screen-production .main-layout > .card-panel:first-child > p { grid-column: 1; grid-row: 2; margin: 1px 0 5px; }
  #screen-production .event-rule-chip { grid-column: 1; grid-row: 3; margin: 0; padding: 7px 10px; }
  #screen-production .warn-box { grid-column: 1; grid-row: 3; }
  #screen-production .form-group { grid-column: 2; grid-row: 1 / 3; margin: 0 !important; align-self: center; }
  #screen-production .form-group label { text-align: left; }
  #screen-production .number-row { margin-top: 3px; }
  #screen-production .cost-preview { grid-column: 2; grid-row: 3; min-height: 0; margin: 0; padding: 0; font-size: .72rem; line-height: 1.25; text-align: left; }
  #screen-production #prod-carryover-note { grid-column: 2; grid-row: 3; }
  #screen-production #btn-ready-prod { grid-column: 3; grid-row: 1 / 4; align-self: stretch; min-height: 86px; margin: 0; }
  .screen > .game-table .table-center-card { top: 43%; width: clamp(160px, 15vw, 215px); min-height: clamp(180px, 31vh, 265px); }
  .screen > .game-table .table-seat { width: clamp(145px, 14vw, 190px); }
  .screen > .game-table .table-seat.seat-lower { top: calc(var(--seat-y) - 15%); }
  .screen > .game-table .table-seat.seat-lower .seat-cards { top: auto; bottom: 44px; }
  .screen > .game-table .table-seat.seat-lower .seat-products { top: 44px; bottom: auto; }
  .screen > .game-table .board-discard { left: 82%; top: 43%; }
  .board-leaves { font-size: 4.5rem; }
  .board-cup { right: 17px; font-size: 4rem; }
}

/* Shared winner reveal shown on every player's device. */
.winner-celebration {
  position: fixed;
  z-index: 1600;
  inset: 0;
  visibility: hidden;
  opacity: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #fff;
  background: radial-gradient(circle at 50% 38%,#1d75bf 0,#102f62 46%,#06152f 100%);
}
.winner-celebration.active { visibility: visible; animation: winnerFadeIn .35s ease forwards; }
.winner-celebration.leaving { animation: winnerFadeOut .45s ease forwards; }
.winner-rays {
  position: absolute;
  width: 130vmax;
  height: 130vmax;
  opacity: .42;
  background: repeating-conic-gradient(from 0deg,#ffd84d 0 6deg,transparent 6deg 15deg);
  animation: winnerRays 18s linear infinite;
  mask-image: radial-gradient(circle,#000 0,transparent 67%);
}
.winner-content {
  position: relative;
  z-index: 2;
  width: min(90vw,620px);
  padding: clamp(26px,6vw,52px) 22px;
  text-align: center;
  border: 2px solid #ffe47a;
  border-radius: 30px;
  background: linear-gradient(160deg,#ffffff24,#ffffff09);
  box-shadow: 0 25px 80px #0009,inset 0 1px #fff8;
  backdrop-filter: blur(8px);
  animation: winnerContentIn .8s cubic-bezier(.2,.85,.2,1.2) both;
}
.winner-kicker { color: #ffe36a; font-size: clamp(.7rem,2.5vw,.9rem); font-weight: 900; letter-spacing: .22em; }
.winner-trophy { margin: 12px auto 5px; font-size: clamp(5rem,20vw,9rem); filter: drop-shadow(0 10px 18px #0007); animation: trophyBounce 1.25s ease-in-out infinite; }
.winner-content h2 { margin: 5px 0; color: #fff; font-size: clamp(2.1rem,9vw,4.5rem); line-height: 1; text-shadow: 0 5px 0 #b16b00,0 9px 22px #0009; }
.winner-content p { margin: 13px 0 7px; color: #eaf7ff; font-size: clamp(.95rem,3.5vw,1.25rem); font-weight: 700; }
.winner-content > strong { display: block; color: #ffe36a; font-size: clamp(1.1rem,4vw,1.55rem); }
.winner-progress { width: min(78%,390px); height: 7px; margin: 28px auto 0; overflow: hidden; border-radius: 20px; background: #06152f99; }
.winner-progress span { display: block; width: 100%; height: 100%; transform-origin: left; background: linear-gradient(90deg,#ff9f1f,#fff18a); animation: winnerProgress 5.2s linear forwards; }
.winner-confetti { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.winner-confetti i {
  position: absolute;
  top: -8%;
  left: var(--x);
  width: 10px;
  height: 18px;
  border-radius: 2px;
  background: var(--color);
  animation: confettiFall 3.4s var(--delay) cubic-bezier(.2,.55,.35,1) infinite;
}
.final-winner { margin: 4px auto 18px; padding: 15px; display: grid; gap: 3px; border: 2px solid #efb528; border-radius: 16px; background: linear-gradient(145deg,#fff8d6,#ffe593); color: #17345c; }
.final-winner span { font-size: .72rem; font-weight: 900; letter-spacing: .12em; }
.final-winner strong { font-size: clamp(1.35rem,5vw,2rem); }
.final-winner small { color: #915312; font-weight: 800; }
@keyframes winnerFadeIn { to { opacity: 1; } }
@keyframes winnerFadeOut { to { opacity: 0; transform: scale(1.035); } }
@keyframes winnerRays { to { transform: rotate(360deg); } }
@keyframes winnerContentIn { from { opacity: 0; transform: translateY(45px) scale(.72); } }
@keyframes trophyBounce { 50% { transform: translateY(-10px) rotate(3deg) scale(1.05); } }
@keyframes winnerProgress { to { transform: scaleX(0); } }
@keyframes confettiFall {
  0% { opacity: 0; transform: translate3d(0,-10vh,0) rotate(0); }
  8% { opacity: 1; }
  100% { opacity: 1; transform: translate3d(var(--drift),115vh,0) rotate(760deg); }
}

.phase-timer {
  margin-left: auto;
  min-width: 78px;
  padding: 5px 9px;
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: center;
  column-gap: 5px;
  border: 2px solid #e7a51d;
  border-radius: 12px;
  color: #17345c;
  background: #fff2b8;
  box-shadow: 0 3px 8px #44290c25;
}
.phase-timer > span { font-size: .82rem; }
.phase-timer > b { font-size: 1rem; line-height: 1; }
.phase-timer > small { grid-column: 1 / -1; margin-top: 2px; font-size: .46rem; font-weight: 700; white-space: nowrap; }
.phase-timer.urgent { color: #fff; border-color: #ffb09b; background: #df3d2f; animation: timerUrgent .7s ease-in-out infinite; }
.phase-timer-floating { position: absolute; z-index: 8; top: 12px; right: 12px; }
.phase-timer-summary { width: fit-content; margin: 0 auto 12px; }
@keyframes timerUrgent { 50% { transform: scale(1.055); box-shadow: 0 0 16px #ef493c88; } }

@media (max-width: 680px) {
  .phase-timer { min-width: 51px; padding: 4px 6px; grid-template-columns: auto auto; }
  .phase-timer > small { display: none; }
}

/* The page stays fixed, but the player-status tab can scroll internally. */
#screen-production .main-layout > .card-panel:nth-child(2),
#screen-action_cards .main-layout > .card-panel:nth-child(2),
#screen-offering .main-layout > .card-panel:nth-child(2) {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}
#screen-production .main-layout > .card-panel:nth-child(2) > h3:first-child,
#screen-action_cards .main-layout > .card-panel:nth-child(2) > h3:first-child,
#screen-offering .main-layout > .card-panel:nth-child(2) > h3:first-child {
  position: sticky;
  z-index: 4;
  top: -1px;
  margin: -4px -4px 8px;
  padding: 7px 4px;
  background: #fffdf8f2;
  backdrop-filter: blur(5px);
}
#screen-action_cards.mobile-show-status .main-layout > .card-panel:nth-child(2) {
  padding-bottom: 28px;
}
#screen-action_cards .last-card-panel { flex: 0 0 auto; }

@media (orientation: portrait) {
  #screen-production.mobile-show-status .main-layout,
  #screen-action_cards.mobile-show-status .main-layout,
  #screen-offering.mobile-show-status .main-layout { overflow: visible; }
  #screen-production.mobile-show-status .main-layout > .card-panel:nth-child(2),
  #screen-action_cards.mobile-show-status .main-layout > .card-panel:nth-child(2),
  #screen-offering.mobile-show-status .main-layout > .card-panel:nth-child(2) {
    height: 43svh;
    max-height: 43svh;
  }
}

@media (orientation: landscape) {
  #screen-production.mobile-show-status .main-layout > .card-panel:nth-child(2),
  #screen-action_cards.mobile-show-status .main-layout > .card-panel:nth-child(2),
  #screen-offering.mobile-show-status .main-layout > .card-panel:nth-child(2) {
    max-height: min(46svh,390px);
  }
}

/* Every game phase stays inside one viewport; controls never cover player seats. */
html:has(#screen-production.active), html:has(#screen-action_cards.active), html:has(#screen-offering.active),
body:has(#screen-production.active), body:has(#screen-action_cards.active), body:has(#screen-offering.active) { height: 100%; overflow: hidden; }

@media (orientation: portrait) {
  #screen-production.active, #screen-action_cards.active, #screen-offering.active {
    display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; height: 100svh; min-height: 0; padding: 0; overflow: hidden;
    background: #f3ead8;
  }
  #screen-production .top-bar, #screen-action_cards .top-bar, #screen-offering .top-bar { grid-row: 1; width: 100%; margin: 0 0 4px; }
  #screen-production .mobile-game-nav, #screen-action_cards .mobile-game-nav, #screen-offering .mobile-game-nav { grid-row: 2; width: calc(100% - 12px); margin: 0 6px 4px; }
  #screen-production > .game-table, #screen-action_cards > .game-table, #screen-offering > .game-table { grid-row: 3; width: 100%; height: 100%; min-height: 0; margin: 0; }
  #screen-production .table-felt, #screen-action_cards .table-felt, #screen-offering .table-felt { height: 100%; min-height: 0; }
  #screen-production > .main-layout, #screen-action_cards > .main-layout, #screen-offering > .main-layout {
    grid-row: 4; width: 100%; max-width: none; min-height: 0; margin: 0; grid-template-columns: 1fr; overflow: hidden;
  }
  .main-layout > .card-panel { max-height: 43svh; padding: 12px 16px; overflow: hidden; }
  .main-layout > .card-panel h2 { margin-bottom: 4px; }
  #screen-production .main-layout > .card-panel:first-child > p { margin-bottom: 3px; }
  #screen-production .event-rule-chip { margin: 5px 0; padding: 6px 9px; }
  #screen-production .form-group { margin: 5px 0 !important; }
  #screen-production .cost-preview { min-height: 0; margin-bottom: 4px; padding: 4px 8px; }
  #screen-production #btn-ready-prod { min-height: 46px; margin-top: 3px; }
  .screen > .game-table .table-center-card { top: 47%; width: clamp(104px, 28vw, 126px); min-height: 0; padding: 7px 6px 6px; }
  .screen > .game-table .table-center-card::before,
  .screen > .game-table .table-center-card::after { width: 23px; height: 10px; }
  .screen > .game-table .table-center-card span { font-size: .58rem; }
  .screen > .game-table .table-center-card .phase-illustration { margin: 3px 0 1px; font-size: 1.55rem; }
  .screen > .game-table .table-center-card strong { margin: 0; font-size: .92rem; }
  .screen > .game-table .table-center-card small { width: calc(100% + 12px); margin: 0 -6px -6px; padding-block: 2px; font-size: .56rem; line-height: 1.1; }
  .screen > .game-table .table-center-card b { font-size: 1.25rem; }
  .screen > .game-table .table-seat { width: min(31vw, 132px); }
  .screen > .game-table .table-seat.seat-lower { top: 88%; }
  .screen > .game-table .table-seat.seat-lower .seat-cards {
    top: 50%; right: auto; bottom: auto; left: calc(100% + 5px); display: flex; transform: translateY(-50%);
  }
  .screen > .game-table .table-seat.seat-lower .seat-products {
    top: 50%; right: calc(100% + 5px); bottom: auto; left: auto; display: flex; transform: translateY(-50%);
  }
  .screen > .game-table .table-seat.seat-lower .seat-cards i { width: 18px; height: 27px; margin-left: -9px; }
  .screen > .game-table .table-seat.seat-lower .seat-cards i:first-child { margin-left: 0; }
  .screen > .game-table .table-seat.seat-lower .product-card { width: 20px; height: 28px; margin-left: -10px; }
  .screen > .game-table .table-seat.seat-lower .product-card:first-child { margin-left: 0; }
  .screen > .game-table .board-discard { top: 50%; }
}

/* Keep the complete demand reveal, including its confirmation button, in one viewport. */
#screen-demand_reveal.active {
  width: 100%;
  height: 100vh;
  height: 100svh;
  min-height: 0;
  padding: clamp(7px, 1.5vh, 14px);
  overflow: hidden;
}
#screen-demand_reveal .card-panel.center {
  width: min(100%, 880px);
  height: 100%;
  min-height: 0;
  margin: 0 auto;
  padding: clamp(10px, 2vh, 18px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  align-content: stretch;
  overflow: hidden;
}
#screen-demand_reveal .card-panel > h2 { margin: 0 0 4px; }
#screen-demand_reveal .demand-card-big { align-self: center; }
#screen-demand_reveal .action-card-deal.active {
  min-height: 0;
  max-height: none;
  margin-top: 6px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}
#screen-demand_reveal .deal-stage {
  min-height: 0;
  height: 100%;
  margin-top: 6px;
  overflow: hidden;
}
#screen-demand_reveal .deal-status { margin-top: 4px; }
#screen-demand_reveal #btn-reveal-done {
  width: min(100%, 520px);
  min-height: 44px;
  margin: 6px auto 0 !important;
  padding: 10px 18px;
}

@media (orientation: portrait) {
  #screen-demand_reveal .card-panel.center { padding: 10px 12px; }
  #screen-demand_reveal .card-panel > h2 { font-size: clamp(1.05rem, 5vw, 1.35rem); }
  #screen-demand_reveal .demand-card-big {
    min-width: 0;
    width: min(46vw, 190px);
    margin: 4px auto;
    padding: 12px 14px;
    border-width: 4px;
    transform: none;
  }
  #screen-demand_reveal .demand-card-big::before {
    margin-bottom: 5px;
    font-size: .48rem;
    letter-spacing: .16em;
  }
  #screen-demand_reveal .demand-card-big .demand-num {
    width: clamp(58px, 17vw, 76px);
    height: clamp(58px, 17vw, 76px);
    margin-bottom: 5px;
    font-size: clamp(2.6rem, 12vw, 3.5rem);
    border-width: 2px;
  }
  #screen-demand_reveal .demand-card-big .demand-sub { margin-top: 0; font-size: .68rem; }
  #screen-demand_reveal .deal-heading { gap: 1px; }
  #screen-demand_reveal .deal-heading span { font-size: .53rem; }
  #screen-demand_reveal .deal-heading strong { font-size: .82rem; }
  #screen-demand_reveal .deal-stage { padding: 52px 5px 5px; border-radius: 12px; }
  #screen-demand_reveal .deal-deck { top: 6px; width: 32px; height: 44px; }
  #screen-demand_reveal .deal-player { width: 46%; min-width: 0; padding: 5px; gap: 4px; grid-template-columns: 25px minmax(0,1fr); }
  #screen-demand_reveal .deal-player-avatar { width: 25px; height: 25px; font-size: .58rem; }
  #screen-demand_reveal .deal-player strong { font-size: .6rem; }
  #screen-demand_reveal .deal-player-hand { min-height: 21px; }
  #screen-demand_reveal .deal-player-hand i { width: 15px; height: 21px; margin-left: -5px; }
  #screen-demand_reveal .deal-status { min-height: 12px; font-size: .62rem; line-height: 1.15; }
}

@media (orientation: landscape) and (max-height: 700px) {
  #screen-demand_reveal .card-panel.center {
    grid-template-columns: minmax(150px, .65fr) minmax(300px, 1.35fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    column-gap: 16px;
  }
  #screen-demand_reveal .card-panel > h2 { grid-column: 1 / -1; }
  #screen-demand_reveal .demand-card-big {
    grid-column: 1;
    grid-row: 2;
    min-width: 0;
    width: min(100%, 220px);
    margin: auto;
    padding: 18px 20px;
  }
  #screen-demand_reveal .demand-card-big .demand-num { width: 78px; height: 78px; font-size: 3.6rem; }
  #screen-demand_reveal .action-card-deal { grid-column: 2; grid-row: 2; }
  #screen-demand_reveal .deal-stage { padding-top: 58px; }
  #screen-demand_reveal .deal-deck { top: 7px; width: 34px; height: 47px; }
  #screen-demand_reveal #btn-reveal-done { grid-column: 1 / -1; grid-row: 3; }
}

/* Splash layout using the original supplied Compete artwork. */
.splash-screen,
html[data-theme="light"] .splash-screen {
  color: #12345f;
  background: radial-gradient(circle at 50% 25%,#fff 0,#eef9ff 46%,#dceff9 100%);
}
.splash-screen::before,
html[data-theme="light"] .splash-screen::before { opacity: .18; background-image: radial-gradient(#66c8ff55 1px,transparent 1px); background-size: 34px 34px; mask-image: linear-gradient(#000,transparent 72%); }
.splash-screen::after,
html[data-theme="light"] .splash-screen::after { display: none; }
.splash-cover-art { position: absolute; z-index: 0; top: 8%; left: 50%; width: min(94vw,760px); height: min(56vh,520px); display: block; object-fit: contain; transform: translateX(-50%); }
.splash-content { position: relative; z-index: 1; width: min(100%,680px); height: 100svh; padding: 0 22px; }
.splash-logos { top: 10px; display: flex; gap: 10px; min-height: 40px; padding: 5px 10px; background: #f9fdfff2; border: 1px solid #a8d5f2; box-shadow: 0 5px 16px #164d8120; }
.splash-logo-sbm { width: clamp(100px,22vw,130px); height: auto; object-fit: contain; }
.splash-logo-kppu { width: clamp(125px,28vw,160px); height: auto; object-fit: contain; }
.splash-logo-divider { height: 28px; }
.splash-logo-divider { background: #ffffff66; }
.splash-loader { position: absolute; top: 73.5%; left: 50%; width: min(380px,72vw); height: 9px; margin: 0; border: 1px solid #f8c85d; background: #07162dcc; transform: translateX(-50%); box-shadow: 0 0 12px #f4b94233; }
.splash-loader span { border-radius: inherit; background: linear-gradient(90deg,#f6a91f,#fff18c,#f6b72e); box-shadow: 0 0 13px #ffd45f; }
.splash-actions { position: absolute; top: 77%; left: 50%; width: min(360px,84vw); gap: 11px; transform: translateX(-50%); }
.splash-landscape,
.splash-skip { width: 100%; min-width: 0; min-height: 50px; margin: 0; padding: 12px 18px; display: flex; align-items: center; justify-content: center; gap: 10px; border-radius: 12px; font-size: .9rem; font-weight: 900; letter-spacing: 0; }
.splash-landscape { color: #102b55; border: 1px solid #e89b10; background: linear-gradient(180deg,#ffd45b,#ffb62d); box-shadow: inset 0 1px #fff4a8,0 4px 0 #d8870b,0 10px 25px #0007; }
.splash-landscape:hover, .splash-landscape:focus-visible { color: #102b55; background: linear-gradient(180deg,#ffe17a,#ffc33d); box-shadow: inset 0 1px #fff7b7,0 4px 0 #d8870b,0 12px 28px #0008; }
.splash-landscape span { color: #15335c; font-size: 1.2rem; }
.splash-skip,
html[data-theme="light"] .splash-skip { color: #102b55; border: 1px solid #c8d7e3; background: #fffdf8; box-shadow: inset 0 1px #fff,0 4px 0 #c9c1b4,0 9px 22px #0006; }
.splash-skip span { color: #f05c22; font-size: .82rem; }
.splash-skip:hover, .splash-skip:focus-visible,
html[data-theme="light"] .splash-skip:hover, html[data-theme="light"] .splash-skip:focus-visible { color: #102b55; border-color: #f0a328; background: #fff7e7; outline: none; }
.landscape-hint, html[data-theme="light"] .landscape-hint { position: absolute; top: 91.5%; left: 50%; width: 100%; margin: 0; color: #315b82; transform: translateX(-50%); }

@media (orientation: landscape) {
  .splash-cover-art { top: 6%; width: min(70vw,900px); height: min(60vh,560px); }
  .splash-content { width: min(100%,1100px); }
  .splash-logos { top: 14px; }
  .splash-loader { top: 67%; left: 50%; width: min(430px,40vw); }
  .splash-actions { top: 72%; left: 50%; width: min(410px,40vw); }
  .landscape-hint { top: 91%; left: 50%; width: 48%; }
}

/* Light mode preserves the visual identity from the supplied Compete cover. */
html { color-scheme: light; }
body { background: radial-gradient(circle at 85% 4%,#a8d8ff 0,transparent 24rem),#eaf7ff; }
.home-cover-image { display: block; width: min(100%,560px); height: auto; margin: -18px auto 16px; border-radius: 18px; box-shadow: 0 12px 28px #164d8126; }
#screen-home .eyebrow, #screen-home .reference-decks { display: none; }
#screen-home .game-owners { display: block; margin: 0 auto 10px; padding: 5px 10px; background: #f9fdff; border: 1px solid #a8d5f2; }
#screen-home .card-panel { color: #163766; background: #f9fdff; border-color: #a8d5f2; box-shadow: 0 18px 45px #174f7e26; }
#screen-home .subtitle { color: #315b82; }
#screen-home .feature-strip span { color: #123d70; background: #eef8ff; border-color: #9fd1f1; }
#screen-home .btn-primary { color: #12345f; background: linear-gradient(180deg,#ffd84f,#ffba24); box-shadow: 0 4px 0 #e28b0d,0 10px 22px #e0961a2e; }
#screen-home .btn-secondary { color: #fff; background: linear-gradient(180deg,#2d91f0,#0865d8); border-color: #075bc4; box-shadow: 0 4px 0 #064ca8; }
#screen-home .divider { color: #315b82; }
#screen-home .divider::before, #screen-home .divider::after { background: #9fcbe8; }

html[data-theme="light"] .round-reward,
html[data-theme="light"] .profit-calculation,
html[data-theme="light"] .production-reveal { background: radial-gradient(circle at center,#2b78bc,#12345f 76%); }
html[data-theme="light"] .event-effect-backdrop,
html[data-theme="light"] .sales-reveal { background: radial-gradient(circle at 50% 42%,#53a2df,#12345f 72%); }

@media (max-width: 680px) {
  #screen-home .card-panel { margin: 0 auto; padding: 14px 16px 20px; border-radius: 0; }
  .home-cover-image { width: calc(100% + 32px); max-width: none; margin: 0 -16px 12px; border-radius: 0 0 18px 18px; box-shadow: none; }
}

/* Keep action-card controls visible within a single portrait viewport. */
@media (orientation: portrait) {
  #screen-action_cards .main-layout > .card-panel:first-child {
    height: min(43svh,370px); max-height: none; padding: 9px 14px;
    display: grid; grid-template-rows: auto auto minmax(0,1fr) auto auto auto auto; overflow: hidden;
  }
  #screen-action_cards #ac-turn-indicator { margin-bottom: 5px; padding: 7px 10px; font-size: .76rem; }
  #screen-action_cards .card-panel h3 { margin-bottom: 5px !important; font-size: .82rem; }
  #screen-action_cards #ac-hand { min-height: 0; margin: 0; padding: 3px 2px 7px; display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; }
  #screen-action_cards #ac-hand .action-card {
    flex: 0 0 auto; width: auto; min-height: 0; height: min(100%,155px); aspect-ratio: 660 / 1030;
    padding: 0; border: 0; border-radius: 8px; scroll-snap-align: start;
  }
  #screen-action_cards #ac-target-picker,
  #screen-action_cards #ac-maxprod-picker,
  #screen-action_cards .target-list { max-height: 48px; display: flex; flex-direction: row; overflow-x: auto; }
  #screen-action_cards .target-btn { flex: 0 0 auto; padding: 6px 9px; }
  #screen-action_cards .ac-action-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
  #screen-action_cards .ac-action-buttons button { width: 100%; min-height: 43px; margin: 0; padding: 8px 10px; }
  #screen-action_cards .ac-action-buttons .hidden { display: none !important; }
  #screen-action_cards .ac-action-buttons:has(#btn-play-card.hidden) { grid-template-columns: 1fr; }
}

/* Full-screen readable action-card detail. */
body.card-modal-open { overflow: hidden; }
.action-card-modal {
  position: fixed;
  z-index: 500;
  inset: 0;
  padding: clamp(10px, 3vw, 28px);
  display: none;
  place-items: center;
  color: #17345c;
  background: linear-gradient(180deg,#dff3fffa,#eef9fffa);
  backdrop-filter: blur(8px);
}
.action-card-modal.active { display: grid; animation: screenIn .2s ease both; }
.action-card-modal-shell {
  width: min(100%, 560px);
  height: min(100%, 820px);
  min-height: 0;
  padding: clamp(10px, 2.5vw, 20px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 10px;
  border: 1px solid #93c9eb;
  border-radius: 22px;
  background: #f9fdff;
  box-shadow: 0 24px 60px #12345f42;
  overflow: hidden;
}
.action-card-modal-preview { min-height: 0; display: grid; place-items: center; overflow: hidden; }
.action-card-modal .modal-card {
  width: min(100%, 390px);
  height: min(100%, 570px);
  min-height: 260px;
  margin: 0;
  padding: clamp(18px, 4vh, 34px) clamp(17px, 5vw, 30px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  transform: none;
  cursor: default;
  overflow: hidden;
}
.action-card-modal .modal-card:hover { transform: none; }
.action-card-modal .modal-card-symbol {
  width: 54px;
  height: 54px;
  margin-bottom: clamp(10px, 2vh, 20px);
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-size: 1.55rem;
  background: #ffffff2c;
}
.action-card-modal .card-label { font-size: clamp(1.45rem, 5vw, 2rem); line-height: 1.12; }
.action-card-modal .card-type { margin: 8px 0 14px; font-size: clamp(.72rem, 2.6vw, .92rem); }
.action-card-modal .card-desc {
  min-height: 0;
  margin: 0;
  padding: clamp(14px, 3vw, 22px);
  overflow-y: auto;
  font-size: clamp(1rem, 3.6vw, 1.2rem);
  line-height: 1.55;
  text-align: left;
}
.action-card-modal-controls:empty { display: none; }
.action-card-modal-controls { display: grid; gap: 7px; }
.action-card-modal-controls > div { margin-top: 0 !important; }
.action-card-modal-controls .form-label { margin-bottom: 4px; font-size: .78rem; }
.action-card-modal-controls .target-list { max-height: 64px; display: flex; gap: 6px; overflow-x: auto; }
.action-card-modal-controls .target-btn { flex: 0 0 auto; padding: 7px 11px; }
.action-card-modal-controls .number-row { margin: 0; }
.action-card-modal-buttons { display: grid; grid-template-columns: 1fr 1.35fr; gap: 10px; }
.action-card-modal-buttons button { width: 100%; min-height: 50px; margin: 0; }
.action-card-modal-buttons #btn-play-card.hidden { display: none; }
.action-card-modal-buttons:has(#btn-play-card.hidden) { grid-template-columns: 1fr; }

@media (orientation: portrait) and (max-height: 700px) {
  .action-card-modal { padding: 7px; }
  .action-card-modal-shell { padding: 8px; gap: 7px; border-radius: 15px; }
  .action-card-modal .modal-card { min-height: 210px; padding: 14px; }
  .action-card-modal .modal-card-symbol { width: 36px; height: 36px; margin-bottom: 7px; font-size: 1rem; }
  .action-card-modal .card-label { font-size: 1.25rem; }
  .action-card-modal .card-type { margin: 4px 0 7px; font-size: .65rem; }
  .action-card-modal .card-desc { padding: 11px; font-size: .9rem; line-height: 1.4; }
  .action-card-modal-buttons button { min-height: 44px; padding: 8px; }
}

/* Collapsible action area keeps the board visible on portrait tablets. */
.action-panel-toggle { display: none; }

@media (orientation: portrait) {
  #screen-production.active,
  #screen-action_cards.active,
  #screen-offering.active {
    grid-template-rows: auto auto minmax(0,1fr) auto auto;
  }
  #screen-production .mobile-game-nav,
  #screen-action_cards .mobile-game-nav,
  #screen-offering .mobile-game-nav { display: flex; }
  #screen-production > .action-panel-toggle,
  #screen-action_cards > .action-panel-toggle,
  #screen-offering > .action-panel-toggle {
    grid-row: 4;
    position: relative;
    z-index: 24;
    width: min(100% - 24px, 420px);
    min-height: 38px;
    margin: -19px auto 0;
    padding: 7px 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 2px solid #e2a220;
    border-radius: 18px 18px 0 0;
    color: #102b55;
    background: linear-gradient(#ffe178,#ffbd31);
    box-shadow: 0 -5px 14px #452a0a2e;
    font-size: .85rem;
  }
  .action-panel-toggle span { font-size: 1.15rem; line-height: 1; transition: transform .3s ease; }
  #screen-production > .main-layout,
  #screen-action_cards > .main-layout,
  #screen-offering > .main-layout {
    grid-row: 5;
    max-height: 43svh;
    opacity: 1;
    transform: translateY(0);
    transform-origin: bottom;
    transition: max-height .38s ease, opacity .25s ease, transform .38s cubic-bezier(.22,.8,.25,1);
  }
  #screen-production.game-actions-hidden > .main-layout,
  #screen-action_cards.game-actions-hidden > .main-layout,
  #screen-offering.game-actions-hidden > .main-layout {
    max-height: 0;
    opacity: 0;
    transform: translateY(100%);
    pointer-events: none;
  }
  #screen-production.game-actions-hidden > .action-panel-toggle,
  #screen-action_cards.game-actions-hidden > .action-panel-toggle,
  #screen-offering.game-actions-hidden > .action-panel-toggle { margin-top: -3px; border-radius: 18px; }
  #screen-production .main-layout > .card-panel:nth-child(2),
  #screen-action_cards .main-layout > .card-panel:nth-child(2),
  #screen-offering .main-layout > .card-panel:nth-child(2) { display: none; }
  #screen-production.mobile-show-status .main-layout > .card-panel:first-child,
  #screen-action_cards.mobile-show-status .main-layout > .card-panel:first-child,
  #screen-offering.mobile-show-status .main-layout > .card-panel:first-child { display: none; }
  #screen-production.mobile-show-status .main-layout > .card-panel:nth-child(2),
  #screen-action_cards.mobile-show-status .main-layout > .card-panel:nth-child(2),
  #screen-offering.mobile-show-status .main-layout > .card-panel:nth-child(2) { display: block; }
}

@media (orientation: portrait) and (min-width: 681px) and (max-width: 1100px) {
  #screen-production .production-warehouse { display: none; }
  #screen-production .main-layout > .card-panel,
  #screen-action_cards .main-layout > .card-panel,
  #screen-offering .main-layout > .card-panel { max-height: 38svh; padding: 13px 20px; }
  #screen-production > .main-layout,
  #screen-action_cards > .main-layout,
  #screen-offering > .main-layout { max-height: 38svh; }
  #screen-production .number-row { max-width: 720px; margin-inline: auto; }
  #screen-production #btn-ready-prod,
  #screen-offering #btn-ready-offer { width: min(100%,420px); margin-inline: auto; display: block; }
}

@media (orientation: landscape) {
  #screen-production > .action-panel-toggle,
  #screen-action_cards > .action-panel-toggle,
  #screen-offering > .action-panel-toggle {
    grid-column: 1 / -1;
    grid-row: 3;
    align-self: start;
    justify-self: center;
    z-index: 25;
    width: min(300px,42vw);
    min-height: 36px;
    padding: 6px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 2px solid #e2a220;
    border-radius: 17px 17px 0 0;
    color: #102b55;
    background: linear-gradient(#ffe178,#ffbd31);
    box-shadow: 0 -4px 12px #37150645;
    transform: translateY(-100%);
  }
  #screen-production > .main-layout,
  #screen-action_cards > .main-layout,
  #screen-offering > .main-layout {
    max-height: 46svh;
    opacity: 1;
    transform: translateY(0);
    transform-origin: bottom;
    transition: max-height .38s ease, opacity .25s ease, transform .38s cubic-bezier(.22,.8,.25,1);
  }
  #screen-production.game-actions-hidden > .main-layout,
  #screen-action_cards.game-actions-hidden > .main-layout,
  #screen-offering.game-actions-hidden > .main-layout {
    max-height: 0;
    margin-bottom: 0;
    opacity: 0;
    transform: translateY(100%);
    pointer-events: none;
  }
}

/* Clearer profit-counting overlay. */
.profit-calculation,
html[data-theme="light"] .profit-calculation {
  color: #fff;
  background: radial-gradient(circle at 50% 40%,#2869a4 0,#12345f 72%);
}
.profit-calculation .calculation-content {
  width: min(92vw,620px);
  padding: clamp(28px,6vw,52px) clamp(18px,5vw,38px);
  border: 1px solid #ffffff38;
  border-radius: 24px;
  background: #09284b5e;
  box-shadow: 0 22px 65px #061b3880, inset 0 1px #ffffff24;
}
.profit-calculation .calculation-kicker {
  color: #ffd45b;
  font-size: clamp(.72rem,2.4vw,.9rem);
  text-shadow: 0 2px 8px #071b33;
}
.profit-calculation .calculation-content h2 {
  color: #fff;
  font-size: clamp(2rem,7vw,3.6rem);
  text-shadow: 0 4px 16px #06182f;
}
.profit-calculation .calculation-content p {
  color: #edf8ff;
  font-size: clamp(.9rem,3vw,1.08rem);
  font-weight: 600;
  line-height: 1.5;
  text-shadow: 0 2px 8px #06182f;
}
.profit-calculation .calculation-progress { height: 8px; background: #061c397a; }
.profit-calculation .calculation-progress span { background: linear-gradient(90deg,#ff9e1f,#ffe477); }

#screen-lobby #btn-add-bot,
#screen-lobby #btn-start { width: min(100%,360px); margin: 12px auto 0; }
#screen-lobby .badge-bot { margin-right: 6px; color: #fff; background: #2689cf; }

/* Supplied action-card artwork is shared by both languages and all players. */
.seat-cards i,
.deal-deck i,
.dealt-action-card,
.deal-player-hand i {
  background: #fff url('aksi-back.png') center / 100% 100% no-repeat;
  border: 0;
}
.board-discard i { background: #fff url('aksi-front (1).png') center / 100% 100% no-repeat; border: 0; }
.board-discard.has-cards span { display: none; }
.action-card,
.action-card.kppu-card,
.action-card:nth-child(n),
.action-card:hover,
.action-card.selected,
.action-card.kppu-card:hover,
.action-card.kppu-card.selected {
  min-height: 0; padding: 0; border: 0; border-radius: 4.5%; background: #fff;
  box-shadow: 0 6px 14px #17345c35;
}
.action-card { width: 190px; height: auto; flex: 0 0 190px; aspect-ratio: 660 / 1030; }
.action-card::before, .action-card::after { content: none; }
.action-card.selected { outline: 3px solid #f47b20; outline-offset: 2px; }
.action-card-art { position: relative; width: 100%; height: 100%; aspect-ratio: 660 / 1030; container-type: inline-size; border-radius: 4.5%; overflow: hidden; background: #fff; }
.action-card-front-image { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; }
.action-card-copy { position: absolute; top: 7%; left: 8%; right: 8%; bottom: 41%; display: flex; flex-direction: column; justify-content: center; text-align: left; }
.action-card-art .action-card-copy .card-label { margin: 0; color: #203b79; font-family: inherit; font-size: 7.5cqi; font-weight: 900; line-height: 1.16; text-wrap: balance; }
.action-card-art .action-card-copy .card-type { margin: 3cqi 0 0; color: #194826; font-size: 3.6cqi; font-weight: 800; letter-spacing: .02em; }
.action-card-art .action-card-copy .card-desc { display: block; margin: 4cqi 0 0; padding: 0; border: 0; border-radius: 0; color: #344666; background: none; font-size: 4.6cqi; line-height: 1.42; overflow: visible; }
.action-card-modal-preview { container-type: size; }
.action-card-modal .modal-card { width: min(100cqw,calc(100cqh * 660 / 1030),360px); height: auto; min-height: 0; max-width: 100%; padding: 0; aspect-ratio: 660 / 1030; flex: none; }
.last-played-art { width: min(100%,190px); margin: 0 auto 12px; }
.last-played-art .action-card-art { height: auto; }
.card-effect .effect-card { width: min(360px,78vw,calc((100svh - 40px) * 660 / 1030)); min-height: 0; padding: 0; border: 0; border-radius: 4.5%; background: #fff; aspect-ratio: 660 / 1030; }
.card-effect .action-card-art { height: auto; }
.card-effect .action-card-copy .effect-icon { display: none; }
.card-effect .action-card-copy .effect-kicker { margin: 0 0 3cqi; color: #194826; font-size: 3cqi; line-height: 1.3; letter-spacing: .1em; }
.card-effect .action-card-copy .effect-title { color: #203b79; font-family: inherit; font-size: 7.5cqi; line-height: 1.16; }
.card-effect .action-card-copy .effect-player { margin-top: 3cqi; color: #344666; font-size: 3.8cqi; line-height: 1.3; }
.card-effect .action-card-copy .effect-target { width: fit-content; margin-top: 2cqi; padding: 1cqi 2cqi; font-size: 3.8cqi; line-height: 1.3; }
.card-effect .action-card-copy .effect-description { margin: 4cqi 0 0; color: #344666; font-size: 4.4cqi; line-height: 1.42; }

@media (orientation: landscape) and (max-height: 600px) {
  .hand-display .action-card { width: 110px; flex-basis: 110px; }
  .action-card-modal-shell { grid-template-columns: minmax(0,1fr) minmax(0,1fr); grid-template-rows: minmax(0,1fr) auto; width: min(100%,720px); }
  .action-card-modal-preview { grid-column: 1; grid-row: 1 / -1; }
  .action-card-modal-controls { grid-column: 2; grid-row: 1; align-content: center; overflow-y: auto; }
  .action-card-modal-buttons { grid-column: 2; grid-row: 2; }
}

/* Reveal market demand with the supplied back and front, once per round. */
#screen-demand_reveal .demand-card-big {
  position: relative; width: min(240px,55vw,calc(39svh * 659 / 1029)); min-width: 0;
  height: auto; aspect-ratio: 659 / 1029; margin: 8px auto; padding: 0; border: 0;
  border-radius: 4.5%; background: none; box-shadow: 0 12px 24px #17345c35;
  transform: none; perspective: 1200px; container-type: inline-size;
}
#screen-demand_reveal .demand-card-big::before { content: none; }
.demand-card-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; animation: demandCardFlip 1.65s cubic-bezier(.45,0,.2,1) both; }
.demand-card-face { position: absolute; inset: 0; border-radius: 4.5%; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; background: #fff; }
.demand-card-face img { display: block; width: 100%; height: 100%; object-fit: contain; }
/* Align the visible artwork inside the back asset's transparent margins. */
.demand-card-back img { position: absolute; left: -16.932%; top: -12.168%; width: 118.473%; height: 112.206%; max-width: none; object-fit: fill; }
.demand-card-front { transform: rotateY(180deg); }
.demand-card-copy { position: absolute; top: 16%; left: 8%; right: 23%; bottom: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
#screen-demand_reveal .demand-card-big .demand-num { width: auto; height: auto; margin: 0; padding: 0; border: 0; border-radius: 0; color: #184e8c; background: none; font-size: 32cqi; line-height: 1; text-shadow: none; }
#screen-demand_reveal .demand-card-big .demand-sub { margin: 4cqi 0 0; color: #344666; font-size: 5.5cqi; line-height: 1.35; font-weight: 750; }
@keyframes demandCardFlip {
  0%, 40% { transform: rotateY(0deg); }
  100% { transform: rotateY(180deg); }
}
@media (orientation: landscape) and (max-height: 700px) {
  #screen-demand_reveal .demand-card-big { width: min(100%,220px,calc((100svh - 150px) * 659 / 1029)); margin: auto; }
}

/* Start menu and room setup are separate views; the guide opens its own HTML page. */
.start-menu-actions { display: grid; gap: 15px; width: min(100%,380px); margin: 25px auto 20px; }
#btn-open-game { width: 100%; min-height: 54px; display: flex; align-items: center; justify-content: center; gap: 24px; border-radius: 13px; font-size: 1rem; }
.how-to-play-link { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 49px; padding: 12px 20px; border: 1px solid #afd0e8; border-radius: 13px; color: #225485; background: #eef7fe; font-size: .91rem; font-weight: 750; text-decoration: none; transition: background .2s ease,border-color .2s ease; }
.how-to-play-link:hover { background: #e0f0fc; border-color: #75afd7; }
.how-to-play-link:focus-visible { outline: 3px solid #f47b20; outline-offset: 4px; }
.how-to-play-link > span { font-size: 1.25rem; }
.start-menu-note { margin: 0; color: #69839b; font-size: .73rem; }
#screen-rooms .room-setup-panel { width: min(100%,590px); margin: 12px auto; padding: clamp(22px,5vw,38px); color: #163766; background: #f9fdff; border-color: #a8d5f2; box-shadow: 0 18px 45px #174f7e26; }
#screen-rooms .room-setup-panel > h1 { margin-top: 6px; font-size: clamp(1.7rem,5vw,2.25rem); line-height: 1.14; }
#screen-rooms .subtitle { margin: 16px 0 24px; color: #59738d; line-height: 1.6; }
#btn-back-to-menu { display: block; margin: -6px 0 24px -8px; color: #416b91; }
.room-setup-kicker { color: #d87521; font-size: .67rem; font-weight: 850; letter-spacing: .16em; }
#screen-rooms .btn-primary { color: #12345f; background: linear-gradient(180deg,#ffd84f,#ffba24); box-shadow: 0 4px 0 #e28b0d,0 10px 22px #e0961a2e; }
#screen-rooms .btn-secondary { color: #fff; background: linear-gradient(180deg,#2d91f0,#0865d8); border-color: #075bc4; box-shadow: 0 4px 0 #064ca8; }
@media (max-width: 680px) {
  .start-menu-actions { margin-top: 22px; }
  #screen-home .home-cover-image { margin-bottom: 18px; }
  #screen-rooms .room-setup-panel { margin: 0 auto; }
}

/* Host controls stay beside each lobby player, including computer players. */
#screen-lobby .player-row { gap: 12px; }
.lobby-player-name { min-width: 0; text-align: left; overflow-wrap: anywhere; }
.lobby-player-controls { display: flex; flex-shrink: 0; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.btn-kick-player { min-height: 36px; padding: 6px 12px; border: 1px solid #efa4a4; border-radius: 9px; color: #9e2634; background: #fff0ef; font: inherit; font-size: .74rem; font-weight: 750; cursor: pointer; }
.btn-kick-player:hover { color: #fff; background: #c6384b; border-color: #c6384b; }
.btn-kick-player:focus-visible { outline: 3px solid #f4bd3d; outline-offset: 3px; }

/* The reveal and the persistent results both reflect the current player's outcome. */
.winner-celebration.is-win { background: radial-gradient(ellipse at 50% 40%,#976222 0,#3d286a 45%,#101a42 100%); }
.winner-celebration.is-loss { background: radial-gradient(ellipse at 50% 40%,#854d88 0,#34316e 45%,#101a42 100%); }
.winner-celebration.is-loss .winner-rays { background: repeating-conic-gradient(from 0deg,#b69cff 0 6deg,transparent 6deg 15deg); }
.winner-content { max-height: calc(100svh - 32px); overflow-y: auto; padding: clamp(22px,4vw,38px) 22px; }
.winner-trophy { margin: 8px auto; font-size: clamp(3.5rem,13vw,6.5rem); }
.winner-content h2.winner-status { font-size: clamp(3rem,11vw,6rem); font-weight: 1000; font-style: italic; color: #ffdf70; letter-spacing: -.05em; text-shadow: 0 4px 0 #b57129,0 0 40px #ffd54d66; }
.winner-content #winner-name { margin-top: 16px; font-size: clamp(1.05rem,4vw,1.7rem); line-height: 1.4; text-shadow: none; overflow-wrap: anywhere; }
.winner-celebration.is-loss .winner-content h2.winner-status { color: #ffc7d8; text-shadow: 0 4px 0 #b34478,0 0 40px #f082b366; }
#btn-view-final { position: relative; z-index: 4; display: block; margin: 22px auto 0; min-width: 190px; }
.winner-progress { margin-top: 20px; }
.winner-progress span { animation-duration: 6.5s; }
#screen-gameover { --result-glow: #ffcb4d; --result-accent: #ffdf70; }
#screen-gameover[data-result="loss"] { --result-glow: #f285bc; --result-accent: #ffcedf; }
.final-stage { position: relative; isolation: isolate; min-height: calc(100svh - 90px); padding: 24px 20px 40px; overflow: hidden; border-radius: 28px; background: radial-gradient(ellipse at 50% 10%,#674771 0,#26366b 42%,#101d45 100%); }
#screen-gameover[data-result="win"] .final-stage { background: radial-gradient(ellipse at 50% 10%,#9a6d2c 0,#493769 36%,#101d45 100%); }
.final-stage::before { content: ''; position: absolute; z-index: -1; top: -420px; left: calc(50% - 650px); width: 1300px; height: 1300px; opacity: .24; background: repeating-conic-gradient(var(--result-glow) 0 5deg,transparent 5deg 17deg); mask-image: radial-gradient(circle,#000 0,transparent 65%); animation: winnerRays 45s linear infinite; pointer-events: none; }
#screen-gameover .final-panel { position: relative; z-index: 2; width: min(100%,720px); max-width: 720px; margin: 0 auto; padding: 32px clamp(20px,5vw,46px); color: #fff; border: 1px solid #ffffff35; border-radius: 25px; background: linear-gradient(145deg,#1f285cdc,#142449ee); box-shadow: 0 25px 90px #050e3588,inset 0 1px #ffffff33; }
#screen-gameover .final-panel::before { display: none; }
.final-kicker { margin: 0; color: var(--result-accent); font-size: .67rem; letter-spacing: .23em; font-weight: 850; }
.final-emblem { margin: 12px 0 4px; font-size: 4rem; line-height: 1.2; filter: drop-shadow(0 8px 18px #070f40); animation: trophyBounce 2.2s ease-in-out infinite; }
#screen-gameover h2.final-status { margin: 0; color: var(--result-accent); font-size: clamp(3.3rem,10vw,5.7rem); font-style: italic; font-weight: 1000; line-height: 1; letter-spacing: -.055em; text-shadow: 0 4px 0 #8d612d,0 0 35px #ffcb4d33; }
#screen-gameover[data-result="loss"] h2.final-status { text-shadow: 0 4px 0 #923968,0 0 35px #f285bc33; }
.final-message { max-width: 440px; margin: 18px auto 24px; color: #dbe6ff; font-size: .9rem; line-height: 1.65; }
#screen-gameover .final-winner { margin: 0 0 20px; padding: 17px; border: 1px solid #f9d777; background: linear-gradient(145deg,#fff9dc,#ffdd85); box-shadow: 0 5px 28px #ffcb4d16; }
.final-winner strong { overflow-wrap: anywhere; line-height: 1.3; }
.final-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px; }
.final-stats > div { padding: 12px 8px; border: 1px solid #ffffff20; border-radius: 12px; background: #ffffff08; }
.final-stats span { display: block; color: #adbfdf; font-size: .72rem; }
.final-stats strong { display: block; margin-top: 3px; color: #fff; font-size: 1.15rem; font-weight: 850; }
#screen-gameover .final-score-title { margin-bottom: 12px; color: #d9e5ff; font-size: .82rem; text-align: left; }
.final-ranking { margin: 0; padding: 0; list-style: none; }
.final-rank-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; padding: 11px 14px; border: 1px solid #ffffff14; border-radius: 11px; background: #ffffff06; text-align: left; }
.final-rank-row.rank-winner { border-color: #fbd57655; background: #ffcc4d14; }
.final-rank-row.rank-me { box-shadow: inset 3px 0 #78c9ff; }
.rank-number { flex: 0 0 30px; color: #a3b8d8; font-size: .84rem; font-weight: 800; }
.rank-winner .rank-number { font-size: 1.3rem; }
.rank-name { flex: 1; min-width: 0; color: #fff; font-size: .86rem; font-weight: 700; overflow-wrap: anywhere; }
.rank-name small { margin-left: 7px; color: #9acbff; font-size: .65rem; font-weight: 600; }
.final-rank-row > strong { flex-shrink: 0; color: #e0edff; font-size: .86rem; }
.rank-winner > strong { color: #ffdf70; }
.final-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; }
.final-actions button { min-height: 48px; padding: 12px; font-size: .84rem; }
#screen-gameover .final-actions .btn-primary { color: #172c52; background: linear-gradient(#ffdc69,#ffbd2b); box-shadow: 0 4px 0 #bd7c13; }
#screen-gameover .final-actions .btn-secondary { color: #e8efff; border: 1px solid #718bb1; background: #314a75; box-shadow: 0 4px 0 #142548; }
.final-confetti { z-index: -1; }
.final-confetti i { width: 7px; height: 13px; opacity: .75; animation-duration: 5s; }
.final-sparkles { position: absolute; z-index: -1; inset: 0; color: var(--result-accent); pointer-events: none; }
.final-sparkles i { position: absolute; font-size: 3rem; font-style: normal; animation: finalStarPulse 2.6s ease-in-out infinite alternate; }
.final-sparkles i:nth-child(1) { left: 6%; top: 14%; }
.final-sparkles i:nth-child(2) { right: 8%; top: 28%; animation-delay: .8s; }
.final-sparkles i:nth-child(3) { left: 12%; top: 65%; animation-delay: 1.4s; }
.final-sparkles i:nth-child(4) { right: 5%; top: 83%; animation-delay: .4s; }
@keyframes finalStarPulse { from { opacity: .35; transform: scale(.7) rotate(-10deg); } to { opacity: 1; transform: scale(1.1) rotate(15deg); } }
@media (max-width: 680px) {
  .final-stage { padding: 16px 10px 28px; border-radius: 20px; }
  #screen-gameover .final-panel { padding: 25px 18px; border-radius: 19px; }
  .final-emblem { font-size: 3.5rem; }
  .final-actions { grid-template-columns: 1fr; }
  .final-rank-row { gap: 8px; padding: 10px; }
  .final-rank-row > strong { font-size: .78rem; }
  .rank-name { font-size: .8rem; }
  .lobby-player-controls { max-width: 125px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .winner-content { width: min(94vw,760px); padding: 16px 24px; display: grid; grid-template-columns: 100px 1fr; gap: 4px 16px; align-items: center; }
  .winner-kicker { grid-column: 1 / -1; }
  .winner-trophy { grid-column: 1; grid-row: 2 / 5; font-size: 4.5rem; }
  .winner-content h2.winner-status { font-size: 3.5rem; }
  .winner-content #winner-name { margin-top: 0; font-size: 1.15rem; }
  .winner-content p { margin: 2px 0; font-size: .85rem; }
  .winner-content > strong, #btn-view-final, .winner-progress { grid-column: 1 / -1; }
  #btn-view-final { margin-top: 10px; }
  .winner-progress { margin-top: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .winner-celebration *, .final-stage::before, .final-stage * { animation: none !important; }
}
