/* The arena changes presentation only; card visibility comes from the engine. */
.learning-actions { display:inline-flex; gap:8px; }
@media(max-width:680px) {
  html[data-hide-skin-controls] body:not(.tutorial-page) .masthead { position:relative; flex-wrap:wrap; }
  html[data-hide-skin-controls] body:not(.tutorial-page) .masthead .brand { flex-basis:100%; padding-right:90px; }
  html[data-hide-skin-controls] body:not(.tutorial-page) .masthead .top-actions { width:100%; max-width:none; flex-wrap:wrap; justify-content:space-between; }
  html[data-hide-skin-controls] body:not(.tutorial-page) .masthead .profile-shortcut { position:absolute; right:0; top:0; min-height:34px; }
  .learning-actions { gap:3px; }
}
.mobile-title, .action-prompt, .castle-trigger, .journal-button { display: none; }
.effects-button { font-variant-numeric: tabular-nums; }
.effects-button[aria-pressed="true"] { color: var(--gold-light); border-color: var(--gold); }
.combat-reference { flex: 0 0 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; color: #c2d2bc; font-size: 10px; line-height: 1.35; text-align: left; }
.combat-reference > span { min-width: 0; }
.combat-reference b { color: var(--gold-light); font-weight: 600; }
.combat-reference .reference-note { grid-column: 1 / -1; color: #aebfa9; font-size: 9px; }
.local-result .actions .reveal-progress { margin: 0; }
#castle-cards, #local-castle-cards, #online-castle-cards { flex-wrap: wrap; }
body:not(.local-mode) .combat-reference { display: none; }
.duel-preview { align-items: flex-start; gap: 28px; }
.duel-preview .versus { align-self: center; color: var(--gold); }
.duel-item.primary-item .card { --card-w: 84px; --card-h: 116px; }
.duel-item.support-item .card { --card-w: 58px; --card-h: 84px; }
.duel-item.primary-item .card-placeholder { width: 84px; height: 116px; }
.duel-item.support-item .card-placeholder { width: 58px; height: 84px; }
.duel-item .card-placeholder { background: radial-gradient(ellipse, rgba(217,183,121,.035), transparent); color: #718477; font-size: 25px; }
.duel-card { align-items: end; gap: 9px; }
.duel-item.support-item .rank { font-size: 20px; }
.duel-item.support-item .suit { font-size: 18px; }
.duelist { min-width: 0; }
.duelist > small { letter-spacing: .04em; }
.battle-bonuses { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; max-width: 200px; min-height: 22px; margin-top: 6px; animation: bonuses-in .3s .5s both; }
.battle-bonuses > * { border: 1px solid var(--line); padding: 3px 5px; border-radius: 4px; color: #c2d2bc; font-size: 9px; font-weight: 500; }
.battle-bonuses b { color: var(--gold-light); background: rgba(217,183,121,.08); }
.battle-bonuses .bonus-wall { color: #bdd5d9; background: rgba(102,143,163,.1); }
.battle-bonuses .bonus-support { animation: bonuses-in .3s .75s both; }
.battle-bonuses .bonus-sabotage { color: #efb099; border-color: #9e6953; animation: sabotage-flash .7s .65s both; }
.battle-total { display: flex; gap: 7px; align-items: baseline; color: var(--gold-light); animation: total-in .35s .95s both; }
.battle-total > small { color: var(--muted); font-size: 10px; }
.battle-total > b { font-family: Georgia, serif; font-size: 33px; line-height: 1.1; font-weight: 400; }
.battle-verdict { color: var(--gold-light); font-family: Georgia, serif; font-size: 20px; text-align: center; animation: total-in .3s 1.25s both; padding: 4px 0 8px; }
.resolving .strength-strip { display: none; }
.resolving .result-notes { max-height: 95px; overflow: auto; }
.in-resolution .card.leaving { animation: card-turn .4s ease both, card-depart .65s 2.25s ease-in forwards; }
.in-resolution .is-winner .primary-item .card { animation: champion-in .4s ease both, victory-glow .65s 1.25s ease both; }
.card.discovered { animation: card-turn .45s ease both, scout-light 1s ease both; }
.card.staging { animation: troop-arrive .28s ease-out both; }
.card.troop-1.staging { animation-name: enemy-arrive; }
.cracking { animation: wall-crack .7s .8s both; }
.castle-sheet { max-width: 540px; }
#castle-description { padding: 18px 22px 0; color: var(--muted); font-size: 12px; }
#castle-cards { display: flex; justify-content: center; gap: 18px; padding: 28px 22px 35px; }
#castle-cards .card { --card-w: 78px; --card-h: 108px; }
#castle-cards .wall { width: 78px; font-size: 9px; }
@keyframes bonuses-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes total-in { from { opacity: 0; transform: scale(.82); } to { opacity: 1; transform: scale(1); } }
@keyframes card-depart { to { opacity: 0; transform: translateY(18px) scale(.82); filter: grayscale(1); } }
@keyframes champion-in { from { opacity: .4; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes victory-glow { 40% { box-shadow: 0 0 28px rgba(240,212,158,.7); transform: translateY(-5px); } to { box-shadow: 0 0 15px rgba(240,212,158,.3); transform: translateY(0); } }
@keyframes scout-light { 40% { box-shadow: 0 0 24px rgba(170,220,210,.9); } }
@keyframes troop-arrive { from { opacity: .5; transform: translateY(17px) rotate(-4deg); } to { opacity: 1; transform: none; } }
@keyframes enemy-arrive { from { opacity: .5; transform: translateY(-17px) rotate(4deg); } to { opacity: 1; transform: none; } }
@keyframes sabotage-flash { 45% { background: #713f32; text-decoration: line-through; transform: rotate(-3deg); } }
@keyframes wall-crack { 30%, 70% { transform: translateX(-3px); } 50%, 85% { transform: translateX(3px); } to { transform: none; color: #efb099; } }

@media (max-width: 680px) {
  html { min-width: 0; scrollbar-width: none; }
  html::-webkit-scrollbar { display: none; }
  :root { --card-w: clamp(31px, calc((100vw - 58px) / 7 - 4px), 43px); --card-h: calc(var(--card-w) * 1.38 + 5px); }
  .app { padding: 8px 10px calc(196px + env(safe-area-inset-bottom)); }
  body:not(.local-mode) .combat-reference { display: grid; }
  .combat-reference { gap: 3px 6px; padding: 6px 8px; font-size: 9px; line-height: 1.25; }
  .combat-reference .reference-note { font-size: 9px; }
  .masthead { gap: 6px; padding-bottom: 9px; }
  .brand { gap: 5px; }
  .brand h1 { font-size: 24px; margin: 0; }
  .brand-mark { width: 21px; height: 29px; }
  .brand .eyebrow, .brand .edition { display: none; }
  .top-actions { max-width: none; gap: 3px; flex-wrap: nowrap; }
  .top-actions .button { min-height: 38px; padding: 4px 5px; font-size: 9px; }
  .effects-button { width: 34px; white-space: nowrap; }
  .journal-button { display: inline-flex; }
  .top-actions [data-action="rules"] { max-width: 49px; }
  .top-actions [data-action="new"] { max-width: 48px; }
  .game-layout { display: block; }
  .table { padding: 9px; border-radius: 12px; background: radial-gradient(ellipse at 50% 50%, rgba(58,95,68,.3), transparent 70%), #142722; }
  .score-strip { margin-bottom: 8px; gap: 5px; grid-template-columns: 1fr 17px 1fr; }
  .player-score { min-height: 40px; padding: 6px 8px; flex-wrap: nowrap; gap: 4px; }
  .player-score h2 { font-family: "Segoe UI", sans-serif; font-size: 11px; font-weight: 600; }
  .player-score > div:first-child > small, .garrison-count small, .wall-count { display: none; }
  .garrison-count > b { font-size: 19px; }
  .garrison-count > b > span { font-size: 10px; }
  .conquest-mark { font-size: 17px; }
  .battlefield { gap: 10px; }
  .army { padding: 0; }
  .army:has(.leaving) { padding-bottom: 0; }
  .army-header { margin-bottom: 6px; min-height: 37px; gap: 6px; }
  .army-header h2 { font-family: "Segoe UI", sans-serif; font-size: 12px; font-weight: 500; }
  .army-header .badge { display: none; }
  .army-header .deck-mark { flex-basis: 7px; width: 7px; height: 12px; margin-right: 0; }
  .castle-trigger { display: inline-flex; align-items: center; gap: 5px; min-height: 37px; padding: 6px 7px; border: 1px solid var(--line); border-radius: 5px; background: rgba(8,18,16,.45); color: #c7d2bb; font-size: 10px; }
  .castle-trigger > span:first-child { color: var(--gold); font-size: 17px; }
  .castle-trigger b { color: var(--gold-light); font-weight: 500; }
  .castle-trigger:disabled { opacity: .75; }
  .castle-trigger.has-eligible { border-color: #b49d6d; box-shadow: 0 0 0 1px rgba(217,183,121,.14); }
  .mini-walls { display: flex; gap: 2px; margin-left: 2px; }
  .mini-walls i { width: 6px; height: 10px; border: 1px solid #b7c6a0; border-top: 2px solid #d9b779; border-radius: 1px; background: #435541; }
  .mini-walls .breach { background: #73442e; border-color: #b77b59; border-top: 0; transform: rotate(8deg); }
  .mini-walls .fallen { opacity: .25; border-color: #718477; background: transparent; }
  .army-formation { display: block; }
  .army .castle-zone, .army .zone-label { display: none; }
  .frontline { padding: 0; gap: 4px; justify-content: space-between; }
  .army .card { padding: 4px; border-radius: 4px; }
  .army .card .rank { font-size: 18px; }
  .army .card .suit { top: 5px; right: 3px; font-size: 14px; }
  .army .card .role, .army .card .bonus, .army .card .loss-mark { display: none; }
  .army .card .known-mark { top: auto; left: auto; right: 3px; bottom: 4px; font-size: 9px; }
  .army .card .slot { font-size: 7px; margin-top: auto; }
  .army .card.selected { outline-offset: 1px; transform: translateY(-3px); }
  .army .card.back::after { font-size: 21px; }
  .army .card.dead::after { font-size: 30px; }
  .phase-panel { padding: 10px; border-radius: 8px; background: radial-gradient(ellipse at 50% 40%, rgba(217,183,121,.065), transparent), #10221b; }
  .phase-top { margin-bottom: 7px; justify-content: center; gap: 6px; }
  .phase-top > * { min-height: 21px; font-size: 8px; padding: 2px 6px; }
  .phase-copy > h2:not(.mobile-title), .phase-copy > p { display: none; }
  .mobile-title { display: block; font-size: 18px !important; text-align: center; line-height: 1.15 !important; }
  .phase-panel > .hint { font-size: 10px; line-height: 1.35; margin-top: 5px; text-align: center; }
  .phase-panel .choice-grid { display: none; }
  .duel-preview { margin-top: 6px; padding: 8px 0 3px; border: 0; gap: 8px; }
  .duelist { flex: 1; gap: 4px; }
  .duelist > small { font-size: 9px; }
  .duelist > strong, .duelist > .support-label { display: none; }
  .duel-preview > .versus { font-size: 18px; padding-top: 12px; }
  .duel-card { gap: 5px; }
  .duel-item.primary-item .card { --card-w: 64px; --card-h: 90px; }
  .duel-item.support-item .card { --card-w: 44px; --card-h: 65px; }
  .duel-item.primary-item .card-placeholder { width: 64px; height: 90px; }
  .duel-item.support-item .card-placeholder { width: 44px; height: 65px; }
  .duel-item > small { font-size: 7px; }
  .duel-item .card .rank { font-size: 23px; }
  .duel-item .card .suit { font-size: 18px; }
  .duel-item.support-item .rank { font-size: 18px; }
  .duel-item.support-item .suit { font-size: 14px; }
  .duel-item.support-item .card:not(.leaving) { outline: 2px solid var(--gold-light); outline-offset: 1px; }
  .duel-item .card .role { font-size: 7px; }
  .duel-item.support-item .role { font-size: 6px; }
  .duel-card .loss-mark { max-width: 65px; font-size: 7px; }
  .duel-card:has(.leaving) { margin-bottom: 23px; }
  .battle-bonuses { max-width: 135px; gap: 3px; min-height: 39px; align-content: start; margin-top: 3px; }
  .battle-bonuses > * { padding: 2px 4px; font-size: 8px; }
  .battle-total > b { font-size: 27px; }
  .battle-total > small { font-size: 8px; }
  .battle-verdict { font-size: 17px; padding: 3px 0 0; }
  .resolving .result-notes { display: none; }
  .phase-panel > .actions { position: fixed; z-index: 20; bottom: 0; left: 0; right: 0; margin: 0; padding: 9px 12px calc(10px + env(safe-area-inset-bottom)); gap: 6px; background: linear-gradient(#1d3027,#13231e); border-top: 1px solid #647050; box-shadow: 0 -8px 24px rgba(0,0,0,.25); }
  .action-prompt { display: block; flex-basis: 100%; color: #d6dcbf; text-align: center; font-size: 10px; line-height: 1.3; padding-bottom: 2px; }
  .actions .button { min-height: 47px; padding: 9px; font-size: 11px; flex: 1; }
  .actions .button.ghost { font-size: 10px; }
  .reveal-progress { width: 100%; min-width: 0; text-align: center; padding: 10px 12px; }
  .resolving .actions > .action-prompt { display: none; }
  .sidebar { display: none; margin-top: 16px; }
  .show-journal .sidebar { display: grid; grid-template-columns: 1fr; }
  .show-journal .sidebar .ledger, .show-journal .sidebar .quick-rules { display: none; }
  .show-journal .sidebar .journal { max-height: none; }
  .show-journal .log-list { max-height: 400px; }
  .footer-note { font-size: 8px; margin-top: 9px; justify-content: center; }
  .footer-note > span:first-child { display: none; }
  .game-setup .score-strip, .game-setup .army.enemy { display: none; }
  .game-setup .phase-copy > p, body[data-phase="over"] .phase-copy > p { display: block; text-align: center; font-size: 11px; margin-top: 7px; }
  .game-setup .phase-panel { padding: 12px; }
  .setup-hand { gap: 10px; padding: 10px 0 3px; }
  .setup-hand .card { --card-w: 54px; --card-h: 79px; padding: 6px; }
  .setup-hand .card .role { display: block; margin-top: auto; padding-top: 4px; font-size: 7px; }
  .setup-hand .card .suit { font-size: 18px; }
  .setup-hand .card .rank { font-size: 23px; }
  .castle-sheet { width: 100%; max-width: 680px; max-height: 80dvh; margin: auto 0 0; border-radius: 17px 17px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .castle-sheet .modal-head { padding: 17px 20px 13px; }
  .castle-sheet .modal-head h2 { font-size: 24px; }
  #castle-cards { gap: 18px; }
}
@media (max-width: 680px) and (max-height: 740px) {
  .battlefield { gap: 7px; }
  .phase-panel { padding: 8px; }
  .phase-top { margin-bottom: 5px; }
  .mobile-title { font-size: 16px !important; }
  .duel-preview { margin-top: 3px; padding-top: 4px; }
  .duel-item.primary-item .card { --card-w: 56px; --card-h: 80px; }
  .duel-item.primary-item .card-placeholder { width: 56px; height: 80px; }
  .duel-item.support-item .card { --card-w: 39px; --card-h: 58px; }
  .duel-item.support-item .card-placeholder { width: 39px; height: 58px; }
  .army-header { min-height: 32px; }
  .castle-trigger { min-height: 32px; }
  .army .card { height: calc(var(--card-w) * 1.3 + 2px); }
  .battle-total > b { font-size: 23px; }
  .battle-verdict { font-size: 15px; }
  .resolving .phase-top { display: none; }
  .resolving .duelist { gap: 3px; }
  .resolving .battle-verdict { padding-top: 0; }
  .phase-panel > .actions { padding-top: 7px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .actions .button { min-height: 44px; }
}
@media (max-width: 350px) {
  .castle-sheet #castle-cards, .castle-sheet #local-castle-cards, .castle-sheet #online-castle-cards { column-gap: 8px; padding-inline: 14px; }
  .brand h1 { font-size: 21px; }
  .brand-mark { width: 18px; }
  .top-actions .button { font-size: 8px; padding: 4px; }
  .duel-item.primary-item .card { --card-w: 56px; --card-h: 82px; }
  .duel-item.primary-item .card-placeholder { width: 56px; height: 82px; }
  .duel-item.support-item .card { --card-w: 39px; --card-h: 60px; }
  .duel-item.support-item .card-placeholder { width: 39px; height: 60px; }
  .army-header h2 { font-size: 11px; }
  .castle-trigger { font-size: 9px; gap: 4px; }
  .setup-hand { gap: 8px; }
  .setup-hand .card { --card-w: 46px; --card-h: 72px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .in-resolution .card.leaving { animation: none !important; }
}
