/* Fox vs Fox page. Mobile first. The farmhouse is a two-by-three grid of rooms; every
   choice is a tap on a spot. Chrome matches the arcade: header, taper, framed cards,
   pill buttons. */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

html, body {
  margin: 0;
  min-height: 100%;
  background-color: var(--bg);
  background-image: radial-gradient(circle, rgba(224, 120, 42, 0.14) var(--dot), transparent var(--dot-edge));
  background-size: 4px 4px;
  color: var(--ink);
  font-family: var(--font-body);
}

button, input { font: inherit; color: inherit; }
button, a { touch-action: manipulation; }
[hidden] { display: none !important; }
a { color: var(--green-bright); }

.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  width: 100%;
  max-width: 32rem;
  margin: 0 auto;
  padding: 0.35rem 0.45rem 0;
  padding-left: max(0.45rem, env(safe-area-inset-left));
  padding-right: max(0.45rem, env(safe-area-inset-right));
}

/* ---- header ---- */

.top {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 0.15rem;
  margin-bottom: 0.3rem;
}

.header-mascot {
  display: block;
  flex: none;
  height: calc(1.05rem + 0.78rem + 0.35rem);
  pointer-events: none;
}
.header-mascot svg { display: block; width: auto; height: 100%; }

.title-block {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

h1 {
  margin: 0;
  max-width: 100%;
  overflow: hidden;
  font-size: 1.05rem;
  line-height: 1.05;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.title-btn {
  display: block;
  margin: 0;
  padding: 0.15rem 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.brand-line {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  max-width: 100%;
  margin: 0.08rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1.1;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark { width: 14px; height: 14px; display: block; flex: none; }

.help-open {
  flex: 0 0 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid var(--green-deep);
  border-radius: 999px;
  background: #000;
  color: var(--green-bright);
  font-weight: 800;
  font-size: 1.15rem;
  line-height: 1;
}

.header-share svg { display: block; }

.taper { flex: none; }

/* ---- ribbon under the header ---- */

.ribbon {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.35rem;
  padding: 0.1rem 0.1rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.ribbon-badge { flex: none; font-size: 1.05rem; line-height: 1; letter-spacing: 0.05em; }

.ribbon-text {
  flex: 1 1 auto;
  display: grid;
  gap: 0.05rem;
  min-width: 0;
  line-height: 1.2;
}

.ribbon-head, .ribbon-status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ribbon-status { color: var(--muted); }
.app[data-screen="turn"] .ribbon-status { color: var(--green-bright); }

.ribbon-games {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 32px;
  padding: 0 0.6rem;
  border: 2px solid var(--green-deep);
  border-radius: 999px;
  background: #000;
  color: var(--green-bright);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/* ---- framed cards ---- */

.panel {
  position: relative;
  width: min(26rem, 100%);
  margin: 0.4rem auto;
  padding: 0.9rem 0.9rem 1rem;
  text-align: center;
}

.panel > * { position: relative; z-index: 1; }

.wizard { margin: auto; }

.challenge {
  margin: 0.1rem 0 0.45rem;
  font-size: clamp(1.3rem, 6.2vw, 1.65rem);
  line-height: 1.15;
  font-weight: 800;
}

.lede { margin: 0 0 0.65rem; color: var(--ink); line-height: 1.4; font-size: 0.95rem; }
.hint { margin: 0.4rem 0 0; color: var(--muted); font-size: 0.82rem; line-height: 1.35; }

.eyebrow {
  margin: 0 0 0.15rem;
  color: var(--green-bright);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---- mascots (inline SVG from art.js) ---- */

.mascot {
  display: block;
  width: 120px;
  margin: 0 auto 0.4rem;
  transform-origin: 50% 90%;
  pointer-events: none;
}
.mascot svg { display: block; width: 100%; height: auto; }
.mascot.mascot-small { width: 78px; margin-bottom: 0.3rem; }
.mascot.mascot-pair { width: 200px; }
.fox-art { display: inline-block; transform-origin: 50% 90%; }
.fox-art svg { display: block; }

.result-foxes { display: flex; justify-content: center; gap: 1rem; margin-bottom: 0.3rem; }

.mascot-welcome { animation: mascot-hop 0.55s ease-out both, mascot-idle 5s ease-in-out 1.1s infinite; }
.mascot-wait { animation: mascot-bob 3.2s ease-in-out infinite; }
.mascot-win { animation: mascot-cheer 0.9s ease-out both; }
.mascot-droop { animation: mascot-droop 1.15s ease-out both; }

@keyframes mascot-hop {
  0% { transform: translateY(14px) scale(0.92, 0.9); opacity: 0; }
  55% { transform: translateY(-7px) scale(1.03, 1.04); opacity: 1; }
  100% { transform: none; }
}
@keyframes mascot-idle {
  0%, 72%, 100% { transform: translateY(0) scaleY(1); }
  80% { transform: translateY(-3px) scaleY(1.02); }
  88% { transform: translateY(0) scaleY(0.96); }
}
@keyframes mascot-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6.5px); }
}
@keyframes mascot-cheer {
  0% { transform: none; }
  28% { transform: translateY(-16px) rotate(-14deg) scale(1.12); }
  52% { transform: translateY(-5px) rotate(10deg) scale(1.06); }
  100% { transform: none; }
}
@keyframes mascot-droop {
  0%, 100% { transform: none; }
  42% { transform: translateY(8px) rotate(12deg) scale(0.94); }
}

.field { display: grid; gap: 0.35rem; margin: 0.4rem 0 0.7rem; text-align: left; }
.field label { font-size: 0.82rem; font-weight: 750; color: var(--muted); }

input[type="text"] {
  width: 100%;
  min-height: 48px;
  padding: 0 0.9rem;
  border: 2px solid var(--green-deep);
  border-radius: 12px;
  background: #0B0812;
  color: var(--ink-bright);
  font-size: 1.05rem;
  font-weight: 700;
}

input[type="text"]:focus { outline: 2px solid var(--green-bright); outline-offset: 1px; }

.actions { display: flex; flex-wrap: wrap; gap: 0.45rem; justify-content: center; margin-top: 0.6rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  min-width: 9.5rem;
  padding: 0 1.2rem;
  border: 0;
  border-radius: 999px;
  background: var(--amber-deep);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.btn.primary { background: var(--green-deep); }
.btn.slim { min-width: 0; }
.btn[disabled] { opacity: 0.45; cursor: default; }

.link-box {
  margin: 0.4rem 0 0;
  padding: 0.6rem 0.7rem;
  border-radius: 12px;
  background: #0B0812;
  color: var(--green-bright);
  font-size: 0.8rem;
  word-break: break-all;
  text-align: left;
}

.qr { width: min(160px, 48vw); height: auto; background: #fff; padding: 0.35rem; border-radius: 8px; }
.qr-panel { display: grid; justify-items: center; gap: 0.4rem; margin: 0.8rem auto 0; padding-top: 0.7rem; border-top: 1px solid rgba(255, 255, 255, 0.12); }

/* ---- score plate: each fox, its name, its treats ---- */

.score-plate {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 0.1rem 0 0.5rem;
}

.score {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 0.4rem;
  padding: 0.35rem 0.55rem;
  border-radius: 12px;
  border: 2px solid var(--plank-edge);
  background: #0B0812;
  text-align: left;
}
.score .fox-head { grid-row: 1 / span 2; display: block; }
.score .fox-head svg { display: block; }
.score small { font-size: 0.72rem; font-weight: 750; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score b { font-size: 1.05rem; line-height: 1.2; letter-spacing: 0.06em; color: var(--ink-bright); min-height: 1.2em; }
.score.active { border-color: var(--green-bright); }
.score.active small { color: var(--green-bright); }
.score.me { background: #17101F; }

/* ---- the farmhouse ---- */

.board-box { margin: 0.2rem 0 0.4rem; }

.house {
  --gap: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  padding: 6px;
  border-radius: 14px;
  background: #0B0812;
  text-align: left;
}

.room {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-height: 118px;
  padding: 0.4rem 0.4rem 0.45rem;
  border-radius: 10px;
  border: 2px solid var(--plank-edge);
  background: var(--plank);
}

.room.reach { border-color: var(--green); box-shadow: inset 0 0 0 1px rgba(240, 168, 104, 0.35); }
.room.here { background: #33283F; border-color: var(--green-bright); }

.room-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.3rem; min-height: 1.2em; }
.room-name { font-size: 0.82rem; font-weight: 800; color: var(--ink-bright); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sniff {
  flex: none;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--amber);
  color: #1a1000;
  font-size: 0.66rem;
  font-weight: 800;
  white-space: nowrap;
}
.sniff.unknown { background: transparent; border: 1.5px dashed var(--muted); color: var(--muted); }
.sniff.stale { background: transparent; border: 1.5px solid var(--amber); color: var(--amber); text-decoration: underline dotted; text-underline-offset: 2px; }

.room-foxes { display: flex; align-items: center; gap: 0.25rem; min-height: 30px; }
.fox-head.on-map { display: inline-block; line-height: 0; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.55)); }
.fox-head.on-map.me { transform: scale(1.12); }
.fox-head.on-map svg { display: block; }
.den {
  margin-right: auto;
  order: 2;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.den::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 0.25rem; border-radius: 2px; vertical-align: 0; }
.den-a::before { background: #F4F0E6; }
.den-b::before { background: #2B2833; box-shadow: 0 0 0 1.5px #7A7488; }

.spots { display: grid; gap: 0.3rem; margin-top: auto; }

.spot {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.35rem;
  min-height: 42px;
  padding: 0.25rem 0.45rem;
  border-radius: 9px;
  border: 2px solid #4A3D5A;
  background: #1C1626;
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 750;
  text-align: left;
  line-height: 1.1;
}
.spot[disabled] { cursor: default; }
.spot-emoji { font-size: 1.15rem; line-height: 1; }
.spot-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spot-tag { display: inline-flex; align-items: center; gap: 0.2rem; font-size: 0.7rem; color: var(--muted); }
.spot-items { font-size: 1rem; line-height: 1; }
.spot-empty { font-size: 0.62rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.snare-ico { display: inline-flex; line-height: 0; }

.spot.opened { border-style: dashed; color: var(--muted); background: #150F1E; }
.spot.opened .spot-emoji { opacity: 0.55; }
.spot.lying { border-color: var(--amber); }
.spot.mine { border-color: var(--green-bright); }
.spot.theirs { border-color: var(--red); border-style: double; }
.spot.snared { border-color: var(--green-bright); }

.spot.can { border-color: var(--green); background: #2A1A12; color: var(--ink-bright); cursor: pointer; }
.spot.can:active { transform: translateY(1px); }
.spot.pick { background: var(--green-deep); border-color: #fff; box-shadow: 0 0 0 2px var(--green-bright); }
.spot.flash { animation: spot-flash 0.7s ease-out both; }

@keyframes spot-flash {
  0% { transform: scale(1); }
  35% { transform: scale(1.06); background: #5A3A1A; }
  100% { transform: scale(1); }
}

/* what happened at a spot, popped over it for a beat */
.bubble {
  position: absolute;
  right: 0.4rem;
  top: -0.8rem;
  z-index: 3;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 2px solid #fff;
  background: #3B2F4A;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.5);
  animation: bubble-pop 0.4s ease-out both;
}
.bubble.found { background: var(--green-deep); border-color: var(--green-bright); }
.bubble.trap { background: #7A1F1F; border-color: var(--red); animation: bubble-pop 0.4s ease-out both, bubble-shake 0.5s ease-in-out 0.3s; }

@keyframes bubble-pop {
  0% { transform: scale(0.4) translateY(6px); opacity: 0; }
  60% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); }
}
@keyframes bubble-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px) rotate(-3deg); }
  75% { transform: translateX(4px) rotate(3deg); }
}

/* doors: bright gaps in the wall between two rooms. Drawn on the lower-numbered room. */
.door {
  position: absolute;
  z-index: 2;
  background: var(--amber);
  border-radius: 3px;
  box-shadow: 0 0 0 2px #0B0812;
}
.door.right { right: calc(-1 * var(--gap) - 2px); top: 50%; width: calc(var(--gap) + 4px); height: 30px; transform: translateY(-50%); }
.door.down { bottom: calc(-1 * var(--gap) - 2px); left: 50%; height: calc(var(--gap) + 4px); width: 30px; transform: translateX(-50%); }

/* ---- turn screen ---- */

.turn-panel { width: min(28rem, 100%); padding-top: 0.7rem; }

.turn-strip {
  display: flex;
  justify-content: space-between;
  margin: 0 0 0.35rem;
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.recap {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.45rem;
  padding: 0.4rem 0.6rem;
  border-radius: 10px;
  background: #0B0812;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: left;
}
.recap .fox-head { flex: none; line-height: 0; }

.notice {
  min-height: 2.6em;
  margin: 0 0 0.45rem;
  text-align: center;
  font-size: 0.86rem;
  font-weight: 750;
  line-height: 1.3;
  color: var(--green-bright);
}
.notice.warn { color: var(--red); }
.notice.good { color: var(--amber); }

.turn-actions { margin-top: 0.4rem; }
.turn-actions .btn.primary { min-width: min(100%, 14rem); }
.skip-btn { min-height: 40px; }

/* ---- sheets ---- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: end center;
  padding: 1rem 0.6rem;
  background: rgba(0, 0, 0, 0.72);
}

.modal-card {
  position: relative;
  width: min(24rem, 100%);
  max-height: 86dvh;
  overflow: auto;
  padding: 1rem 0.9rem 1rem;
  text-align: center;
}

.modal-card > * { position: relative; z-index: 1; }
.modal-card h2 { margin: 0 0 0.4rem; font-size: 1.1rem; }

.sheet-x {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  z-index: 2;
  width: 2.2rem;
  height: 2.2rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--green-bright);
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
}

.game-list { display: grid; gap: 0.4rem; text-align: left; }
.game-row {
  display: grid;
  gap: 0.1rem;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  background: #0B0812;
  color: var(--ink);
  text-decoration: none;
}
.game-row b { color: var(--ink-bright); }
.game-row small { color: var(--muted); }

.modal-card h3.sheet-next { margin: 0.9rem 0 0.3rem; font-size: 0.95rem; color: var(--ink-bright); }

.install-app { margin-top: 0.6rem; }
.install-btn { width: 100%; min-height: 44px; }
.install-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin: 0;
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  background: var(--amber);
  color: #1a1000;
  font-weight: 800;
  text-align: center;
}

.help-list { margin: 0.2rem 0 0.4rem; padding: 0; list-style: none; text-align: left; display: grid; gap: 0.5rem; }
.help-list li { display: grid; grid-template-columns: 30px 1fr; gap: 0.5rem; align-items: start; font-size: 0.9rem; line-height: 1.35; }
.help-list b { color: var(--ink-bright); }
.help-list .snare-ico { justify-content: center; padding-top: 0.15rem; }
.legend-ico {
  display: grid;
  place-items: center;
  width: 26px;
  height: 22px;
  border-radius: 999px;
  border: 1.5px dashed var(--muted);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}
.legend-ico.door-ico { border: 0; border-radius: 3px; width: 10px; height: 22px; margin-left: 8px; background: var(--amber); box-shadow: 0 0 0 2px #0B0812; }

.legal-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.45rem;
  margin: auto 0 0;
  padding: 0.6rem 0 max(0.4rem, env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 0.72rem;
}
.legal-foot a { color: var(--muted); text-decoration: none; }

.copied-toast {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 40;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.55rem 0.9rem;
  border: 2px solid var(--green-bright);
  border-radius: 999px;
  background: #000;
  color: #fff;
  font-weight: 750;
}

/* ---- narrow phones: tighter rooms ---- */

@media (max-width: 380px) {
  .panel { padding-left: 0.5rem; padding-right: 0.5rem; }
  .house { padding: 4px; --gap: 8px; }
  .room { padding: 0.3rem 0.3rem 0.35rem; min-height: 108px; }
  .spot { min-height: 40px; padding: 0.2rem 0.35rem; font-size: 0.74rem; }
  .spot-emoji { font-size: 1rem; }
  .room-name { font-size: 0.76rem; }
}

/* ---- wide: the house grows a little, everything stays in one column ---- */

@media (min-width: 720px) {
  .app { max-width: 34rem; }
  .room { min-height: 132px; }
  .spot { min-height: 46px; font-size: 0.86rem; }
}

@media (prefers-reduced-motion: reduce) {
  .taper::before, .glint::before, .mascot, .fox-art, .spot.flash, .bubble { animation: none; }
}
