@font-face {
  font-family: "Quicksand";
  src: url("../assets/fonts/Quicksand.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Nunito";
  src: url("../assets/fonts/Nunito.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #120a24;
  color: #fff8ee;
  font-family: "Nunito", "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
button, p, h1, h2, span { user-select: none; }
canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
#topbar {
  position: fixed;
  z-index: 3;
  top: calc(10px + env(safe-area-inset-top));
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
}
.screen {
  display: none;
  position: fixed;
  z-index: 2;
  inset: 0;
  flex-direction: column;
  align-items: center;
  padding: calc(62px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  gap: 12px;
}
.screen.show { display: flex; }
#shop.show, #skies.show, #skills.show, #settings.show, #pause.show, #over.show {
  background:
    radial-gradient(ellipse 80% 42% at 50% -8%, #4a2d78 0%, rgba(74, 45, 120, 0) 70%),
    #160d30;
}
#breath.show {
  background:
    radial-gradient(circle at 50% 36%, #5a3a18 0%, #2a1848 28%, #160d30 62%);
}
h1, h2, .primary, #dist { font-family: "Quicksand", "Nunito", sans-serif; }
h1 {
  margin: 0;
  font-size: clamp(36px, 8vw, 60px);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #fff6d4;
}
h2 { margin: 0; font-size: 28px; font-weight: 700; color: #fff6d4; }
.crest {
  width: 78px;
  height: 104px;
  object-fit: contain;
  filter: drop-shadow(0 10px 0 #120a24);
}
.tag { margin: 0; color: #ffe3a8; font-size: 16px; letter-spacing: 0.04em; }
.fine { margin: 0; color: #d9c8ef; font-size: 14px; text-align: center; max-width: 420px; line-height: 1.35; }
.card .fine { text-align: left; max-width: none; }
.pill, button, .card {
  background: #24143f;
  color: #fff8ee;
  border: 2px solid #e7b85a;
  border-radius: 999px;
}
.card {
  background: #1d1236;
  border-color: #8d6a32;
  box-shadow: inset 0 1px 0 #3a2860;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 8px;
  font-size: 14px;
  font-weight: 800;
}
.pill img, button img { width: 22px; height: 22px; object-fit: contain; pointer-events: none; }
.pill b { font-weight: 800; }
button {
  min-height: 52px;
  min-width: 108px;
  padding: 10px 18px;
  font: 700 18px/1.2 "Nunito", system-ui, sans-serif;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
button.primary {
  background: linear-gradient(180deg, #ffd56a, #ffb703 45%, #e8941a);
  color: #2a1608;
  border-color: #ffe7a8;
  min-height: 64px;
  font-family: "Quicksand", "Nunito", sans-serif;
  font-size: 26px;
  box-shadow: 0 4px 0 #a86408, 0 0 0 5px rgba(255, 183, 3, 0.16);
}
.nav { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; }
.nav button {
  min-width: 0;
  flex-direction: column;
  gap: 4px;
  border-radius: 22px;
  min-height: 74px;
  padding: 8px 4px;
  font-size: 13px;
}
.nav img, .nav svg { width: 28px; height: 28px; }
.set-head {
  margin: 8px 4px 0;
  color: #ffe3a8;
  font-family: "Quicksand", "Nunito", sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.set-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.set-top b { font-size: 17px; }
.set-top span { color: #ffd27a; font-weight: 800; }
.set-note { margin: 0; color: #d9c8ef; font-size: 13px; line-height: 1.35; }
input[type="range"] {
  width: 100%;
  accent-color: #ffb703;
  height: 28px;
  touch-action: pan-x;
}
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; min-width: 0; }
button.on, .seg button.on { background: #ffb703; color: #2a1608; border-color: #ffe08a; }
button:disabled { opacity: 0.45; cursor: default; }
button:active:not(:disabled) { transform: scale(0.96); }
button.primary:active:not(:disabled) { box-shadow: 0 0 0 10px rgba(255, 183, 3, 0.28); }
.row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.col { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.bar { display: flex; align-items: center; gap: 12px; width: min(560px, 100%); }
.bar h2 { flex: 1; text-align: center; margin-right: 72px; }
.list {
  width: min(560px, 100%);
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 12px;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
.card {
  border-radius: 22px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}
.card b { font-size: 18px; color: #fff6d4; }
.card button { align-self: flex-end; }
.sky-top { display: flex; align-items: center; gap: 10px; }
.sky-chip {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 2px solid #ffd27a;
  flex: none;
}
.skin-card { gap: 10px; }
.skin-row { display: flex; gap: 12px; align-items: center; }
.skin-row img { width: 54px; height: 72px; object-fit: contain; }
.skin-row div { display: flex; flex-direction: column; gap: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.actions button { align-self: auto; min-height: 44px; padding: 8px 12px; font-size: 15px; }
.panel {
  width: min(440px, 100%);
  background: #1b1038;
  border: 2px solid #ffd27a;
  border-radius: 32px;
  padding: 22px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  text-align: center;
  box-shadow: 0 10px 0 #100824, 0 0 0 6px rgba(255, 183, 3, 0.14);
}
.panel .col, .panel button { width: 100%; }
#hud { display: none; position: fixed; inset: 0; z-index: 2; pointer-events: none; }
#hud.show { display: block; }
#hud button { pointer-events: auto; }
#distblock {
  position: absolute;
  top: calc(56px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  background: #1b1038;
  border: 2px solid #ffd27a;
  border-radius: 20px;
  padding: 8px 16px 10px;
  text-align: center;
  min-width: 180px;
  max-width: min(320px, calc(100vw - 150px));
  box-sizing: border-box;
  box-shadow: 0 6px 0 #100824;
}
#dist { display: block; font-size: 30px; font-weight: 700; color: #fff6d4; }
#worldname {
  display: block;
  color: #ffe3a8;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#light {
  position: absolute;
  top: calc(118px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(220px, 46vw);
  height: 12px;
  background: #2a1848;
  border: 2px solid #ffd27a;
  border-radius: 999px;
  overflow: hidden;
}
#lightfill { display: block; height: 100%; width: 70%; background: linear-gradient(90deg, #ff8a3d, #ffd56a); }
#btn-pause {
  position: absolute;
  top: calc(54px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  width: 58px;
  min-width: 58px;
  height: 58px;
  border-radius: 50%;
  padding: 0;
}
#btn-pause img { width: 28px; height: 28px; }
body.playing #topbar { display: none; }
#hearts {
  position: absolute;
  left: calc(12px + env(safe-area-inset-left));
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: none;
  gap: 6px;
}
#hearts.show { display: flex; }
#hearts i {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #3a2458;
  border: 2px solid #ffd27a;
}
#hearts i.on { background: #ff4d6d; box-shadow: inset 0 -4px 0 #c41840; }
#fightbar {
  display: none;
  position: absolute;
  right: calc(12px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: min(300px, 74vw);
  text-align: right;
  background: #1b1038;
  border: 2px solid #ffd27a;
  border-radius: 22px;
  padding: 12px;
  box-shadow: 0 6px 0 #100824;
}
#fightbar.show { display: block; }
#fightbar .row { justify-content: flex-end; }
#ename { margin: 0 0 6px; font-weight: 700; }
#ehp {
  height: 12px;
  background: #2a1848;
  border: 2px solid #ffd27a;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}
#ehpfill { display: block; height: 100%; width: 100%; background: #ff4d6d; }
#hint {
  position: absolute;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 14px;
  color: #fff8ee;
  font-weight: 800;
  pointer-events: none;
  background: #1b1038;
  border: 2px solid #ffd27a;
  border-radius: 999px;
  white-space: nowrap;
}
#hint:empty { display: none; }
.orb {
  width: min(200px, 46vw);
  height: min(200px, 46vw);
  margin-top: 10vh;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 42%, #fff6d0 0%, #ffd56a 28%, #ff8a3d 58%, #7a3410 100%);
  border: 4px solid #fff1c2;
  box-shadow: 0 0 0 16px rgba(255, 183, 3, 0.16), 0 0 80px #ffb703;
}
#toast {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  background: #1b1038;
  border: 2px solid #ffd27a;
  border-radius: 999px;
  padding: 10px 16px;
  opacity: 0;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast { transition: opacity 0.2s ease; box-shadow: 0 6px 0 #100824; }
#menu.show { padding-top: calc(86px + env(safe-area-inset-top)); }
@media (orientation: landscape) {
  h1 { font-size: 36px; margin: 0; }
  #menu.show { justify-content: center; padding-top: calc(64px + env(safe-area-inset-top)); }
  .orb { margin-top: 0; width: 120px; height: 120px; }
}
