/* Floor is Boar — a tall thin game about getting away from something.
   Everything is portrait, because the whole point is up. */

:root {
  --ink:   #f2eefb;
  --dim:   #a79ec0;
  --bg:    #140f1c;
  --panel: #211a2e;
  --line:  #3a2f4f;
  --hot:   #ffbe3d;
  --boar:  #c0392b;
  --sky:   #2b2140;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 30;
  background: var(--hot); color: #241700; padding: .5rem .8rem; border-radius: 0 0 .5rem 0;
}
.skip-link:focus { left: 0; }

.bar {
  display: flex; align-items: center; gap: .9rem;
  padding: .6rem 1rem;
  border-bottom: 1px solid var(--line);
  background: #150f1f70;
  position: sticky; top: 0; z-index: 8;
  backdrop-filter: blur(6px);
}
.bar h1 { font-size: 1.1rem; margin: 0; }
.bar .home { color: var(--dim); text-decoration: none; font-size: .9rem; }
.bar .home:hover { color: var(--ink); }
.bar .tag { margin: 0 0 0 auto; color: var(--dim); font-size: .78rem; }

main { padding: 1rem; }

.screen { display: none; }
.screen.active { display: block; }

.panel {
  max-width: 34rem; margin: 1.2rem auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1.3rem 1.5rem;
  box-shadow: 0 18px 50px #0009;
}
.panel h2 { margin: 0 0 .5rem; font-size: 1.6rem; }
.panel h3 { margin: 1.3rem 0 .4rem; font-size: 1rem; color: var(--hot); }
.lede { color: var(--dim); margin: .2rem 0 1rem; }
.hint { color: var(--dim); font-size: .9rem; }
.hint kbd {
  background: #120e1b; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: .3rem; padding: 0 .35rem; font-size: .82rem; color: var(--ink);
}
.best { font-size: 1.05rem; color: var(--hot); font-weight: 700; margin: .2rem 0 0; }

.row { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }

