:root {
  --ink: #6c6091;
  --muted: #9a90b2;
  --line: #d3c8eb;
  --paper: #fffdf6;
  --mint: #88dbc3;
  --pink: #ffd5e7;
  --bg: #f5f2fc;
  font-size: 16px;
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
body {
  font-family: 'Itim', ui-rounded, sans-serif;
  color: var(--ink);
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  display: flex;
  justify-content: center;
  overflow: hidden;
  user-select: none;
  touch-action: manipulation;
}
button {
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible {
  outline: 3px solid #a491d5;
  outline-offset: 4px;
}
button:disabled {
  cursor: default;
  opacity: 0.4;
}
#stage {
  position: relative;
  width: min(100%, 660px);
  height: 100%;
  padding: max(15px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  height: 64px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-family: 'Fredoka', 'Itim', sans-serif;
  font-size: 25px;
  line-height: 0.92;
  font-weight: 600;
  letter-spacing: -0.8px;
}
.brand img {
  width: 45px;
  height: 49px;
  object-fit: contain;
}
.brand span {
  display: block;
}
.hud {
  display: flex;
  gap: 12px;
  flex: 1;
  justify-content: center;
}
.hud-value {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.25;
}
.hud-value span {
  font-size: 0.65rem;
  color: var(--muted);
}
.hud-value strong {
  font-size: 1.25rem;
}
.hud-value:first-child {
  background: #eae3f8;
  border-radius: 16px;
  padding: 5px 12px;
}
.top-actions {
  display: flex;
  gap: 7px;
}
.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 3px 8px #71639516;
  transition: transform 0.15s;
}
.icon-btn:hover {
  transform: translateY(-2px);
}
.icon-btn:active {
  transform: scale(0.93);
}
.ui-icon {
  display: inline-block;
  flex-shrink: 0;
  width: 23px;
  height: 23px;
  background: center/contain no-repeat;
}
.ui-hint {
  background-image: url('../assets/minimal/icons/hint.svg');
}
.ui-sound {
  background-image: url('../assets/minimal/icons/sound.svg');
}
.ui-mute {
  background-image: url('../assets/minimal/icons/mute.svg');
}
.ui-restart {
  background-image: url('../assets/minimal/icons/restart.svg');
}
.ui-star,
.ui-leaf {
  background-image: url('../assets/minimal/icons/star.svg');
}
.ui-heart {
  background-image: url('../assets/minimal/icons/heart.svg');
}
.hint-btn b {
  position: absolute;
  top: -5px;
  right: -3px;
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  background: #ff929e;
  color: white;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 400;
}
.level-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.7rem;
  padding: 0 2px;
  flex-shrink: 0;
}
.progress-track {
  flex: 1;
  height: 8px;
  background: #e3dbf3;
  border-radius: 20px;
  overflow: hidden;
}
#progress-fill {
  height: 100%;
  width: 0;
  background: var(--mint);
  border-radius: 20px;
  transition: width 0.3s;
}
#board-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  min-width: 0;
}
#board-viewport {
  position: absolute;
  inset: 0 0 24px;
  overflow: hidden;
}
#board {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-origin: center;
}
.board-instruction {
  position: absolute;
  bottom: 2px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
}
.tile,
.slot.full,
.flight {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  box-shadow:
    0 3px 0 #d8cdec,
    0 5px 8px #76629212;
}
.tile {
  position: absolute;
  width: 88px;
  height: 88px;
  display: grid;
  place-items: center;
  padding: 7px;
  transition: filter 0.2s;
}
.tile .an {
  pointer-events: none;
}
.tile:not(.covered):hover {
  filter: brightness(1.025);
  outline: 2px solid #ad9bd6;
  outline-offset: 1px;
}
.tile.covered {
  cursor: default;
  filter: brightness(0.77) saturate(0.65);
}
.tile.pile-card {
  box-shadow:
    0 3px 0 #c5b7df,
    0 5px 0 #b8a8d4;
}
.tile.pile-card.covered {
  background: #d8cdec;
  filter: brightness(0.88);
  box-shadow:
    0 3px 0 #bbabd6,
    0 5px 0 #ac9ac8;
}
.tile.pile-card.covered .an {
  opacity: 0.13;
}
.tile.shake {
  animation: shake 0.3s;
}
.tile.hinted {
  animation: pulse 0.6s ease-in-out 4;
}
.tile.deal {
  animation: deal 0.4s ease-out backwards;
}
#tray-area {
  flex-shrink: 0;
  width: 100%;
}
.tray-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  padding: 0 8px 7px;
  color: var(--muted);
}
#tray-count {
  color: var(--ink);
  font-size: 0.9rem;
  white-space: nowrap;
}
.tray-panel {
  padding: 10px;
  background: var(--pink);
  border-radius: 20px;
}
#tray {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
}
.slot {
  min-width: 0;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: #fffaf6;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 4px;
  box-shadow: inset 0 2px 3px #8e78b509;
}
.slot.full {
  border-radius: 10px;
}
.slot.pending .an {
  visibility: hidden;
}
.danger .tray-panel {
  animation: trayWarning 1.5s ease-in-out infinite;
}
.danger .tray-heading {
  color: #d27590;
}
.flight {
  position: fixed;
  z-index: 800;
  pointer-events: none;
  transform-origin: top left;
  padding: 7px;
}
.fx-leaf {
  position: fixed;
  width: 14px;
  height: 14px;
  pointer-events: none;
  z-index: 900;
}
.float-score {
  position: fixed;
  z-index: 950;
  font-size: 1.2rem;
  color: #58b99e;
  pointer-events: none;
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #80749b30;
  backdrop-filter: blur(7px);
  overflow-y: auto;
  animation: fadeIn 0.25s;
}
.modal.hidden {
  display: none;
}
.modal-card {
  width: min(100%, 400px);
  padding: 32px;
  text-align: center;
  background: #fffdfb;
  border: 1px solid #ece5f5;
  border-radius: 30px;
  box-shadow: 0 18px 60px #79649120;
  animation: bounceIn 0.4s ease-out;
}
.welcome-brand {
  justify-content: center;
  font-size: 38px;
  margin: 0 0 22px;
}
.welcome-brand img {
  width: 66px;
  height: 76px;
}
.eyebrow {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0 0 12px;
}
.modal-animals {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 22px 0;
}
.an.big {
  width: 78px;
  height: 85px;
  animation: bob 3s ease-in-out infinite;
}
.an.big:nth-child(2) {
  width: 96px;
  height: 105px;
  animation-delay: 0.35s;
}
.an.big:nth-child(3) {
  animation-delay: 0.7s;
}
.modal h2 {
  font-size: 1.6rem;
  font-weight: 400;
  margin-bottom: 12px;
  line-height: 1.3;
}
.modal .sub {
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--muted);
  margin-bottom: 24px;
}
.modal .sub b {
  color: var(--ink);
  font-weight: 400;
}
.cta {
  display: block;
  width: 100%;
  min-height: 50px;
  padding: 12px 18px;
  background: var(--mint);
  border-radius: 16px;
  color: #326c60;
  font-size: 1.15rem;
  box-shadow: 0 3px 0 #69c4ac;
  transition: transform 0.15s;
}
.cta:hover {
  transform: translateY(-2px);
}
.cta:active {
  transform: translateY(2px);
}
.modal-note {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 16px;
}
.ghost {
  display: block;
  width: 100%;
  background: transparent;
  padding: 16px 12px 0;
  font-size: 0.95rem;
  color: var(--muted);
}
.modal-emblem {
  width: 45px;
  height: 45px;
  margin-bottom: 8px;
}
#modal-start {
  background: var(--bg);
  backdrop-filter: none;
}
#modal-start .modal-card {
  background: transparent;
  box-shadow: none;
  border: 0;
  padding: 26px;
}
#modal-start .modal-animals {
  margin: 32px 0;
}
#modal-start h2 {
  font-size: 1.75rem;
}
.how-to {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin: 0 0 24px;
}
.how-to span {
  background: #ece6f7;
  border-radius: 12px;
  padding: 8px 13px;
  font-size: 0.85rem;
}
@keyframes deal {
  from {
    transform: translateY(-22px) scale(0.8);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}
@keyframes shake {
  0%,
  100% {
    translate: 0 0;
  }
  25%,
  75% {
    translate: -3px 0;
  }
  50% {
    translate: 3px 0;
  }
}
@keyframes pulse {
  50% {
    outline: 3px solid #85d9c1;
    outline-offset: 2px;
    filter: brightness(1.06);
  }
}
@keyframes trayWarning {
  50% {
    background: #ffc1d8;
  }
}
@keyframes bob {
  0%,
  100% {
    translate: 0 0;
  }
  50% {
    translate: 0 -5px;
  }
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
}
@keyframes bounceIn {
  from {
    transform: translateY(14px) scale(0.95);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}
@media (max-width: 420px) {
  #stage {
    padding-left: 9px;
    padding-right: 9px;
    gap: 8px;
  }
  #topbar {
    height: 51px;
    gap: 7px;
  }
  .brand {
    font-size: 20px;
    gap: 5px;
  }
  .brand img {
    width: 32px;
    height: 38px;
  }
  .hud {
    gap: 7px;
  }
  .hud-value strong {
    font-size: 1rem;
  }
  .hud-value span {
    font-size: 0.58rem;
  }
  .hud-value:first-child {
    padding: 4px 8px;
  }
  .top-actions {
    gap: 5px;
  }
  .icon-btn {
    width: 31px;
    height: 31px;
  }
  .ui-icon {
    width: 19px;
    height: 19px;
  }
  .hint-btn b {
    width: 16px;
    height: 16px;
    font-size: 0.65rem;
  }
  .level-progress {
    font-size: 0.6rem;
    gap: 7px;
  }
  .tray-panel {
    padding: 8px;
    border-radius: 16px;
  }
  #tray {
    gap: 4px;
  }
  .slot {
    padding: 3px;
    border-radius: 7px;
  }
  .slot.full {
    border-radius: 7px;
  }
  .tray-heading {
    font-size: 0.58rem;
  }
  .board-instruction {
    font-size: 0.62rem;
  }
  .modal-card {
    padding: 27px 22px;
  }
  .modal h2 {
    font-size: 1.45rem;
  }
  .modal .sub {
    font-size: 0.9rem;
  }
}
@media (max-width: 340px) {
  .brand {
    font-size: 17px;
  }
  .brand img {
    width: 27px;
  }
  .hud {
    gap: 4px;
  }
  .icon-btn {
    width: 28px;
    height: 28px;
  }
  .top-actions {
    gap: 4px;
  }
}
@media (max-height: 500px) and (min-width: 600px) {
  #stage {
    width: min(100%, 840px);
    gap: 5px;
  }
  #topbar {
    height: 40px;
  }
  .brand {
    font-size: 19px;
  }
  .brand img {
    height: 35px;
  }
  .tray-panel,
  .tray-heading {
    max-width: 430px;
    margin: auto;
  }
  .tray-panel {
    padding: 6px;
  }
  #board-viewport {
    inset: 0 0 18px;
  }
  .modal-card {
    padding: 20px;
  }
  .modal-animals {
    margin: 8px 0;
  }
  .an.big {
    height: 60px;
  }
  .an.big:nth-child(2) {
    height: 70px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}
