:is(#home,#lobby,#outcome,#settings,#plant-dialog) {
  --shell:#182d31;
  --shell-raised:#253e3f;
  --shell-line:#57716c;
  --shell-text:#fff0ce;
  --shell-muted:#c4d1bd;
  --shell-gold:#f8d28a;
  --shell-gold-shadow:#a7764d;
}
#app:has(#home:not([hidden])) { padding:0; }
#home {
  position:relative;
  isolation:isolate;
  min-height:100svh;
  background:#193637;
  color:var(--shell-text);
}
.home-scene {
  position:absolute;
  inset:0;
  z-index:-1;
  overflow:hidden;
  image-rendering:pixelated;
}
.home-art,.home-light { position:absolute; inset:0; }
.home-art {
  background:url('/assets/field-menu.webp') 67% center/cover no-repeat;
  transform-origin:70% 43%; animation:home-pan 13s ease-in-out infinite alternate;
  transition:filter .18s ease;
}
#home:has(.home-action button:is(:hover,:focus-visible,:active)) .home-art { filter:brightness(1.075) saturate(1.08); }
.home-light {
  background:linear-gradient(117deg,transparent 48%,#ffdc8b22 65%,#82b2a819 70%,transparent 82%);
  animation:home-light 8s ease-in-out infinite alternate;
}
@keyframes home-pan { from { transform:scale(1.02); } to { transform:scale(1.095) translate(-.75%,.55%); } }
@keyframes home-light { from { transform:translateX(-5%); opacity:.28; } to { transform:translateX(8%); opacity:.92; } }
.home-scene::after {
  content:"";
  position:absolute;
  inset:0;
  background:linear-gradient(90deg,#112527f5 0%,#112527df 18%,#132b2c7d 42%,transparent 69%),
             linear-gradient(0deg,#142829cf,transparent 26%);
}
.home-scene span {
  position:absolute; z-index:1; top:var(--y); left:var(--x); width:4px; height:4px;
  background:#f3d08b; box-shadow:2px 2px #a89654a0; opacity:.45;
  animation:home-drift var(--pace) steps(12,end) infinite alternate;
}
.home-scene span:nth-of-type(1) { --x:75%; --y:34%; --pace:4.7s; }
.home-scene span:nth-of-type(2) { --x:69%; --y:49%; --pace:6.2s; }
.home-scene span:nth-of-type(3) { --x:82%; --y:43%; --pace:5.5s; }
.home-scene span:nth-of-type(4) { --x:56%; --y:58%; --pace:5.1s; }
@keyframes home-drift { from { transform:translate(0,7px); opacity:.15; } to { transform:translate(-12px,-17px); opacity:.72; } }
#screen-transition {
  position:fixed; inset:0; width:100%; height:100%; max-width:none; max-height:none; margin:0; padding:0;
  z-index:12; background:#0b1719; pointer-events:auto;
}
.home-inner {
  --home-inset:clamp(20px,7vw,100px);
  display:grid;
  grid-template-rows:auto 1fr auto;
  justify-items:start;
  gap:clamp(16px,3.6vh,32px);
  width:100%;
  max-width:1440px;
  min-height:100svh;
  margin:auto;
  padding:max(16px,env(safe-area-inset-top)) max(var(--home-inset),env(safe-area-inset-right))
          max(18px,env(safe-area-inset-bottom)) max(var(--home-inset),env(safe-area-inset-left));
}
#mode-label {
  grid-row:1;
  padding:3px 0;
  color:var(--shell-gold);
  font-size:.76rem;
  font-weight:750;
  letter-spacing:.075em;
}
.home-console {
  grid-row:2; align-self:center; width:min(56%,680px);
  animation:home-enter .4s ease-out both;
}
.home-title {
  position:relative; width:fit-content; max-width:100%; padding:9px clamp(13px,2.25vw,28px) 12px;
  border:2px solid #875142; border-top-color:#c17e60; border-bottom-color:#4e3430;
  background:linear-gradient(0deg,#1b3032f7,#31494bf5);
  box-shadow:inset 0 0 0 3px #192e31, 4px 5px #0a1b20a6;
}
.home-title::before,.home-title::after { content:""; position:absolute; top:6px; width:4px; height:4px; background:#c3a069; box-shadow:1px 1px #101f20; }
.home-title::before { left:6px; }.home-title::after { right:6px; }
.home-secondary { display:grid; grid-template-columns:1fr 1fr; gap:6px; margin-top:6px; }
.home-secondary .quiet { display:flex; align-items:center; justify-content:center; gap:8px; min-width:78px; background:#263d3e; border-color:#9a6454; box-shadow:inset 0 1px #7e9a8d7a,inset 0 -3px #11282a; }
.home-secondary img,.home-action img { image-rendering:pixelated; }
.home-secondary .menu-symbol { width:13px; }
@keyframes home-enter {
  from { opacity:0; transform:translateY(8px); }
}
#activity-title {
  max-width:8em;
  font-size:clamp(2.5rem,7.75vw,6.75rem);
  font-weight:950;
  letter-spacing:.045em;
  line-height:1.05;
  color:#f6df9f;
  text-shadow:2px 2px #647359,4px 4px #102525;
  overflow-wrap:anywhere;
  text-wrap:balance;
}
.home-tagline { margin-top:.48rem; color:#e1e8cd; font-size:clamp(.86rem,1.8vw,1.12rem); letter-spacing:.06em; }
.home-action { width:min(100%,318px); margin-top:clamp(11px,2.3vh,20px); }
.home-action .primary {
  display:flex;
  align-items:center;
  gap:10px;
  width:100%;
  min-height:54px;
  border:2px solid #e07763;
  border-bottom-color:#8d493d;
  border-radius:2px;
  background:linear-gradient(0deg,#354739,#536047);
  color:#fff0c5;
  box-shadow:inset 0 0 0 2px #293b32,inset 0 3px #a29f6680,3px 4px #142326;
  font-size:1.16rem;
  letter-spacing:.02em;
}
.home-action .primary::after {
  content:"";
  margin-inline-start:auto;
  width:.48em;
  height:.48em;
  border:solid currentColor;
  border-width:2px 2px 0 0;
  transform:rotate(45deg);
}
#home button { transition:filter .16s ease,background-color .16s ease; }
#home button:active { transform:translateY(2px); }
body.reduced #home :is(button,.home-art) { transition:none; }
#home-status { margin-top:12px; color:#fadd97; font-size:.9rem; }
#home-status:empty { display:none; }
.privacy { color:#d0dbca; font-size:.75rem; line-height:1.5; }
.home-entry { grid-row:3; display:flex; align-items:center; flex-wrap:wrap; gap:4px 12px; }
#edit-alias { background:#233c3dc9; font-size:.8rem; padding:.25em .55em; }
.onboard-dialog {
  padding:0; width:min(92vw,460px); color:#f6eaca; background:#1c3034; border:1px solid #758b7b;
  box-shadow:0 6px #101f21; border-radius:3px;
}
dialog[open]::backdrop { background:#09191eb8; animation:shade-in .26s ease-out both; }
dialog[open].dial-down::backdrop { animation:shade-out .15s ease-in both; }
.crt-switching { pointer-events:none; }
@keyframes shade-in { from { opacity:0; } to { opacity:1; } }
@keyframes shade-out { from { opacity:1; } to { opacity:0; } }
body.reduced dialog[open]::backdrop { animation:none; }
.onboard-dialog .dialog-head { margin:0; padding:9px 14px; background:#294143; border-bottom:1px solid #5a746e; }
.onboard-content { display:grid; gap:8px; padding:12px 14px 14px; }
.onboard-content p { color:#cbd9c4; font-size:.9rem; line-height:1.45; }
#alias-input { width:100%; min-height:44px; padding:0 .65em; color:#f6eaca; background:#142a2d; border:1px solid #789189; border-radius:2px; font:inherit; }
#alias-input:focus { outline:2px solid var(--blue); }
#alias-error { color:#ffc6aa; }
.onboard-actions { display:flex; gap:6px; align-items:center; justify-content:flex-end; flex-wrap:wrap; }
.onboard-actions button { font-weight:790; }
.onboard-actions .primary { padding:.28rem .7rem; box-shadow:0 2px #9f784a; }
#calibration { display:grid; gap:10px; }
.calibration-level { position:relative; height:24px; border:1px solid #6f9287; background:linear-gradient(90deg,#264447 49.5%,#96b5a6 49.5% 50.5%,#264447 50.5%); }
.calibration-level span { position:absolute; left:var(--level,50%); top:50%; width:12px; height:12px; transform:translate(-50%,-50%) rotate(45deg); background:#f4ce80; }

#game.drafting { --clearing-width:43cqw; isolation:isolate; }
.drafting #battle-world { width:calc(100% + var(--camera-travel,0px)); }
#battle-world { transition:transform .54s cubic-bezier(.43,.02,.22,1); }
.draft-rear #battle-world { transform:translateX(calc(-1 * var(--camera-travel))); }
body.reduced #battle-world { transition:none; }
#lobby,#enemy-preview { position:absolute; top:0; bottom:0; }
#lobby {
  z-index:7;
  inset-inline:0 var(--clearing-width);
  display:grid;
  grid-template-rows:auto minmax(0,auto);
  align-content:center;
  gap:clamp(3px,1.65dvh,12px);
  padding:clamp(5px,1.8cqw,20px);
  border-inline-end:3px solid #ac795a;
  background:linear-gradient(135deg,#314a42,#172d30 85%);
  box-shadow:4px 0 #122426b5,inset 0 0 0 1px #56756a,inset 0 3px #94b39842;
  container-type:size;
  animation:draft-slide .34s cubic-bezier(.22,1,.36,1) both;
}
@keyframes draft-slide { from { transform:translateX(-102%); } to { transform:translateX(0); } }
.draft-closing #lobby { animation:draft-slide-away .24s ease-in both; }
@keyframes draft-slide-away { to { transform:translateX(-102%); } }
#enemy-preview {
  right:0;
  width:var(--clearing-width);
  container-type:size;
  pointer-events:none;
}
#enemy-roster {
  height:100%;
  display:grid;
  grid-template-columns:repeat(7,minmax(0,1fr));
  grid-auto-rows:minmax(0,1fr);
  place-items:center;
  list-style:none;
  margin:0;
  padding:8cqh 3cqw 4cqh;
}
#enemy-roster li {
  width:min(13.2cqw,16cqh,56px);
  aspect-ratio:1;
  background-image:var(--enemy-idle-image);
  background-size:600% auto;
  background-position:0 0;
  background-repeat:no-repeat;
  image-rendering:pixelated;
  filter:drop-shadow(1px 2px #132a23);
  animation:enemy-idle .93s steps(6,jump-none) var(--enemy-idle-delay) infinite;
}
@keyframes enemy-idle { to { background-position-x:100%; } }
.lineup-heading { display:flex; align-items:baseline; justify-content:space-between; gap:4px; }
#selection-title { font-size:clamp(.87rem,4.6cqw,1.45rem); line-height:1.12; color:#fae2ab; white-space:nowrap; }
#deck-message { color:#e4ca8c; text-align:right; font-size:clamp(.68rem,3.6cqw,.88rem); font-weight:720; }
.draft-empty { border-style:dashed; background:var(--battle-inset); box-shadow:none; }
.draft-empty .battle-card-art { aspect-ratio:1; display:grid; place-items:center; }
.draft-empty .battle-card-art::before { content:""; width:6px; height:6px; background:#74907c66; transform:rotate(45deg); }
.draft-empty .battle-card-cost { visibility:hidden; }
.slot-appear { animation:slot-sprout .25s steps(6,end) var(--slot-delay,0ms) both; }
.slot-inbound { visibility:hidden; }
.slot-landed { animation:slot-land .19s steps(5,end) both; }
.plant-flight { position:fixed; transform-origin:top left; z-index:10; pointer-events:none; filter:drop-shadow(1px 2px #102221); }
@keyframes slot-sprout { from { opacity:0; transform:translateY(8px) scale(.65); } to { opacity:1; transform:none; } }
@keyframes slot-land { from { transform:scale(1.15); filter:brightness(1.3); } to { transform:none; filter:none; } }
#library { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); grid-auto-rows:clamp(32px,22cqh,76px); gap:3px; min-width:0; overflow-y:auto; scrollbar-width:thin; }
.plant-entry { position:relative; min-width:0; }
.plant-option { display:grid; place-items:center; align-content:center; width:100%; height:100%; min-height:0; padding:0 1px; background:linear-gradient(#526c51,#314d42); border:1px solid #73917b; border-radius:2px; box-shadow:inset 0 1px #c0d4a044; }
.plant-option strong { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
.plant-option img { width:clamp(18px,12cqh,45px); max-width:100%; }
.plant-entry[data-selected=true] .plant-option { filter:grayscale(1); background:#303e3c; border-color:#729385; }
.plant-entry[data-replacing=true] .plant-option { border-color:#ffe093; box-shadow:inset 0 0 0 1px #ffe093; }
.plant-spark { position:absolute; z-index:2; top:49%; left:50%; width:4px; height:4px; color:#ffdf95; background:currentColor; pointer-events:none; box-shadow:-13px -4px,14px 3px,-9px 10px,9px -11px; animation:plant-spark .29s steps(7,end) both; }
@keyframes plant-spark { from { opacity:1; transform:scale(.28); } to { opacity:0; transform:scale(1.25); } }
.plant-price { display:flex; align-items:center; gap:2px; color:#f3d69a; font-size:clamp(.59rem,3cqw,.78rem); line-height:1; font-weight:850; font-variant-numeric:tabular-nums; }
.sun-icon { width:.9em; height:.9em; background:url('/assets/sun-core.png') center/contain no-repeat; image-rendering:pixelated; }
.info { position:absolute; right:1px; top:1px; display:grid; place-items:center; width:15px; min-height:16px; padding:0; border:0; color:#dce4ce; background:#223934; font-size:.66rem; font-weight:850; }
@container (max-width:220px) { .info { width:11px; min-height:13px; font-size:.6rem; } }
.lobby-confirm { display:flex; align-items:center; gap:6px; padding:0 3px; background:#223735; border:1px solid #62756b; }
#lobby-status { margin-inline-end:auto; color:#f5deb3; font-size:.77rem; }
#lobby-status:empty { display:none; }
.lineup-actions { display:flex; gap:5px; margin-inline-start:auto; }
.lobby-confirm button { padding:.22rem .5rem; }
.lobby-confirm #start { border-color:#ee956f; box-shadow:inset 0 -3px #bd8957; }
#launch-countdown {
  position:absolute; inset:0; z-index:8;
  display:grid; place-items:center;
  background:linear-gradient(#0c1c1cb5,#10221ebd);
}
.launch-display {
  position:relative; display:grid; justify-items:center; padding:6px 22px 0;
  border-block:1px solid #a88a5f; background:#192e2de8; color:#fff0b4;
  box-shadow:0 5px #132524ba;
}
.launch-display::before,.launch-display::after {
  content:""; position:absolute; top:5px; bottom:5px; width:4px;
  border-block:2px solid #edba81; pointer-events:none;
}
.launch-display::before { left:5px; border-left:2px solid #edba81; }
.launch-display::after { right:5px; border-right:2px solid #edba81; }
.launch-display p { font-size:clamp(.77rem,2.3vw,.99rem); font-weight:820; letter-spacing:.14em; }
#launch-digit { display:block; width:auto; height:clamp(68px,36dvh,128px); image-rendering:pixelated; }
@media (prefers-reduced-motion:reduce) { #battle-world { transition:none; } }

#outcome {
  --result-accent:#f5d283;
  --result-wash:#2d301f;
  --result-edge:#655937;
  --result-ink:#222819;
  --result-pad:clamp(16px,4vw,36px);
  max-width:940px;
  margin:clamp(4px,4dvh,34px) auto;
  display:grid;
  grid-template-columns:minmax(0,1.05fr) minmax(250px,.95fr);
  border:1px solid #496259;
  background:#172c29;
  color:#f5ead1;
}
#outcome[data-result=lost] {
  --result-accent:#ffac94;
  --result-wash:#392823;
  --result-edge:#754e42;
  --result-ink:#36231d;
}
.outcome-score {
  display:flex;
  flex-direction:column;
  gap:clamp(12px,2.4vw,24px);
  padding:var(--result-pad);
  border-top:3px solid var(--result-accent);
  background:linear-gradient(135deg,var(--result-wash),#192d28 74%);
}
.outcome-hero { display:grid; gap:clamp(3px,1vw,8px); }
#result-alias { color:#d1d8c4; font-size:.9rem; overflow-wrap:anywhere; }
#result-title {
  color:var(--result-accent);
  font-size:clamp(2.55rem,8vw,5.7rem);
  font-weight:900;
  letter-spacing:.03em;
  line-height:1;
}
.outcome-metric { padding-top:clamp(8px,1.6vw,15px); border-top:1px solid var(--result-edge); }
#result-metric-label,#result-summary { color:#d1d8c4; font-size:.84rem; }
#result-metric {
  font-size:clamp(1.6rem,4vw,2.65rem);
  font-variant-numeric:tabular-nums;
  font-weight:820;
  line-height:1.25;
  margin:.14em 0;
}
.outcome-actions { display:flex; flex-wrap:wrap; gap:6px; margin-top:auto; }
.outcome-actions button { border-radius:4px; padding:.42em .68em; }
.outcome-actions .primary {
  display:flex; align-items:center; gap:.7em;
  background:var(--result-accent); border-color:var(--result-accent); color:var(--result-ink);
  box-shadow:inset 0 -2px #151d2242;
}
.outcome-actions .quiet { background:#1d342e; border-color:#526a5b; }
.outcome-board { min-width:0; padding:var(--result-pad); border-left:1px solid #496259; }
.outcome-board-head { display:flex; align-items:baseline; justify-content:space-between; gap:8px; margin-bottom:.55rem; }
#result-board-title { font-size:clamp(1.1rem,3vw,1.5rem); }
#result-board-link {
  display:flex; align-items:center; gap:6px;
  color:#c2ccbd; font-size:.76rem; white-space:nowrap;
}
#result-board-link::before { content:""; width:6px; height:6px; border-radius:50%; background:#aab7a7; }
#result-board-link[data-state=live]::before { background:#9adc9a; }
#result-board-link[data-state=retry]::before { background:#eccb79; }
#result-leaders {
  display:grid; margin:0; padding:0; border-top:1px solid #50665a; list-style:none;
}
#result-leaders li {
  display:grid; align-items:center; grid-template-columns:2ch minmax(0,1fr) auto; gap:.62rem;
  min-height:clamp(34px,5dvh,48px); padding:.28rem .42rem;
  border-bottom:1px solid #40584d; font-variant-numeric:tabular-nums;
}
#result-leaders li[data-self=true] { background:#2f4537; box-shadow:inset 2px 0 var(--result-accent); }
#result-leaders li span:first-child { color:#dcbe82; font-weight:800; }
#result-leaders li span:nth-child(2) { overflow-wrap:anywhere; }
#result-leaders li span:last-child { color:#d5dbca; white-space:nowrap; font-size:.86rem; }
#result-board-empty,#result-standing { padding:.65rem .42rem 0; color:#ccd7c6; font-size:.83rem; }
#result-standing { color:var(--result-accent); }
#review {
  grid-column:1 / -1;
  border-top:1px solid #496259;
  background:#1a302b;
}
#review summary { padding:12px var(--result-pad); cursor:pointer; font-weight:740; }
#wrong-review { display:grid; gap:10px; margin:0; padding:0 var(--result-pad) 16px calc(var(--result-pad) + 1.15em); color:#e9e9cc; overflow-wrap:anywhere; }
@media (orientation:landscape) and (max-height:450px) {
  #outcome { --result-pad:clamp(12px,3vw,24px); margin-block:8px; }
}
@media (max-width:600px) {
  #outcome { grid-template-columns:1fr; }
  .outcome-board { border-left:0; border-top:1px solid #496259; }
}

:is(#settings,#plant-dialog) {
  width:min(calc(100vw - 24px),620px);
  max-height:calc(100dvh - 28px);
  padding:0;
  color:var(--shell-text);
  background:var(--shell);
  border-color:var(--shell-line);
  border-radius:4px;
}
:is(#settings,#plant-dialog) .dialog-head {
  position:sticky;
  top:0;
  z-index:1;
  margin:0;
  padding:8px 16px;
  color:var(--shell-text);
  background:var(--shell-raised);
  border-bottom:1px solid var(--shell-line);
}
#settings .settings-list,#plant-content { display:grid; gap:12px; padding:12px 16px 16px; }
.setting-group { border-block:1px solid var(--shell-line); }
#settings .setting-group :is(label,.setting-locked) { display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:48px; color:#ebeed5; }
.setting-group > * + * { border-top:1px solid #395757; }
.setting-locked strong { color:#c5e0ac; font-size:.85rem; }
#settings .setting-group input { width:22px; height:22px; margin:0 4px 0 auto; }
.setting-tilt { display:grid; justify-items:start; gap:6px; }
#tilt-status { color:var(--shell-muted); line-height:1.5; }
#settings #leave { justify-self:end; color:#ffcab8; }
#plant-content .description {
  grid-template-columns:clamp(48px,15vw,83px) minmax(0,1fr);
  align-items:start;
  gap:14px;
  padding:12px 0;
  border-bottom:1px solid #395757;
}
#plant-content .description:last-child { border-bottom:0; }
#plant-content .description img {
  width:100%;
  padding:4px;
  border:1px solid #53736b;
  background:#244746;
}
#plant-content .description p { color:var(--shell-muted); line-height:1.5; }
#plant-content summary { display:list-item; width:max-content; padding-block:10px; cursor:pointer; }

@media (orientation:landscape) and (max-height:500px) {
  .home-inner { gap:10px; }
  .home-action { width:min(100%,260px); }
  .home-action .primary { min-height:48px; }
  #activity-title { font-size:clamp(2.05rem,6.5vw,4.2rem); }

}
@media (orientation:portrait) and (max-width:640px) {
  .home-art { background-position:84% top; background-size:auto 74%; }
  .home-scene::after { background:linear-gradient(180deg,#193637a0 0%,transparent 25%,transparent 44%,#19363775 63%,#193637 80%); }
  .home-inner { gap:16px; }
  .home-console { align-self:end; width:min(100%,390px); }
  .home-action { width:min(100%,350px); }
  #activity-title { font-size:clamp(2.55rem,11vw,4.6rem); }
  #game.drafting { --clearing-width:40cqw; }
  #lobby { padding:5px; }
  .lobby-confirm { font-size:.83rem; flex-wrap:wrap; }
  .lobby-confirm #lobby-status { order:3; flex-basis:100%; }
}
@media (prefers-reduced-motion:reduce) {
  #home :is(button,.home-art) { transition:none; }
  dialog[open]::backdrop { animation:none; }
}
