:root {
  --gold: #ffe2a2;
  --edge: #b58b4a;
  --shell: #111d1be8;
  --space: clamp(8px, 1.55dvh, 24px);
  --button: clamp(42px, 6.5dvh, 80px);
  --font: clamp(13px, min(1.55vw, 3.4dvh), 24px);
}
.jungle-screen, .jungle-dialog {
  color: #f5ead0;
  background: linear-gradient(90deg,#061612e8,#10281e48 57%,#07191333), url('./jungle222.webp') center / cover #122d25;
}
#home {
  display: grid;
  grid-template-columns: minmax(0, 35fr) minmax(0, 65fr);
  gap: clamp(12px, 2vw, 52px);
  align-items: center;
  padding: max(var(--t),2dvh) max(var(--r),3.4vw) max(var(--b),2dvh) max(var(--l),4.6vw);
  overflow: hidden;
}
.version {
  position: absolute;
  z-index: 1;
  inset: var(--t) var(--r) auto auto;
  padding: .35em .8em;
  border: 1px solid var(--edge);
  border-radius: 5px;
  background: #11201de8;
  color: var(--gold);
  font: 700 clamp(11px,1vw,17px) Georgia,serif;
}
.menu {width: 100%; min-width: 0; display: grid; gap: var(--space)}
.title-lockup {padding: 0 0 clamp(2px,1dvh,12px)}
.title-lockup h1 {
  color: var(--gold);
  font: italic 950 clamp(30px,min(6.05vw,11dvh),150px)/1.13 Georgia,"Microsoft YaHei",serif;
  letter-spacing: -.055em;
  margin: 0;
  white-space: nowrap;
  background: linear-gradient(#fff6d5 8%,#ffdb8a 43%,#b57829 49%,#ffe79f 73%,#ecab4c);
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px #743f18) drop-shadow(0 5px 4px #000b);
}
.title-lockup p {
  color: #fff2d1;
  letter-spacing: .25em;
  font: 700 clamp(10px,1.35vw,29px) Georgia,serif;
  text-shadow: 0 2px 4px #000;
  margin-top: .36em;
}
.menu nav {display: grid; gap: calc(.66 * var(--space))}
.menu nav button,.jungle-dialog nav button,.back,.gold-action,#reset-controls,.result .links button {
  border: 1px solid var(--edge);
  border-radius: clamp(5px,.65vw,12px);
  background: linear-gradient(160deg,#51402b,#182321 44%,#14201e 72%,#3b2b18);
  box-shadow: inset 0 0 0 2px #121810a0,0 3px 10px #0005;
  color: #fff0ce;
  font-weight: 800;
  text-shadow: 0 2px 3px #161009;
}
.menu nav button {min-height: var(--button); text-align: left; padding-inline: 1.2em; font-size: clamp(14px,2vw,44px)}
.menu nav button::before {content: '◆'; color: #e7b662; font-size: .54em; margin-right: 1.65em; vertical-align: .18em}
.gold-action,.jungle-dialog .gold-action {
  border-color: #ffd582;
  background: linear-gradient(#ffdf91,#a45b17 15%,#8c4a13 49%,#5d3410 52%,#b87523 88%,#ffc36d);
  color: #fff3d3;
  box-shadow: inset 0 0 0 2px #f7cd7690,0 0 22px #f3a54a45,0 4px 14px #0006;
}
.menu > .gold-action {min-height: calc(1.29 * var(--button)); font-size: clamp(18px,2.65vw,58px)}
.menu footer {display: flex; gap: .8em; align-items: center; color: #efdfb6; font-size: clamp(10px,1vw,17px)}
.menu footer button {min-height: clamp(24px,3.5dvh,44px); padding-inline: .7em; background: #152820dd; border-color: #827147}
.home-hero,.picker figure {
  display: grid;
  grid-template-rows: minmax(0,1fr) auto;
  align-items: stretch;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
}
.home-hero {max-height: 88dvh; margin-inline: -1vw 0}
.portrait-stage {display: grid; place-items: center; position: relative; isolation: isolate; min-width: 0; min-height: 0}
.portrait-stage::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 12% 7% 6%;
  background: radial-gradient(ellipse at 54% 45%,#dcf8c929 0%,#478e6e21 39%,transparent 69%);
}
.portrait-stage img {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  filter: drop-shadow(0 clamp(5px,1.5dvh,18px) clamp(5px,1.3dvh,18px) #020b08db);
}
.home-hero figcaption,.picker figcaption {
  min-width: 0;
  color: #fff0ca;
  background: linear-gradient(110deg,#17251eea,#121c18d9);
  border: 1px solid #ad894e;
  border-radius: 8px;
  padding: clamp(7px,1.4dvh,19px) clamp(10px,2vw,34px);
  box-shadow: 0 4px 12px #0005;
}
.home-hero figcaption {justify-self: center; max-width: 90%; margin-top: calc(-1 * var(--space))}
figcaption strong {display: block; color: var(--gold); font: 800 clamp(17px,min(3vw,5.4dvh),54px)/1.1 Georgia,"Microsoft YaHei",serif}
figcaption span {display: block; margin-top: .4em; font-size: var(--font); line-height: 1.38}
.picker figcaption span {min-height: 2.76em}
.jungle-dialog {border: 1px solid var(--edge); box-shadow: 0 20px 72px #000a; padding: 0}
.jungle-dialog::backdrop {background: #04100cd4}
.wide-dialog {max-width: none; margin: auto; overflow: hidden; width: min(88vw,1640px)}
.wide-dialog form {
  display: grid;
  grid-template-rows: auto minmax(0,1fr) auto;
  min-height: min(64dvh,590px);
  max-height: calc(100dvh - var(--t) - var(--b) - 8px);
  background: #0a1715d9;
}
.jungle-dialog header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: .6em;
  align-items: center;
  border-bottom: 1px solid #ac864e99;
  padding: calc(.7 * var(--space)) max(12px,1.7vw);
  background: #101c19e0;
}
.jungle-dialog header h2 {grid-column: 2; grid-row: 1; text-align: center; color: var(--gold); font: 800 clamp(21px,min(3.5vw,6dvh),58px) Georgia,"Microsoft YaHei",serif}
.jungle-dialog header button {grid-row: 1; justify-self: start; min-height: clamp(40px,5.5dvh,63px); font-size: var(--font)}
#guide {padding: 0 14px 14px}
#exit-match p {padding: var(--space); color: #f5ead0}
#exit-match .links {justify-content: flex-end; padding: 0 var(--space) var(--space)}
#exit-match .links button {min-height: 42px; padding-inline: 12px; background-color: #13201deb; border-color: var(--edge)}
.wide-dialog footer {display: flex; justify-content: flex-end; gap: var(--space); padding: calc(.7 * var(--space)) max(12px,1.7vw); border-top: 1px solid #ac864e99}
.wide-dialog footer button {min-height: clamp(42px,6dvh,64px); font-size: var(--font)}
#species {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  border: 0;
  border-radius: 0;
  margin: 0;
}
#species form {height: 100%; max-height: none; min-height: 0; grid-template-rows: auto minmax(0,1fr); padding: var(--t) var(--r) var(--b) var(--l); background: #06161232}
#species header {background: linear-gradient(90deg,#101c19d9,#0b1b14c9,#101c1999); border-top: 1px solid #ac864e77}
.picker {
  display: grid;
  grid-template-columns: minmax(0,45fr) minmax(0,55fr);
  gap: clamp(10px,2vw,42px);
  min-height: 0;
  padding: var(--space) clamp(2px,1.45vw,30px) 0;
}
.skin-list {display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); grid-template-rows: repeat(4,minmax(0,1fr)); gap: clamp(4px,.65vw,14px); min-height: 0}
.skin-list button {
  display: grid;
  grid-template-rows: minmax(0,1fr) auto;
  min-height: 0;
  padding: clamp(2px,.42vw,8px);
  color: #ffebc3;
  background: radial-gradient(ellipse at 50% 43%,#406052ca,#172c25f0 62%,#101d18f0);
  border: 1px solid #ad895478;
  border-radius: 8px;
  font-size: clamp(11px,min(1.3vw,3.4dvh),23px);
  font-weight: 750;
  line-height: 1.25;
}
.skin-list button img {display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain}
.skin-list button span {padding-block: .18em; white-space: nowrap; text-shadow: 0 1px 3px #000}
.skin-list button[aria-pressed=true] {border-color: #f5ca70; box-shadow: inset 0 0 0 1px #f1c874,0 0 12px #fabc5070; background: radial-gradient(ellipse at 50% 43%,#6b6640,#2b3427 75%)}
.picker figcaption {display: grid; grid-template-columns: minmax(0,1fr) auto; gap: var(--space); align-items: center}
.pick-action {display: grid; gap: 4px; justify-items: center}
.pick-action p {color: #f3d796; font-size: clamp(10px,1.05vw,19px); line-height: 1}
.pick-action button {min-height: clamp(40px,6.5dvh,72px); padding-inline: clamp(10px,1.7vw,30px); font-size: var(--font); white-space: nowrap}
.settings-layout,.record-layout {display: grid; min-height: 0; gap: var(--space); padding: var(--space) max(12px,1.7vw)}
.settings-layout {grid-template-columns: minmax(88px,23%) minmax(0,1fr)}
.settings-layout nav {display: grid; gap: calc(.65 * var(--space)); align-content: start}
.settings-layout nav button {min-height: var(--button); font-size: var(--font)}
.jungle-dialog nav button[aria-pressed=true] {border-color: #ffd982; background: linear-gradient(#90601d,#513510); color: #fff3c4}
.setting-fields,.recent-scroll,#achievement-list {min-height: 0; overflow: auto; touch-action: pan-y; overscroll-behavior: contain}
.setting-fields label {min-height: var(--button); border-color: #b48d5070; font-size: var(--font)}
.setting-fields input,.setting-fields select {max-width: 55%; accent-color: #e1b356}
.record-layout {grid-template-columns: minmax(0,1fr) minmax(0,1.35fr); overflow: auto; touch-action: pan-y}
.record-layout section {display: grid; grid-template-rows: auto minmax(0,1fr); gap: 5px; min-height: 0}
.record-layout .records {display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-content: start; margin: 0}
.record-layout .records div,.result .records div {border-color: #8c6a3a; background: #211e18d8; color: #e7cc94; font-size: var(--font); padding: clamp(4px,1dvh,15px) clamp(5px,1.15vw,20px)}
.record-layout .records b,.result .records b {color: #fff0c6; font-size: clamp(13px,1.7vw,29px)}
.record-layout h3 {margin: 0; color: var(--gold); font-size: var(--font)}
.record-layout table {width: 100%; border-collapse: collapse; text-align: center; font-size: var(--font)}
.record-layout th,.record-layout td {padding: .5em .22em; border-bottom: 1px solid #9d81565f}
.record-layout th {color: var(--gold); background: #192723; position: sticky; top: 0}
#achievement-list {display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-content: start; gap: var(--space); padding: var(--space) max(12px,1.7vw)}
#achievement-list article {padding: .82em; border: 1px solid #a486505f; border-radius: 8px; background: #162621d9; font-size: var(--font)}
#achievement-list article.earned {border-color: #e2b96b; color: var(--gold)}
.result.card {border-color: #ab824a; background: linear-gradient(150deg,#30291df5,#111b1ef5)}
#interlude .result {width: min(79vw,1380px); padding: clamp(10px,2.5dvh,42px); gap: var(--space); touch-action: pan-y}
.result h2 {color: var(--gold); font-size: clamp(21px,min(3.5vw,6dvh),56px)}
.result > p {color: #ead9b5; font-size: var(--font)}
.result .primary {background: linear-gradient(#f4d187,#b77c32); color: #271604; min-height: var(--button); font-size: var(--font)}
.result .links {gap: var(--space)}
.result .links button {min-height: clamp(37px,5.5dvh,64px); padding-inline: 1em; font-size: var(--font)}
.hud .stats,.hud .leader,.hud .pause,#pad button {border-color: #82704e}
.hud .leader .player {color: #ffdc91}
@media (min-aspect-ratio: 19/10) {
  .skin-list {grid-template-columns: repeat(4,minmax(0,1fr)); grid-template-rows: repeat(3,minmax(0,1fr))}
}
@media (max-height: 460px) and (orientation: landscape) {
  :root {--button: clamp(40px,10.4dvh,48px); --space: clamp(5px,2dvh,10px)}
  #home {padding-left: max(var(--l),3.6vw); padding-right: max(var(--r),2.8vw)}
  .menu nav button {font-size: clamp(14px,2.3vw,21px)}
  .home-hero {max-height: 91dvh}
  .jungle-dialog header {padding-block: 3px}
  .wide-dialog {width: 89vw; max-width: calc(100vw - var(--l) - var(--r))}
  .wide-dialog form {min-height: min(75dvh,340px)}
  .settings-layout nav button {min-height: 40px}
}
@media (orientation: portrait) {
  #home {grid-template-columns: 1fr; grid-template-rows: minmax(0,1fr) auto; align-items: end; gap: 10px; padding-top: calc(var(--t) + 22px)}
  .home-hero {grid-row: 1; margin: 0}
  .home-hero figcaption {margin-top: 0}
  .menu {grid-row: 2; margin-inline: auto; max-width: 440px}
  .title-lockup h1 {font-size: clamp(30px,10vw,57px)}
  .picker {grid-template-columns: 1fr; grid-template-rows: minmax(0,1fr) minmax(0,1fr)}
  .picker figure {grid-row: 1}
  .skin-list {grid-template-columns: repeat(4,minmax(0,1fr)); grid-template-rows: repeat(3,minmax(0,1fr))}
  .record-layout {grid-template-columns: 1fr; grid-template-rows: auto minmax(0,1fr)}
  #achievement-list {grid-template-columns: 1fr}
  #interlude .result {width: 100%}
}
@media (max-height: 345px) and (orientation: landscape) {
  :root {--space: 4px; --button: 30px}
  .menu footer button {min-height: 22px}
}