/* A spacious landing page and a two-row game header keep narrow screens clear. */
.ui-home {
  background-image: url('../assets/minimal/icons/home.svg');
}
#topbar {
  height: auto;
  min-height: 70px;
  display: grid;
  grid-template-columns: 1fr auto;
  row-gap: 8px;
  column-gap: 12px;
}
#topbar .brand {
  grid-column: 1;
  grid-row: 1 / 3;
  font-size: 24px;
}
#topbar .brand img {
  width: 43px;
  height: 48px;
}
#topbar .hud {
  grid-column: 2;
  grid-row: 1;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}
#topbar .hud-value {
  flex-direction: row;
  gap: 6px;
}
#topbar .hud-value:first-child {
  padding: 3px 10px;
  border-radius: 10px;
}
#topbar .hud-value strong {
  font-size: 1rem;
}
#topbar .hud-value span {
  font-size: 0.7rem;
}
#topbar .top-actions {
  grid-column: 2;
  grid-row: 2;
  justify-content: flex-end;
  gap: 9px;
}
#topbar .icon-btn {
  width: 34px;
  height: 34px;
}
#topbar .ui-icon {
  width: 21px;
  height: 21px;
}
#stage {
  gap: 10px;
}
#board-viewport {
  inset: 8px 0 24px;
}
#modal-start {
  padding: 0;
  display: flex;
  align-items: safe center;
  justify-content: center;
  overflow-y: auto;
}
#modal-start.hidden {
  display: none;
}
.landing-shell {
  width: min(100%, 1040px);
  min-height: min(100dvh, 800px);
  padding: 32px 44px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.landing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.landing-header .brand {
  font-size: 23px;
}
.landing-tag {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.85rem;
  color: var(--muted);
}
.landing-main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 40px;
  padding: 45px 0;
}
.landing-copy .eyebrow {
  color: #8f7dac;
  font-size: 0.95rem;
  margin-bottom: 18px;
}
.landing-copy h1 {
  font-weight: 400;
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1.25;
  letter-spacing: -0.5px;
  margin-bottom: 20px;
}
.landing-copy h1 span {
  color: #9a86bd;
}
.landing-description {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
  margin-bottom: 22px;
}
.landing-rules {
  display: flex;
  gap: 18px;
  margin-bottom: 30px;
  font-size: 0.9rem;
}
.landing-rules span {
  display: flex;
  align-items: center;
  gap: 8px;
}
.landing-rules b {
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #e7def5;
  color: #8a75ad;
  width: 32px;
  height: 32px;
  font-size: 1.1rem;
  font-weight: 400;
}
.landing-rules span:last-child b {
  background: #ffe0eb;
  color: #c5829b;
}
.landing-copy .cta {
  max-width: 320px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 22px;
  font-size: 1.2rem;
  border-radius: 18px;
}
.landing-copy .modal-note {
  max-width: 320px;
  text-align: center;
}
.landing-art {
  position: relative;
  width: 100%;
  max-width: 430px;
  aspect-ratio: 1;
  justify-self: center;
  isolation: isolate;
}
.hero-halo {
  position: absolute;
  inset: 10% 3% 7%;
  border-radius: 50%;
  background: #eae2f8;
  z-index: -1;
}
.hero-tile {
  position: absolute;
  width: 37%;
  aspect-ratio: 1;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 23px;
  padding: 10px;
  box-shadow:
    0 6px 0 #d4c8e9,
    0 13px 24px #8972ab12;
  display: grid;
  place-items: center;
}
.hero-fox {
  left: 6%;
  top: 23%;
  transform: rotate(-12deg);
}
.hero-rabbit {
  left: 34%;
  top: 9%;
  transform: rotate(5deg);
  z-index: 2;
}
.hero-frog {
  right: 0;
  top: 38%;
  transform: rotate(12deg);
  z-index: 3;
}
.hero-bubble {
  position: absolute;
  left: 2%;
  top: 3%;
  border-radius: 16px 16px 3px 16px;
  padding: 10px 16px;
  background: #fffdfb;
  font-size: 0.9rem;
  transform: rotate(-7deg);
}
.hero-mini-tray {
  position: absolute;
  left: 15%;
  right: 5%;
  bottom: 6%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  align-items: center;
  background: var(--pink);
  border-radius: 20px;
  padding: 10px;
  transform: rotate(-4deg);
}
.hero-mini-tray img,
.hero-mini-tray span {
  width: 100%;
  aspect-ratio: 1;
  height: auto;
  padding: 4px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.hero-mini-tray span {
  display: grid;
  place-items: center;
  color: #dd9bb9;
  font-size: 2rem;
}
.landing-footer {
  text-align: center;
  font-size: 0.8rem;
  color: #b1a5c6;
}
.landing-footer span {
  padding: 0 9px;
}
.home-emblem {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  background: #ede6f8;
  border-radius: 22px;
  margin: 0 auto 22px;
}
.home-emblem .ui-icon {
  width: 31px;
  height: 31px;
}
.home-card .ghost {
  padding-top: 20px;
}
@media (max-width: 600px) {
  .landing-shell {
    min-height: 100dvh;
    padding: max(24px, env(safe-area-inset-top)) 24px max(20px, env(safe-area-inset-bottom));
    gap: 12px;
  }
  .landing-header .brand {
    font-size: 20px;
  }
  .landing-header .brand img {
    width: 34px;
    height: 38px;
  }
  .landing-tag {
    font-size: 0.7rem;
  }
  .landing-main {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 12px 0 22px;
  }
  .landing-art {
    grid-row: 1;
    max-width: 280px;
    max-height: 32dvh;
  }
  .landing-copy {
    text-align: center;
  }
  .landing-copy .eyebrow {
    font-size: 0.78rem;
    margin-bottom: 10px;
  }
  .landing-copy h1 {
    font-size: 2rem;
    margin-bottom: 12px;
  }
  .landing-description {
    font-size: 0.9rem;
    line-height: 1.65;
    margin-bottom: 16px;
  }
  .landing-rules {
    justify-content: center;
    gap: 20px;
    margin-bottom: 22px;
    font-size: 0.8rem;
  }
  .landing-rules b {
    width: 28px;
    height: 28px;
    border-radius: 10px;
  }
  .landing-copy .cta {
    margin: 0 auto;
    max-width: 340px;
  }
  .landing-copy .modal-note {
    margin: 14px auto 0;
  }
  .hero-tile {
    border-radius: 18px;
    padding: 7px;
  }
  .hero-bubble {
    font-size: 0.7rem;
    padding: 7px 10px;
  }
  .hero-mini-tray {
    padding: 7px;
    gap: 5px;
    border-radius: 16px;
  }
  .hero-mini-tray img,
  .hero-mini-tray span {
    border-radius: 9px;
  }
  .hero-mini-tray span {
    font-size: 1.4rem;
  }
}
@media (max-width: 420px) {
  #topbar {
    min-height: 66px;
    row-gap: 7px;
    column-gap: 8px;
  }
  #topbar .brand {
    font-size: 22px;
  }
  #topbar .brand img {
    width: 36px;
    height: 43px;
  }
  #topbar .top-actions {
    gap: 8px;
  }
  #topbar .icon-btn {
    width: 30px;
    height: 30px;
  }
  #topbar .ui-icon {
    width: 18px;
    height: 18px;
  }
  #topbar .hud {
    gap: 10px;
  }
  #topbar .hud-value strong {
    font-size: 0.9rem;
  }
  #topbar .hud-value span {
    font-size: 0.65rem;
  }
  #topbar .hud-value:first-child {
    padding: 2px 8px;
  }
  #stage {
    gap: 7px;
  }
  #board-viewport {
    inset: 4px 0 23px;
  }
  .tray-heading {
    padding-left: 3px;
    padding-right: 3px;
  }
}
@media (max-height: 650px) and (max-width: 600px) {
  .landing-shell {
    padding-top: 14px;
    gap: 8px;
  }
  .landing-art {
    max-width: 200px;
    max-height: 29dvh;
  }
  .landing-main {
    gap: 10px;
    padding: 8px 0 12px;
  }
  .landing-copy h1 {
    font-size: 1.6rem;
    margin-bottom: 8px;
  }
  .landing-copy .eyebrow {
    display: none;
  }
  .landing-description {
    font-size: 0.82rem;
    margin-bottom: 10px;
  }
  .landing-rules {
    margin-bottom: 14px;
  }
  .landing-copy .cta {
    min-height: 46px;
    padding: 11px 20px;
  }
  .landing-copy .modal-note {
    margin-top: 10px;
  }
  .landing-footer {
    font-size: 0.7rem;
  }
}
@media (max-height: 500px) and (min-width: 601px) {
  .landing-shell {
    min-height: 100dvh;
    padding: 15px 30px;
    gap: 10px;
  }
  .landing-main {
    padding: 6px 0;
    gap: 20px;
  }
  .landing-art {
    max-width: 260px;
  }
  .landing-copy h1 {
    font-size: 1.9rem;
    margin-bottom: 10px;
  }
  .landing-copy .eyebrow {
    margin-bottom: 8px;
  }
  .landing-description {
    font-size: 0.85rem;
    margin-bottom: 12px;
  }
  .landing-rules {
    margin-bottom: 15px;
  }
  #topbar {
    min-height: 43px;
    grid-template-columns: auto 1fr auto;
  }
  #topbar .brand {
    grid-row: 1;
    grid-column: 1;
  }
  #topbar .hud {
    grid-column: 2;
    grid-row: 1;
    justify-content: center;
  }
  #topbar .top-actions {
    grid-column: 3;
    grid-row: 1;
  }
}
/* Fixed-height responsive landing and compact game controls. */
#modal-start {
  height: 100dvh;
  overflow: hidden;
  align-items: center;
  overscroll-behavior: none;
}
.landing-shell {
  height: 100%;
  min-height: 0;
  max-height: 860px;
  padding: clamp(14px, 3dvh, 32px) 36px;
  gap: 12px;
  overflow: hidden;
}
.landing-header,
.landing-footer {
  flex-shrink: 0;
}
.landing-main {
  min-height: 0;
  padding: 12px 0;
  gap: 25px;
}
.landing-art {
  max-height: 100%;
  max-width: min(400px, 45dvh);
}
.landing-copy .cta {
  justify-content: center;
  text-align: center;
  margin: 0 auto;
  display: block;
}
.landing-copy .cta span {
  display: none;
}
.level-picker-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 320px;
  margin: 14px 0 0;
  padding: 10px;
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
  border: 1px solid var(--line);
  border-radius: 15px;
}
.level-picker-button span {
  font-size: 1.15rem;
}
.landing-copy .modal-note {
  margin-top: 12px;
}
#topbar {
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  min-height: 65px;
  row-gap: 4px;
}
#topbar .brand {
  grid-column: 1;
  grid-row: 1;
  font-size: 23px;
}
#topbar .brand img {
  width: 34px;
  height: 38px;
}
#topbar .hud {
  grid-column: 1;
  grid-row: 2;
  justify-content: flex-start;
  padding-left: 43px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1;
}
#topbar .hud strong {
  font-weight: 400;
  color: var(--ink);
}
#topbar .top-actions {
  grid-column: 2;
  grid-row: 1 / 3;
  align-items: center;
  gap: 10px;
}
#topbar .icon-btn {
  width: 36px;
  height: 36px;
}
.secondary {
  width: 100%;
  min-height: 46px;
  background: #eee7f8;
  border-radius: 15px;
  margin-top: 14px;
  padding: 11px;
  font-size: 1rem;
}
.level-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 22px 0 5px;
}
.level-choice {
  aspect-ratio: 1;
  border-radius: 15px;
  background: #f1ecf9;
  border: 2px solid transparent;
  color: var(--ink);
  font-size: 1.5rem;
}
.level-choice:hover {
  background: #e5dbf5;
}
.level-choice[aria-pressed='true'] {
  background: #d8f4e9;
  border-color: #88cdb6;
  color: #3f7e6b;
}
.levels-card .sub {
  margin-bottom: 10px;
}
@media (max-width: 600px) {
  .landing-shell {
    padding: max(15px, env(safe-area-inset-top)) 24px max(12px, env(safe-area-inset-bottom));
    gap: 8px;
  }
  .landing-main {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: clamp(8px, 2dvh, 18px);
    padding: 6px 0;
  }
  .landing-art {
    order: -1;
    flex-shrink: 1;
    min-height: 0;
    width: min(260px, 30dvh);
    max-height: none;
  }
  .landing-copy {
    flex-shrink: 0;
    width: 100%;
  }
  .landing-copy .eyebrow {
    display: none;
  }
  .landing-copy h1 {
    font-size: clamp(1.45rem, 3.6dvh, 2rem);
    margin-bottom: 10px;
  }
  .landing-description {
    font-size: 0.86rem;
    margin-bottom: 12px;
    line-height: 1.5;
  }
  .landing-rules {
    margin-bottom: 16px;
  }
  .landing-copy .cta {
    min-height: 48px;
    padding: 12px;
    font-size: 1.15rem;
    max-width: 340px;
  }
  .level-picker-button {
    max-width: 340px;
    margin: 12px auto 0;
    padding: 9px;
    font-size: 0.95rem;
  }
  .landing-copy .modal-note {
    margin-top: 9px;
  }
  .landing-footer {
    font-size: 0.7rem;
  }
  .landing-tag {
    font-size: 0.65rem;
  }
  #topbar .brand {
    font-size: 21px;
  }
  #topbar .top-actions {
    gap: 8px;
  }
  #topbar .icon-btn {
    width: 33px;
    height: 33px;
  }
}
@media (max-height: 620px) and (max-width: 600px) {
  .landing-art {
    width: 21dvh;
  }
  .landing-description {
    font-size: 0.77rem;
    margin-bottom: 8px;
  }
  .landing-rules {
    margin-bottom: 10px;
    font-size: 0.75rem;
  }
  .landing-copy h1 {
    font-size: 1.4rem;
    margin-bottom: 8px;
  }
  .landing-copy .cta {
    min-height: 42px;
    padding: 10px;
  }
  .level-picker-button {
    margin-top: 9px;
    padding: 7px;
  }
  .landing-copy .modal-note {
    font-size: 0.68rem;
  }
  .landing-footer {
    display: none;
  }
  .hero-bubble {
    display: none;
  }
}
@media (max-height: 500px) and (min-width: 601px) {
  .landing-shell {
    max-height: none;
    padding: 12px 28px;
  }
  .landing-main {
    gap: 22px;
    padding: 0;
  }
  .landing-art {
    max-width: 250px;
  }
  .landing-copy h1 {
    font-size: 1.65rem;
  }
  .landing-copy .eyebrow {
    display: none;
  }
  .landing-description {
    font-size: 0.8rem;
    margin-bottom: 9px;
  }
  .landing-rules {
    margin-bottom: 12px;
  }
  .landing-copy .cta {
    min-height: 42px;
    padding: 9px;
  }
  .level-picker-button {
    margin-top: 9px;
    padding: 7px;
  }
  .landing-footer {
    display: none;
  }
  #topbar {
    min-height: 53px;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
  }
  #topbar .top-actions {
    grid-column: 2;
    grid-row: 1 / 3;
  }
  #topbar .hud {
    grid-column: 1;
    grid-row: 2;
  }
}

