/* BUILDLE — on top of Legendle's Sky Glass theme (css/style.css): same fonts, panels,
   buttons, hearts, stats and results panel. This file only adds Buildle's own parts:
   the timer, the build tree, the Start cover, "Not an Item" and the wrong-guess list. */

/* ---------- Red theme ----------
   Buildle swaps Legendle's navy for a muted red everywhere (outlines, badges, labels,
   panels' shadows), so the two games are easy to tell apart. Pink buttons stay. */
:root {
  --navy: #6b1f26;      /* outlines and dark accents (Legendle: navy #1e2a6e) */
  --navy-2: #8c2f36;
  --red-fill: #b9474d;  /* the "?" box */
  --red-shadow: #6b1f26;
}
html { background: #4a2030; }
/* Buildle's own background (battlefield at sunset): still first frame + looping video,
   same layering as Legendle (see css/style.css). Phones get the centre crop, on the axe. */
html::before {
  background: url("/buildle/media/bg.jpg?v=3d631035") center center / cover no-repeat;
  background: image-set(url("/buildle/media/bg.webp?v=9657f31f") type("image/webp"), url("/buildle/media/bg.jpg?v=3d631035") type("image/jpeg")) center center / cover no-repeat;
}
@media (max-width: 760px) {
  html::before { background-position: center center; }
  .bg-video { object-position: center center; }
}
@media (max-width: 700px) and (orientation: portrait) {
  html::before {
    background: url("/buildle/media/bg-mobile.jpg?v=e4533b78") center center / cover no-repeat;
    background: image-set(url("/buildle/media/bg-mobile.webp?v=86034f08") type("image/webp"), url("/buildle/media/bg-mobile.jpg?v=e4533b78") type("image/jpeg")) center center / cover no-repeat;
  }
}
body::before { background: linear-gradient(180deg, rgba(48, 10, 14, 0) 0%, rgba(48, 10, 14, 0) 45%, rgba(48, 10, 14, 0.35) 100%); }
.panel { box-shadow: 0 10px 30px rgba(70, 16, 22, 0.28); }
.prompt, .yesterday, .win p, .legend, .arch-sub, .start-note { text-shadow: 0 1px 2px rgba(70, 16, 22, 0.85); }
.streak-badge { box-shadow: 0 4px 0 rgba(107, 31, 38, 0.35); }
.streak-badge.cold { background: rgba(107, 31, 38, 0.7); }
.stats div span { background: rgba(107, 31, 38, 0.82); }
.btn.btn-navy { box-shadow: 0 4px 0 rgba(70, 16, 22, 0.5); }
.btn.btn-navy:active { box-shadow: 0 1px 0 rgba(70, 16, 22, 0.5); }
.heart.lost .fill { fill: #8a6a6e; }
.toast { box-shadow: 0 8px 24px rgba(70, 16, 22, 0.4); }
.suggestions { box-shadow: 0 14px 34px rgba(70, 16, 22, 0.35); }
#guess-input::placeholder { color: #a8686d; }
footer { text-shadow: 0 1px 2px rgba(48, 10, 14, 0.9); }

/* While playing on a phone, the big title shrinks so the tree and the keyboard both fit */
@media (max-width: 700px) {
  body.started:not(.finished) .title { font-size: 40px; }
  body.started:not(.finished) .subtitle,
  body.started:not(.finished) .streak-badge { display: none; }
  body.started:not(.finished) .title-wrap { padding-top: 8px; }
}

/* ---------- Timer ----------
   30 blocks, one per second, that run out one at a time like a loading bar. From 10
   seconds left the blocks, the number and the clock turn red and pulse. */
.timer { display: flex; align-items: center; gap: 10px; max-width: 440px; margin: 0 auto 14px; }
.timer .clock { width: 30px; height: 30px; flex: none; shape-rendering: crispEdges; }
.clock .rim { fill: var(--navy); }
.clock .face { fill: #fff; }
.clock .hands { fill: var(--navy); }
.timer-bar {
  flex: 1; display: flex; gap: 2px; height: 20px; padding: 2px; border-radius: 6px;
  background: rgba(107, 31, 38, 0.55); border: 2px solid #fff;
  box-shadow: 0 3px 0 rgba(107, 31, 38, 0.35);
}
.timer-bar i { flex: 1; border-radius: 1px; background: #2fbf71; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18), inset 0 2px 0 rgba(255, 255, 255, 0.35); }
.timer-bar i.gone { background: transparent; box-shadow: none; }
.timer-num {
  min-width: 54px; text-align: right; font-family: var(--pixel); font-weight: normal;
  font-size: 30px; line-height: 1; color: #fff; text-shadow: var(--outline); font-variant-numeric: tabular-nums;
}
.timer.low .timer-bar i:not(.gone) { background: #e5484f; }
.timer.low .timer-bar { border-color: #ffd1d4; }
.timer.low .timer-num { color: #ffd1d4; }
.timer.low .clock .face { fill: #ff8a8f; }
.timer.low .timer-num, .timer.low .clock { animation: tpulse 1s steps(2) infinite; }
.timer.out .timer-bar { border-color: #ff5c66; }
.timer.done .timer-num, .timer.done .clock { animation: none; }
.timer.done .timer-num { font-size: 24px; }
@keyframes tpulse { 50% { transform: scale(1.18); } }

/* ---------- Stage: the build tree, with the Start cover over it until the game begins ---------- */
.stage { position: relative; min-height: 214px; display: grid; place-items: center; margin-bottom: 14px; }
.start-cover { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 6px 0; }
.start-btn { height: 62px; padding: 0 44px; font-size: 32px; letter-spacing: 0.08em; animation: breathe 1.6s ease-in-out infinite; }
.start-btn:disabled { animation: none; }
@keyframes breathe { 50% { transform: scale(1.05); } }
.start-note { margin: 0; font-size: 13px; font-weight: 600; text-shadow: 0 1px 2px rgba(70, 16, 22, 0.8); }
.ghost-tree { display: flex; flex-direction: column; align-items: center; gap: 12px; opacity: 0.55; }
.ghost-tree .g-row { display: flex; gap: 22px; }
.g-slot {
  width: 46px; height: 46px; border-radius: 10px; display: grid; place-items: center;
  background: rgba(107, 31, 38, 0.6); border: 2px dashed #fff;
  font-family: var(--pixel); font-size: 24px; text-shadow: var(--outline);
}
.g-slot.big { width: 62px; height: 62px; font-size: 34px; }

/* ---------- Build tree ----------
   Each item sits in a column with the items it's built from underneath, joined by
   white lines like the in-game shop: a stub down from the parent, a bar across the
   children, and a drop into each child. Sizes shrink one step per level. */
.tree { width: 100%; display: flex; justify-content: center; overflow-x: auto; padding: 2px 0 4px; }
.tree:empty { display: none; }
.bt-node { --s: 48px; --line: 3px; position: relative; display: flex; flex-direction: column; align-items: center; padding: 0 4px; min-width: 0; }
.bt-node.d0 { --s: 76px; }
.bt-node.d1 { --s: 54px; }
.bt-node.d2 { --s: 40px; }
.bt-node.d3 { --s: 32px; }
.slot { position: relative; z-index: 1; }
.slot .thumb, .slot.mystery { width: var(--s); height: var(--s); }
.bt-node .nm {
  display: block; max-width: calc(var(--s) + 26px); margin-top: 4px; text-align: center;
  font: 700 11px/1.15 Inter, system-ui, sans-serif; color: #fff;
  text-shadow: 0 1px 2px rgba(70, 16, 22, 0.95), 0 0 2px rgba(70, 16, 22, 0.9);
}
.bt-node.d2 .nm, .bt-node.d3 .nm { font-size: 9.5px; max-width: calc(var(--s) + 22px); }
.bt-kids { position: relative; display: flex; justify-content: center; align-items: flex-start; padding-top: 14px; }
/* stub down from the parent */
.bt-kids::before { content: ""; position: absolute; top: 0; left: 50%; height: 14px; margin-left: calc(var(--line) / -2); border-left: var(--line) solid #fff; }
/* drop into each child, and the bar across them */
.bt-kids > .bt-node { padding-top: 14px; }
.bt-kids > .bt-node::before { content: ""; position: absolute; top: 0; left: 50%; height: 14px; margin-left: calc(var(--line) / -2); border-left: var(--line) solid #fff; }
.bt-kids > .bt-node::after { content: ""; position: absolute; top: 0; left: 0; right: 0; border-top: var(--line) solid #fff; }
.bt-kids > .bt-node:first-child::after { left: 50%; margin-left: calc(var(--line) / -2); }
.bt-kids > .bt-node:last-child::after { right: 50%; margin-right: calc(var(--line) / -2); }
.bt-kids > .bt-node:only-child::after { display: none; }
.tree .bt-kids::before, .tree .bt-kids > .bt-node::before, .tree .bt-kids > .bt-node::after {
  filter: drop-shadow(0 2px 0 rgba(107, 31, 38, 0.55));
}
.tree .thumb { background: #3b1015; box-shadow: 0 3px 0 rgba(107, 31, 38, 0.45); }
.tree .bt-node.d0 > .bt-kids > .bt-node { animation: grow 0.35s ease both; }
.tree .bt-node.d0 > .bt-kids > .bt-node:nth-child(2) { animation-delay: 0.08s; }
.tree .bt-node.d0 > .bt-kids > .bt-node:nth-child(3) { animation-delay: 0.16s; }
@keyframes grow { from { opacity: 0; transform: translateY(-8px); } }

/* Today's item: a pulsing "?" until the game ends, then its icon flips in */
.slot.mystery {
  display: grid; place-items: center; border-radius: 12px;
  background: linear-gradient(180deg, #cc5a60, var(--red-fill)); border: 3px solid #fff;
  box-shadow: 0 4px 0 var(--red-shadow), 0 0 0 4px rgba(185, 71, 77, 0.4);
  animation: mpulse 1.4s ease-in-out infinite;
}
.slot.mystery .q { font-family: var(--pixel); font-size: 46px; line-height: 1; color: #fff; text-shadow: var(--outline-lg); }
@keyframes mpulse { 50% { box-shadow: 0 4px 0 var(--red-shadow), 0 0 0 9px rgba(185, 71, 77, 0); } }
.slot.mystery.revealed { background: none; border: 0; box-shadow: none; animation: reveal 0.6s ease both; }
.slot.mystery.revealed .thumb { width: 100%; height: 100%; border-width: 3px; }
.slot.mystery.won .thumb { border-color: #7ef0b0; box-shadow: 0 0 0 4px rgba(47, 191, 113, 0.55); }
.slot.mystery.lost .thumb { border-color: #ff5c8a; box-shadow: 0 0 0 4px rgba(229, 72, 106, 0.5); }
.slot.mystery.still { animation: none; }
@keyframes reveal { 0% { transform: rotateY(90deg) scale(0.8); } 60% { transform: rotateY(0) scale(1.12); } 100% { transform: none; } }
.gold { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; font-family: var(--pixel); font-size: 17px; color: #ffd45c; text-shadow: var(--outline); }
.gold .coin { width: 12px; height: 12px; background: #ffd45c; border: 2px solid var(--navy); border-radius: 3px; box-shadow: inset -2px -2px 0 #e0a400; }

/* Item icons (Legendle's .thumb, square art) */
.item-thumb { border-radius: 10px; background: #3b1015; font-size: 15px; }
.item-thumb img { object-fit: contain; image-rendering: auto; }

/* ---------- Search additions ---------- */
.search { margin-top: 2px; }
.not-item {
  position: absolute; left: 50%; bottom: calc(100% + 6px); z-index: 30; transform: translateX(-50%);
  padding: 6px 12px 5px; border-radius: 8px; white-space: nowrap;
  font-family: var(--pixel); font-size: 18px; letter-spacing: 0.06em; color: #fff;
  background: var(--red); border: 2px solid #fff; box-shadow: 0 4px 0 #7a0f2a; text-shadow: var(--outline);
}
.not-item::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -7px; border: 7px solid transparent; border-top-color: #fff; }
.not-item.pop { animation: npop 0.35s ease; }
@keyframes npop { 0% { transform: translateX(-50%) scale(0.6); opacity: 0; } 60% { transform: translateX(-50%) scale(1.1); opacity: 1; } 100% { transform: translateX(-50%) scale(1); } }
.search-row.shake #guess-input { box-shadow: 0 0 0 3px rgba(229, 72, 106, 0.85); }
.suggestions .item-thumb { width: 36px; height: 36px; }

/* ---------- Wrong guesses ---------- */
.wrong-wrap { max-width: 440px; margin: 14px auto 0; }
.wrong-head { text-align: center; font-family: var(--pixel); font-size: 15px; letter-spacing: 0.05em; color: #fff; text-shadow: var(--outline); margin-bottom: 8px; }
.wrong-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.wrong-list li {
  display: flex; align-items: center; gap: 10px; padding: 5px 10px 5px 6px; border-radius: 10px;
  background: rgba(229, 72, 106, 0.85); border: 2px solid rgba(255, 255, 255, 0.8);
  font-family: var(--pixel); font-size: 18px; color: #fff; text-shadow: 2px 0 0 #7a0f2a, -2px 0 0 #7a0f2a, 0 2px 0 #7a0f2a, 0 -2px 0 #7a0f2a;
}
.wrong-list li span { flex: 1; min-width: 0; }
.wrong-list li .x { font-family: Inter, sans-serif; font-size: 16px; }
.wrong-list li.new { animation: wpop 0.4s ease; }
@keyframes wpop { 0% { transform: scale(0.85); opacity: 0; } 70% { transform: scale(1.03); opacity: 1; } 100% { transform: none; } }

.win .answer .item-thumb { border-radius: 12px; }

/* ---------- Phones ---------- */
@media (max-width: 460px) {
  .bt-node { padding: 0 2px; }
  .bt-node.d0 { --s: 64px; }
  .bt-node.d1 { --s: 46px; }
  .bt-node.d2 { --s: 34px; }
  .bt-node.d3 { --s: 28px; }
  .bt-node .nm { font-size: 10px; }
  .bt-node.d2 .nm, .bt-node.d3 .nm { font-size: 8.5px; max-width: calc(var(--s) + 14px); }
  .slot.mystery .q { font-size: 38px; }
  .timer-num { font-size: 26px; min-width: 46px; }
  .not-item { font-size: 16px; }
  .wrong-list li { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .start-btn, .slot.mystery, .timer.low .timer-num, .timer.low .clock, .tree .bt-node, .wrong-list li.new, .not-item.pop { animation: none !important; }
}

/* After midnight, if a game was still going: a link to the new item replaces the countdown */
.countdown a { color: #fff; font-size: 26px; text-decoration: none; }
