/* WarKart Online: account and party windows share the game's rendered frames. */
.account-screen { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 24px; background: radial-gradient(ellipse at 50% 28%, #1c2624ba, #080b0cf5); backdrop-filter: blur(7px); overflow: auto; }
.account-screen[hidden], .hero-slot[hidden] { display: none !important; }
.account-card { display: grid; grid-template-columns: .9fr 1fr; gap: 32px; width: min(880px, 100%); max-height: calc(100dvh - 48px); padding: 32px; overflow: auto; color: #ebdfc1; border: 10px solid transparent; border-image: url('/assets/ui/window-frame.png') 12% / 16px / 4px stretch; background: linear-gradient(135deg, #2d2b24f5, #111713fa); box-shadow: 0 24px 80px #000a; }
.account-welcome { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; border-right: 1px solid #caa45b44; padding: 16px 28px 16px 0; }
.account-logo { width: min(100%, 300px); height: auto; filter: drop-shadow(0 8px 12px #0009); }
.account-welcome h1 { color: #f1d793; font: 700 27px/1.25 Georgia, serif; margin: 24px 0 12px; }
.account-welcome p { font: 14px/1.7 'Trebuchet MS', sans-serif; color: #bfb59d; margin: 0; }
.account-heroes { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 28px; color: #a98c4e; font-size: 26px; }
.account-heroes img { width: 84px; height: 84px; border: 3px ridge #9a8b66; border-radius: 50%; background: radial-gradient(#393c30, #111712); }
.account-body { min-width: 0; }
.account-tabs, .online-tabs { display: flex; gap: 8px; }
.account-tabs button, .online-tabs button { flex: 1; min-height: 44px; padding: 7px 10px; color: #ccba91; background: linear-gradient(#33332b, #1e211a); border: 2px ridge #6c6a5a; font: 700 15px Georgia, serif; cursor: pointer; }
.account-tabs button.selected, .online-tabs button.selected { color: #ffe7a4; border-color: #b89543; background: linear-gradient(#4e2b21, #281d16); box-shadow: inset 0 0 10px #caa34c25; }
.account-heading { margin: 20px 0 16px; font: 700 22px/1.25 Georgia, serif; color: #f2d79b; }
.account-form { display: grid; gap: 12px; }
.account-form label, .online-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.account-form label[hidden] { display: none; }
.account-form label > span, .online-field > span { color: #cfc09c; font: 700 12px/1.25 'Trebuchet MS', sans-serif; }
.account-form input, .online-field select, .friend-request-form input { width: 100%; min-width: 0; min-height: 44px; padding: 9px 11px; border: 2px ridge #777569; border-radius: 2px; outline-offset: 2px; background: #131812; color: #f2ead8; font: 16px/1.2 'Trebuchet MS', sans-serif; }
.account-form input:focus, .online-field select:focus, .friend-request-form input:focus { outline: 2px solid #ddb967; }
.account-form label small { font: 11px/1.3 'Trebuchet MS', sans-serif; color: #a99e84; }
.account-form .button { min-height: 48px; margin-top: 4px; font-size: 18px; }
.account-social { margin-top: 18px; }
.social-divider { display: flex; gap: 12px; align-items: center; color: #a99d83; font: 12px/1.3 'Trebuchet MS', sans-serif; }
.social-divider::before, .social-divider::after { content: ''; height: 1px; flex: 1; background: #74634480; }
.social-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.social-buttons .button { min-height: 44px; min-width: 0; gap: 8px; padding: 7px 10px; font-size: 14px; }
.social-buttons b { font: 700 21px/1 Arial, sans-serif; color: #f5e4bd; }
.account-practice { display: flex; justify-content: center; align-items: center; gap: 12px; min-height: 44px; width: 100%; margin: 12px 0 0; padding: 8px; border: 0; background: none; color: #dfc78a; font: 13px/1.4 'Trebuchet MS', sans-serif; cursor: pointer; }
.account-practice:hover, .online-link:hover { color: #fff0bd; text-decoration: underline; }
.online-message { margin: 10px 0; padding: 9px 12px; border: 1px solid #a37a39; background: #3c2919d9; color: #f3d697; font: 13px/1.45 'Trebuchet MS', sans-serif; overflow-wrap: anywhere; }
.online-message.error { border-color: #ac6852; background: #4b211dd9; color: #ffd1b3; }
.online-message.success { border-color: #6f8f58; background: #1e361dd9; color: #d5ebbd; }
.online-message[hidden] { display: none; }
.online-modal { width: min(900px, calc(100vw - 36px)); max-height: calc(100dvh - 36px); padding: 24px; background: linear-gradient(#292b25, #151c15); color: #eadfc0; }
.online-modal[open] { display: flex; flex-direction: column; gap: 0; overflow: hidden; }
.online-modal::backdrop { background: #050a0cc9; backdrop-filter: blur(5px); }
.online-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 46px; flex-shrink: 0; }
.online-eyebrow { font: 700 10px/1.2 'Trebuchet MS', sans-serif; letter-spacing: 1.8px; color: #bda46b; }
.online-heading h2 { font: 700 26px/1.2 Georgia, serif; padding: 0; margin: 5px 0 0; color: #f4d792; }
.online-heading .icon-button { width: 44px; height: 44px; flex: 0 0 44px; }
.online-profile { display: flex; align-items: center; gap: 12px; margin: 18px 0; padding: 12px; background: #0d150f66; border: 1px solid #7e704247; flex-shrink: 0; }
.rank-medallion { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; border: 3px ridge #b9964e; background: radial-gradient(#51422b, #171e16); color: #edc671; flex-shrink: 0; }
.rank-medallion .icon { width: 28px; height: 28px; }
.online-player-copy { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 0; }
.online-player-copy strong { font: 700 22px/1.2 Georgia, serif; color: #f0d99a; overflow: hidden; text-overflow: ellipsis; }
.online-player-copy span { font: 12px/1.2 'Trebuchet MS', sans-serif; color: #bcb08c; }
.online-purse { display: flex; align-items: center; gap: 5px; color: #f1cd72; }
.online-purse img { width: 30px; height: 30px; }
.online-purse strong { font-size: 17px; }
.online-link { min-height: 44px; padding: 5px 8px; background: none; border: 0; color: #cbb581; font: 12px/1.3 'Trebuchet MS', sans-serif; cursor: pointer; }
.online-tabs { flex-shrink: 0; }
.online-tabs button { font-size: 14px; }
.online-tabs span { font: 11px/1.2 'Trebuchet MS', sans-serif; color: #bba375; margin-left: 4px; }
.online-content { min-height: 0; flex: 1 1 auto; overflow: auto; padding: 18px 3px 12px; overscroll-behavior: contain; outline-offset: -2px; }
.online-content h3 { font: 700 17px/1.25 Georgia, serif; color: #e9ce8d; margin: 0 0 10px; }
.online-copy { color: #bcb195; font: 13px/1.6 'Trebuchet MS', sans-serif; margin: 0 0 16px; }
.online-empty { text-align: center; padding: 22px 18px; border: 1px solid #85734a44; background: #161f1466; }
.online-empty .icon { width: 42px; height: 42px; color: #c7a55d; margin-bottom: 10px; }
.online-empty h3 { margin-bottom: 9px; }
.online-empty .button { min-height: 44px; min-width: 180px; font-size: 15px; }
.party-roster { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 16px; }
.party-member { display: flex; align-items: center; gap: 9px; min-width: 0; min-height: 76px; padding: 10px; background: linear-gradient(#34362b99, #192118bb); border: 1px solid #7c70494f; }
.party-member.self { border-color: #ac8a45; }
.party-member.empty { border-style: dashed; opacity: .5; color: #aa9d78; justify-content: center; font: 12px 'Trebuchet MS', sans-serif; }
.party-member img, .party-portrait { width: 45px; height: 45px; border: 2px ridge #948358; border-radius: 50%; background: #121b13; flex-shrink: 0; }
.party-portrait { display: grid; place-items: center; color: #dabb73; font: 700 22px Georgia, serif; }
.party-member-copy { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.party-member-copy strong { font: 700 14px/1.2 Georgia, serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.party-member-copy small { color: #b3a78a; font: 11px/1.2 'Trebuchet MS', sans-serif; }
.party-ready { font: 700 10px/1.2 'Trebuchet MS', sans-serif; color: #bcb196; }
.party-ready.yes { color: #a9d57c; }
.party-options { display: grid; grid-template-columns: 1.5fr 1fr 70px 1fr; gap: 10px; padding: 14px 0; border-top: 1px solid #a68c4433; border-bottom: 1px solid #a68c4433; }
.online-field select { padding-inline: 7px; font-size: 13px; }
.party-hero { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-top: 14px; }
.party-hero .online-field { flex: 1; max-width: 240px; }
.party-gold { display: flex; align-items: center; gap: 8px; min-height: 44px; font: 12px 'Trebuchet MS', sans-serif; color: #cbbb92; }
.party-gold input { accent-color: #d5b267; width: 20px; height: 20px; }
.party-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.party-actions .button { min-height: 44px; min-width: 130px; padding: 7px 12px; font-size: 14px; flex: 1; }
.party-actions .online-link { margin-left: auto; }
.party-rank-note { margin: 12px 0 0; color: #bcae88; font: 12px/1.45 'Trebuchet MS', sans-serif; }
.friend-request-form { display: flex; gap: 8px; margin: 12px 0 18px; }
.friend-request-form .button { min-width: 94px; min-height: 44px; padding: 6px 10px; font-size: 13px; }
.online-list { display: grid; gap: 8px; margin: 0 0 18px; }
.online-person-row { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 9px 10px; border: 1px solid #7e70443f; background: #0f1b1266; }
.online-person-copy { flex: 1; min-width: 0; }
.online-person-copy strong { display: block; font: 700 15px/1.3 Georgia, serif; overflow: hidden; text-overflow: ellipsis; }
.online-person-copy small { display: block; color: #ac9f7f; font: 11px/1.35 'Trebuchet MS', sans-serif; margin-top: 3px; }
.online-person-row .button { min-height: 44px; min-width: 72px; padding: 5px 10px; font-size: 12px; }
.online-person-row .online-link { min-width: 44px; }
.ranked-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.ranked-summary > div { background: #0b16119c; border: 1px solid #97824a4f; padding: 14px 8px; text-align: center; }
.ranked-summary strong { display: block; color: #f1d485; font: 700 26px Georgia, serif; }
.ranked-summary span { display: block; margin-top: 5px; color: #b9ad8e; font: 11px 'Trebuchet MS', sans-serif; }
.ranked-table { width: 100%; border-collapse: collapse; font: 13px 'Trebuchet MS', sans-serif; }
.ranked-table th { color: #c7af77; text-align: left; padding: 9px 8px; font-size: 11px; font-weight: 400; }
.ranked-table td { padding: 12px 8px; border-top: 1px solid #7f764239; }
.ranked-table tr.self { background: #6b592b2f; color: #f4d88b; }
.ranked-table td:last-child, .ranked-table th:last-child { text-align: right; }
.ranked-table .rank-name { color: #b5a780; font-size: 11px; }
.online-footer { display: flex; justify-content: space-between; gap: 10px; border-top: 1px solid #7d6d393f; padding-top: 12px; flex-shrink: 0; color: #9c947c; font: 11px 'Trebuchet MS', sans-serif; }
#online-connection i { display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: #90ba67; box-shadow: 0 0 5px #90ba6766; }
#online-connection.reconnecting i { background: #d69b48; box-shadow: none; }

/* Hero charge lives next to the collected spell, not inside the speedometer. */
.spell-dock { display: flex; align-items: stretch; justify-content: center; gap: 10px; width: 100%; }
.race-bottom-center:has(.hero-slot:not([hidden])) { width: min(520px, 48vw); }
.spell-dock .item-slot { flex: 1 1 0; min-width: 0; }
.hero-slot { --hero-color: #91dff2; position: relative; display: flex; align-items: center; gap: 9px; flex: 1 1 0; min-width: 0; min-height: 80px; padding: 10px 12px 18px; border: 6px solid transparent; border-image: url('/assets/ui/window-frame.png') 12% / 10px / 2px stretch; background: linear-gradient(#263137ec, #101b23f0); color: #e3ddc8; pointer-events: auto; cursor: pointer; touch-action: none; user-select: none; }
.hero-icon { width: 48px; height: 48px; flex: 0 0 48px; border: 2px ridge #af9d72; box-shadow: 0 0 7px #0008; object-fit: cover; }
.hero-copy { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.hero-caption { color: #cbb880; font: 10px/1.2 'Trebuchet MS', sans-serif; }
.hero-copy strong { color: #d8eff6; font: 700 14px/1.2 Georgia, serif; }
#hero-charge-value { color: #91bccc; font: 700 11px/1.2 'Trebuchet MS', sans-serif; }
.hero-slot > kbd { margin-left: auto; font-size: 11px; }
.hero-charge { position: absolute; left: 8px; right: 8px; bottom: 5px; height: 7px; overflow: hidden; border: 1px solid #9d8a57; background: #090f13; box-shadow: inset 0 1px 3px #000; }
.hero-charge i { display: block; width: 0; height: 100%; background: linear-gradient(#c6fcff, #489aca); box-shadow: 0 0 6px #65d9ef; transition: width .12s linear; }
.hero-slot.ready { border-color: transparent; background: linear-gradient(#304a53, #19353e); filter: drop-shadow(0 0 5px #77d9f85c); }
.hero-slot.ready .hero-icon { border-color: #cfedeb; box-shadow: 0 0 12px #7cdbf177; }
.hero-slot.ready #hero-charge-value { color: #dcfff6; }
.hero-slot:active, .hero-slot.pressed { filter: brightness(1.25); }
.hero-slot[aria-disabled=true] { cursor: default; }

@media (max-width: 760px) {
  .account-screen { padding: calc(12px + var(--safe-top)) 12px calc(12px + var(--safe-bottom)); }
  .account-card { grid-template-columns: 1fr; gap: 12px; padding: 18px; width: min(430px, 100%); max-height: calc(100dvh - 24px - var(--safe-top) - var(--safe-bottom)); }
  .account-welcome { padding: 0; border: 0; }
  .account-logo { width: 190px; max-height: 76px; object-fit: contain; }
  .account-welcome h1, .account-welcome p, .account-heroes { display: none; }
  .account-heading { font-size: 19px; margin: 12px 0; }
  .account-form { gap: 9px; }
  .account-form label small { display: none; }
  .account-social { margin-top: 12px; }
  .account-practice { margin-top: 6px; }
  .online-modal { width: calc(100vw - 24px); max-height: calc(100dvh - 24px - var(--safe-top) - var(--safe-bottom)); padding: 16px; }
  .online-heading h2 { font-size: 21px; }
  .online-profile { margin: 12px 0; padding: 9px; gap: 7px; flex-wrap: wrap; }
  .rank-medallion { width: 38px; height: 38px; }
  .rank-medallion .icon { width: 23px; height: 23px; }
  .online-player-copy strong { font-size: 18px; }
  .online-player-copy span { font-size: 10px; }
  .online-purse { gap: 3px; }
  .online-purse img { width: 23px; height: 23px; }
  .online-purse strong { font-size: 14px; }
  .online-profile .online-link { font-size: 11px; padding: 4px; }
  .online-tabs { gap: 5px; }
  .online-tabs button { padding: 5px; font-size: 13px; }
  .online-tabs span { font-size: 10px; }
  .online-content { padding-top: 14px; }
  .party-roster { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
  .party-member { padding: 7px; min-height: 68px; gap: 7px; }
  .party-member img, .party-portrait { width: 34px; height: 34px; }
  .party-member-copy strong { font-size: 12px; }
  .party-member-copy small { font-size: 10px; }
  .party-ready { font-size: 9px; }
  .party-options { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; padding: 12px 0; }
  .online-field select { font-size: 14px; }
  .party-actions { gap: 7px; margin-top: 12px; }
  .party-actions .button { min-width: 110px; font-size: 13px; }
  .party-actions .online-link { width: 100%; margin: 0; }
  .party-hero { gap: 8px; }
  .party-hero .online-field { max-width: none; }
  .party-gold { font-size: 11px; }
  .online-person-row { flex-wrap: wrap; gap: 6px; padding: 9px; }
  .online-person-copy { min-width: 105px; }
  .online-person-row .button { min-width: 66px; font-size: 11px; padding: 5px 7px; }
  .online-footer { padding-top: 9px; font-size: 10px; }
  .ranked-summary > div { padding: 10px 5px; }
  .ranked-summary strong { font-size: 22px; }
  .ranked-table { font-size: 12px; }
  .ranked-table td, .ranked-table th { padding: 9px 5px; }
}
@media (max-width: 760px) and (max-height: 680px) and (orientation: portrait) {
  .account-card { padding: 12px 16px; gap: 6px; }
  .account-logo { height: 54px; width: 150px; }
  .account-heading { margin: 9px 0; font-size: 18px; }
  .account-form label { gap: 4px; }
  .account-social { margin-top: 9px; }
  .social-buttons { margin-top: 7px; }
}
@media (orientation: landscape) and (max-height: 560px) {
  .account-screen { padding: 10px; }
  .account-card { grid-template-columns: .7fr 1fr; width: min(820px, 100%); padding: 14px 22px; gap: 22px; max-height: calc(100dvh - 20px); }
  .account-welcome { border-right: 1px solid #caa45b44; padding-right: 20px; }
  .account-logo { width: 230px; max-height: none; }
  .account-welcome h1 { display: block; font-size: 23px; margin: 16px 0 10px; }
  .account-welcome p { display: block; font-size: 12px; }
  .account-heroes { display: flex; margin-top: 16px; }
  .account-heroes img { width: 66px; height: 66px; }
  .account-heading { font-size: 19px; margin: 10px 0; }
  .account-form { gap: 8px; }
  .account-form label { gap: 3px; }
  .account-form label small { display: none; }
  .account-social { margin-top: 8px; }
  .social-buttons { margin-top: 6px; }
  .account-practice { margin-top: 3px; }
  .online-modal { max-height: calc(100dvh - 20px); padding: 13px 18px; }
  .online-heading { min-height: 44px; }
  .online-heading h2 { font-size: 21px; }
  .online-profile { margin: 7px 0; padding: 5px 9px; }
  .rank-medallion { width: 36px; height: 36px; }
  .online-player-copy strong { font-size: 17px; }
  .online-player-copy span { font-size: 10px; }
  .online-tabs button { min-height: 44px; }
  .online-content { padding-top: 12px; }
  .party-roster { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .party-options { grid-template-columns: 1.5fr 1fr 70px 1fr; }
}





/* A very short landscape viewport separates the form from the provider rail. */
@media (orientation: landscape) and (max-height: 420px) {
  .account-card { position: relative; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; padding: 12px 18px; }
  .account-welcome { padding: 0 16px 140px 0; justify-content: start; }
  .account-logo { width: 190px; }
  .account-welcome h1 { font-size: 20px; margin: 10px 0; }
  .account-welcome p, .account-heroes { display: none; }
  .account-heading { margin: 8px 0; font-size: 17px; }
  .account-form { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .account-form #account-email-row { grid-column: 1 / -1; }
  .account-form #account-password-row { grid-column: 1 / -1; }
  .account-form:has(#account-nickname-row:not([hidden])) #account-nickname-row { grid-column: 1; }
  .account-form:has(#account-nickname-row:not([hidden])) #account-email-row { grid-column: 2; }
  .account-form .button { grid-column: 1 / -1; min-height: 44px; margin: 0; }
  .account-social { position: absolute; width: 200px; left: 18px; bottom: 62px; margin: 0; }
  .social-buttons { gap: 6px; }
  .social-buttons .button { font-size: 12px; padding: 5px; }
  .social-buttons b { font-size: 17px; }
  .account-practice { position: absolute; width: 200px; left: 18px; bottom: 15px; margin: 0; font-size: 12px; }
}


/* Race decisions stay visible while the roster/options panel scrolls. */
.online-actions { flex-shrink: 0; padding-bottom: 10px; }
.online-actions[hidden] { display: none; }
.online-actions .party-actions { margin-top: 8px; }
.online-actions .party-rank-note { margin-top: 7px; font-size: 11px; }
@media (max-width: 760px) and (orientation: portrait) {
  .online-actions .party-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .online-actions .party-actions .button { min-width: 0; }
  .online-actions .party-actions .online-link { width: auto; min-height: 44px; }
  .online-actions .party-rank-note { font-size: 10px; line-height: 1.35; }
}
@media (orientation: landscape) and (max-height: 340px) {
  .account-heading, .account-welcome h1 { display: none; }
  .account-body .account-form { margin-top: 9px; }
  .account-welcome .account-logo { width: 160px; }
  .online-profile { display: none; }
  .online-actions .party-rank-note { display: none; }
  .online-actions { padding-bottom: 5px; }
}

.online-heading-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
@media (orientation: landscape) and (max-height: 420px) {
  .online-profile { display: none; }
  .online-heading { margin-bottom: 8px; }
  .online-actions .party-rank-note { display: none; }
  .online-actions { padding-bottom: 5px; }
}







#countdown.waiting { width: min(80vw, 520px); font-size: clamp(24px, 5vw, 46px); line-height: 1.25; letter-spacing: .08em; text-align: center; }
@media (max-width: 760px) and (max-height: 700px) and (orientation: portrait) {
  .active-effects:has(.active-effect:nth-child(6)) { display: grid; grid-template-columns: repeat(3, 34px); gap: 4px; }
}


/* WarKart 2.1: preserve detailed desktop slots; the phone shows spell art only. */
.hero-art {
  position: relative; display: block; width: 48px; height: 48px; flex: 0 0 48px;
  overflow: hidden; border: 2px ridge #af9d72; background: #071018;
  box-shadow: 0 0 7px #0008;
}
.hero-art .hero-icon, .hero-reveal > .spell-icon {
  display: block; width: 100%; height: 100%; border: 0; object-fit: cover;
  box-shadow: none; align-self: stretch; flex: none;
}
.hero-reveal { display: none; }
.hero-slot.ready .hero-art { border-color: #cfedeb; box-shadow: 0 0 12px #7cdbf177; }
.active-effect.course-debuff > .icon {
  width: 37px; height: 37px; padding: 3px; grid-row: 1 / -1;
  border: 1px solid #a4af99; background: radial-gradient(#32515e, #0b1621);
  color: #bceafa;
}
.active-effect.vilehoof > .icon { color: #c6eb73; background: radial-gradient(#3c572b, #152019); border-color: #9aaf5c; }

@media (orientation: landscape) and (max-height: 560px) and (pointer: fine) {
  .race-bottom-center:has(.hero-slot:not([hidden])) { width: min(360px, calc(100vw - 348px)); left: 50%; transform: translateX(-50%); bottom: 12px; }
  .spell-dock { gap: 8px; }
  .spell-dock .item-slot, .hero-slot { min-height: 68px; padding: 7px; gap: 7px; }
  .hero-slot { padding-bottom: 13px; }
  .spell-dock .item-icon, .hero-art { width: 36px; height: 36px; flex: 0 0 36px; }
  .hero-copy strong, .spell-dock .item-slot strong { font-size: 12px; }
  .hero-copy { gap: 4px; }
  .hero-caption { display: none; }
  #hero-charge-value { font-size: 10px; }
  .hero-charge { left: 6px; right: 6px; bottom: 4px; height: 5px; }
}

@media (pointer: coarse) {
  .hud { --spell-size: 64px; --spell-gap: 10px; }
  .race-bottom-center, .race-bottom-center:has(.hero-slot:not([hidden])) {
    left: 50%; right: auto; bottom: calc(12px + var(--safe-bottom));
    width: max-content; max-width: calc(100vw - 24px - var(--safe-left) - var(--safe-right));
    transform: translateX(-50%); flex-direction: column; align-items: center; gap: 8px;
  }
  .hud .spell-dock { width: max-content; flex-direction: row-reverse; gap: var(--spell-gap); align-items: center; }
  .hud .spell-dock .item-slot, .hud .spell-dock .hero-slot {
    display: flex; align-items: stretch; justify-content: center; flex-direction: row;
    width: var(--spell-size); height: var(--spell-size); min-width: var(--spell-size); min-height: var(--spell-size);
    max-width: var(--spell-size); flex: 0 0 var(--spell-size); padding: 2px; gap: 0;
    border: 4px solid transparent; border-image: url('/assets/ui/window-frame.png') 12% / 6px / 1px stretch;
    background: #101511ed; box-shadow: 0 3px 7px #0009; pointer-events: auto;
    touch-action: none; user-select: none; -webkit-user-select: none;
  }
  .hud .spell-dock .item-copy, .hud .spell-dock .hero-copy, .hud .spell-dock kbd { display: none !important; }
  .hud .spell-dock .item-icon, .hud .spell-dock .hero-art {
    display: block; width: 100%; height: 100%; min-width: 0; flex: 1 1 auto;
    margin: 0; border: 1px solid #a6986d; align-self: stretch; overflow: hidden;
    box-shadow: inset 0 0 5px #0009; background: #071018;
  }
  .hud .spell-dock .item-icon .icon { display: block; width: 75%; height: 75%; margin: 12.5%; }
  .hud .spell-dock .item-icon .spell-icon { width: 100%; height: 100%; }
  .hud .spell-dock .item-slot.empty .item-icon { opacity: .5; }
  .hud .spell-dock .hero-art > .hero-icon { opacity: .24; filter: grayscale(.8); }
  .hud .spell-dock .hero-reveal {
    display: block; position: absolute; inset: 0;
    clip-path: inset(calc(100% - var(--hero-fill, 0%)) 0 0 0);
    transition: clip-path .12s linear; pointer-events: none;
  }
  .hud .spell-dock .hero-charge {
    position: absolute; left: 0; right: auto; top: 0; bottom: auto;
    width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
    overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%);
    background: none; box-shadow: none; white-space: nowrap;
  }
  .hud .spell-dock .hero-slot.ready {
    background: #20363d; filter: drop-shadow(0 0 6px #8ae4f5a8);
    box-shadow: 0 0 0 1px #d0f6e4, 0 0 12px #82cfed77;
  }
  .hud .spell-dock .hero-slot.ready .hero-art { border-color: #d9ffed; box-shadow: none; }
  .hud .spell-dock .item-slot:active, .hud .spell-dock .hero-slot:active,
  .hud .spell-dock .item-slot.pressed, .hud .spell-dock .hero-slot.pressed { filter: brightness(1.25); transform: none; }
  .active-effect.course-debuff > .icon { width: 30px; height: 30px; grid-column: 1; grid-row: 1; }
}

@media (pointer: coarse) and (orientation: portrait) {
  .hud { --spell-size: 56px; --spell-gap: 8px; }
  /* No transformed ancestor: the drift badge stays fixed to the viewport. */
  .race-bottom-center { left: calc(50% - var(--spell-size) / 2); transform: none; }
  .race-bottom-center:has(.hero-slot:not([hidden])) { left: calc(50% - var(--spell-size) - var(--spell-gap) / 2); transform: none; }
  .hud:has(.hero-slot:not([hidden])) .speedometer { bottom: calc(132px + var(--safe-bottom)); }
  .hud:has(.hero-slot:not([hidden])) .drift-indicator { bottom: calc(144px + var(--safe-bottom)); }
  .hud:has(.hero-slot:not([hidden])) .fps-counter { top: calc(112px + var(--safe-top)); bottom: auto; left: calc(12px + var(--safe-left)); transform: none; }
  .active-effects:has(.active-effect:nth-child(7)) { display: grid; grid-template-columns: repeat(4, 34px); gap: 4px; }
  .active-effects:has(.active-effect:nth-child(7)) .active-effect {
    width: 34px; min-width: 34px; padding: 2px; grid-template-columns: 1fr; grid-template-rows: 26px 16px; gap: 2px;
  }
  .active-effects:has(.active-effect:nth-child(7)) .active-effect img,
  .active-effects:has(.active-effect:nth-child(7)) .active-effect > .icon { width: 26px; height: 26px; grid-column: 1; grid-row: 1; }
}
@media (pointer: coarse) and (orientation: portrait) and (max-width: 374px) {
  .hud { --spell-size: 48px; --spell-gap: 8px; }
}
@media (pointer: coarse) and (orientation: portrait) and (max-height: 700px) {
  .hud:has(.hero-slot:not([hidden])) { --dial-size: 126px; }
  .active-effect.course-debuff > .icon { width: 26px; height: 26px; }
}
@media (pointer: coarse) and (orientation: landscape) and (max-height: 540px) {
  .hud .drift-indicator { width: 216px; }
  .active-effect.course-debuff > .icon { width: 26px; height: 26px; }
}
@media (pointer: coarse) and (orientation: landscape) and (max-height: 340px) {
  .hud { --spell-size: 56px; --spell-gap: 8px; }
  .active-effects:has(.active-effect:nth-child(7)) { left: 140px; right: 140px; gap: 4px; }
  .active-effects:has(.active-effect:nth-child(7)) .active-effect { width: 52px; min-width: 52px; }
  .active-effect.course-debuff > .icon { width: 22px; height: 22px; }
}
@media (pointer: fine) and (max-width: 1100px) and (max-height: 540px) and (orientation: landscape) {
  .active-effect.course-debuff > .icon { width: 26px; height: 26px; grid-column: 1; grid-row: 1; }
}
@media (prefers-reduced-motion: reduce) { .hud .spell-dock .hero-reveal { transition: none; } }
