/* Board experience shared by all editions. */
:root{--bg:#101b22;--fg:#edf4ef;--mut:#a0b4b6;--edge:#365058;--neu:#3e5357;--p1:#69c7bb;--p2:#ed8592;--card:#192a31;--bd:#30434b;color-scheme:dark}
body{background:radial-gradient(ellipse at 20% 0%,#29453f70,transparent 55%),var(--bg);font-family:Inter,ui-sans-serif,system-ui,sans-serif}
body.orchard{--card:#fff7e5;--p1:#548f73;--p2:#c4646e;--neu:#d7cdab;--edge:#c1b591}
body.signal{--p1:#62d3e8;--p2:#ee83ab;--neu:#304459;--edge:#35516a}
main,.orchard main,.signal main{max-width:860px;padding:24px clamp(12px,3vw,32px) 48px}
h1{font-size:clamp(32px,6vw,52px);letter-spacing:-.055em;line-height:1.1;margin:24px 0 10px}
.editions{gap:4px;padding:5px;border:1px solid var(--bd);background:var(--card);border-radius:14px;width:fit-content;margin-bottom:24px}
.editions a{border:0;border-radius:9px;min-height:38px;padding:0 16px;color:var(--mut);font-size:13px;font-weight:650}
.editions a[aria-current=page]{background:var(--p1);color:#10251f}
#msg{min-height:40px;margin:12px 0 16px;font-size:13px;max-width:640px;line-height:1.6}
.battle-shell{border:1px solid var(--bd);border-radius:22px;overflow:hidden;background:var(--card);box-shadow:0 22px 70px #0002}
.battle-top{display:flex;justify-content:space-between;align-items:center;padding:20px 24px 16px;gap:12px}
.eyebrow{display:block;font-size:9px;letter-spacing:.18em;font-weight:800;color:var(--mut);margin-bottom:6px}
.battle-top strong{font-size:15px;font-weight:600;letter-spacing:-.02em}
.live-pill{font-size:9px;letter-spacing:.1em;border:1px solid var(--bd);border-radius:20px;padding:7px 10px;white-space:nowrap;color:var(--p1)}
.live-pill i,.key-dot{display:inline-block;width:6px;height:6px;border-radius:50%;background:var(--p1);margin-right:6px}
.battle-ended .live-pill{visibility:hidden}
.battle-stats{display:flex;border-top:1px solid var(--bd);border-bottom:1px solid var(--bd);padding:12px 24px;gap:24px;font-size:11px;color:var(--mut)}
.battle-stats b{font-size:15px;color:var(--fg);margin-right:4px;font-variant-numeric:tabular-nums}
#map{width:100%;height:min(70svh,710px);max-height:none;border:0;border-radius:0;box-sizing:border-box;display:block;background:radial-gradient(ellipse at 50% 80%,color-mix(in srgb,var(--p1) 9%,transparent),transparent 65%),var(--bg);touch-action:none}
.route{fill:none;stroke:var(--edge);stroke-width:.55;stroke-linecap:round}
.route-active{stroke:var(--p1);stroke-width:.8;opacity:.5}
.route-flow{fill:none;stroke:var(--p1);stroke-width:.35;stroke-dasharray:1 3;pointer-events:none}
.board-node{cursor:pointer;outline:none}.board-node:hover>circle:nth-child(2),.board-node:focus-visible>circle:nth-child(2){stroke:var(--fg);stroke-width:1}
.battle-footer{padding:14px 22px;display:flex;gap:18px;align-items:center;font-size:10px;color:var(--mut);border-top:1px solid var(--bd)}
.rival-keys{display:flex;flex-wrap:wrap;gap:12px}.key-dot.neutral{background:var(--neu)}.board-hint{margin-left:auto}
.feedback-settings{display:flex;align-items:center;gap:8px;margin:12px 0 22px;font-size:11px;color:var(--mut)}
.feedback-settings>span{margin-right:auto}.feedback-settings button{font-size:11px;padding:7px 10px;min-height:36px;background:transparent}
button{border-radius:10px;border:1px solid var(--bd);background:var(--card);color:var(--fg);min-height:42px;font:inherit;cursor:pointer;transition:background .18s,transform .18s,border-color .18s}
button:hover{background:color-mix(in srgb,var(--p1) 12%,var(--card));border-color:var(--p1)}button:active{transform:scale(.96)}button:disabled{opacity:.5;cursor:default}button.on{border-color:var(--p1);background:color-mix(in srgb,var(--p1) 13%,var(--card));box-shadow:inset 0 0 0 1px var(--p1)}
button:focus-visible,a:focus-visible,summary:focus-visible{outline:2px solid var(--p1);outline-offset:4px}
.card{background:var(--card);border:1px solid var(--bd);border-radius:18px;padding:20px;margin-top:16px}
.panel-heading{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:18px}.panel-heading h2{font-size:20px;line-height:1.2;margin:0;letter-spacing:-.035em}
svg.fruit-icon{width:32px;height:32px;max-height:none;display:inline-block;vertical-align:middle;touch-action:auto;border:0;border-radius:0;background:none;filter:drop-shadow(0 2px 2px #0002);pointer-events:none}
.selection-panel,.selection-empty{border-top:1px solid var(--bd);margin-top:18px;padding-top:20px}.selection-empty{display:flex;align-items:center;gap:14px;font-size:12px}.selection-empty>span{font-size:28px;color:var(--p1)}.selection-empty small{display:block;margin-top:4px;font-size:11px}.stock-row{display:flex;flex-wrap:wrap;gap:8px}.stock-button{display:flex;align-items:center;gap:8px;padding:8px 12px}.stock-button b{font-size:13px}.selection-panel .panel-heading button{font-size:12px}.production-label{font-size:11px;color:var(--mut);margin-top:20px}.command-hint{display:block;font-size:11px;margin-top:14px}
.type-wheel{background:radial-gradient(circle,transparent 0 var(--wheel-hole,22px),color-mix(in srgb,var(--card) 94%,transparent) calc(var(--wheel-hole,22px) + 2px) 100%,transparent 101%);border-color:transparent;box-shadow:none;pointer-events:none;transform-origin:center}.type-wheel button{display:grid;place-items:center;pointer-events:auto}
.shield-ring{filter:drop-shadow(0 0 1.8px #4bdcff);animation:shield-pulse 1s ease-in-out infinite alternate}.ability-arc{filter:drop-shadow(0 0 1.4px currentColor)}.shop-cooldown{transform-box:fill-box;transform-origin:center;animation:shop-cooldown 1s linear infinite}.node-shaking{transform-box:fill-box;transform-origin:center;animation:shield-shake .16s linear 3}@keyframes shield-pulse{from{opacity:.68}to{opacity:1;stroke-width:2.1}}@keyframes shop-cooldown{to{transform:rotate(360deg);stroke-dashoffset:12}}@keyframes shield-shake{0%,100%{translate:0 0}25%{translate:-1px 0}75%{translate:1px 0}}
.endgame-dialog{width:min(420px,calc(100% - 40px));box-sizing:border-box;border:1px solid var(--bd);border-radius:22px;padding:28px;background:var(--card);color:var(--fg);box-shadow:0 24px 90px #0009}
.endgame-dialog::backdrop{background:#050a0dcc;backdrop-filter:blur(4px)}.endgame-message{font-size:22px;font-weight:750;letter-spacing:-.03em;margin:0 0 24px}.endgame-actions{display:flex;justify-content:flex-end;gap:10px}.endgame-actions button{padding:8px 14px}.endgame-retry{background:var(--p1);color:var(--bg)}
@media(min-width:1100px){main,.orchard main,.signal main{max-width:1140px;display:grid;grid-template-columns:minmax(0,1.6fr) minmax(320px,1fr);column-gap:28px}.editions,main>header,main>h1,#msg{grid-column:1/-1}.battle-shell{grid-column:1;grid-row:4 / span 3}#panel{grid-column:2;grid-row:4;margin-top:0;align-self:start}.feedback-settings{grid-column:1;grid-row:7}.card:not(#panel){grid-column:2;align-self:start}#map{height:min(70svh,680px)}}
@media(max-width:520px){main,.orchard main,.signal main{padding-top:14px}.battle-top{padding:16px}.battle-top strong{font-size:12px}.battle-stats{gap:14px;padding:10px 16px;font-size:9px}.battle-stats b{font-size:13px}.battle-footer{gap:12px;padding:12px;font-size:9px}.board-hint{display:none}.card{padding:16px}svg.fruit-icon{width:28px;height:28px}.feedback-settings{gap:5px}.feedback-settings>span{font-size:10px}.editions a{padding:0 12px}}
:root[data-motion=off] *, :root[data-motion=off] *:before,:root[data-motion=off] *:after{animation:none!important;transition:none!important;scroll-behavior:auto!important}
@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}
/* Keep the shared palette above the legacy automatic dark-mode selector. */
html:root:not([data-theme=light]){--bg:#101b22;--fg:#edf4ef;--mut:#a0b4b6;--edge:#365058;--neu:#3e5357;--p1:#69c7bb;--p2:#ed8592;--card:#192a31;--bd:#30434b}
@media(min-width:1100px){main,.orchard main,.signal main{padding-top:18px;row-gap:0}.editions{margin-bottom:8px}h1{margin-top:10px}.battle-top{padding-top:14px;padding-bottom:12px}#map{height:clamp(390px,60svh,650px)}}
@media(max-width:1099px){#map{height:min(106vw,70svh)}}
#lobby,#match{grid-column:1/-1}#match{max-width:860px;width:100%;margin:auto}

/* Let large displays carry a larger battlefield instead of a fixed 650px board. */
@media(min-width:1100px){
  main,.orchard main,.signal main{max-width:1800px;width:calc(100% - 48px);box-sizing:border-box;grid-template-columns:minmax(0,1fr) clamp(320px,27vw,440px);column-gap:32px}
  #map{height:min(78svh,1200px)}
  #match{max-width:none;display:grid;grid-template-columns:minmax(0,1fr) clamp(320px,27vw,440px);gap:0 32px}
  #match[hidden]{display:none}
  #match .battle-shell{grid-row:2 / span 3}
  #match #panel{grid-row:2}
  #match .feedback-settings{grid-row:5}
}
body,button,#map,.type-wheel{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;touch-action:manipulation}
input{-webkit-user-select:text;user-select:text;font-size:16px}
#map,.type-wheel{touch-action:none}
.type-wheel .wheel-progress{position:absolute;inset:0;width:100%;height:100%;max-height:none;border:0;background:none;pointer-events:none;fill:none;stroke:var(--fg);stroke-width:2}
.type-wheel .wheel-progress circle:first-child{opacity:.25}
.type-wheel button.hover{border-color:var(--fg);box-shadow:0 0 0 3px var(--p1)}
.type-wheel .wheel-counter-direction{position:absolute;pointer-events:none;color:var(--fg);opacity:.14;font-size:20px;font-weight:400;line-height:1;user-select:none}
.type-wheel button small{font-size:10px;color:var(--fg);font-variant-numeric:tabular-nums}
.battle-shell{position:relative}
.match-countdown{position:absolute;inset:0;z-index:8;display:grid;place-items:center;background:#10141099;color:#fff;font-size:clamp(28px,5vw,64px);font-weight:800;text-shadow:0 2px 12px #000;cursor:wait;touch-action:none}.match-countdown[hidden]{display:none}
.battle-tools{display:flex;align-items:center;justify-content:flex-end;gap:6px;padding:6px 8px;flex-shrink:0;background:var(--card);z-index:3}
.battle-tools button{min-height:44px;font-size:12px}
.battle-settings-button{width:36px;height:36px;padding:0;border-radius:50%;font-size:19px;background:var(--card);box-shadow:0 2px 10px #0003}
.battle-settings-dialog{width:min(360px,calc(100% - 36px));border:1px solid var(--bd);border-radius:16px;background:var(--card);color:var(--fg);box-shadow:0 18px 80px #0008}
.battle-settings-dialog::backdrop{background:#101410bb;backdrop-filter:blur(3px)}
.battle-settings-form{display:grid;gap:12px}.battle-settings-form h2{margin:0;font-size:20px}.battle-settings-form>label:not(.shop-setting){display:grid;gap:5px;font-weight:650}.battle-settings-form select{font:inherit;padding:9px;border:1px solid var(--bd);border-radius:8px;background:var(--bg);color:var(--fg)}.battle-settings-form .shop-setting{display:flex;align-items:center;gap:8px}.battle-settings-form input{width:20px;height:20px}.battle-settings-form .feedback-settings{display:flex;gap:6px;padding-top:10px;border-top:1px solid var(--bd)}.battle-settings-form .feedback-settings button{font-size:11px;padding:6px 9px;min-height:34px}.settings-actions{display:flex;justify-content:space-between;gap:8px;padding-top:6px;border-top:1px solid var(--bd)}
#friends-panel{position:absolute;right:24px;top:16px;z-index:20;margin:0;max-width:calc(100vw - 32px)}
#friends-panel,#match-profile{background:transparent;border:0;padding:0;border-radius:0}
#friends-panel[open],#match-profile[open]{background:var(--card);border:1px solid var(--bd);border-radius:18px;padding:10px}
#friends-panel>summary,#match-profile>summary{list-style:none;display:grid;place-items:center;width:40px;height:40px;box-sizing:border-box;padding:0;margin:0;border:1px solid var(--bd);border-radius:50%;background:var(--card);color:var(--fg);cursor:pointer}
#friends-panel>summary::-webkit-details-marker,#match-profile>summary::-webkit-details-marker{display:none}
#friends-panel[open]>summary,#match-profile[open]>summary{margin-left:auto;margin-bottom:4px}
.account-icon{width:20px;height:20px;fill:currentColor;stroke:currentColor;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round}.account-icon circle{stroke:none}
#friends-panel[open]{width:330px;box-shadow:0 12px 35px #0007}#lobby{max-height:65dvh;overflow:auto}#lobby input{width:100%}#lobby form[hidden]{display:none}.profile-name-row{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:0 0 10px}.profile-name-row strong{font-size:15px}.profile-name-row button{min-width:32px;min-height:32px;padding:3px}#invite-toasts{position:fixed;z-index:50;top:calc(16px + env(safe-area-inset-top));left:50%;transform:translateX(-50%);width:min(420px,calc(100vw - 24px));display:grid;gap:8px;pointer-events:none}#invite-toasts:empty{display:none}.invite-toast{display:flex;align-items:center;flex-wrap:wrap;gap:6px;padding:9px;margin:0;border:1px solid var(--p1);border-radius:10px;background:var(--card);box-shadow:0 8px 24px #0005;font-size:12px;pointer-events:auto}
@media(max-width:1099px){
 html{padding:0;overscroll-behavior:none;height:100%;overflow:hidden}
 body{height:100dvh;overflow:hidden;overscroll-behavior:none}
 main,.orchard main,.signal main{box-sizing:border-box;height:100dvh;width:100%;padding:calc(8px + env(safe-area-inset-top)) 8px calc(156px + env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:4px}
 h1{font-size:21px;margin:4px 0;line-height:32px}#friends-panel{top:calc(8px + env(safe-area-inset-top));right:8px;max-width:65vw}
 #msg{font-size:11px;line-height:1.3;min-height:28px;margin:2px 0;flex-shrink:0}
 .battle-shell{flex:1;min-height:0;border-radius:14px;display:flex;flex-direction:column}
 #map{flex:1;width:100%;height:100%;min-height:0;max-height:none}
 .battle-footer{padding:6px 8px;font-size:9px;gap:8px}.board-hint{display:none}
 #panel{position:fixed;bottom:0;left:0;right:0;z-index:5;margin:0;padding:8px 12px calc(8px + env(safe-area-inset-bottom));border-radius:14px 14px 0 0;background:var(--card)}
 #panel .fruit-icon{width:26px;height:26px}
 #match{display:flex;flex:1;flex-direction:column;min-height:0}#match[hidden]{display:none}
 #match-status{font-size:10px;margin:0}#rename-match{display:none}header.row{flex-shrink:0;margin:0;justify-content:space-between}header h1{font-size:18px}#leave-match{font-size:11px}
}
#match-profile{position:absolute;right:24px;top:16px;z-index:20;margin:0;max-width:60vw;font-size:12px}#match-profile[open]{width:300px}#match-profile #rename-match{display:flex}#match-profile p{color:var(--mut)}
@media(max-width:1099px){#match-profile{top:calc(8px + env(safe-area-inset-top));right:8px;padding:0}header.row{justify-content:flex-start;gap:8px}}

.production-cycle{display:grid;grid-template-columns:auto auto;justify-content:start;align-items:center;gap:3px 12px;width:fit-content;margin:8px 0}
.production-cycle[hidden]{display:none}
.production-pair{display:flex;align-items:center;gap:7px;padding:2px 8px;border-radius:8px;background:var(--card);font-size:13px}
.production-next{background:transparent;color:var(--mut)}
.production-buff,.production-debuff{position:relative;display:grid;place-items:center;width:20px;height:30px;font-size:16px;line-height:1}
.production-buff::before,.production-debuff::after{position:absolute;left:0;right:0;text-align:center;font:700 10px/1 system-ui}
.production-buff::before{content:"↑";top:0;color:#7ae6aa}
.production-debuff::after{content:"↓";bottom:0;color:#ff8997}
.production-cycle progress{grid-column:1/-1;width:100%;height:4px;accent-color:var(--p1)}

.battle-shell .production-cycle{grid-template-columns:auto auto auto;flex-shrink:0;margin:8px 52px 8px 12px}
@media(min-width:1100px){
 .production-cycle{width:auto;grid-template-columns:auto auto minmax(0,1fr);grid-column:1/-1;justify-self:stretch}
 .battle-shell .production-cycle{grid-template-columns:auto auto auto minmax(36px,1fr);margin-right:12px}
}
#production-countdown{font-size:11px;color:var(--mut);white-space:nowrap}

.portion-control{display:grid;gap:4px;flex-shrink:0;width:min(260px,calc(100% - 80px));margin:8px 12px;font-size:12px;font-weight:650}.portion-control[hidden]{display:none}.portion-control>span:first-child{display:flex;justify-content:space-between}.portion-control input{width:100%;margin:0;accent-color:var(--p1)}.portion-ticks{display:flex;justify-content:space-between;color:var(--mut);font-size:10px}

#friends{padding:0;list-style:none}
#friends li{display:grid;grid-template-columns:10px 1fr auto;gap:2px 8px;align-items:center;padding:6px 0}
#friends small{grid-column:2;line-height:1.4}
#friends li button{grid-column:3;grid-row:1/3}
.presence-dot{width:9px;height:9px;border-radius:50%;background:#238541}
.presence-dot.offline{background:var(--mut)}
#player-stats{font-weight:650}
#open-maps{position:absolute;top:16px;right:74px;min-height:40px;background:var(--card)}
@media(max-width:1099px){#open-maps{top:calc(8px + env(safe-area-inset-top));right:56px}}
#map-library,#map-editor{width:min(480px,calc(100vw - 44px));max-height:86dvh;overflow:auto;color:var(--fg);background:var(--card);border:1px solid var(--bd);border-radius:18px;padding:18px}
#map-library::backdrop,#map-editor::backdrop{background:#101410b8}
.map-heading,.map-actions,.map-fields{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:10px}
.map-heading{justify-content:space-between}
.map-heading h2{margin:0}
#map-editor label,#map-library label{display:grid;gap:4px;margin-bottom:8px;font-weight:600}
.map-fields>label{flex:1;min-width:100px}
#map-editor :is(input,select),#map-library :is(select,textarea){font:inherit;padding:7px;border:1px solid var(--bd);border-radius:8px;background:var(--bg);color:var(--fg)}
.map-preview{width:100%;height:clamp(130px,26vh,230px);background:var(--bg);border:1px solid var(--bd);border-radius:10px;touch-action:manipulation}
.map-preview line{stroke:var(--mut);stroke-width:1}
.map-preview circle{fill:var(--card);stroke:var(--mut);stroke-width:.55}
.map-preview text{font:bold 3.4px system-ui;text-anchor:middle;dominant-baseline:central;fill:var(--fg);pointer-events:none}
.map-preview .map-home circle{fill:var(--p1)}
.map-preview .map-selected circle,.map-preview .map-cursor{fill:none;stroke:var(--p1);stroke-width:1.3;pointer-events:none}
#editor-board .map-preview{height:min(43dvh,380px);cursor:crosshair;touch-action:none}
#editor-board line{stroke-width:1.6;cursor:pointer}
.map-guides{pointer-events:none;fill:none}
.map-grid-line,.map-symmetry-line{vector-effect:non-scaling-stroke}
.map-grid-line{stroke:var(--mut);stroke-opacity:.35;stroke-width:1px}
.map-symmetry-line{stroke:var(--p1);stroke-width:1.5px;stroke-dasharray:5 4}
.editor-view-tools label{display:inline-flex;align-items:center;gap:5px;min-height:44px}
#map-comments{max-height:150px;overflow:auto;padding-left:18px}
#map-comments p{white-space:pre-wrap;overflow-wrap:anywhere;margin:0 0 6px}
#comment-form textarea{width:100%;box-sizing:border-box}
.map-actions [aria-pressed=true]{outline:2px solid var(--p1)}
#editor-status,#library-status{color:var(--fg);overflow-wrap:anywhere}
#map-editor [hidden],#map-library [hidden]{display:none}

.map-player-count{display:flex;flex-wrap:wrap;gap:6px;margin:0;padding:0;border:0}
.map-player-count legend{padding:0;margin-bottom:5px;font-weight:650}
:is(.battle-settings-form,#variant-form,#map-library) .map-player-count label{
  display:inline-flex;align-items:center;justify-content:center;gap:7px;min-height:40px;
  min-width:56px;margin:0;padding:0 6px;border-radius:8px;border:1px solid var(--bd);cursor:pointer
}
.map-player-count label:has(:checked){border-color:var(--p1)}
.map-player-count label:has(:disabled){opacity:.5;cursor:default}
:is(.battle-settings-form,#variant-form,#map-library) .map-player-count input{
  width:16px;height:16px;min-height:0;margin:0;padding:0;accent-color:var(--p1)
}
.map-navigation{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:6px}
.map-navigation small{grid-column:1/-1;text-align:center}
.map-navigation .map-step{width:40px;min-height:44px;padding:0;font-size:26px;line-height:1}
.map-step:disabled{opacity:.35;cursor:default}
#map-library .map-player-count{margin-bottom:8px}

/* Use the available viewport even on phones without the Fullscreen API. */
.board-fullscreen,.board-fullscreen body{overflow:hidden;overscroll-behavior:none}
.board-fullscreen .battle-shell{
 position:fixed;inset:0;z-index:60;width:100%;height:100vh;height:100dvh;
 box-sizing:border-box;display:flex;flex-direction:column;min-height:0;
 padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
 border:0;border-radius:0;background:var(--bg)
}
.board-fullscreen #map{flex:1;width:100%;height:0;min-height:0;max-height:none}
.board-fullscreen .battle-tools{position:absolute;top:env(safe-area-inset-top);right:env(safe-area-inset-right);background:transparent}
.board-fullscreen .battle-footer,.board-fullscreen .battle-shell .production-cycle{display:none}
.board-fullscreen .type-wheel{z-index:70}
.battle-tools .battle-settings-button{width:44px;font-size:19px}

.team-settings{display:grid;gap:8px}
.team-settings[hidden]{display:none}
.team-settings label{display:flex;align-items:center;gap:8px}
.team-settings select{flex:1;min-width:0}
