:root {
  --ink: #15171C;
  --ember: #EE5A24;
  --gold: #F5B82E;
  --slate: #7C8A98;
  --white: #FFFFFF;
  --mist: #E9ECEF;
  --soot: #1D2027;
  --ash: #2B3038;
  --muted: #A9B1BB;
  --gx: 50vw;
  --gy: 50vh;
  --glow: 0.5;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  grid-template-areas: "top" "stage" "copy" "meter" "foot";
  overflow: hidden;
  background: var(--ink);
  color: var(--white);
  font-family: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ember light thrown by the forge */
.glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at var(--gx) var(--gy), rgba(238, 90, 36, calc(0.22 * var(--glow))) 0, rgba(238, 90, 36, calc(0.08 * var(--glow))) 22vmax, transparent 46vmax),
    radial-gradient(ellipse 60vmax 18vmax at var(--gx) 100%, rgba(245, 184, 46, calc(0.05 * var(--glow))), transparent 70%);
  z-index: 0;
}

.top, .stage, .copy, .meter, .foot { position: relative; z-index: 1; }
.top { grid-area: top; } .stage { grid-area: stage; } .copy { grid-area: copy; } .meter { grid-area: meter; } .foot { grid-area: foot; }
.top { z-index: 3; }

/* header */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: clamp(14px, 2.6vh, 28px) clamp(16px, 4vw, 48px) 0;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--white);
  text-decoration: none;
  border-radius: 10px;
}
.brand-mark { width: clamp(34px, 4vw, 44px); height: auto; overflow: visible; }
.wordmark {
  font-weight: 800;
  font-size: clamp(20px, 2.2vw, 26px);
  letter-spacing: -0.035em;
  line-height: 1;
  font-variation-settings: "opsz" 96;
}
.wordmark span { color: var(--ember); }

.icon-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .2s, background-color .2s;
}
.icon-btn:hover { color: var(--white); background: rgba(255,255,255,.06); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn .on { display: none; }
.icon-btn[aria-pressed="true"] { color: var(--gold); }
.icon-btn[aria-pressed="true"] .on { display: inline; }
.icon-btn[aria-pressed="true"] .off { display: none; }

/* stage */
.stage {
  min-height: 0;
  margin: 0 clamp(8px, 3vw, 40px);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  display: block;
}

.floor { stroke: var(--ash); stroke-width: 1; vector-effect: non-scaling-stroke; }

.ol, .ol * {
  fill: none;
  stroke: var(--white);
  stroke-width: 3.6;
  stroke-linejoin: round;
}

#piece { cursor: pointer; }
#pieceGlow { pointer-events: none; }
.hit { cursor: pointer; outline: none; }
.hit-pad { fill: transparent; stroke: none; }
.hit:focus-visible .ol, .hit:focus-visible .ol * { stroke: var(--gold); }
#hearth:focus-visible .hearth { stroke: var(--gold); }

.chimney { stroke: none; }
.flame { fill: var(--gold); opacity: .8; mix-blend-mode: screen; }
.flame.f2 { fill: #FFE7A8; }
.hearth { fill: var(--soot); stroke: var(--ash); stroke-width: 1.6; }
.coals circle { fill: #ffcf5a; opacity: .75; animation: flicker 1.8s ease-in-out infinite alternate; }
.coals circle:nth-child(2n) { animation-duration: 1.3s; animation-delay: -.4s; fill: var(--gold); }
.coals circle:nth-child(3n) { animation-duration: 2.3s; animation-delay: -1.1s; fill: #fff1c7; }
@keyframes flicker { from { opacity: .35; } to { opacity: .95; } }


.bucket { fill: var(--soot); stroke: #3a404b; stroke-width: 1.6; stroke-linejoin: round; }
.band { stroke: #3a404b; stroke-width: 1.4; }
.water { fill: #2a3a4a; }
.crate { fill: #241f1c; stroke: #4a3a2e; stroke-width: 1.6; }
.plank { stroke: #4a3a2e; stroke-width: 1.2; }

.hammer-head { fill: var(--ink); stroke: var(--white); stroke-width: 2.2; }

body.has-hammer #anvil, body.has-hammer .stage {
  cursor: url("hammer-cursor.svg") 8 26, pointer;
}

/* fish */
.fish-btn {
  position: absolute;
  right: clamp(12px, 4vw, 56px);
  bottom: clamp(4px, 2vh, 20px);
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--ash);
  background: rgba(29, 32, 39, .7);
  cursor: pointer;
  transition: transform .2s cubic-bezier(.3,1.6,.5,1), border-color .2s;
}
.fish-btn svg { width: 28px; height: 18px; }
.fish-btn:hover { border-color: var(--slate); transform: rotate(-12deg) scale(1.06); }
.fish-btn:active { transform: scale(.92); }
.fish-btn.nope { animation: nope .35s; }
@keyframes nope { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* copy */
.copy {
  text-align: center;
  padding: clamp(4px, 1.5vh, 16px) 20px 0;
}
.meter { text-align: center; padding: 0 20px; }
h1 {
  margin: 0;
  font-weight: 800;
  font-size: clamp(30px, 5.2vw, 64px);
  letter-spacing: -0.035em;
  line-height: 1.02;
  font-variation-settings: "opsz" 96;
  text-wrap: balance;
  transition: opacity .25s, transform .25s;
}
h1.swap { opacity: 0; transform: translateY(6px); }
.sub {
  margin: .45em 0 0;
  font-weight: 500;
  font-size: clamp(16px, 1.6vw, 20px);
  color: var(--muted);
}

.heat {
  width: min(220px, 56vw);
  height: 4px;
  margin: clamp(14px, 2.2vh, 22px) auto 0;
  border-radius: 4px;
  background: var(--ash);
  overflow: hidden;
}
.heat span {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left;
  transform: scaleX(0);
  background: linear-gradient(90deg, #7a2a10, var(--ember) 55%, var(--gold) 85%, #fff4d0);
  background-size: 220px 100%;
  border-radius: inherit;
}

.hint {
  margin: 10px 0 0;
  min-height: 1.4em;
  font-size: 14px;
  font-weight: 500;
  color: var(--slate);
  transition: opacity .5s;
}
.hint.hide { opacity: 0; }

.foot {
  text-align: center;
  font-size: 12px;
  color: #5B6470;
  padding: 10px 16px clamp(10px, 2vh, 20px);
}

#fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

a:focus-visible, button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* landscape phones: tighten */
@media (max-height: 500px) and (orientation: landscape) {
  .foot { display: none; }
  h1 { font-size: 26px; }
  .sub { font-size: 14px; margin-top: .25em; }
  .heat { margin-top: 8px; }
  .hint { margin-top: 4px; font-size: 12px; }
  .top { padding-top: 8px; }
}

/* portrait: headline above a scene sized to its art; fish top-left, clear of the hammer swing */
@media (max-aspect-ratio: 4/5) {
  body {
    grid-template-rows: auto minmax(0, 1fr) auto auto auto minmax(0, 1fr) auto;
    grid-template-areas: "top" "." "copy" "stage" "meter" "." "foot";
  }
  .copy { padding-top: 0; padding-bottom: clamp(8px, 3vh, 28px); }
  .stage { margin: 0; width: 100%; aspect-ratio: 248 / 180; max-height: 62dvh; justify-self: center; }
  .meter { padding-top: 6px; }
  .fish-btn { top: 4px; left: 16px; right: auto; bottom: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .coals circle { animation: none; }
  h1, .fish-btn { transition: none; }
}
