/* Kelfirius: Fire Warrior. Shares the site's palette and type. */
@font-face {
  font-family: "Gloock";
  src: url("../assets/fonts/gloock-latin.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Archivo";
  src: url("../assets/fonts/archivo-latin.woff2") format("woff2");
  font-weight: 100 900; font-stretch: 62% 125%; font-style: normal; font-display: swap;
}

:root {
  --soot: #0b0605; --char: #170c09; --ember: #b3261e; --flame: #ff6a13; --gold: #ffb830;
  --hot: #fff3d6; --ivory: #f6e7d2; --ash: #c2ae9b; --line: rgba(246, 231, 210, 0.18);
  --display: "Gloock", "Times New Roman", serif;
  --body: "Archivo", system-ui, sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --game-top: 0px; --game-h: 100vh;
  --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px);
  --sb: env(safe-area-inset-bottom, 0px); --st: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--soot); color: var(--ivory);
  font-family: var(--body); -webkit-text-size-adjust: 100%;
  overscroll-behavior: none; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; background: var(--soot); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 3.1rem; padding: 0.9rem 1.7rem;
  background: var(--gold); color: #1b0b04; border: 0; border-radius: 999px;
  font: 700 0.95rem/1 var(--body); font-stretch: 85%; letter-spacing: 0.06em; text-transform: uppercase;
  transition: background-color 0.25s var(--ease-out), box-shadow 0.4s var(--ease-out), transform 0.25s var(--ease-out);
}
.btn:hover { background: var(--hot); transform: translateY(-2px); box-shadow: 0 8px 20px -10px rgba(255, 106, 19, 0.75), 0 0 0 1px rgba(255, 106, 19, 0.95), 0 -2px 8px -3px rgba(255, 140, 30, 0.9); }
.btn:active { transform: translateY(0); }
.btn-ghost { background: rgba(11, 6, 5, 0.62); color: var(--ivory); box-shadow: inset 0 0 0 1px rgba(246, 231, 210, 0.45); }
.btn-ghost:hover { background: rgba(246, 231, 210, 0.08); color: var(--hot); box-shadow: inset 0 0 0 1px var(--gold), 0 -2px 8px -3px rgba(255, 140, 30, 0.85); }
.link { background: none; border: 0; padding: 0.5rem 0; font-size: 0.85rem; letter-spacing: 0.04em; color: var(--ash); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; }
.link:hover { color: var(--gold); }
.link[aria-pressed="false"] { color: #8a7a6c; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; z-index: 30; display: grid; }
.screen.dim { place-items: center; background: rgba(8, 4, 3, 0.72); padding: 1rem; overflow: auto; }

#title { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: center; background: linear-gradient(90deg, rgba(8, 4, 3, 0.9) 0%, rgba(8, 4, 3, 0.72) 42%, rgba(8, 4, 3, 0.1) 72%, rgba(8, 4, 3, 0) 100%); overflow: auto; }
#title .art {
  grid-column: 2; grid-row: 1; justify-self: end; align-self: stretch;
  height: 100%; width: 100%; object-fit: cover; object-position: 50% 20%;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 34%, #000 100%), linear-gradient(0deg, transparent 0%, #000 22%);
  -webkit-mask-composite: source-in; mask-image: linear-gradient(90deg, transparent 0%, #000 34%, #000 100%), linear-gradient(0deg, transparent 0%, #000 22%);
  mask-composite: intersect;
  pointer-events: none;
}
#title .panel { grid-column: 1; grid-row: 1; padding: clamp(1.2rem, 4vw, 4rem); padding-left: calc(clamp(1.2rem, 5vw, 5rem) + var(--sl)); max-width: 44rem; }
.back { display: inline-block; margin-bottom: clamp(0.6rem, 3vh, 2rem); color: var(--ash); font-size: 0.82rem; letter-spacing: 0.08em; text-transform: uppercase; text-decoration: none; }
.back::before { content: "← "; }
.back:hover { color: var(--gold); }
h1 { margin: 0; font-weight: 400; line-height: 0.92; }
.t1 {
  display: block; font-family: var(--display); font-size: clamp(3.2rem, 11vw, 8.5rem); letter-spacing: -0.02em;
  background: linear-gradient(180deg, #fff3d6 8%, #ffcf63 38%, #ff7a1c 68%, #b3261e 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 28px rgba(255, 106, 19, 0.45));
  padding-bottom: 0.08em;
}
.t2 { display: block; margin-top: 0.4rem; font: 700 clamp(0.95rem, 2.2vw, 1.5rem)/1 var(--body); font-stretch: 85%; letter-spacing: 0.42em; text-transform: uppercase; color: var(--gold); }
.lede { margin: clamp(0.8rem, 3vh, 1.6rem) 0; max-width: 34rem; font-size: clamp(0.95rem, 1.5vw, 1.12rem); line-height: 1.55; color: var(--ivory); text-wrap: pretty; }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.actions.col { flex-direction: column; }
.minor { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1.4rem; margin-top: 1rem; font-size: 0.85rem; color: var(--ash); }
#best { color: var(--gold); letter-spacing: 0.04em; }

.how { display: grid; grid-template-columns: repeat(auto-fit, minmax(13.5rem, 1fr)); gap: 1rem 1.6rem; margin-top: 1.2rem; padding: 1.1rem 1.2rem; background: rgba(11, 6, 5, 0.78); border: 1px solid var(--line); border-radius: 14px; }
.how h2 { margin: 0 0 0.5rem; font: 700 0.78rem/1 var(--body); letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); }
.how p { margin: 0; font-size: 0.88rem; line-height: 1.5; color: var(--ivory); }
.how dl { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 0.8rem; margin: 0; font-size: 0.86rem; }
.how dt { font-weight: 700; color: var(--hot); white-space: nowrap; }
.how dd { margin: 0; color: var(--ash); }
.how.compact { grid-template-columns: 1fr 1fr; }
body[data-device="touch"] .how.compact { display: none; }

.card { width: min(30rem, 100%); padding: clamp(1.2rem, 4vw, 2.2rem); text-align: center; background: linear-gradient(180deg, rgba(40, 18, 10, 0.94), rgba(14, 7, 5, 0.96)); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 30px 80px -20px #000, 0 -2px 30px -8px rgba(255, 106, 19, 0.5); }
.card h2 { margin: 0 0 1rem; font: 400 clamp(1.8rem, 5vw, 2.6rem)/1 var(--display); color: var(--hot); }
.card .actions { justify-content: center; }
.card .minor { justify-content: center; }
.big { margin: 0; font: 400 clamp(2.6rem, 9vw, 4.2rem)/1 var(--display); color: var(--gold); font-variant-numeric: tabular-nums; }
.sub { margin: 0.3rem 0 1rem; color: var(--ash); font-size: 0.9rem; letter-spacing: 0.06em; text-transform: uppercase; }
.stats { display: flex; justify-content: center; gap: 1.6rem; margin: 0 0 1.4rem; }
.stats dt { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ash); }
.stats dd { margin: 0.2rem 0 0; font: 400 1.6rem/1 var(--display); color: var(--hot); font-variant-numeric: tabular-nums; }

/* ---------- HUD ---------- */
#hud { position: fixed; z-index: 10; left: 0; right: 0; top: var(--game-top); display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 0.6rem; padding: calc(0.6rem + var(--st)) calc(0.8rem + var(--sr)) 0 calc(0.8rem + var(--sl)); pointer-events: none; }
.hud-left { display: flex; align-items: center; gap: 0.6rem; }
.portrait { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px var(--gold), 0 0 18px rgba(255, 106, 19, 0.6); }
.bars { display: grid; gap: 5px; width: clamp(130px, 26vw, 230px); }
.bar { position: relative; height: 12px; border-radius: 99px; background: rgba(10, 5, 4, 0.72); box-shadow: inset 0 0 0 1px rgba(246, 231, 210, 0.22); overflow: hidden; }
.bar i { position: absolute; inset: 1px; border-radius: 99px; transform-origin: left center; transition: transform 0.18s var(--ease-out); }
.bar.hp i { background: linear-gradient(90deg, #8f1414, #ff4a2e); }
.bar.heat { height: 9px; }
.bar.heat i { background: linear-gradient(90deg, #ff7a1c, #ffd66b); }
.bar.heat.low { animation: low 0.45s; }
@keyframes low { 0%, 60% { box-shadow: inset 0 0 0 1px #ff4a2e, 0 0 12px #ff4a2e; } }
.row { display: flex; align-items: center; gap: 0.5rem; }
.bar.phoenix { flex: 1; height: 17px; }
.bar.phoenix i { background: linear-gradient(90deg, #6b2bd6, #ff5fa2, #ffcf63); transform: scaleX(0); }
.bar.phoenix span { position: absolute; inset: 0; display: grid; place-items: center; font: 700 0.7rem/1 var(--body); letter-spacing: 0.12em; text-transform: uppercase; color: var(--hot); text-shadow: 0 1px 2px #000; }
.bar.phoenix.ready { animation: ready 0.9s ease-in-out infinite; }
@keyframes ready { 50% { box-shadow: inset 0 0 0 1px var(--hot), 0 0 16px 2px rgba(255, 140, 60, 0.9); } }
#weapon { font: 700 0.7rem/1 var(--body); letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold); white-space: nowrap; text-shadow: 0 1px 3px #000; }
.hud-mid { padding-top: 0.2rem; font: 400 clamp(1rem, 2.4vw, 1.4rem)/1 var(--display); color: var(--hot); text-shadow: 0 2px 10px #000; white-space: nowrap; }
.hud-right { display: flex; justify-content: flex-end; align-items: flex-start; gap: 0.7rem; }
.score-box { display: grid; justify-items: end; gap: 3px; text-shadow: 0 2px 8px #000; }
#score { font: 400 clamp(1.2rem, 3vw, 1.8rem)/1 var(--display); color: var(--gold); font-variant-numeric: tabular-nums; }
#combo { min-height: 0.8rem; font: 700 0.7rem/1 var(--body); letter-spacing: 0.1em; text-transform: uppercase; color: var(--hot); }
.icon-btn { pointer-events: auto; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; border: 0; background: rgba(11, 6, 5, 0.6); box-shadow: inset 0 0 0 1px rgba(246, 231, 210, 0.35); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--ivory); stroke-width: 2.4; stroke-linecap: round; }
#hud.danger .bar.hp { animation: danger 0.7s ease-in-out infinite; }
@keyframes danger { 50% { box-shadow: inset 0 0 0 1px #ff4a2e, 0 0 14px 2px rgba(255, 60, 40, 0.8); } }

#boss { position: fixed; z-index: 10; left: 50%; top: calc(var(--game-top) + 3rem + var(--st)); transform: translateX(-50%); width: min(460px, 40vw); text-align: center; pointer-events: none; }
#boss-name { display: block; margin-bottom: 4px; font: 400 1.05rem/1 var(--display); color: #cfefff; text-shadow: 0 2px 8px #000; }
#boss .bar { height: 11px; }
#boss .bar i { background: linear-gradient(90deg, #1f6fd6, #8fe3ff); }

#banner { position: fixed; z-index: 12; left: 0; right: 0; top: calc(var(--game-top) + var(--game-h) * 0.26); display: grid; justify-items: center; gap: 0.4rem; text-align: center; pointer-events: none; opacity: 0; }
#banner strong { font: 400 clamp(2rem, 7vw, 4.6rem)/1 var(--display); background: linear-gradient(180deg, #fff3d6 10%, #ffcf63 45%, #ff7a1c 85%); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 4px 22px rgba(255, 90, 10, 0.7)); padding-bottom: 0.1em; }
#banner span { font: 700 clamp(0.7rem, 1.6vw, 0.95rem)/1 var(--body); letter-spacing: 0.34em; text-transform: uppercase; color: var(--ivory); text-shadow: 0 2px 8px #000; }
#banner.show { animation: banner 2.6s var(--ease-out) both; }
@keyframes banner { 0% { opacity: 0; transform: translateY(14px) scale(0.96); } 14% { opacity: 1; transform: none; } 78% { opacity: 1; } 100% { opacity: 0; transform: translateY(-8px); } }

#hint { position: fixed; z-index: 11; left: 50%; top: calc(var(--game-top) + var(--game-h) - 2.9rem); transform: translate(-50%, 8px); margin: 0; max-width: min(34rem, 86vw); padding: 0.5rem 0.95rem; border-radius: 99px; background: rgba(11, 6, 5, 0.74); box-shadow: inset 0 0 0 1px rgba(246, 231, 210, 0.2); font-size: clamp(0.74rem, 1.5vw, 0.9rem); line-height: 1.3; text-align: center; color: var(--ivory); opacity: 0; transition: opacity 0.4s, transform 0.4s var(--ease-out); pointer-events: none; }
#hint.show { opacity: 1; transform: translate(-50%, 0); }
body[data-device="touch"]:not(.portrait) #hint { top: calc(var(--game-top) + 6.2rem + var(--st)); max-width: 46vw; }

/* ---------- touch controls ---------- */
#touch { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
/* left thumb: an arrow pad. Up is jump, down drops through ledges. The hit area reaches past the disc. */
.dpad { --d: 172px; position: absolute; left: calc(14px + var(--sl)); bottom: calc(14px + var(--sb)); width: var(--d); height: var(--d); border-radius: 50%; pointer-events: auto; touch-action: none; background: rgba(14, 7, 5, 0.36); box-shadow: inset 0 0 0 1.5px rgba(246, 231, 210, 0.2); }
.dpad::before { content: ''; position: absolute; inset: -30px; border-radius: 50%; }
.dp { position: absolute; width: 34%; height: 34%; display: grid; place-items: center; border-radius: 30%; background: rgba(14, 7, 5, 0.52); box-shadow: inset 0 0 0 1.5px rgba(255, 184, 48, 0.6); pointer-events: none; transition: transform 0.08s, background-color 0.08s; }
.dp svg { width: 56%; height: 56%; fill: none; stroke: var(--hot); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.dp-up { left: 33%; top: 3%; }
.dp-down { left: 33%; bottom: 3%; }
.dp-left { left: 3%; top: 33%; }
.dp-right { right: 3%; top: 33%; }
.dp.on { transform: scale(0.92); background: rgba(255, 122, 28, 0.6); }
.tb { --s: 58px; position: absolute; right: calc(var(--x) + var(--sr)); bottom: calc(var(--y) + var(--sb)); width: var(--s); height: var(--s); display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; pointer-events: auto; touch-action: none; background: rgba(14, 7, 5, 0.52); box-shadow: inset 0 0 0 1.5px rgba(255, 184, 48, 0.6); transition: transform 0.08s, background-color 0.08s; }
.tb svg { width: 52%; height: 52%; fill: none; stroke: var(--hot); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.tb.down { transform: scale(0.9); background: rgba(255, 122, 28, 0.6); }
.tb-attack { --s: 88px; --x: 22px; --y: 26px; background: rgba(179, 38, 30, 0.5); }
.tb-fire { --s: 68px; --x: 128px; --y: 30px; }
.tb-shield { --s: 62px; --x: 30px; --y: 132px; }
.tb-summon { --s: 60px; --x: 110px; --y: 112px; }
.tb-dash { --s: 54px; --x: 214px; --y: 38px; }
.tb-swap { --s: 48px; --x: 190px; --y: 118px; }
.tb-ult { --s: 58px; --x: 116px; --y: 190px; opacity: 0.4; box-shadow: inset 0 0 0 1.5px rgba(246, 231, 210, 0.35); }
.tb-ult.ready { opacity: 1; background: rgba(120, 40, 200, 0.55); box-shadow: inset 0 0 0 2px #ffcf63, 0 0 22px 4px rgba(255, 110, 150, 0.8); animation: pulse 0.9s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }

/* ---------- small and short screens ---------- */
@media (max-height: 460px) {
  .lede { display: none; }
  .t1 { font-size: clamp(2.6rem, 17vh, 5rem); }
  .back { margin-bottom: 0.4rem; }
  .btn { min-height: 2.6rem; padding: 0.7rem 1.3rem; font-size: 0.85rem; }
  .portrait { width: 40px; height: 40px; }
  .bars { gap: 4px; }
  .card { padding: 1rem 1.2rem; }
  .card h2 { font-size: 1.6rem; margin-bottom: 0.6rem; }
  .card .actions.col { flex-direction: row; justify-content: center; }
  .big { font-size: 2.4rem; }
  .stats { margin-bottom: 0.8rem; }
  .how { max-height: 46vh; overflow: auto; padding: 0.7rem 0.9rem; }
}
@media (max-height: 360px) {
  .dpad { --d: 150px; left: calc(10px + var(--sl)); bottom: calc(8px + var(--sb)); }
  .tb-attack { --s: 76px; --x: 18px; --y: 18px; }
  .tb-fire { --s: 60px; --x: 110px; --y: 22px; }
  .tb-shield { --s: 54px; --x: 26px; --y: 108px; }
  .tb-summon { --s: 52px; --x: 96px; --y: 92px; }
  .tb-dash { --s: 48px; --x: 184px; --y: 28px; }
  .tb-swap { --s: 42px; --x: 164px; --y: 96px; }
  .tb-ult { --s: 50px; --x: 98px; --y: 156px; }
}
body.portrait #title { grid-template-columns: 1fr; grid-template-rows: 1fr; background: linear-gradient(180deg, rgba(8, 4, 3, 0.15) 0%, rgba(8, 4, 3, 0.55) 40%, rgba(8, 4, 3, 0.95) 72%); }
body.portrait #title .art { grid-column: 1; height: 62%; align-self: start; object-position: 50% 12%; -webkit-mask-image: linear-gradient(180deg, #000 45%, transparent 100%); mask-image: linear-gradient(180deg, #000 45%, transparent 100%); z-index: -1; }
body.portrait #title .panel { align-self: end; padding-bottom: calc(1.6rem + var(--sb)); }
body.portrait .t1 { font-size: clamp(3rem, 17vw, 5.4rem); }
body.portrait .hud-mid { display: none; }
body.portrait #hud { grid-template-columns: 1fr 1fr; }
@media (max-width: 700px) and (orientation: landscape) { #title { grid-template-columns: 1.3fr 1fr; } }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; margin: 0; padding: 2rem; text-align: center; background: var(--soot); z-index: 99; }
@media (prefers-reduced-motion: reduce) {
  #banner.show { animation-duration: 2.6s; animation-timing-function: linear; }
  .tb-ult.ready, .bar.phoenix.ready, #hud.danger .bar.hp { animation: none; }
}

/* ---------- phones in portrait: ask for landscape ---------- */
#rotate { z-index: 60; place-items: end center; background: var(--soot); overflow: hidden; }
#rotate .art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%; opacity: 0.5; -webkit-mask-image: linear-gradient(180deg, #000 30%, transparent 78%); mask-image: linear-gradient(180deg, #000 30%, transparent 78%); }
.rotate-card { position: relative; display: grid; justify-items: center; gap: 0.9rem; padding: 1.5rem 1.6rem calc(2.4rem + var(--sb)); max-width: 24rem; text-align: center; }
.rotate-card h2 { margin: 0; font: 400 clamp(1.7rem, 8vw, 2.3rem)/1.1 var(--display); color: var(--hot); }
.rotate-card p { margin: 0; font-size: 0.95rem; line-height: 1.5; color: var(--ivory); }
.rotate-icon { width: 68px; height: 68px; fill: none; stroke: var(--gold); stroke-width: 3; stroke-linecap: round; animation: turn 2.4s var(--ease-out) infinite; }
@keyframes turn { 0%, 20% { transform: rotate(0deg); } 55%, 85% { transform: rotate(-90deg); } 100% { transform: rotate(0deg); } }
@media (prefers-reduced-motion: reduce) { .rotate-icon { animation: none; transform: rotate(-90deg); } }