.btn {
  background: var(--hot); color: #241700; border: 0;
  border-radius: .7rem; padding: .6rem 1.1rem;
  font: inherit; font-weight: 700; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.big { padding: .85rem 1.6rem; font-size: 1.1rem; }
.btn.ghost { background: #332a47; color: var(--ink); }

.score { display: grid; gap: .45rem; margin: .8rem 0 0; }
.score div {
  display: flex; justify-content: space-between; gap: 1rem;
  background: #2a2240; border-radius: .6rem; padding: .5rem .8rem; font-size: .92rem;
}
.score b { color: var(--hot); }

/* ---- the game ---- */
.hud {
  max-width: 34rem; margin: 0 auto .5rem;
  display: flex; gap: .5rem; align-items: center; justify-content: center;
}
.chip {
  background: #2a2240; border: 1px solid var(--line);
  border-radius: .5rem; padding: .25rem .6rem; font-size: .85rem;
}
.chip.big { font-size: 1.25rem; font-weight: 800; color: var(--hot); padding: .25rem .8rem; }
.chip.warn { color: var(--boar); }

.stage {
  position: relative;
  width: min(100%, 34rem);
  max-height: calc(100vh - 11rem);
  aspect-ratio: 3 / 5;
  margin: 0 auto;
}
#climb {
  display: block; width: 100%; height: 100%;
  background: var(--sky); border: 1px solid var(--line); border-radius: .8rem;
  touch-action: none;
}

.toast {
  position: absolute; left: 50%; top: .8rem; transform: translateX(-50%);
  /* ⚠️ its natural width: placed from the middle, a toast only had half the
     stage to grow into, and on a phone it wrapped onto a second line right
     over the boss's hearts */
  width: max-content; max-width: 94%; text-align: center;
  background: #140f1cdd; border: 1px solid var(--line);
  border-radius: .6rem; padding: .3rem .8rem; margin: 0;
  font-size: .9rem; backdrop-filter: blur(3px);
}

/* ---- phones: the whole thing is one steering pad ---- */
.touch, .pad { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.touch { position: absolute; inset: 0; z-index: 4; }
.pad { position: absolute; inset: 0; }

body.full { overflow: hidden; }
body.full .bar, body.full .hud, body.full .row, body.full .skip-link { display: none; }
body.full main { padding: 0; }
body.full .stage {
  position: fixed; inset: 0; width: 100vw; height: 100vh;
  max-height: none; aspect-ratio: auto; margin: 0;
}
body.full #climb { border: 0; border-radius: 0; }

@media (max-width: 620px) {
  main { padding: .5rem; }
  .panel { padding: 1rem; }
  .stage { max-height: calc(100vh - 9rem); }
}

/* 🔊 the sound button: just the picture */
.btn.icon { padding: .45rem .7rem; font-size: 1.05rem; line-height: 1.2; }

/* ---- 🏰 the towers, 3 November 2026 ---- */
.towers { display: grid; grid-template-columns: repeat(3, 1fr); gap: .55rem; margin-top: .5rem; }
.tower {
  display: flex; flex-direction: column; gap: .15rem; text-align: left;
  border: 2px solid var(--line); border-radius: .8rem; padding: .6rem .7rem;
  color: var(--ink); font: inherit; cursor: pointer; min-height: 5.6rem;
  box-shadow: inset 0 -18px 30px #0005;
}
.tower:hover { filter: brightness(1.12); }
.tower:active { transform: translateY(1px); }
.tower:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.t-name { font-weight: 800; font-size: 1rem; }
.t-line { font-size: .76rem; color: #e9e2f7cc; line-height: 1.25; }
.t-best { font-size: .82rem; font-weight: 700; color: var(--hot); margin-top: auto; }
.t-lava  { background: linear-gradient(160deg, #7a1c08, #2e0806 70%); border-color: #ff7a2b; }
.t-ice   { background: linear-gradient(160deg, #2f6fa5, #0f2446 70%); border-color: #8fe3ff; }
.t-space { background: linear-gradient(160deg, #3a1d70, #07031a 70%); border-color: #c08cff; }
.tower.locked { filter: grayscale(.75) brightness(.8); border-style: dashed; }
.tower.locked .t-best { color: var(--dim); }
.tower.nope { animation: nope .4s; }
@keyframes nope { 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
.tower-msg { min-height: 1.5em; }
.unlocked {
  background: linear-gradient(90deg, #ffbe3d33, #ffbe3d11) !important; border: 1px solid var(--hot);
  display: block !important; text-align: center; font-size: 1rem !important;
}
@media (max-width: 480px) {
  .towers { grid-template-columns: 1fr; }
  .tower { min-height: 0; display: grid; grid-template-columns: 1fr auto; column-gap: .6rem; }
  .t-name { grid-column: 1; }
  .t-line { grid-column: 1; }
  .t-best { grid-column: 2; grid-row: 1 / span 2; align-self: center; margin: 0; text-align: right; }
}
@media (prefers-reduced-motion: reduce) { .tower.nope { animation: none; } }

/* ---- 🛒 coins and the Pig Shop, 3 November 2026 ---- */
.shop-btn {
  background: linear-gradient(180deg, #ffe27a, #ffbe3d 55%, #e09a1a); color: #2a1a00;
  box-shadow: 0 0 0 2px #ffe9a8 inset, 0 6px 18px #ffbe3d44; position: relative;
}
.purse-mini { display: inline-block; margin-left: .35rem; padding: .05rem .45rem; border-radius: .5rem; background: #2a1a0022; font-weight: 800; }
.new-badge {
  position: absolute; top: -.55rem; right: -.5rem; background: #ff4d6d; color: #fff;
  font-size: .68rem; font-weight: 900; padding: .1rem .4rem; border-radius: .5rem;
  box-shadow: 0 2px 8px #0008; animation: newpulse 1.1s ease-in-out infinite;
}
.new-badge[hidden] { display: none; }
@keyframes newpulse { 50% { transform: scale(1.15) rotate(-4deg); } }
.boosts-line { color: #ffe27a; margin: .35rem 0 0; }
.chip.coin { color: #ffd34d; font-weight: 800; }
/* five chips now, so they stay on one line and shrink on a phone */
.hud { flex-wrap: wrap; }
.chip { white-space: nowrap; }
@media (max-width: 480px) {
  .hud { gap: .3rem; }
  .chip { font-size: .74rem; padding: .2rem .4rem; }
  .chip.big { font-size: 1.02rem; padding: .15rem .5rem; }
}
.chip.life { color: #ff8fa6; font-weight: 800; }

/* ⚠️ `.score div` makes every div in the score a flex row, so the box that
   holds the coin rows has to say it is not one */
.score .coins-box { display: grid; grid-template-columns: 1fr; justify-content: stretch; gap: .45rem; background: none; padding: 0; border-radius: 0; }
.score .coins-won {
  display: grid; grid-template-columns: 1fr auto; align-items: center;
  background: linear-gradient(90deg, #ffbe3d33, #ffbe3d0d); border: 1px solid #ffbe3d88;
}
.score .coins-won b { font-size: 1.3rem; color: #ffd34d; }
.score .coins-won small { grid-column: 1 / -1; color: var(--dim); font-size: .8rem; }
.score .coins-next { display: block; text-align: center; background: #2a2240; color: var(--ink); }

.panel.shop { max-width: 40rem; }
.shop-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; }
.shop-head h2 { margin: 0; }
.purse {
  position: relative; font-size: 1.25rem; font-weight: 900; color: #2a1a00;
  background: linear-gradient(180deg, #ffe27a, #ffbe3d); border-radius: 2rem; padding: .3rem 1rem;
  box-shadow: 0 0 0 2px #fff3c4 inset, 0 0 22px #ffbe3d66;
}
.purse b { font-size: 1.45rem; }
.purse-word { font-size: .85rem; font-weight: 800; }
.purse.spend { animation: spend .45s; }
@keyframes spend { 30% { transform: scale(.88); filter: brightness(1.4); } 60% { transform: scale(1.08); } }
.purse-minus {
  position: absolute; right: .6rem; top: 100%; color: #ff8fa6; font-weight: 900; font-size: 1.1rem;
  animation: minus 1.1s ease-out forwards; pointer-events: none; text-shadow: 0 2px 4px #000a;
}
@keyframes minus { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(26px); } }
.coin-fly {
  position: fixed; z-index: 50; font-size: 1.3rem; pointer-events: none;
  transition: transform .65s cubic-bezier(.3, -.3, .7, 1), opacity .65s ease-in;
}
#shop-pig {
  display: block; width: 100%; height: auto; aspect-ratio: 480 / 190; margin: .8rem 0 .3rem;
  border-radius: .8rem; border: 1px solid var(--line); background: var(--sky);
}
.shop-ready { color: #ffe27a; min-height: 1.2em; margin: .2rem 0; }
.shop-tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin: .5rem 0 .7rem; }
.shop-tabs button {
  flex: 1 1 auto; font: inherit; font-weight: 800; color: var(--ink); cursor: pointer;
  background: #2a2240; border: 2px solid var(--line); border-radius: .7rem; padding: .5rem .7rem;
}
.shop-tabs button.on { background: #ffbe3d; color: #241700; border-color: #ffe27a; box-shadow: 0 4px 14px #ffbe3d44; }
.shop-tabs button:focus-visible, .card:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.shop-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.card {
  display: flex; flex-direction: column; align-items: center; gap: .2rem; text-align: center;
  font: inherit; color: var(--ink); cursor: pointer; position: relative;
  background: linear-gradient(170deg, #2e2545, #1b1528); border: 2px solid var(--line);
  border-radius: .9rem; padding: .65rem .5rem .55rem; min-height: 11rem;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px #0007; }
.card:active { transform: translateY(1px) scale(.98); }
.c-icon { font-size: 2.1rem; line-height: 1.1; filter: drop-shadow(0 3px 4px #0008); }
.c-pig, .c-trail { width: 96px; height: 84px; }
.c-name { font-weight: 900; font-size: .95rem; }
.c-what { font-size: .74rem; color: #d8d0ea; line-height: 1.25; flex: 1; }
.c-now { font-size: .78rem; color: #c9c3d6; }
.c-now b { color: #7dffb0; }
.c-pips { display: flex; gap: .25rem; }
.c-pips i { width: .7rem; height: .7rem; border-radius: 50%; background: #3a2f4f; border: 1px solid #5d4e7a; }
.c-pips i.on { background: #7dffb0; border-color: #c8ffe0; box-shadow: 0 0 6px #7dffb0; }
.c-price {
  margin-top: .2rem; font-weight: 900; font-size: .95rem; padding: .18rem .7rem; border-radius: 1rem;
  background: #120e1b; color: #ffd34d; border: 1px solid #ffbe3d66;
}
.card.s-can { border-color: #ffbe3d; box-shadow: 0 0 0 1px #ffbe3d44, 0 0 18px #ffbe3d33; }
.card.s-can .c-price { background: #ffbe3d; color: #241700; }
.card.s-poor { opacity: .78; }
.card.s-poor .c-price { color: #ff8fa6; border-color: #ff8fa655; }
.card.s-max, .card.s-full { border-color: #7dffb088; }
.card.s-max .c-price, .card.s-full .c-price { color: #7dffb0; border-color: #7dffb066; }
.card.s-wearing { border-color: #5ad1ff; box-shadow: 0 0 0 1px #5ad1ff55, 0 0 18px #5ad1ff33; }
.card.s-wearing .c-price { background: #5ad1ff; color: #08202c; }
.card.s-owned .c-price { color: #5ad1ff; border-color: #5ad1ff66; }
.card.bought { animation: bought .5s; }
@keyframes bought { 30% { transform: scale(1.1) rotate(-2deg); box-shadow: 0 0 34px #ffd34d; } 60% { transform: scale(.97); } }
.card.worn { animation: worn .35s; }
@keyframes worn { 40% { transform: scale(1.05); box-shadow: 0 0 26px #5ad1ff; } }
.card.nope { animation: nope .4s; }
.shop-msg { min-height: 1.5em; font-weight: 700; color: var(--hot); text-align: center; margin: .7rem 0 0; }
@media (max-width: 620px) {
  .shop-grid { grid-template-columns: repeat(2, 1fr); gap: .45rem; }
  .card { min-height: 0; padding: .55rem .4rem; }
  .c-icon { font-size: 1.8rem; }
  .shop-tabs button { flex: 1 1 45%; padding: .45rem .4rem; font-size: .92rem; }
  .purse { font-size: 1.1rem; padding: .25rem .8rem; }
}
@media (prefers-reduced-motion: reduce) {
  .new-badge, .purse.spend, .card.bought, .card.worn, .card.nope, .purse-minus { animation: none; }
  .card { transition: none; }
}

/* ---- ✨ wave 3, 7 November 2026: the Candy Tower, three new ways to play,
   the race's own screen and the pets shelf ---- */
/* five towers: two across (on a phone the rule above keeps them one across) */
@media (min-width: 481px) { .towers { grid-template-columns: repeat(2, 1fr); } }
.tower, .mode { position: relative; }
.t-candy { background: linear-gradient(160deg, #ff7ac8, #7a2a8a 75%); border-color: #ffd1ec; }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: .55rem; margin-top: .5rem; }
.mode {
  display: flex; flex-direction: column; gap: .15rem; text-align: left;
  border: 2px solid var(--line); border-radius: .8rem; padding: .6rem .7rem;
  color: var(--ink); font: inherit; cursor: pointer; min-height: 6.2rem;
  box-shadow: inset 0 -18px 30px #0005;
}
.mode:hover { filter: brightness(1.12); }
.mode:active { transform: translateY(1px); }
.mode:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.m-race  { background: linear-gradient(160deg, #1f7a55, #0b2a22 75%); border-color: #7dffb0; }
.m-storm { background: linear-gradient(160deg, #4a2f8a, #120a26 75%); border-color: #c9a6ff; }
.m-rush  { background: linear-gradient(160deg, #8a1f2a, #2a0a10 75%); border-color: #ffd34d; }
.pets-badge { right: auto; left: -.5rem; background: #7a4fff; }
.tab-new { font-size: .62rem; font-weight: 900; background: #ff4d6d; color: #fff; border-radius: .4rem; padding: 0 .3rem; vertical-align: middle; }
.tab-new[hidden] { display: none; }
.c-pet { width: 96px; height: 84px; }
.c-nopet { display: grid; place-items: center; height: 84px; font-size: 2.4rem; }
.dim-stars { opacity: .35; }
@media (max-width: 480px) {
  .modes { grid-template-columns: 1fr; }
  .mode { min-height: 0; display: grid; grid-template-columns: 1fr auto; column-gap: .6rem; }
  .mode .t-name { grid-column: 1; }
  .mode .t-line { grid-column: 1; }
  .mode .t-best { grid-column: 2; grid-row: 1 / span 2; align-self: center; margin: 0; text-align: right; max-width: 7.5rem; font-size: .76rem; }
}

/* 👥 the race's own screen */
.race-pigs { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: .4rem 0; }
.rp { display: flex; flex-direction: column; align-items: center; gap: .2rem; text-align: center; border-radius: .8rem; padding: .5rem; border: 2px solid var(--line); }
.rp canvas { width: 120px; height: 96px; }
.rp b { font-size: 1.05rem; }
.rp span { font-size: .82rem; color: #d8d0ea; }
.rp1 { background: linear-gradient(170deg, #5a2a40, #1b1528); border-color: #ff9ec7; }
.rp2 { background: linear-gradient(170deg, #1f4466, #1b1528); border-color: #7fc8ff; }
.race-pick { display: flex; gap: .45rem; flex-wrap: wrap; }
.race-pick button {
  flex: 1 1 auto; font: inherit; font-weight: 800; color: var(--ink); cursor: pointer;
  background: #2a2240; border: 2px solid var(--line); border-radius: .7rem; padding: .5rem .6rem;
  display: flex; flex-direction: column; align-items: center; min-height: 2.9rem; justify-content: center;
}
.race-pick button small { font-weight: 600; font-size: .72rem; color: var(--dim); }
.race-pick button.on { background: #7dffb0; color: #0b2a18; border-color: #c8ffe0; box-shadow: 0 4px 14px #7dffb044; }
.race-pick button.on small { color: #1f5a3a; }
.race-pick button.locked { filter: grayscale(.8) brightness(.75); border-style: dashed; }
.race-pick button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.race-msg { min-height: 1.5em; }
@media (max-width: 480px) {
  .towers-pick button { flex: 1 1 30%; }
}
