/* MOSSGUARD Wiki: cozy pixel style matching the game (parchment cards on a mossy forest floor). */
@font-face { font-family: "Pixelify"; src: url(/fonts/PixelifySans-Regular.ttf); font-display: swap; }
@font-face { font-family: "Pixelify"; src: url(/fonts/PixelifySans-Bold.ttf); font-weight: 700; font-display: swap; }

:root {
  --cream: #fbf1d8; --paper: #f5e6c4; --brown: #5a3a2a; --brown2: #8a6a50; --gold: #ffcc55; --gold-dk: #b07a10;
  --green: #4a8a3a; --violet: #8a5ab0; --ink: #2e1e34; --sky: rgba(20, 40, 25, .55);
}
* { box-sizing: border-box; }
html { font-size: 17px; }
body {
  margin: 0; font-family: "Pixelify", system-ui, sans-serif; color: var(--brown); line-height: 1.45;
  background: #3d6b34 url(/img/ground_meadow.png) 0 0 / 64px 64px; image-rendering: auto;
  font-feature-settings: "liga" 0, "clig" 0, "calt" 0;
}
#sky { position: fixed; inset: 0; background: var(--sky); pointer-events: none; z-index: 0; transition: background 1s; }
body.night #sky { background: rgba(8, 10, 40, .72); }
.px, .spr { image-rendering: pixelated; image-rendering: crisp-edges; }
img.px { vertical-align: middle; }
a { color: #2f6f9f; }
a:hover { color: #1d4f7a; }

/* ---- sprites: CSS steps animation over a horizontal strip */
.spr {
  display: inline-block; vertical-align: middle; flex: none;
  width: calc(var(--w) * var(--s) * 1px); height: calc(var(--h) * var(--s) * 1px);
  background-repeat: no-repeat; background-position: 0 0;
  background-size: calc(var(--w) * var(--t) * var(--s) * 1px) calc(var(--h) * var(--s) * 1px);
  animation: spr calc(var(--n) * .16s) steps(var(--n)) infinite;
}
@keyframes spr { to { background-position-x: calc(var(--w) * var(--n) * var(--s) * -1px); } }
@media (prefers-reduced-motion: reduce) { .spr { animation: none; } }

/* ---- header */
header.top {
  position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  padding: 8px 14px; background: rgba(40, 26, 44, .92); border-bottom: 3px solid #1c1222; box-shadow: 0 2px 0 rgba(0, 0, 0, .3);
}
.logo { display: flex; align-items: center; gap: 6px; text-decoration: none; color: var(--gold); font-weight: 700; font-size: 1.35rem;
  text-shadow: 2px 2px 0 #3a2410; }
.logo small { color: var(--cream); font-size: .8rem; font-weight: 400; }
.search { position: relative; flex: 1 1 200px; max-width: 360px; }
.search input { width: 100%; font: inherit; padding: 6px 10px; border: 3px solid #1c1222; border-radius: 6px; background: var(--cream); color: var(--brown); }
#results { position: absolute; left: 0; right: 0; top: 110%; background: var(--cream); border: 3px solid #1c1222; border-radius: 6px; display: none;
  max-height: 60vh; overflow: auto; box-shadow: 0 6px 0 rgba(0, 0, 0, .25); }
#results a { display: block; padding: 6px 10px; text-decoration: none; color: var(--brown); border-bottom: 1px solid #e8d6ac; }
#results a:hover, #results a.sel { background: var(--gold); }
.tools { display: flex; gap: 8px; margin-left: auto; }
.tools button, .tools a, .filters button, button#nexttip, button#pclear {
  font: inherit; cursor: pointer; padding: 5px 10px; border: 3px solid #1c1222; border-radius: 6px; text-decoration: none;
  background: #5aa0e0; color: #fff; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .25); text-shadow: 1px 1px 0 rgba(0, 0, 0, .3);
}
.tools button:active, .filters button:active { transform: translateY(2px); }
.menu { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .9rem; }
.menu a { color: var(--cream); text-decoration: none; }
.menu a:hover { color: var(--gold); }

main { position: relative; z-index: 1; max-width: 1040px; margin: 0 auto; padding: 16px 14px 40px; }
h1 { color: var(--gold); text-shadow: 3px 3px 0 #3a2410, -1px -1px 0 #3a2410; margin: .4em 0; font-size: 2rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel h1, article h1 { color: var(--brown); text-shadow: none; }
h2 { margin: .3em 0 .5em; font-size: 1.25rem; }
.lead { color: var(--cream); text-shadow: 1px 1px 0 #1c1222; font-size: 1.05rem; max-width: 760px; }
.center { text-align: center; margin-left: auto; margin-right: auto; }
.crumbs { color: var(--cream); font-size: .85rem; }
.crumbs a { color: var(--gold); }
.note { font-size: .85rem; color: var(--brown2); }

/* ---- parchment panels + cards */
.panel, article.panel, .card, .hoot, .faq {
  background: var(--cream); border: 3px solid #4a2e22; border-radius: 8px;
  box-shadow: inset 0 0 0 3px #e8d6ac, 0 4px 0 rgba(0, 0, 0, .3);
}
.panel { padding: 14px 18px; margin: 16px 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.card { display: flex; flex-direction: column; gap: 4px; padding: 12px; color: var(--brown); text-decoration: none; transition: transform .12s; }
a.card:hover { transform: translateY(-3px) rotate(-.4deg); box-shadow: inset 0 0 0 3px var(--gold), 0 7px 0 rgba(0, 0, 0, .3); }
.card b { font-size: 1.05rem; }
.card small { color: var(--brown2); font-size: .82rem; }
.card .ic { width: 52px; height: 52px; display: grid; place-items: center; background: #3a2a3a; border-radius: 6px; border: 2px solid #1c1222; }
.card .ic.power, .ic.power { background: radial-gradient(#9a6ae0, #4a2a70); }
.ic.power.big { width: 84px; height: 84px; display: grid; place-items: center; border-radius: 10px; border: 3px solid #1c1222; }
.card.sec { align-items: center; text-align: center; }
.card.sec .ic { width: 60px; height: 60px; }
.evo-mini { display: flex; align-items: center; gap: 3px; }
.badge { display: inline-block; font-size: .72rem; padding: 1px 7px; border-radius: 10px; color: #fff; background: #7a7a7a; width: fit-content; }
.badge.z-meadow { background: #5aa040; } .badge.z-marsh { background: #4a8070; } .badge.z-frost { background: #5a90c8; } .badge.z-ember { background: #d06a30; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.filters button { background: #8a7a70; }
.filters button.on { background: #e0a030; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 20px; background: var(--paper);
  border: 2px solid #d8c090; text-decoration: none; color: var(--brown); }
.chip:hover { background: var(--gold); }

.hero-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.hero-head > img, .hero-head > .spr { background-color: rgba(255, 245, 220, .9); border: 3px solid #4a2e22; border-radius: 10px; padding: 8px; box-sizing: content-box; }
.hero-head .lead { margin: 0; }

.recipe { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 1.05rem; }
.forms { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .forms { grid-template-columns: 1fr; } }
.form { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 8px; }
.form-a { background: linear-gradient(135deg, #fff4c8, #ffe08a); border: 3px solid var(--gold-dk); }
.form-b { background: linear-gradient(135deg, #f0e2ff, #d6b8ff); border: 3px solid var(--violet); }
.form h3 { margin: .1em 0; }
.form p { margin: .2em 0; }
.tag { font-size: .72rem; padding: 1px 6px; border-radius: 4px; background: #3a2410; color: #fff; }

.tablewrap { overflow-x: auto; }
table.stats { border-collapse: collapse; width: 100%; font-size: .9rem; }
table.stats th, table.stats td { padding: 5px 8px; border-bottom: 1px solid #e8d6ac; text-align: center; white-space: nowrap; }
table.stats.left td, table.stats.left th { text-align: left; white-space: normal; }
table.stats th { color: var(--brown2); font-weight: 700; }
table.stats .fa { background: #fff1c0; } table.stats .fb { background: #ecdcff; }
table.kv { border-collapse: collapse; }
table.kv th { text-align: left; padding: 4px 14px 4px 0; color: var(--brown2); }
table.kv td { padding: 4px 10px 4px 0; }
table.kv.small { font-size: .8rem; }
table.waves td { padding: 6px; vertical-align: top; }
table.waves td:first-child { font-weight: 700; white-space: nowrap; }

.say { display: flex; gap: 12px; align-items: center; margin: 8px 0; padding: 8px; background: var(--paper); border-radius: 8px; }
.say p { margin: .1em 0; }
.say .ic { width: 44px; height: 44px; display: grid; place-items: center; background: #3a2a3a; border-radius: 6px; flex: none; }
.hoot { display: flex; gap: 16px; align-items: center; padding: 14px 18px; margin: 18px 0; }
.hoot p { margin: .3em 0 .6em; font-size: 1.05rem; }
ul.tips { list-style: none; padding: 0; display: grid; gap: 8px; }
li.tip { background: var(--cream); border: 3px solid #4a2e22; border-radius: 8px; padding: 8px 12px 8px 40px; position: relative; }
li.tip::before { content: ""; position: absolute; left: 10px; top: 10px; width: 20px; height: 20px; background: url(/img/icon_star.png) 0 0 / 20px; image-rendering: pixelated; }
.faq { padding: 10px 16px; margin: 10px 0; }
.faq summary { cursor: pointer; font-weight: 700; }
.zone-banner { height: 70px; background-size: 64px; image-rendering: pixelated; border-radius: 6px; display: flex; align-items: flex-end; justify-content: center; }
.zone-head { background-size: 64px; image-rendering: pixelated; border-radius: 10px; border: 3px solid #4a2e22; padding: 14px; }
.zone-head div { display: flex; align-items: flex-end; gap: 4px; }
.zone-head h1 { margin: 6px 0 0; }
.card.enemy .spr { align-self: flex-start; }
.card .where { color: var(--green); }

/* ---- planner */
.planner { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .planner { grid-template-columns: 1fr; } }
.planner h2 { color: var(--cream); text-shadow: 1px 1px 0 #1c1222; }
.picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; margin-bottom: 14px; }
.pick { font: inherit; font-size: .72rem; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; cursor: pointer;
  background: var(--cream); border: 3px solid #4a2e22; border-radius: 8px; color: var(--brown); }
.pick.on { background: var(--gold); border-color: var(--gold-dk); transform: translateY(-2px); }
.pick.dim { opacity: .45; }
#evos .evo { display: flex; gap: 10px; align-items: center; padding: 10px; margin-bottom: 8px; border-radius: 8px; background: var(--cream); border: 3px solid #4a2e22; }
#evos .evo.ready { border-color: var(--gold-dk); box-shadow: 0 0 0 3px var(--gold); animation: glow 1.2s ease-in-out infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 0 3px #fff3b0, 0 0 14px #ffd860; } }
#evos .evo small { display: block; color: var(--brown2); }
#evos .note { color: var(--cream); }

/* ---- home: the den */
.den-wrap { position: relative; border: 4px solid #2a1a22; border-radius: 12px; overflow: hidden; box-shadow: 0 6px 0 rgba(0, 0, 0, .35); }
#den { display: block; width: 100%; height: auto; image-rendering: pixelated; cursor: pointer; touch-action: manipulation; }
.den-title { position: absolute; left: 0; right: 0; top: 6px; text-align: center; pointer-events: none; }
.den-title h1 { justify-content: center; font-size: 2.6rem; margin: 0; }
.den-title p { color: var(--cream); text-shadow: 2px 2px 0 #1c1222; margin: 0; }
.den-hint { position: absolute; bottom: 4px; width: 100%; text-align: center; color: var(--cream); text-shadow: 1px 1px 0 #1c1222; font-size: .85rem; margin: 0; pointer-events: none; }
.secs .card { min-height: 110px; justify-content: center; }

/* ---- footer + play button */
footer { position: relative; z-index: 1; text-align: center; padding: 20px 14px 30px; color: var(--cream); font-size: .85rem; text-shadow: 1px 1px 0 #1c1222; }
footer a { color: var(--gold); }
a.play { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; background: #ffcc33; color: var(--brown); text-shadow: none;
  border: 3px solid #4a2e22; border-radius: 8px; text-decoration: none; font-weight: 700; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .2), 0 3px 0 rgba(0, 0, 0, .3); }
a.play:hover { background: #ffe066; color: var(--brown); }
a.play.big { font-size: 1.3rem; padding: 12px 26px; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: scale(1.04); } }

/* ---- night: fireflies drift over everything */
.firefly { position: fixed; width: 3px; height: 3px; background: #fff8a0; border-radius: 50%; box-shadow: 0 0 8px 3px rgba(255, 240, 120, .55);
  pointer-events: none; z-index: 2; animation: fly 9s ease-in-out infinite alternate; }
@keyframes fly { 0% { transform: translate(0, 0); opacity: .2; } 50% { opacity: 1; } 100% { transform: translate(60px, -80px); opacity: .3; } }
.heart-pop { position: fixed; pointer-events: none; z-index: 50; width: 20px; height: 20px; background: url(/img/icon_heart.png) 0 0 / 20px; image-rendering: pixelated;
  animation: pop 1s ease-out forwards; }
@keyframes pop { to { transform: translateY(-60px) scale(1.3); opacity: 0; } }

@media (max-width: 600px) {
  html { font-size: 15px; }
  .den-title h1 { font-size: 1.8rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
