:root {
  color-scheme: dark;
  --gold: #f4cf77;
  --gold-deep: #a87024;
  --cream: #fff8e8;
  --ink: #1d1720;
  --green: #0b4a37;
  --green-dark: #042b22;
  --burgundy: #6c1630;
  --burgundy-dark: #330817;
  --blue-black: #101827;
  --muted: #b9b7ad;
  --safe-bottom: max(10px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  background: #03140f;
  font-family: ui-rounded, 'Avenir Next', system-ui, sans-serif;
  color: var(--cream);
  overscroll-behavior: none;
}
button { font: inherit; }
button:focus-visible { outline: 3px solid #fff0a8; outline-offset: 3px; }

.game-shell {
  position: relative;
  width: min(100%, 520px);
  min-height: 100svh;
  margin: 0 auto;
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(180deg, rgba(2,7,12,.5), rgba(0,34,25,.16) 30%, rgba(55,5,20,.48)),
    url('assets/solitaire-tabletop.webp') center / cover;
  box-shadow: 0 0 90px #000;
}

.game-shell::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(0,0,0,.28), transparent 9% 91%, rgba(0,0,0,.28));
}

.ambient { position: absolute; z-index: -1; border-radius: 50%; filter: blur(60px); opacity: .25; }
.ambient-a { width: 240px; height: 150px; top: 5%; right: -15%; background: #306cbd; }
.ambient-b { width: 260px; height: 180px; bottom: 3%; left: -20%; background: #c21d51; }

.titlebar {
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 16px 8px;
  background: linear-gradient(#070c16f2, #071420e6);
  border-bottom: 1px solid #c3984855;
}
.brand-mark { width: 38px; height: 38px; border: 1px solid #e3b95b; transform: rotate(45deg); display: grid; place-items: center; background: #7a1532; box-shadow: inset 0 0 0 3px #270814, 0 0 18px #e1b85233; }
.brand-mark span { transform: rotate(-45deg); font-family: Georgia, serif; font-weight: 700; font-size: 25px; color: #ffe39a; }
.brand-copy { flex: 1; }
.brand-copy p { margin: 0 0 -2px; color: #a9b3bf; letter-spacing: .16em; text-transform: uppercase; font-size: 8px; }
.brand-copy h1 { margin: 0; font: 700 25px/1 Georgia, serif; letter-spacing: -.02em; }
.brand-copy em { color: var(--gold); font-style: normal; }
.icon-button { border: 1px solid #e6c87455; width: 36px; height: 36px; border-radius: 50%; color: #efd78f; background: #0e1725bb; font-size: 18px; }

.duelist {
  margin: 10px 12px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #b7c6d43d;
  border-radius: 15px;
  padding: 9px 11px;
  background: linear-gradient(105deg, #0c1019f2, #1a2334e8);
  box-shadow: 0 9px 24px #0008, inset 0 1px #ffffff0f;
  transition: filter .25s, border-color .25s, box-shadow .25s;
}
.duelist.active { border-color: #82bcff; box-shadow: 0 0 22px #3c85d344, 0 9px 24px #0008; }
.duelist.inactive { filter: saturate(.55) brightness(.74); }
.avatar { position: relative; flex: 0 0 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; border: 2px solid #b79049; box-shadow: inset 0 0 0 3px #080b11; font: 700 23px Georgia, serif; }
.avatar-bot { background: radial-gradient(circle at 36% 28%, #4d668b, #101725 60%); color: #b8d6ff; }
.avatar-player { background: radial-gradient(circle at 36% 28%, #c64f6d, #4e0e23 60%); color: #ffe2e9; }
#botThinking { position: absolute; width: 9px; height: 9px; right: -1px; bottom: 0; background: #63d8ff; border: 2px solid #0b111b; border-radius: 50%; opacity: 0; }
.thinking #botThinking { opacity: 1; animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px #63d8ff00; } 0%, 100% { box-shadow: 0 0 0 1px #63d8ff88; } }
.duelist-main { min-width: 0; flex: 1; }
.duelist-name { display: flex; justify-content: space-between; align-items: baseline; gap: 5px; }
.duelist-name b, .player-zone-head b { font: 700 18px Georgia, serif; }
.duelist-name small, .player-zone-head small { color: #8998ab; letter-spacing: .12em; font-size: 7px; }
.score { text-align: right; padding-left: 9px; border-left: 1px solid #ffffff17; }
.score small { display: block; color: #8190a3; font-size: 7px; letter-spacing: .15em; }
.score strong { color: var(--gold); font: 700 25px Georgia, serif; font-variant-numeric: tabular-nums; }
.charge-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 7px; margin-top: 5px; }
.charge-row > span, .charge-row > strong { color: #9ba6b4; font-size: 8px; text-transform: uppercase; letter-spacing: .06em; }
.charge-track { height: 5px; border-radius: 4px; background: #0008; overflow: hidden; box-shadow: inset 0 1px 2px #000; }
.charge-track i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #40aa90, #fbdb77); border-radius: inherit; transition: width .35s; box-shadow: 0 0 8px #ffe786; }

.match-ribbon { display: grid; grid-template-columns: 54px 1fr 54px; align-items: center; margin: 8px 16px 0; }
.match-ribbon > div:not(.turn-center) { text-align: center; color: #aab3b8; font-size: 9px; }
.match-ribbon small { display: block; font-size: 7px; letter-spacing: .12em; }
.match-ribbon strong { color: #f7df9b; font-size: 16px; }
.turn-center { text-align: center; }
.turn-center p { margin: 0 0 5px; color: #f8e5aa; font-size: 9px; letter-spacing: .13em; font-weight: 700; }
.timer-track { position: relative; height: 7px; background: #06150fbb; border: 1px solid #9a864d66; border-radius: 8px; overflow: visible; }
.timer-track i { display: block; height: 100%; border-radius: inherit; width: 100%; background: linear-gradient(90deg, #f1ce69, #d3546e); transition: width .2s linear; }
.timer-track span { position: absolute; right: -24px; top: -6px; color: #e9dba9; font-size: 9px; font-variant-numeric: tabular-nums; }

.table-zone { position: relative; margin: 7px 8px 0; min-height: 470px; border: 1px solid #b7934957; border-radius: 22px; background: linear-gradient(#06382b55, #00251bbb), radial-gradient(circle at 50% 20%, #14705555, transparent 55%); box-shadow: inset 0 0 42px #00120d, 0 8px 26px #0007; overflow: hidden; }
.table-zone::before { content: ''; position: absolute; inset: 6px; border: 1px solid #d1af5e24; border-radius: 17px; pointer-events: none; }
.table-label { position: absolute; z-index: 1; top: 9px; left: 15px; right: 15px; display: flex; align-items: center; gap: 8px; color: #b5c7b9; font: 600 7px ui-rounded, system-ui, sans-serif; letter-spacing: .14em; text-transform: uppercase; }
.table-label b { color: #d9cfa8; font-weight: 600; }
#boardCanvas { display: block; width: 100%; height: 450px; touch-action: manipulation; }
.status-pill { position: static; min-width: 0; flex: 1; transform: none; white-space: nowrap; padding: 3px 10px; border: 1px solid #e7ca7b45; border-radius: 18px; background: #031b15dd; color: #ddd4b5; text-align: center; font-size: 8px; letter-spacing: .04em; box-shadow: 0 3px 8px #0006; overflow: hidden; text-overflow: ellipsis; }
.status-pill.attention { animation: status-pop .45s ease 2; color: #fff0ad; border-color: #f4ce6c; }
@keyframes status-pop { 50% { transform: scale(1.045); box-shadow: 0 0 18px #f2ca5c66; } }

.foundation-zone { display: grid; grid-template-columns: 1fr 94px 1fr; align-items: center; min-height: 100px; padding: 5px 16px; }
.foundation-wrap { position: relative; z-index: 0; isolation: isolate; text-align: center; }
.foundation-wrap::after { content: ''; position: absolute; z-index: -1; left: 50%; top: 58%; width: 70px; height: 70px; border: 2px solid #ffe38a; border-radius: 50%; opacity: 0; transform: translate(-50%, -50%) scale(.45); pointer-events: none; }
.foundation-wrap.receiving::after { animation: foundation-ring .48s .17s cubic-bezier(.15,.75,.25,1) both; }
.foundation-wrap.receiving .foundation-card { animation: foundation-land .34s .14s cubic-bezier(.18,.82,.24,1) both; }
@keyframes foundation-ring { 0% { opacity: .9; transform: translate(-50%, -50%) scale(.45); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.55); } }
@keyframes foundation-land { 0%, 100% { transform: translateY(0) scale(1); } 45% { transform: translateY(2px) scale(1.13); filter: brightness(1.35) drop-shadow(0 0 12px #ffe27c); } }
.foundation-wrap > small, .mini-hand > small { display: block; margin-bottom: 3px; color: #d8c787; font-size: 6px; letter-spacing: .12em; }
.playing-card { position: relative; width: 53px; height: 72px; border: 0; border-radius: 7px; color: #1a1820; background: linear-gradient(145deg, #fffdf5, #eaddc2); box-shadow: 0 5px 12px #0009, inset 0 0 0 2px #fff, inset 0 0 0 3px #b89a62; }
.playing-card.red { color: #a8183e; }
.playing-card .rank { position: absolute; left: 6px; top: 4px; font: 700 17px/1 Georgia, serif; }
.playing-card .suit { position: absolute; inset: 0; display: grid; place-items: center; padding-top: 7px; font-size: 28px; }
.playing-card .alt { position: absolute; right: -7px; top: -7px; width: 23px; height: 23px; display: grid; place-items: center; border-radius: 50%; color: #291a00; background: #f6d16f; border: 2px solid #fff3b9; font: 700 12px Georgia, serif; box-shadow: 0 2px 6px #0008; }
.foundation-card { width: 58px; height: 78px; }
.foundation-card.golden { background: linear-gradient(145deg, #fff1a6, #b77a18); box-shadow: 0 0 22px #ffd95baa, inset 0 0 0 2px #fff6c9, inset 0 0 0 4px #7d4b00; }
.mini-hand { text-align: center; opacity: .7; }
.hand-row { display: flex; justify-content: center; }
.bot-mini-card { position: relative; width: 29px; height: 43px; margin-left: -6px; border-radius: 5px; color: #191820; background: #f5ead2; border: 1px solid #b69353; box-shadow: 0 3px 6px #0008, inset 0 0 0 1px #fff; }
.bot-mini-card.red { color: #a8193e; }
.bot-mini-card b { position: absolute; left: 3px; top: 2px; font: 700 11px Georgia, serif; }
.bot-mini-card i { position: absolute; inset: 0; display: grid; place-items: center; padding-top: 5px; font-style: normal; font-size: 16px; }
.bot-mini-card.used { filter: brightness(.5) saturate(.35); transform: translateY(5px); }
.streak-medallion { justify-self: end; width: 49px; height: 49px; border-radius: 50%; display: grid; place-content: center; text-align: center; border: 1px solid #e2bd5a; background: radial-gradient(circle, #4b1a24, #170b12); box-shadow: 0 0 14px #b92a4c33; }
.streak-medallion small { font-size: 6px; color: #c7aeb4; letter-spacing: .1em; }
.streak-medallion strong { color: #ffe192; font: 700 18px Georgia, serif; }

.player-zone { margin-top: 0; padding: 9px 14px calc(12px + var(--safe-bottom)); background: linear-gradient(115deg, #3e091ae8, #6e1830ee 55%, #360715f2); border-top: 1px solid #e0b25866; box-shadow: 0 -11px 35px #0008, inset 0 1px #ffffff12; transition: filter .25s, box-shadow .25s; }
.player-zone.active { box-shadow: 0 -10px 32px #c7356244, inset 0 1px #ffffff18; }
.player-zone.inactive { filter: saturate(.65) brightness(.72); }
.player-zone-head { display: flex; align-items: center; gap: 8px; height: 35px; }
.player-zone-head .avatar { flex-basis: 35px; height: 35px; font-size: 19px; }
.player-zone-head > div:nth-child(2) { flex: 1; }
.player-zone-head b, .player-zone-head small { display: block; }
.score-player { display: block; border: 0; }
.score-player small { color: #c98a9a; }
.player-hand { display: flex; align-items: flex-end; justify-content: flex-start; gap: 9px; min-height: 90px; margin-top: 3px; padding: 4px 2px 2px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; }
.player-hand::-webkit-scrollbar { display: none; }
.player-hand .playing-card { flex: 0 0 61px; width: 61px; height: 83px; cursor: pointer; scroll-snap-align: center; transition: transform .18s, filter .18s; }
.player-hand .playing-card:hover:not(:disabled), .player-hand .playing-card:focus-visible { transform: translateY(-6px); }
.player-hand .playing-card:disabled { filter: brightness(.58) saturate(.4); }
.player-hand .playing-card.locked { filter: brightness(.72) saturate(.65); cursor: wait; }
.player-hand .playing-card.used { transform: translateY(12px) scale(.9); opacity: .34; }
.player-charge { margin: 3px 4px 8px; }
.player-charge > span, .player-charge > strong { color: #dfabb7; }
.power-bar { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 6px; }
.power-button { min-width: 0; height: 51px; padding: 4px 5px; border: 1px solid #e2c47666; border-radius: 9px; display: flex; align-items: center; gap: 5px; color: #f8ead1; background: linear-gradient(135deg, #19293d, #0d1320); box-shadow: inset 0 1px #ffffff10, 0 3px 8px #0005; }
.power-button.perk { background: linear-gradient(135deg, #6e2f51, #331227); }
.power-button:disabled { filter: grayscale(.7) brightness(.55); }
.power-button .power-glyph { flex: 0 0 33px; height: 39px; border-radius: 7px; display: grid; place-items: center; color: #231a0a; font-size: 19px; background: radial-gradient(circle at 35% 25%, #fff2af, #b87922); box-shadow: inset 0 0 0 2px #fff6ba55; }
.power-glyph.has-art { color: transparent; background-position: center; background-size: cover; box-shadow: inset 0 0 0 1px #ffecaa88, 0 2px 7px #0008; }
.power-button i { min-width: 0; flex: 1; text-align: left; font-style: normal; }
.power-button small { display: block; color: #b9a779; letter-spacing: .1em; font-size: 5px; }
.power-button b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 10px Georgia, serif; }
.power-button em { align-self: flex-start; color: #e8d395; font-size: 7px; font-style: normal; }
.end-turn { margin-top: 8px; width: 100%; height: 39px; border-radius: 10px; border: 1px solid #f2cc7466; color: #fff0ce; background: linear-gradient(#9a2948, #631429); box-shadow: inset 0 1px #ffffff22, 0 4px 10px #0005; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; font-size: 10px; }
.end-turn span { float: right; font-size: 17px; line-height: 8px; }
.end-turn:disabled { filter: grayscale(.8) brightness(.55); }

.overlay { position: absolute; z-index: 20; inset: 0; display: grid; align-items: end; padding-top: max(20px, env(safe-area-inset-top)); background: #02080dd9; backdrop-filter: blur(9px); opacity: 0; pointer-events: none; transition: opacity .25s; }
.overlay.visible { opacity: 1; pointer-events: auto; }
.overlay-panel { width: 100%; max-height: 94svh; overflow: auto; padding: 27px 18px calc(22px + var(--safe-bottom)); border-radius: 28px 28px 0 0; background: linear-gradient(160deg, #12251f 0%, #071611 55%, #190910 100%); border: 1px solid #d1ac5866; box-shadow: 0 -20px 80px #000c, inset 0 1px #ffffff16; }
#loadoutOverlay { align-items: start; overflow-y: auto; padding: max(18px, env(safe-area-inset-top)) 10px max(18px, env(safe-area-inset-bottom)); }
#loadoutOverlay .loadout-panel { width: min(100%, 490px); max-height: none; margin: 0 auto; border-radius: 24px; box-shadow: 0 20px 80px #000d, inset 0 1px #ffffff16; }
#coinOverlay { align-items: center; padding: max(18px, env(safe-area-inset-top)) 10px max(18px, env(safe-area-inset-bottom)); }
#coinOverlay .coin-panel { width: min(100%, 440px); margin: 0 auto; border-radius: 24px; box-shadow: 0 20px 80px #000d, inset 0 1px #ffffff16; }
.eyebrow { color: #c8a751; text-align: center; font-size: 8px; font-weight: 700; letter-spacing: .24em; }
.overlay h2 { margin: 4px 0 4px; text-align: center; color: #fff4d4; font: 700 34px/1.1 Georgia, serif; }
.overlay h2 + p { max-width: 380px; margin: 0 auto 18px; color: #aab9b1; text-align: center; font-size: 10px; line-height: 1.5; }
.loadout-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border-radius: 12px; background: #020b08aa; }
.loadout-tabs button { height: 38px; border: 0; border-radius: 9px; color: #7d9187; background: transparent; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.loadout-tabs button.active { color: #ffe9aa; background: linear-gradient(#183b30, #10281f); box-shadow: inset 0 0 0 1px #cba95155; }
.loadout-tabs span { margin-left: 4px; color: #c8b36d; font-size: 8px; }
.power-choices { display: grid; grid-auto-flow: column; grid-auto-columns: 106px; gap: 9px; margin: 14px -18px 10px; padding: 2px 18px 10px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.power-choices::-webkit-scrollbar { display: none; }
.choice-card { position: relative; scroll-snap-align: start; height: 145px; border: 1px solid #b79c5b55; border-radius: 13px; padding: 8px; color: #e5ddd1; background: linear-gradient(160deg, #27384b, #0c151e 60%); box-shadow: 0 7px 12px #0007, inset 0 1px #ffffff12; text-align: left; overflow: hidden; }
.choice-card.perk { background: linear-gradient(160deg, #753152, #261021 60%); }
.choice-card.selected { border-color: #ffe49a; box-shadow: 0 0 0 2px #d7ad4d, 0 0 22px #f5c95d55; transform: translateY(-1px); }
.choice-card .choice-art { height: 82px; display: grid; place-items: center; margin: -8px -8px 7px; font-size: 35px; color: #ffe6a1; background: radial-gradient(circle at 50% 40%, #cb9c4655, transparent 60%), repeating-linear-gradient(45deg,#213b43 0 5px,#1b3038 5px 10px); border-bottom: 1px solid #dac27844; }
.choice-card.perk .choice-art { background: radial-gradient(circle at 50% 40%, #e1729b55, transparent 60%), repeating-linear-gradient(45deg,#59223b 0 5px,#471b31 5px 10px); }
.choice-card .choice-art img { width: 100%; height: 100%; display: block; background-color: #30106e; }
.choice-card b { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 700 12px Georgia, serif; }
.choice-card small { color: #9eaaad; font-size: 6px; letter-spacing: .1em; }
.choice-card em { position: absolute; right: 6px; top: 6px; width: 18px; height: 18px; border-radius: 50%; display: none; place-items: center; color: #291800; background: #f6d479; font-style: normal; font-size: 10px; }
.choice-card.selected em { display: grid; }
.power-description { min-height: 64px; display: flex; align-items: center; gap: 11px; padding: 10px; border: 1px solid #ad94504a; border-radius: 12px; background: #06100dcc; }
.power-description > .power-glyph { flex: 0 0 39px; height: 39px; border-radius: 9px; display: grid; place-items: center; color: #ffe096; background: #5b3c1c; }
.power-description b { color: #ffebba; font: 700 14px Georgia, serif; }
.power-description p { margin: 2px 0 0; color: #9cac9f; font-size: 8px; line-height: 1.4; }
.difficulty-picker { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; padding: 10px 11px; border: 1px solid #ad94504a; border-radius: 12px; background: #06100dcc; }
.difficulty-picker small, .difficulty-picker b { display: block; }
.difficulty-picker small { color: #9cac9f; font-size: 6px; letter-spacing: .13em; }
.difficulty-picker b { margin-top: 2px; color: #ffe5a2; font: 700 13px Georgia, serif; }
.difficulty-options { display: grid; grid-template-columns: repeat(5, 29px); gap: 4px; }
.difficulty-options button { width: 29px; height: 29px; border: 1px solid #8f824f66; border-radius: 8px; color: #82958b; background: #0d211b; font-size: 9px; font-weight: 800; }
.difficulty-options button.selected { color: #271600; border-color: #ffe29a; background: linear-gradient(#ffe29a, #bd8430); box-shadow: 0 0 12px #e9bd5155; }
.primary-button { margin-top: 14px; width: 100%; height: 50px; border: 1px solid #ffe5a2aa; border-radius: 12px; color: #271600; background: linear-gradient(#ffe69a, #c88e34); box-shadow: inset 0 1px #fff8d2, 0 8px 20px #0008; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; font-size: 10px; }
.primary-button span { float: right; font-size: 20px; line-height: 8px; }
.primary-button:disabled { filter: grayscale(1) brightness(.5); }

.coin-panel, .result-panel { padding-top: 38px; padding-bottom: calc(38px + var(--safe-bottom)); }
.coin-disc { --coin-flip-duration: 1.6s; --coin-end-rotation: 2880deg; position: relative; width: 126px; height: 126px; margin: 19px auto 23px; border-radius: 50%; color: #2e1b02; background: radial-gradient(circle at 34% 26%, #fff2b5, #d39a35 45%, #7a4715 72%); border: 5px double #ffecad; box-shadow: 0 0 35px #eab94f66, inset -10px -15px 24px #63330c88; font-size: 56px; transform-style: preserve-3d; will-change: transform; }
.coin-face { position: absolute; inset: 0; display: grid; place-items: center; border-radius: 50%; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.coin-moon { transform: rotateY(180deg); }
.coin-disc.result-sun { transform: rotateY(0deg); }
.coin-disc.result-moon { transform: rotateY(180deg); }
.coin-disc.flipping { animation: coin-flip var(--coin-flip-duration) cubic-bezier(.12, .58, .18, 1) forwards; }
@keyframes coin-flip {
  0% { transform: translateY(0) rotateY(180deg) scale(1); }
  16% { transform: translateY(-17px) rotateY(720deg) scale(.96); }
  34% { transform: translateY(-6px) rotateY(1260deg) scale(.92); }
  52% { transform: translateY(-14px) rotateY(1800deg) scale(.94); }
  70% { transform: translateY(-4px) rotateY(2340deg) scale(.97); }
  100% { transform: translateY(0) rotateY(var(--coin-end-rotation)) scale(1); }
}
.coin-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.coin-actions button { height: 65px; border: 1px solid #c9a45e77; border-radius: 13px; color: #f4e3b9; background: linear-gradient(#223b35, #0c1b17); }
.coin-actions b, .coin-actions small { display: block; }
.coin-actions b { font: 700 20px Georgia, serif; }
.coin-actions small { margin-top: 3px; color: #91a89e; font-size: 7px; letter-spacing: .13em; }
.coin-result { margin: 16px 0 0; min-height: 18px; color: #d4bd7c; text-align: center; font-size: 10px; }
.result-crown { width: 78px; height: 78px; display: grid; place-items: center; margin: 0 auto 15px; border-radius: 50%; color: #271600; background: radial-gradient(circle, #fff0a0, #b87a25); border: 3px double #fff1b1; font-size: 34px; box-shadow: 0 0 35px #edbd4c55; }
.final-score { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; width: 250px; margin: 25px auto; text-align: center; }
.final-score small { display: block; color: #97a9a0; font-size: 7px; letter-spacing: .15em; }
.final-score strong { color: #ffe6a1; font: 700 42px Georgia, serif; }
.final-score > span { color: #9e884f; }

.toast-overlay { position: absolute; z-index: 15; inset: 0; display: grid; place-items: center; background: #02090777; opacity: 0; pointer-events: none; transition: opacity .2s; }
.toast-overlay.visible { opacity: 1; }
.toast-overlay > div { width: 78%; padding: 19px; border: 1px solid #d3b15888; border-radius: 15px; text-align: center; background: #071711ee; box-shadow: 0 14px 40px #000b; }
.toast-overlay strong, .toast-overlay span { display: block; }
.toast-overlay strong { color: #ffe5a1; font: 700 23px Georgia, serif; }
.toast-overlay span { margin-top: 6px; color: #a8b8b0; font-size: 9px; }

.flying-card {
  position: absolute;
  z-index: 19;
  left: 0;
  top: 0;
  opacity: 0;
  pointer-events: none;
  border-radius: 7px;
  color: #1b1820;
  background: linear-gradient(145deg, #fffef6, #eadfc9);
  border: 1px solid #b49252;
  box-shadow: 0 10px 24px #000b, 0 0 18px #ffe58688, inset 0 0 0 2px #fff;
  transform: translate3d(var(--sx), var(--sy), 0);
}
.flying-card::before { content: ''; position: absolute; z-index: -1; left: 18%; right: 18%; bottom: 55%; height: 78%; border-radius: 50%; background: linear-gradient(180deg, transparent, #ffe68a99); filter: blur(9px); opacity: .8; transform: translateY(52%); }
.flying-card.red { color: #a71940; }
.flying-card b { position: absolute; left: 7%; top: 4%; font: 700 clamp(11px, 3.6vw, 17px) Georgia, serif; }
.flying-card span { position: absolute; inset: 0; display: grid; place-items: center; padding-top: 10%; font-size: clamp(18px, 6vw, 28px); }
.flying-card.active { animation: card-flight .32s linear both; }
@keyframes card-flight {
  0% { opacity: 1; transform: translate3d(var(--sx), var(--sy), 0) rotate(0) scale(1); }
  48% { opacity: 1; transform: translate3d(var(--mx), var(--my), 0) rotate(-7deg) scale(1.13); }
  100% { opacity: 0; transform: translate3d(var(--tx), var(--ty), 0) rotate(2deg) scale(.9); }
}

.score-pop { position: absolute; z-index: 21; left: 0; top: 0; opacity: 0; pointer-events: none; color: #fff1a2; text-shadow: 0 2px 4px #000, 0 0 12px #ffd665; font: 800 18px/1 Georgia, serif; transform: translate3d(var(--pop-x), var(--pop-y), 0) translate(-50%, -50%); }
.score-pop.bot { color: #b9ddff; text-shadow: 0 2px 4px #000, 0 0 12px #67b9ff; }
.score-pop.active { animation: score-rise .72s .13s cubic-bezier(.16,.72,.25,1) both; }
@keyframes score-rise { 0% { opacity: 0; transform: translate3d(var(--pop-x), var(--pop-y), 0) translate(-50%, -25%) scale(.7); } 24% { opacity: 1; transform: translate3d(var(--pop-x), var(--pop-y), 0) translate(-50%, -70%) scale(1.18); } 100% { opacity: 0; transform: translate3d(var(--pop-x), var(--pop-y), 0) translate(-50%, -170%) scale(.92); } }

.value-bump { animation: value-bump .36s cubic-bezier(.16,.82,.24,1); }
.charge-track.charge-bump { animation: charge-bump .48s ease-out; }
.streak-medallion.streak-bump { animation: streak-bump .4s cubic-bezier(.16,.82,.24,1); }
@keyframes value-bump { 45% { color: #fff6c8; transform: scale(1.28); text-shadow: 0 0 14px #ffe074; } }
@keyframes charge-bump { 35% { transform: scaleY(1.8); box-shadow: 0 0 13px #ffe584; } }
@keyframes streak-bump { 45% { transform: scale(1.15) rotate(-4deg); box-shadow: 0 0 22px #f0c95a88; } }

.power-burst {
  position: absolute;
  z-index: 24;
  left: 50%;
  top: 44%;
  width: 190px;
  min-height: 92px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px;
  border: 1px solid #f6d77b;
  border-radius: 16px;
  opacity: 0;
  pointer-events: none;
  color: #fff1c3;
  background: linear-gradient(120deg, #0b1f19ee, #3e1024f2);
  box-shadow: 0 16px 55px #000d, 0 0 30px #f0c65b55, inset 0 1px #fff4bf44;
  transform: translate(-50%, -50%) scale(.55) rotate(-3deg);
}
.power-burst.show { animation: power-reveal 1.15s cubic-bezier(.2,.8,.2,1) both; }
.power-burst img { width: 67px; height: 67px; flex: 0 0 67px; border-radius: 11px; border: 1px solid #ffdfa0; box-shadow: 0 0 18px #f7cf6855; background-color: #30106e; }
.power-burst small, .power-burst strong { display: block; }
.power-burst small { color: #c8ad68; font-size: 6px; letter-spacing: .15em; }
.power-burst strong { margin-top: 4px; font: 700 18px/1 Georgia, serif; }
.power-burst-ring { position: absolute; inset: -17px; z-index: -1; border: 1px solid #ffe18a66; border-radius: 24px; }
.power-burst.show .power-burst-ring { animation: ring-pulse .7s ease-out; }
@keyframes power-reveal {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.55) rotate(-3deg); }
  18%, 70% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0); }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(.92); }
}
@keyframes ring-pulse { from { opacity: 1; transform: scale(.72); } to { opacity: 0; transform: scale(1.35); } }

.celebration-layer { position: absolute; z-index: 23; inset: 0; overflow: hidden; pointer-events: none; }
.celebration-layer i { position: absolute; left: var(--x); top: -18px; width: 7px; height: 14px; border-radius: 2px; opacity: 0; }
.celebration-layer.active i { animation: confetti-fall 2.8s cubic-bezier(.15,.65,.25,1) var(--delay) both; }
.celebration-layer.defeat i { filter: grayscale(.75) brightness(.68); }
@keyframes confetti-fall {
  0% { opacity: 0; transform: translate3d(0,-20px,0) rotate(0); }
  8% { opacity: 1; }
  100% { opacity: 0; transform: translate3d(var(--drift),105svh,0) rotate(var(--spin)); }
}

.game-shell.shake { animation: shell-shake .36s ease-out; }
@keyframes shell-shake {
  0%, 100% { transform: translateX(0); }
  22% { transform: translateX(-5px) rotate(-.25deg); }
  48% { transform: translateX(4px) rotate(.2deg); }
  72% { transform: translateX(-2px); }
}

/* Competitive mobile visual system: arcade rivalry + clean solitaire table. */
:root { --gold: #ffd93d; --cream: #fff; --green: #08a877; --green-dark: #006b57; --burgundy: #f02d78; --blue-black: #19205d; }
body { background: radial-gradient(circle at 50% 5%, #274abf, #16083e 58%, #08021e); font-family: "Arial Rounded MT Bold", ui-rounded, system-ui, sans-serif; }
.game-shell { background: linear-gradient(180deg, #1d79e8 0 9%, #3f177b 9% 20%, #00a77b 20% 73%, #1667d9 73% 100%); box-shadow: 0 0 0 1px #7ae8ff55, 0 0 80px #030019; }
.game-shell::after { background: linear-gradient(90deg, #00184966, transparent 8% 92%, #00184966); }
.ambient { filter: blur(45px); opacity: .55; }
.ambient-a { background: #26ddff; }
.ambient-b { background: #ff3d9b; }

.titlebar { min-height: 61px; padding-bottom: 7px; background: linear-gradient(180deg, #229df5, #1263d5); border-bottom: 3px solid #ffdf3e; box-shadow: 0 5px 0 #51209c, 0 9px 20px #12013d88; }
.brand-mark { width: 39px; height: 39px; border: 3px solid #fff; border-radius: 11px; transform: rotate(-5deg); background: linear-gradient(145deg, #ffec48, #ff8a21); box-shadow: 0 4px 0 #a63c18, 0 0 16px #fff27e; }
.brand-mark span { transform: none; color: #622173; font-family: inherit; font-size: 25px; font-weight: 1000; text-shadow: 0 2px #fff; }
.brand-copy p { color: #d8f7ff; font-size: 8px; font-weight: 900; }
.brand-copy h1 { font-family: inherit; font-size: 24px; font-weight: 1000; letter-spacing: -.055em; text-shadow: 0 3px 0 #133380, 0 4px 7px #00164c; }
.brand-copy em { color: #ffe63e; text-shadow: 0 3px 0 #bc3e34, 0 4px 7px #00164c; }
.icon-button { border: 3px solid #fff; color: #5b238c; background: linear-gradient(#ffed52, #ffad28); box-shadow: 0 4px 0 #9d3f2a; font-weight: 1000; }

.duelist { margin: 10px 10px 0; border: 3px solid #fff; border-radius: 18px; padding: 8px 10px; background: linear-gradient(105deg, #ff3a86, #c42181 62%, #7d1d83); box-shadow: 0 5px 0 #65145c, 0 9px 20px #1b034588; }
.duelist.active { border-color: #fff67a; box-shadow: 0 0 0 3px #ffce28, 0 5px 0 #65145c, 0 0 25px #ffef62; }
.duelist.inactive { filter: saturate(.75) brightness(.82); }
.avatar { border: 3px solid #fff; box-shadow: 0 3px 0 #4a1769, inset 0 0 0 3px #741a70; font-family: inherit; font-weight: 1000; }
.avatar-bot { background: radial-gradient(circle at 38% 25%, #ffef75, #ff663b 50%, #a9146c 75%); color: #fff; text-shadow: 0 3px #8b145a; }
.duelist-name b, .player-zone-head b { font-family: inherit; font-weight: 1000; text-shadow: 0 2px #52104c; }
.duelist-name small, .player-zone-head small { color: #ffe7f3; font-weight: 900; }
.score { border-left: 0; min-width: 66px; padding: 5px 8px; border-radius: 12px; background: #4c126cb8; box-shadow: inset 0 0 0 2px #ffffff33; }
.score small { color: #ffd9ef; font-weight: 900; }
.score strong { color: #fff34f; font-family: inherit; font-weight: 1000; text-shadow: 0 3px 0 #a62b40; }
.charge-row > span, .charge-row > strong { color: #fff; font-weight: 900; }
.charge-track { height: 8px; border: 2px solid #fff7; background: #311051; box-shadow: inset 0 2px 2px #160529; }
.charge-track i { background: linear-gradient(90deg, #42e5ff, #55f294, #ffe842); box-shadow: 0 0 10px #9bffff; }

.match-ribbon { margin: 8px 10px 0; grid-template-columns: 58px 1fr 58px; padding: 6px; border: 3px solid #ffd83d; border-radius: 15px; background: linear-gradient(#6423b0, #321272); box-shadow: 0 4px 0 #1a0747, 0 7px 14px #19053f99; }
.match-ribbon > div:not(.turn-center) { color: #eedfff; font-weight: 900; }
.match-ribbon strong { color: #fff; font-size: 19px; text-shadow: 0 2px #23105e; }
.turn-center p { color: #fff; font-size: 10px; font-weight: 1000; text-shadow: 0 2px #25086b; }
.timer-track { height: 12px; border: 2px solid #fff; background: #1d0a54; box-shadow: 0 3px 0 #16063f; }
.timer-track i { background: linear-gradient(90deg, #36e9ff, #4cff9c, #ffe839); }
.timer-track span { right: -27px; top: -7px; color: #fff; font-size: 11px; font-weight: 1000; }

.table-zone { margin: 8px 7px 0; border: 4px solid #62efce; border-radius: 22px; background: radial-gradient(circle at 50% 15%, #27d09b, #05a879 48%, #00735d 100%); box-shadow: inset 0 0 45px #00594477, 0 5px 0 #014e51, 0 10px 24px #15033f88; }
.table-zone::before { border: 2px solid #aaffdf55; }
.table-label { color: #e5fff8; font-weight: 1000; }
.table-label b { color: #fff34d; font-weight: 1000; }
.status-pill { padding: 2px 8px; border: 1px solid #fff; background: linear-gradient(#7031c3, #421283); color: #fff; font-weight: 900; box-shadow: 0 2px 0 #26075d, 0 3px 8px #003d3399; }

.foundation-zone { margin-top: -1px; min-height: 102px; background: linear-gradient(180deg, #45208c, #26105f); border-block: 3px solid #ffd83d; box-shadow: 0 5px 0 #14043c; }
.foundation-wrap > small, .mini-hand > small { color: #fff; font-weight: 1000; }
.playing-card { color: #172038; background: #fff; border: 2px solid #e3e7ec; border-radius: 8px; box-shadow: 0 5px 0 #8c8d9b, 0 7px 12px #13063099, inset 0 0 0 1px #fff; }
.playing-card.red { color: #ed2554; }
.playing-card .rank { font-family: inherit; font-weight: 1000; }
.foundation-card { border-color: #ffe248; box-shadow: 0 0 0 3px #fff, 0 6px 0 #e08c1a, 0 0 22px #ffe74d; }
.foundation-card.golden { background: linear-gradient(145deg, #fff58a, #ffc52e); }
.bot-mini-card { border: 2px solid #fff; color: #172038; background: #fff; box-shadow: 0 3px 0 #7a318e; }
.bot-mini-card.red { color: #ed2554; }
.streak-medallion { border: 3px solid #fff; background: linear-gradient(#ffed4f, #ff9c24); box-shadow: 0 4px 0 #b44a22; }
.streak-medallion small { color: #70205a; font-weight: 1000; }
.streak-medallion strong { color: #fff; font-family: inherit; text-shadow: 0 2px #a33732; }

.player-zone { padding-top: 8px; background: linear-gradient(115deg, #128bec, #1761d5 56%, #2535a9); border-top: 3px solid #fff; box-shadow: 0 -5px 0 #57209e, 0 -12px 28px #1c075b88; }
.player-zone.active { box-shadow: 0 -4px 0 #ffe13d, 0 -9px 28px #43d8ff88; }
.avatar-player { background: radial-gradient(circle at 35% 25%, #7cf3ff, #257ee8 52%, #2639a4); color: #fff; text-shadow: 0 3px #20309b; }
.score-player { background: #17369fc7; }
.score-player small { color: #cdefff; }
.player-hand .playing-card { box-shadow: 0 6px 0 #777d91, 0 9px 14px #07145588, inset 0 0 0 1px #fff; }
.power-bar { gap: 8px; }
.power-button { height: 57px; border: 3px solid #fff; border-radius: 13px; background: linear-gradient(#ffdf44, #ff8b22); box-shadow: 0 5px 0 #a33631, 0 8px 12px #07145588; color: #fff; }
.power-button.perk { background: linear-gradient(#d94cff, #7224cb); box-shadow: 0 5px 0 #3b117b, 0 8px 12px #07145588; }
.power-button .power-glyph { border: 2px solid #fff; background-color: #54218c; }
.power-button small { color: #fff2a5; font-weight: 1000; }
.power-button b { font-family: inherit; font-weight: 1000; text-shadow: 0 2px #4c1760; }
.power-button em { color: #fff; font-weight: 1000; }
.power-button:disabled { filter: grayscale(.65) brightness(.68); }
.end-turn { height: 44px; border: 3px solid #fff; border-radius: 13px; color: #54205f; background: linear-gradient(#fff04f, #ffae26); box-shadow: 0 5px 0 #b0442a, 0 8px 14px #06154f77; font-weight: 1000; }

.overlay { background: #18043ddf; backdrop-filter: blur(7px); }
.overlay-panel { border: 4px solid #fff; color: #fff; background: linear-gradient(165deg, #5420aa, #25106d 60%, #901d81); box-shadow: 0 7px 0 #180347, 0 20px 70px #060019dd; }
.eyebrow { color: #5ff3ff; font-weight: 1000; }
.overlay h2 { color: #fff34c; font-family: inherit; font-weight: 1000; text-shadow: 0 4px 0 #a52c5d, 0 6px 8px #12033f; }
.overlay h2 + p { color: #efe7ff; font-weight: 700; }
.loadout-tabs { background: #17054f; border: 2px solid #7f55d0; }
.loadout-tabs button { color: #c9b8ef; font-weight: 1000; }
.loadout-tabs button.active { color: #32115f; background: linear-gradient(#fff051, #ffae28); box-shadow: 0 3px 0 #a33b35; }
.choice-card { border: 3px solid #fff; background: linear-gradient(160deg, #2299ee, #263bb0 65%); box-shadow: 0 5px 0 #17115f, 0 8px 15px #07001e88; }
.choice-card.perk { background: linear-gradient(160deg, #f044a0, #7c1cb3 65%); }
.choice-card.selected { border-color: #fff; box-shadow: 0 0 0 4px #ffe43e, 0 6px 0 #a83b37, 0 0 24px #fff05399; }
.choice-card b, .power-description b, .difficulty-picker b { font-family: inherit; font-weight: 1000; }
.power-description, .difficulty-picker { border: 2px solid #a67af2; background: #1a0757cc; }
.power-description p, .difficulty-picker small { color: #d9cbfa; }
.difficulty-options button { border: 2px solid #9b7ae0; color: #d7cafa; background: #321275; font-weight: 1000; }
.difficulty-options button.selected { color: #54205f; border-color: #fff; background: linear-gradient(#fff04f, #ffab28); box-shadow: 0 3px 0 #a43a34; }
.primary-button { border: 3px solid #fff; color: #54205f; background: linear-gradient(#fff04f, #ff9f22); box-shadow: 0 6px 0 #aa3a33, 0 10px 18px #100135aa; font-weight: 1000; }
.coin-disc { color: #682164; background: radial-gradient(circle at 34% 26%, #fff98e, #ffc82d 45%, #f07025 72%); border-color: #fff; box-shadow: 0 7px 0 #a73932, 0 0 35px #ffea4d; }
.coin-actions button { border: 3px solid #fff; color: #fff; background: linear-gradient(#259eea, #3152c8); box-shadow: 0 5px 0 #191a7c; }
.coin-actions b { font-family: inherit; font-weight: 1000; }

@media (min-height: 820px) {
  .table-zone { min-height: 500px; }
  #boardCanvas { height: 480px; }
  .player-hand { min-height: 96px; }
}

@media (max-height: 735px) {
  .titlebar { min-height: 56px; padding-top: max(7px, env(safe-area-inset-top)); padding-bottom: 5px; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-copy h1 { font-size: 22px; }
  .duelist { margin-top: 6px; padding-block: 6px; }
  .avatar { width: 36px; flex-basis: 36px; height: 36px; }
  .table-zone { min-height: 400px; }
  #boardCanvas { height: 380px; }
  .foundation-zone { min-height: 83px; }
  .foundation-card { width: 47px; height: 64px; }
  .player-zone { padding-top: 5px; }
  .player-hand { min-height: 72px; }
  .player-hand .playing-card { flex-basis: 52px; width: 52px; height: 70px; }
}

@media (min-width: 521px) {
  body { padding: 0; }
  .game-shell { min-height: 0; border-radius: 26px; border: 1px solid #7ae8ff55; }
  .overlay-panel { border-radius: 28px; margin-bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* A complete, non-scrolling 9:16 mobile stage. */
html, body { width: 100%; height: 100%; overflow: hidden; }
body { display: grid; place-items: center; }
.game-shell {
  width: min(100vw, 56.25svh, 520px);
  height: min(100svh, 177.7778vw, 924px);
  min-height: 0;
  aspect-ratio: 9 / 16;
  display: grid;
  grid-template-rows: 52px 52px 44px minmax(0, 1fr) 68px 178px;
  grid-template-areas: "title" "bot" "match" "table" "foundation" "player";
}
.titlebar { grid-area: title; min-height: 0; }
.duelist { grid-area: bot; min-height: 0; height: 47px; margin: 3px 8px 2px; padding-block: 5px; }
.match-ribbon { grid-area: match; min-height: 0; height: 39px; margin: 2px 8px 3px; padding: 3px 5px; }
.table-zone { grid-area: table; min-height: 0; height: auto; margin: 3px 6px 4px; }
#boardCanvas { width: 100%; height: 100%; }
.foundation-zone { grid-area: foundation; min-height: 0; height: 68px; padding-block: 2px; }
.player-zone { grid-area: player; position: relative; min-height: 0; height: 178px; padding: 5px 8px max(6px, env(safe-area-inset-bottom)); overflow: hidden; }

.game-shell.in-match {
  grid-template-rows: 6.7% 5.3% minmax(0, 1fr) 4% 25%;
  grid-template-areas: "bot" "match" "table" "foundation" "player";
}
.game-shell.in-match .titlebar { display: none; }
.game-shell.in-match .duelist { height: calc(100% - 5px); margin: 3px 8px 2px; }
.game-shell.in-match .duelist-name small { font-size: 9px; }
.game-shell.in-match .score small { font-size: 9px; }
.game-shell.in-match .score strong { font-size: 28px; }
.game-shell.in-match .charge-row > span,
.game-shell.in-match .charge-row > strong { font-size: 9px; }
.game-shell.in-match .match-ribbon { height: calc(100% - 5px); margin: 2px 8px 3px; }
.game-shell.in-match .match-ribbon small { font-size: 8px; }
.game-shell.in-match .turn-center p { font-size: 11px; }
.game-shell.in-match .table-label { font-size: 9px; }
.game-shell.in-match .status-pill { font-size: 8px; }

.foundation-zone { position: relative; z-index: 6; height: auto; grid-template-columns: 1fr minmax(96px, 118px) 1fr; padding: 0 13px; overflow: visible; background: transparent; border: 0; box-shadow: none; }
.foundation-zone::before { content: ''; position: absolute; z-index: -1; left: 13px; right: 13px; top: 50%; height: 4px; border-radius: 4px; background: linear-gradient(90deg, #59ecff, #fff33e 35% 65%, #59ecff); box-shadow: 0 2px 0 #371083, 0 0 14px #5cecff; transform: translateY(-50%); }
.foundation-wrap { align-self: center; justify-self: center; width: clamp(104px, 24vw, 124px); height: clamp(90px, 20vw, 108px); padding: 4px 9px 6px; border-radius: 17px; background: linear-gradient(#29218e, #48177e); border: 3px solid #fff; box-shadow: 0 5px 0 #ff9e26, 0 0 25px #57eaff99; }
.foundation-wrap > small { margin-bottom: 2px; color: #fff34d; font-size: 9px; letter-spacing: .09em; text-shadow: 0 2px #531079; }
.mini-hand > small { font-size: 8px; }
.foundation-card { width: auto; height: calc(100% - 18px); max-height: 78px; aspect-ratio: 53 / 72; }
.foundation-card .rank { font-size: 17px; }
.foundation-card .suit { font-size: 27px; }
.mini-hand { align-self: end; opacity: .9; transform: translateY(-16px); }
.streak-medallion { width: 48px; height: 48px; }
.foundation-zone .streak-medallion { align-self: start; transform: translateY(16px); }
.streak-medallion small { font-size: 8px; }
.streak-medallion strong { font-size: 18px; }

.player-zone { height: auto; display: grid; grid-template-rows: 34px minmax(0, 1fr) 17px 52px; row-gap: 2px; padding: 5px 8px max(6px, env(safe-area-inset-bottom)); }
.player-zone-head { position: relative; height: 34px; gap: 7px; padding-right: 172px; }
.player-zone-head .avatar { flex-basis: 31px; width: 31px; height: 31px; font-size: 17px; }
.player-zone-head > div:nth-child(2) { min-width: 0; }
.player-zone-head b { font-size: 16px; }
.player-zone-head small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 8px; }
.score-player { position: absolute; top: 1px; right: 92px; min-width: 72px; height: 32px; padding: 2px 7px; }
.score-player small { font-size: 8px; }
.score-player strong { font-size: 24px; line-height: 20px; }
.player-hand { min-height: 0; height: auto; margin: 0; padding: 2px; }
.player-hand .playing-card { flex: 0 0 auto; width: auto; height: min(84px, 100%); aspect-ratio: 53 / 72; }
.player-hand .playing-card .rank { font-size: 15px; }
.player-hand .playing-card .suit { font-size: 23px; }
.player-charge { height: 17px; margin: 0 3px; }
.player-charge > span, .player-charge > strong { font-size: 8px; }
.power-bar { height: 52px; gap: 6px; }
.power-button { height: 52px; padding: 3px 4px; border-width: 2px; }
.power-button .power-glyph { flex-basis: 34px; height: 40px; }
.power-button b { font-size: 10px; }
.power-button small { font-size: 7px; }
.power-button em { font-size: 8px; }
.end-turn { position: absolute; z-index: 2; right: 8px; top: 6px; width: 84px; height: 34px; margin: 0; border-width: 2px; font-size: 9px; box-shadow: 0 3px 0 #b0442a; }
.end-turn span { font-size: 14px; }
.bot-mini-card { width: 25px; height: 35px; }
#resultOverlay { align-items: center; padding: max(16px, env(safe-area-inset-top)) 10px max(16px, env(safe-area-inset-bottom)); }
#resultOverlay .result-panel { width: min(100%, 440px); margin: 0 auto; border-radius: 24px; }

@media (max-height: 620px) {
  .game-shell { grid-template-rows: 46px 48px 40px minmax(0, 1fr) 62px 162px; }
  .game-shell.in-match { grid-template-rows: 6.7% 5.3% minmax(0, 1fr) 4% 25%; }
}

/* Split lower HUD: player left, shared foundation center, rival right. */
.game-shell {
  grid-template-rows: 52px 44px minmax(0, 1fr) 232px;
  grid-template-areas: "title" "match" "table" "bottom";
}
.game-shell.in-match {
  grid-template-rows: 5.3% minmax(0, 1fr) 29%;
  grid-template-areas: "match" "table" "bottom";
}

.bottom-hud {
  grid-area: bottom;
  position: relative;
  z-index: 6;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 56px;
  overflow: visible;
  border-top: 3px solid #fff33e;
  background: linear-gradient(180deg, #27207f, #1768d8 54%, #1b47b8);
  box-shadow: 0 -5px 0 #55219b, 0 -12px 28px #1c075b88;
}
.duel-panels {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(88px, 22vw, 114px) minmax(0, 1fr);
  position: relative;
}

#playerZone,
#botHud {
  grid-area: auto;
  min-width: 0;
  min-height: 0;
  height: auto;
  margin: 0;
  padding: 7px 8px 5px;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
}
#playerZone {
  display: grid;
  grid-template-rows: 34px minmax(0, 1fr) 17px 31px;
  gap: 3px;
  background: linear-gradient(135deg, #168fea, #2258cd);
}
#botHud {
  display: grid;
  grid-template-rows: 34px minmax(0, 1fr) 17px;
  gap: 4px;
  background: linear-gradient(225deg, #f02d78, #8b268f);
}
.game-shell.in-match #botHud { height: auto; margin: 0; }
#playerZone.active { box-shadow: inset 0 0 0 3px #fff04f, inset 0 0 22px #6fffff66; }
#botHud.active { border: 0; box-shadow: inset 0 0 0 3px #fff04f, inset 0 0 22px #ffef6266; }

.player-zone-head,
.bot-zone-head {
  min-width: 0;
  height: 34px;
  display: grid;
  align-items: center;
  gap: 5px;
  padding: 0;
}
.player-zone-head { grid-template-columns: 31px minmax(0, 1fr) 53px; }
.bot-zone-head { grid-template-columns: 53px minmax(0, 1fr) 31px; }
.player-zone-head .avatar,
.bot-zone-head .avatar {
  width: 31px;
  height: 31px;
  min-width: 31px;
  flex-basis: 31px;
  font-size: 17px;
}
.player-zone-head > div:nth-child(2),
.bot-name { min-width: 0; }
.player-zone-head b,
.player-zone-head small,
.bot-name b,
.bot-name small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-zone-head b,
.bot-name b { color: #fff; font-size: 13px; font-weight: 1000; line-height: 14px; text-shadow: 0 2px #28308e; }
.player-zone-head small,
.bot-name small { color: #d9f6ff; font-size: 7px; font-weight: 1000; letter-spacing: .1em; }
.bot-name { text-align: right; }
.bot-name small { color: #ffe5f4; }

.bottom-hud .score,
.bottom-hud .score-player {
  position: static;
  width: 53px;
  min-width: 0;
  height: 31px;
  padding: 2px 5px;
  text-align: center;
  border-radius: 9px;
  background: #172d84aa;
  box-shadow: inset 0 0 0 1px #ffffff44;
}
.bottom-hud #botHud .score { background: #571054aa; }
.game-shell.in-match .bottom-hud .score small,
.bottom-hud .score small { font-size: 6px; }
.game-shell.in-match .bottom-hud .score strong,
.bottom-hud .score strong { display: block; font-size: 20px; line-height: 19px; }

#playerZone .player-hand {
  min-width: 0;
  min-height: 0;
  height: auto;
  margin: 0;
  padding: 3px 2px 1px;
  justify-content: center;
  gap: 5px;
}
#playerZone .player-hand .playing-card {
  flex: 0 0 auto;
  width: auto;
  height: min(88px, 100%);
  aspect-ratio: 53 / 72;
}
#playerZone .player-hand .playing-card .rank { font-size: 15px; }
#playerZone .player-hand .playing-card .suit { font-size: 24px; }

#botHud .mini-hand {
  min-height: 0;
  align-self: stretch;
  display: grid;
  align-content: center;
  margin: 0;
  opacity: 1;
  transform: none;
}
#botHud .mini-hand > small { margin-bottom: 4px; color: #ffe7f3; font-size: 7px; font-weight: 1000; }
#botHud .bot-mini-card { width: 31px; height: 44px; }
#botHud .bot-mini-card b { font-size: 12px; }
#botHud .bot-mini-card i { font-size: 18px; }

.bottom-hud .charge-row { min-width: 0; height: 17px; margin: 0; gap: 4px; }
.game-shell.in-match .bottom-hud .charge-row > span,
.game-shell.in-match .bottom-hud .charge-row > strong,
.bottom-hud .charge-row > span,
.bottom-hud .charge-row > strong { color: #fff; font-size: 7px; }
.bottom-hud .charge-track { height: 7px; border-width: 1px; }

.bottom-hud .end-turn {
  position: static;
  width: 100%;
  height: 31px;
  margin: 0;
  padding: 0 8px;
  border-width: 2px;
  border-radius: 10px;
  font-size: 8px;
  box-shadow: 0 3px 0 #b0442a;
}

.bottom-hud .foundation-zone {
  grid-area: auto;
  position: relative;
  z-index: 8;
  min-width: 0;
  min-height: 0;
  height: auto;
  margin: 0 -5px;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  overflow: visible;
  background: transparent;
  border: 0;
  box-shadow: none;
}
.bottom-hud .foundation-zone::before { display: none; }
.bottom-hud .foundation-wrap {
  width: clamp(92px, 21vw, 110px);
  height: clamp(108px, 24vw, 124px);
  padding: 5px 8px 7px;
  transform: translateY(-8px);
}
.bottom-hud .foundation-wrap > small { font-size: 8px; }
.bottom-hud .foundation-card { height: calc(100% - 18px); max-height: 88px; }
.bottom-hud .streak-medallion {
  position: absolute;
  right: -4px;
  bottom: 8px;
  width: 43px;
  height: 43px;
  transform: none;
}
.bottom-hud .streak-medallion small { font-size: 7px; }
.bottom-hud .streak-medallion strong { font-size: 17px; }

.bottom-hud > .power-bar {
  height: 56px;
  padding: 2px 8px max(4px, env(safe-area-inset-bottom));
  gap: 6px;
  background: linear-gradient(180deg, #202087, #142d91);
  box-shadow: inset 0 2px #62eaff55;
}
.bottom-hud > .power-bar .power-button { height: 50px; }

@media (max-width: 380px) {
  .duel-panels { grid-template-columns: minmax(0, 1fr) 84px minmax(0, 1fr); }
  #playerZone, #botHud { padding-inline: 5px; }
  .player-zone-head { grid-template-columns: 27px minmax(0, 1fr) 45px; }
  .bot-zone-head { grid-template-columns: 45px minmax(0, 1fr) 27px; }
  .player-zone-head .avatar, .bot-zone-head .avatar { width: 27px; height: 27px; min-width: 27px; flex-basis: 27px; font-size: 14px; }
  .bottom-hud .score, .bottom-hud .score-player { width: 45px; }
  .player-zone-head b, .bot-name b { font-size: 11px; }
  .bottom-hud .charge-row > span { display: none; }
}

@media (max-height: 620px) {
  .game-shell { grid-template-rows: 46px 40px minmax(0, 1fr) 204px; }
  .game-shell.in-match { grid-template-rows: 5.3% minmax(0, 1fr) 29%; }
  .bottom-hud { grid-template-rows: minmax(0, 1fr) 50px; }
  .bottom-hud > .power-bar { height: 50px; }
  .bottom-hud > .power-bar .power-button { height: 44px; }
  .bottom-hud .foundation-wrap { height: 100px; }
  #playerZone .player-hand .playing-card { height: min(72px, 100%); }
}
