* { box-sizing: border-box; }
:root {
  --game-panel-padding: clamp(1.375rem, 5vw, 2rem);
  --game-panel-gap: 1rem;
}
[data-location="henesys"], [data-location="plaza"] {
  --location-frame: url("../assets/interfaz/rotulo_henesys.webp");
  --location-frame-ratio: 960 / 317;
}
[data-location="ellinia"] {
  --location-frame: url("../assets/interfaz/rotulo_ellinia.webp");
  --location-frame-ratio: 960 / 304;
}
html, body { height: 100%; margin: 0; }
body { background: #b9cbd0; color: #fff; font: 500 1rem/1.4 system-ui, sans-serif; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.loading-screen {
  --loading-art: url("../assets/interfaz/fondo_carga.webp");
  position: fixed; inset: 0; z-index: 3;
  display: grid; place-items: center; padding: 1rem;
  background: #102345 var(--loading-art) center / cover no-repeat;
}
.loading-screen[hidden] { display: none; }
.loading-screen__dragon {
  position: absolute; inset: 0 auto auto 0;
  width: clamp(94px, 20vmin, 170px); height: clamp(94px, 20vmin, 170px);
  pointer-events: none;
}
[data-loading-destination] .loading-screen__dragon { display: none; }
#portal-fade, [data-portal-arrival] .loading-screen::after {
  inset: 0; background: #102345;
}
#portal-fade { position: fixed; z-index: 5; opacity: 0; }
[data-portal-arrival] .loading-screen::after {
  content: ""; position: absolute; pointer-events: none;
  animation: reveal-portal-destination .34s ease-out both;
}
@keyframes reveal-portal-destination { from { opacity: 1; } to { opacity: 0; } }
[data-loading-destination="hub"] .loading-screen, [data-loading-destination="plaza"] .loading-screen {
  --loading-art: url("../assets/interfaz/carga_hub.webp");
  background-color: #345b68;
}
[data-loading-destination="nivel-1"] .loading-screen {
  --loading-art: url("../assets/interfaz/carga_bosque.webp");
}
.loading-screen__content {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: clamp(.55rem, 2svh, 1.1rem);
  width: min(100%, 34rem); text-align: center;
}
.loading-screen__logo {
  display: block; width: min(76vw, 53svh, 32rem); height: auto;
  filter: drop-shadow(0 .35rem .65rem #061225a6);
}
.loading-screen__destination, .loading-screen__status { display: none; }
[data-loading-destination] .loading-screen__logo { display: none; }
[data-loading-destination] .loading-screen__content {
  width: min(100%, 31rem); gap: .85rem;
}
[data-loading-destination] .loading-screen__destination {
  display: grid; width: min(100%, 22rem);
  font: 700 clamp(1.35rem, 4.7vw, 2rem) / 1.1 Georgia, serif;
}
.loading-screen__progress {
  appearance: none; width: min(76%, 25rem); height: .9rem; overflow: hidden;
  border: 2px solid #bd8550; border-radius: 1rem;
  background: #182537; box-shadow: 0 .15rem .5rem #081021aa;
}
[data-loading-destination] .loading-screen__progress { width: min(65%, 17rem); }
.loading-screen__progress::-webkit-progress-bar { background: transparent; }
.loading-screen__progress::-webkit-progress-value {
  border-radius: 1rem; background: linear-gradient(#ffdb87, #d18b36);
}
.loading-screen__progress::-moz-progress-bar {
  border-radius: 1rem; background: linear-gradient(#ffdb87, #d18b36);
}
.loading-screen__progress:indeterminate {
  background: repeating-linear-gradient(115deg, #182537 0 9px, #26354a 9px 18px);
}
.loading-screen__progress[hidden] { display: none; }
.loading-screen__actions { display: grid; place-items: center; width: 100%; }
.loading-screen__actions > * { grid-area: 1 / 1; }
:root:not([data-loading-destination]) .loading-screen__start[hidden] {
  display: block; visibility: hidden;
}
.loading-screen[data-error] .loading-screen__actions { display: none; }
.loading-screen__start {
  min-width: min(66%, 12rem);
  font: 700 clamp(1.15rem, 3vw, 1.4rem) / 1.2 Georgia, serif;
}
.loading-screen[data-error] .loading-screen__status {
  display: block;
}
.location-plaque {
  grid-template-columns: minmax(0, 1fr); place-items: center;
  margin: 0; padding-block-start: .6em; aspect-ratio: var(--location-frame-ratio);
  background: var(--location-frame) center / contain no-repeat;
  color: #fff0d7; text-align: center; text-shadow: 0 2px 3px #120a16;
  filter: drop-shadow(0 .25rem .5rem #09061099);
}
.location-plaque__label { white-space: nowrap; }
.location-title {
  position: fixed; z-index: 1;
  top: calc(max(1rem, env(safe-area-inset-top)) + 3.55rem); left: 50%;
  transform: translateX(-50%);
  display: grid; width: min(14rem, 58vw);
  font: 700 clamp(1.15rem, 4.6vw, 1.55rem) / 1.1 Georgia, serif;
  pointer-events: none;
  animation: show-location-title 3.2s ease both;
}
.location-title[hidden] { display: none; }
[data-location="plaza"] .location-title { width: min(19rem, 76vw); }
@keyframes show-location-title {
  0%, 100% { opacity: 0; }
  9%, 82% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .loading-screen__dragon { display: none; }
  [data-portal-arrival] .loading-screen::after { animation: none; opacity: 0; }
  .location-title { animation-name: show-location-title-still; }
  @keyframes show-location-title-still {
    from, to { opacity: 1; }
  }
}
#feedback { position: fixed; left: max(1rem, env(safe-area-inset-left)); }
#feedback {
  padding: .5rem .85rem; border-radius: .65rem; background: #20333b; font-size: .875rem;
}
#feedback { bottom: max(1.2rem, env(safe-area-inset-bottom)); pointer-events: none; }
#feedback label { display: inline-flex; align-items: center; gap: .3rem; margin-left: .65rem; pointer-events: auto; }
#wand { font: inherit; color: #fff; background: #31474f; border: 1px solid #789398; border-radius: .3rem; }
#wand:disabled { opacity: 1; }
#feedback strong { margin-right: .65rem; }
#feedback span { color: #d5e3e6; white-space: nowrap; }
#controls {
  position: fixed; left: 50%; transform: translateX(-50%);
  background: #20333b; border-radius: .85rem;
}
#controls { bottom: max(1.2rem, env(safe-area-inset-bottom)); display: flex; gap: .35rem; padding: .35rem; }
#controls[hidden] { display: none; }
button {
  min-width: 3.1rem; min-height: 2.75rem; padding: .35rem .8rem; border: 0;
  border-radius: .55rem; background: #31474f; color: inherit; font: inherit; text-decoration: none;
  cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: none;
}
button:active, button[data-pressed] { background: #52707b; }
button:focus-visible { outline: 2px solid white; }
#hud {
  --hud-icon-size: clamp(1.7rem, 4vw, 2.45rem);
  position: fixed;
  inset: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    auto max(1rem, env(safe-area-inset-left));
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  align-items: start; gap: .4rem; pointer-events: none;
}
#hud[hidden] { display: none; }
#health img, .game-toolbar__counter img {
  display: block; width: var(--hud-icon-size); height: var(--hud-icon-size); object-fit: contain;
}
#health, .game-toolbar__counter {
  display: flex; align-items: center; gap: .12rem; padding: .15rem .35rem;
  border-radius: .65rem; background: #20333be8;
}
#health { justify-self: start; max-width: 100%; flex-wrap: wrap; }
#game-toolbar { grid-column: 2; display: flex; align-items: center; gap: .4rem; }
.game-toolbar__counter { gap: .35rem; min-height: 2.75rem; padding-right: .65rem; }
#money, #score { min-width: 1ch; font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.coin-icon {
  display: grid; place-items: center; width: calc(var(--hud-icon-size) * .76);
  aspect-ratio: 1; margin: calc(var(--hud-icon-size) * .12);
  border: 2px solid #f3bd55; border-radius: 50%;
  background: radial-gradient(circle at 33% 24%, #fff1a4, #e5a137 65%, #af601b);
  box-shadow: inset 0 0 0 2px #bb731f, 0 1px 1px #161f2b;
}
.coin-icon::after {
  content: ""; width: 27%; aspect-ratio: 1; transform: rotate(45deg);
  border: 1px solid #ffe69b; border-radius: 1px; background: #c88727;
}
#boss-health {
  display: block; width: 100%; height: .45rem;
  appearance: none; border: 0; border-radius: .3rem; overflow: hidden;
  background-color: #31474f; accent-color: #e59852;
}
#boss-health::-webkit-progress-bar { background-color: #31474f; }
#boss-health::-webkit-progress-value { background-color: #e59852; }
#boss-health::-moz-progress-bar { background-color: #e59852; }
:is(.action-tooltip, .scene-speech, .scene-indicator) {
  position: fixed; z-index: 1; transform: translate(-50%, calc(-100% - .5rem));
}
:is(.action-tooltip, .scene-speech, .scene-indicator)[hidden] { display: none; }
:is(.action-tooltip, .scene-speech) {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .45rem .75rem; border-radius: .65rem; background: #20333b;
  color: #fff; font-size: .875rem; font-weight: 700; text-decoration: none; white-space: nowrap;
}
.action-tooltip { min-height: 2.75rem; touch-action: manipulation; }
:is(.action-tooltip, .scene-speech)::after {
  content: ""; position: absolute; left: 50%; top: calc(100% - 1px); transform: translateX(-50%);
  border-top: .35rem solid #20333b; border-right: .35rem solid transparent; border-left: .35rem solid transparent;
  pointer-events: none;
}
.action-tooltip:focus-visible { outline: 2px solid white; outline-offset: 2px; }
.scene-speech { margin: 0; pointer-events: none; font-weight: 600; }
.scene-indicator {
  width: min(7rem, 28vw); padding: .3rem .42rem; border-radius: .4rem;
  background: #20333be8; pointer-events: none;
}
.game-panel {
  --game-panel-width: 26rem;
  width: min(100%, var(--game-panel-width)); padding: var(--game-panel-padding);
  border: 2px solid #c38c54; border-radius: .9rem;
  background: linear-gradient(#4a2b36, #2a1b27); color: #fff0d7; text-align: center;
  box-shadow: inset 0 0 0 .25rem #2815218c, 0 .6rem 2rem #160f19ad;
}
.game-panel--wide { --game-panel-width: 33rem; }
dialog.game-panel {
  width: min(var(--game-panel-width), calc(100% - 2rem));
  max-height: min(calc(100% - 2rem), 42rem);
}
dialog.game-panel::backdrop { background: #1815228c; }
dialog.game-panel[open], .game-panel:not(dialog, [hidden]), .game-panel__body {
  display: grid; gap: var(--game-panel-gap);
}
.game-panel__body { min-width: 0; justify-items: center; }
.game-panel__body p { margin: 0; }
.game-panel__title {
  margin: 0; font: 700 clamp(1.35rem, 4.6vw, 2.1rem) / 1.12 Georgia, serif;
  text-shadow: 0 2px 3px #120a16;
}
.game-panel__actions {
  display: flex; flex-wrap: wrap; justify-content: center; gap: .55rem .75rem;
}
.game-panel__action {
  display: inline-flex; align-items: center; justify-content: center; min-height: 2.75rem;
  padding: .45rem clamp(.6rem, 2.2vw, 1.15rem); border: 1px solid #a8747c; border-radius: .55rem;
  background: linear-gradient(#5d3a56, #362435); color: #ffefd7;
  box-shadow: inset 0 1px 0 #e9b09655, 0 3px 0 #1e1123;
  font-size: clamp(.875rem, 2.4vw, 1rem); font-weight: 700; white-space: nowrap; text-decoration: none;
  touch-action: manipulation;
}
.game-panel__action[hidden] { display: none; }
.game-panel__action--primary {
  border-color: #f0c587; background: linear-gradient(#e6b775, #bb7f48); color: #2f1a16;
  box-shadow: inset 0 1px 0 #ffe7ac99, 0 3px 0 #552b28;
}
.game-panel__action:hover { filter: brightness(1.12); }
.game-panel__action:active { translate: 0 1px; }
.game-panel__action:focus-visible { outline: 2px solid #c4967c; outline-offset: -4px; }
.game-panel__action--primary:focus-visible { outline-color: #654122; }
.game-panel button:disabled { opacity: .65; cursor: default; }
@media (max-width: 1090px) {
  #feedback {
    bottom: calc(max(1.2rem, env(safe-area-inset-bottom)) + 4rem);
    max-width: calc(100% - 2rem); padding: .35rem .55rem; font-size: .75rem;
  }
}
@media (max-width: 360px) {
  #controls { gap: .25rem; }
  #controls button { padding-inline: .55rem; }
}

.loading-screen:has(.characters:not([hidden])) { overflow: auto; align-items: safe center; }
.loading-screen:has(.characters:not([hidden])) .loading-screen__logo { width: min(55vw, 35svh, 21rem); }
.loading-screen:has(.characters #character-form:not([hidden])) .loading-screen__logo {
  width: min(45vw, 28svh, 17rem);
}
.loading-screen:has(.characters:not([hidden])) .loading-screen__actions:has(#start-game[hidden]) { display: none; }
.characters #character-menu:not([hidden]), #character-form:not([hidden]) {
  display: grid; justify-items: center; gap: var(--game-panel-gap);
}
.character-list {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(8rem, 100%), 1fr)); gap: .45rem;
  width: 100%; max-height: min(13rem, 26svh); overflow: auto; padding: .18rem;
}
.character-list:empty { display: none; }
.character-card {
  display: flex; align-items: center; gap: .4rem; min-width: 0;
  text-align: left; overflow-wrap: anywhere; background: #4a364d; touch-action: manipulation;
}
.character-card[data-active] { outline: 1px solid #f4cc81; }
.avatar {
  display: inline-block; flex: none; vertical-align: middle; object-fit: cover;
  width: 1.7rem; height: 1.7rem; border: 1px solid #c68c53; border-radius: .38rem;
  background: radial-gradient(ellipse at 50% 65%, #6d5355, #39263c 80%);
  box-shadow: 0 0 0 1px #422336, 0 1px 2px #100d18;
}
#character-status { margin: 0; color: #ffceac; font-size: .9rem; }
#character-status:empty { display: none; }
#character-form [hidden] { display: none; }
#character-form > label { display: grid; gap: .32rem; width: min(100%, 17rem); text-align: left; }
#character-form > label > input, #pin-entry input {
  width: 100%; min-height: 2.75rem; padding: .35rem .65rem; border: 1px solid #98717c;
  border-radius: .4rem; background: #171525; color: white; font: inherit;
}
#pin-entry {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .65rem;
  width: min(100%, 17rem); min-inline-size: 0; border: 0; padding: 0; margin: 0; text-align: left;
}
#pin-entry legend { margin-bottom: .32rem; padding: 0; }
#pin-entry input { min-width: 0; padding-inline: .25rem; text-align: center; font-size: 1.25rem; }
#avatar-picker {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(.25rem, 1.25vw, .45rem); width: min(100%, 17rem); min-inline-size: 0; border: 0; padding: 0; margin: 0;
}
#avatar-picker legend { margin: 0 auto .32rem; }
#avatar-picker label { display: block; position: relative; cursor: pointer; }
#avatar-picker input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: inherit; }
#avatar-picker .avatar { display: block; width: 100%; height: auto; aspect-ratio: 1; border-width: 2px; }
#avatar-picker input:checked + .avatar { border-color: #ffe3a4; outline: 2px solid #e5ab59; }
#avatar-picker input:focus-visible + .avatar { outline: 2px solid white; outline-offset: 2px; }

.game-toolbar__button {
  display: grid; place-items: center; pointer-events: auto; touch-action: manipulation;
  width: 2.75rem; min-width: 2.75rem; height: 2.75rem; padding: 0;
  overflow: hidden; border: 1px solid #bd935c; background: #31474f; color: #ffdda2;
}
.game-toolbar__button:hover { background: #435b61; }
.game-toolbar__button .avatar {
  display: block; width: 100%; height: 100%; border: 0; border-radius: inherit; box-shadow: none;
}
#open-game-menu { overflow: visible; border: 0; border-radius: 0; background: transparent; }
.game-toolbar__menu-icon {
  display: block; width: calc(100% - 4px); height: calc(100% - 4px);
  filter: drop-shadow(0 1px 1px #2d1714);
}
#open-game-menu:hover .game-toolbar__menu-icon { filter: drop-shadow(0 1px 1px #2d1714) brightness(1.12); }
dialog.game-panel--carved {
  --game-panel-width: min(27rem, calc(100svmin - 2rem));
  width: var(--game-panel-width); height: var(--game-panel-width); max-width: none;
  padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none;
  overflow: hidden;
}
.game-panel__frame {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: clamp(.45rem, 2svmin, .85rem);
  min-width: 0; min-height: 0; padding: clamp(1rem, 9svmin, 2.65rem);
  background:
    url("../assets/interfaz/marco_estadisticas.webp") center / 100% 100% no-repeat,
    radial-gradient(ellipse at 50% 15%, #6c3e2c, #382217 80%) center / 92% 91% no-repeat;
}
.game-panel__frame .game-panel__title { color: #ffe3ad; font-size: clamp(1.2rem, 6svmin, 2.1rem); }
.game-panel__frame > .game-panel__body {
  min-height: 0; align-content: start; padding: .15rem .22rem .25rem;
  overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #bd8b56 #4f3026;
}
#game-menu .game-panel__body { justify-items: stretch; gap: .6rem; }
#npc-dialog-panel:not(.game-panel__frame) { display: contents; }
.game-panel__frame .game-panel__action:not(.game-panel__action--primary),
.character-stats__values > div, .shop-item {
  min-height: 3.25rem; border: 1px solid #b9804d; border-radius: .65rem;
  background: linear-gradient(#714837, #4f3026); box-shadow: inset 0 1px #dda27355, 0 2px 2px #25130f;
}
.character-stats__body { justify-items: stretch; gap: .65rem; }
.character-stats__name {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  margin: 0; color: #ffdfab; font-size: 1.1rem; font-weight: 700; overflow-wrap: anywhere;
}
.character-stats__name .avatar {
  width: 2.9rem; height: 2.9rem; border: 2px solid #d8a961; border-radius: .6rem;
  box-shadow: 0 0 0 1px #422214, 0 3px 5px #1f0f0b;
}
.character-stats__values { display: grid; gap: .45rem; margin: 0; text-align: left; }
.character-stats__values > div {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .4rem;
  padding: .3rem .5rem;
}
.character-stats__values dt {
  display: flex; align-items: center; gap: .55rem; font-weight: 700; line-height: 1.2;
}
.character-stats__values dt img {
  flex: none; display: block; width: 2.4rem; height: 2.4rem; object-fit: contain;
  filter: drop-shadow(0 2px 2px #26130b);
}
.character-stats__values dd {
  min-width: 2rem; margin: 0; padding: .08rem .35rem;
  border: 1px solid #a47340; border-radius: .45rem; background: #392219; color: #ffe4a8;
  font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; text-align: center;
}
.shop-content { justify-items: stretch; gap: .5rem; }
.shop-balance { color: #ffcf88; font-weight: 700; }
.shop-items { display: grid; gap: .45rem; margin: 0; padding: 0; list-style: none; text-align: left; }
.shop-item {
  position: relative; display: grid; grid-template-columns: 2.3rem minmax(0, 1fr) auto;
  align-items: center; gap: .45rem; padding: .3rem .55rem; cursor: pointer;
}
.shop-item input {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: inherit;
}
.shop-item img { display: block; width: 2.3rem; height: 2.3rem; object-fit: contain; }
.shop-item__name { color: #ffe3ad; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.shop-item[data-unavailable] > :is(img, span) { opacity: .68; }
.shop-item:hover { border-color: #e2b877; }
.shop-item:has(input:checked) {
  border-color: #ffdaa0; background: linear-gradient(#95613e, #67402d);
  box-shadow: inset 0 0 0 1px #ffdaa0, 0 2px 2px #25130f;
}
.shop-item:has(input:focus-visible) { outline: 2px solid #ffe0a0; outline-offset: -4px; }
.shop-price {
  --hud-icon-size: 1.15rem;
  display: inline-flex; align-items: center; gap: .25rem; color: #ffe0a0; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.game-status {
  margin: 0; padding: .45rem .7rem; border-radius: .45rem; background: #382a30;
  color: #ffdda7; font-size: .85rem;
}
#save-status { position: fixed; inset: 3.9rem .65rem auto auto; z-index: 1; max-width: calc(100% - 1.3rem); }
.leaderboard { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.leaderboard :is(th, td) { padding: .38rem .45rem; border-bottom: 1px solid #9d74677d; }
.leaderboard th { color: #f5cc96; }
.leaderboard :is(th, td):nth-child(2) { text-align: left; overflow-wrap: anywhere; }
.leaderboard .avatar { margin-right: .4rem; }
.leaderboard tr[data-current-player] { background: #805441; }
@media (max-width: 420px) {
  #hud { gap: .25rem; left: max(.6rem, env(safe-area-inset-left)); right: max(.6rem, env(safe-area-inset-right)); }
  #health { --hud-icon-size: 1.28rem; gap: 0; padding-inline: .24rem; }
  #health:has(img:nth-child(7)) { --hud-icon-size: min(1.28rem, 4.3vw); }
  #game-toolbar { gap: .25rem; }
  .game-toolbar__counter { padding-right: .4rem; gap: .24rem; }
  #hud :is(#money, #score) { font-size: 1rem; }
}