/* Both landing actions share one alignment and width at every breakpoint. */
.landing-copy .cta,
.landing-copy .level-picker-button,
.landing-copy .modal-note {
  width: 100%;
  max-width: 320px;
  margin-left: 0;
  margin-right: 0;
}
.landing-copy .cta,
.landing-copy .level-picker-button {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}
@media (max-width: 600px) {
  .landing-copy .cta,
  .landing-copy .level-picker-button,
  .landing-copy .modal-note {
    max-width: 340px;
    margin-left: auto;
    margin-right: auto;
  }
}
/* Covered cards keep their intended shading; disabled buttons cannot be picked. */
.tile:disabled {
  opacity: 1;
}

.advance-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  padding: 15px 12px;
  margin-top: 18px;
  background: #e4daf7;
  border: 1.5px solid #b7a0dc;
  border-radius: 17px;
  color: #756093;
  transition:
    background 0.15s,
    transform 0.15s;
}
.advance-button strong {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.15rem;
  font-weight: 500;
}
.advance-button span {
  font-size: 0.8rem;
  color: #8d7aab;
}
.advance-button:hover {
  background: #d9ccf0;
  transform: translateY(-2px);
}
.advance-button:active {
  transform: translateY(1px);
}

/* Apply safe-area padding after responsive rules, including landscape notches. */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}
#stage {
  --stage-side: 16px;
  padding: calc(15px + var(--safe-top)) calc(var(--stage-side) + var(--safe-right))
    calc(12px + var(--safe-bottom)) calc(var(--stage-side) + var(--safe-left));
}
.modal {
  padding: calc(24px + var(--safe-top)) calc(24px + var(--safe-right))
    calc(24px + var(--safe-bottom)) calc(24px + var(--safe-left));
}
/* The landing shell owns safe padding, so its full-screen wrapper stays flush. */
#modal-start { padding: 0; }
.landing-shell {
  --landing-top: clamp(14px, 3dvh, 32px);
  --landing-bottom: clamp(14px, 3dvh, 32px);
  --landing-side: 36px;
  padding: calc(var(--landing-top) + var(--safe-top))
    calc(var(--landing-side) + var(--safe-right))
    calc(var(--landing-bottom) + var(--safe-bottom))
    calc(var(--landing-side) + var(--safe-left));
}
@media (max-width: 600px) {
  .landing-shell { --landing-top: 15px; --landing-bottom: 12px; --landing-side: 24px; }
}
@media (max-width: 420px) { #stage { --stage-side: 9px; } }
@media (max-height: 500px) and (min-width: 601px) {
  .landing-shell { --landing-top: 12px; --landing-bottom: 12px; --landing-side: 28px; }
}
