:root {
  --ink: #edf6f1;
  --muted: #afc8cb;
  --gold: #efc77d;
  --panel: #112737ed;
  --line: #749a9e50;
  --aqua: #75dbc8;
  --safe: env(safe-area-inset-bottom, 0px);
}
* {
  box-sizing: border-box;
}
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #132b3b;
  color: var(--ink);
  font-family:
    system-ui,
    -apple-system,
    Segoe UI,
    sans-serif;
  overscroll-behavior: none;
}
#app {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
}
#world {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}
button,
input,
select {
  font: inherit;
}
button {
  border: 1px solid var(--line);
  background: linear-gradient(160deg, #315567, #193346);
  color: var(--ink);
  border-radius: 12px;
  min-height: 44px;
  padding: 10px 18px;
  font-weight: 650;
  cursor: pointer;
  transition:
    filter 0.15s,
    transform 0.15s;
  touch-action: manipulation;
}
button:hover {
  filter: brightness(1.16);
}
button:active {
  transform: scale(0.96);
}
button:disabled {
  opacity: 0.4;
  cursor: default;
}
.primary {
  background: linear-gradient(135deg, #f6d89c, #dba65c);
  color: #213441;
  border-color: #ffe1a5;
}
.hidden {
  display: none !important;
}
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(90deg, #0b2137ad, #16344928, #0b213768);
  z-index: 20;
  overflow: auto;
  padding: 24px;
}
.logo {
  max-width: 330px;
  width: 80%;
  max-height: 25vh;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 8px 24px #132334);
}
.titlebox {
  text-align: center;
  width: 420px;
  max-width: 100%;
  display: grid;
  gap: 12px;
  justify-items: center;
}
.titlebox > button,
.titlebox .pair {
  width: min(300px, 100%);
}
.pair {
  display: flex;
  gap: 10px;
}
.pair > * {
  flex: 1;
}
.titlebox p {
  font-size: 15px;
  line-height: 1.65;
  text-shadow: 0 2px 8px #000;
  margin: 0 0 6px;
}
.titlebox small {
  color: #d1dedc;
}
.eyebrow {
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 2px;
  color: var(--gold);
  text-transform: uppercase;
}
#loading {
  flex-direction: column;
  background: radial-gradient(ellipse at center, #1e5768, #0c2035);
  gap: 16px;
}
#loading:before {
  content: "✦";
  font-size: 400px;
  position: absolute;
  opacity: 0.06;
  animation: orbit 18s infinite linear;
  pointer-events: none;
}
.loadbar {
  height: 5px;
  width: 260px;
  background: #5a798640;
  border-radius: 9px;
  overflow: hidden;
}
.loadbar i {
  display: block;
  height: 100%;
  background: var(--gold);
  animation: load 1.6s ease-out forwards;
}
#loading small {
  max-width: 80%;
  text-align: center;
  color: var(--muted);
}
@keyframes load {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}
@keyframes orbit {
  to {
    transform: rotate(360deg);
  }
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 24px 100px #06142190;
  overflow: hidden;
}
.panelhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
}
h1,
h2,
h3 {
  font-family: Georgia, serif;
  letter-spacing: 0.3px;
  margin: 6px 0;
  color: #fff6df;
}
h1 {
  font-size: 30px;
}
h2 {
  font-size: 24px;
}
h3 {
  font-size: 19px;
}
p {
  line-height: 1.65;
}
.creator {
  width: 880px;
  max-width: 100%;
  max-height: 94dvh;
  display: flex;
  flex-direction: column;
}
.creatorbody {
  display: grid;
  grid-template-columns: 38% 62%;
  overflow: auto;
  padding: 20px;
}
.preview {
  text-align: center;
  background: radial-gradient(ellipse, #2f64746b, transparent);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.preview canvas {
  width: 100%;
  max-width: 280px;
  height: 300px;
  object-fit: contain;
}
.preview p {
  font-size: 13px;
  color: var(--muted);
  padding: 0 12px;
}
form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 10px;
}
label {
  font-size: 12px;
  color: var(--muted);
  display: grid;
  gap: 6px;
}
input,
select {
  width: 100%;
  min-height: 43px;
  background: #203f50;
  border: 1px solid #5c829065;
  border-radius: 9px;
  color: #fff;
  padding: 8px;
  min-width: 0;
}
input[type="color"] {
  padding: 4px;
}
.wide {
  grid-column: 1/-1;
}
.glass {
  background: linear-gradient(140deg, #183749ec, #0e2336dd);
  border: 1px solid #b8d9cb42;
  box-shadow: 0 6px 24px #07213138;
  border-radius: 14px;
  backdrop-filter: blur(7px);
}
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#hud button {
  pointer-events: auto;
}
.herobar {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  width: 290px;
}
.herobar > div {
  flex: 1;
  min-width: 0;
}
.herobar strong {
  font-size: 13px;
  display: block;
  margin-bottom: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.herobar canvas {
  width: 48px;
  height: 54px;
}
.herobar button {
  padding: 8px;
  min-width: 40px;
}
.bar {
  height: 17px;
  background: #041b2b;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  margin: 4px 0;
}
.bar i {
  display: block;
  height: 100%;
  transition: width 0.4s;
  background: linear-gradient(90deg, #25987e, #8ce9b4);
}
.bar span {
  position: absolute;
  inset: 0;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  text-shadow: 0 1px 2px #000;
}
.mp i {
  background: linear-gradient(90deg, #427acc, #82c2f6);
}
.enemyhp i {
  background: linear-gradient(90deg, #bc5070, #f48b81);
}
.questbar {
  position: absolute;
  top: 16px;
  left: 320px;
  width: 350px;
  padding: 14px;
  display: grid;
  gap: 6px;
}
.questbar strong {
  font-size: 13px;
}
.questbar small {
  font-size: 11px;
  color: var(--muted);
}
.topright {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  width: 175px;
}
.topright button {
  min-height: 36px;
  padding: 8px 10px;
  font-size: 11px;
}
.topright canvas {
  border: 1px solid #d7c69c66;
  border-radius: 12px;
  background: #132d42;
  width: 160px;
  height: 116px;
  pointer-events: auto;
  cursor: pointer;
}
.location {
  position: absolute;
  left: 16px;
  bottom: 18px;
  padding: 10px 16px;
  font-size: 12px;
}
.worldbuttons {
  position: absolute;
  right: 20px;
  bottom: 22px;
  display: flex;
  gap: 8px;
}
.worldbuttons button {
  min-height: 48px;
}
.worldbuttons small {
  opacity: 0.6;
}
#joystick {
  display: none;
  position: absolute;
  left: 25px;
  bottom: 35px;
  width: 115px;
  height: 115px;
  border-radius: 50%;
  background: #153b4a55;
  border: 2px solid #ffffff38;
  pointer-events: auto;
  touch-action: none;
}
#stick {
  width: 45px;
  height: 45px;
  position: absolute;
  left: 33px;
  top: 33px;
  border-radius: 50%;
  background: #d7e9d390;
  border: 2px solid #f0dfb5;
  pointer-events: none;
}
#hint {
  position: absolute;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: #0a2736c9;
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 12px;
  white-space: nowrap;
}
.modal {
  position: absolute;
  inset: 0;
  background: #031725a6;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 35;
  padding: 24px;
}
.modal > .panel {
  width: 950px;
  max-width: 100%;
  height: min(760px, 93dvh);
  display: flex;
  flex-direction: column;
}
nav {
  display: flex;
  gap: 5px;
  padding: 12px 20px;
  overflow-x: auto;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
}
nav button {
  font-size: 12px;
  white-space: nowrap;
  padding: 8px 14px;
}
nav .active {
  color: #213441;
  background: var(--gold);
}
#modalBody {
  overflow: auto;
  padding: 22px;
  min-height: 0;
  flex: 1;
}
#modalBody p {
  font-size: 14px;
  color: var(--muted);
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}
.card {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 14px;
  background: #26495844;
}
.card small {
  display: block;
  color: var(--muted);
  line-height: 1.6;
}
.card button {
  margin-top: 8px;
  font-size: 12px;
}
.card .rarity {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--gold);
}
.card.completed {
  opacity: 0.55;
  border-color: #69ceb8;
}
.statgrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin: 12px 0;
}
.stat {
  background: #30556444;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px;
}
.stat span {
  display: block;
  font-size: 11px;
  color: var(--muted);
}
.stat b {
  font-size: 20px;
}
.statuslayout {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 24px;
}
.statuslayout canvas {
  width: 220px;
  height: 280px;
}
.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar select {
  max-width: 200px;
}
.worldmap {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.maplegend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
  margin: 10px 0;
}
.dialogscreen {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: linear-gradient(transparent, #091b3480);
  pointer-events: auto;
}
.letterbox {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow:
    inset 0 30px #071725,
    inset 0 -18px #071725;
}
.dialogcard {
  position: absolute;
  bottom: 7%;
  left: 8%;
  width: 84%;
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 24px;
  padding: 24px;
}
.dialogcard canvas {
  width: 160px;
  height: 170px;
  align-self: end;
}
.dialogcard p {
  font-size: 17px;
  margin: 12px 0 18px;
  max-height: 27dvh;
  overflow: auto;
}
.dialogcard h2:empty {
  display: none;
}
#choices {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
#choices button {
  text-align: left;
  font-size: 13px;
}
.enemybar {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 350px;
  padding: 16px;
}
.enemybar > span {
  font-weight: 700;
}
.enemybar small {
  display: block;
  color: #f8d49c;
  margin-top: 8px;
  font-size: 12px;
}
.battlebottom {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  padding: 14px;
}
.battlebottom #commands {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.battlebottom button {
  font-size: 12px;
  padding: 12px 6px;
}
.battlebottom #battleLog {
  min-height: 30px;
  font-size: 13px;
  color: #d3e7dc;
  margin-bottom: 12px;
}
.battlebottom #battleSub {
  max-height: 30dvh;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.battlebottom #battleSub button {
  text-align: left;
}
.battlebottom #battleSub small {
  display: block;
  opacity: 0.7;
  font-weight: 400;
  margin-top: 4px;
}
#toast {
  position: absolute;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -15px);
  padding: 14px 24px;
  border: 1px solid #dbc48d77;
  background: #0e344bef;
  border-radius: 12px;
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  transition: 0.25s;
  text-align: center;
  max-width: 90%;
  font-size: 14px;
}
#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
#banner {
  position: absolute;
  top: 25%;
  width: 100%;
  text-align: center;
  font: 32px Georgia;
  color: #fff1c8;
  letter-spacing: 3px;
  pointer-events: none;
  opacity: 0;
  text-shadow: 0 3px 14px #000;
  z-index: 10;
}
#banner.show {
  animation: banner 3s forwards;
}
@keyframes banner {
  0% {
    opacity: 0;
    transform: translateY(12px);
  }
  20%,
  75% {
    opacity: 1;
    transform: none;
  }
  100% {
    opacity: 0;
  }
}
.skilltree .card {
  position: relative;
}
.skilltree .learned {
  border-color: #8deac5;
  background: #3d896844;
}
.skilltree .locked {
  opacity: 0.5;
}
a {
  color: var(--aqua);
}
.credit {
  font-size: 13px;
  color: var(--muted);
}

body.battling .questbar,
body.battling .topright,
body.battling .location,
body.battling .worldbuttons,
body.battling #joystick,
body.battling #hint {
  display: none;
}
.dialogcard canvas {
  border-radius: 12px;
  border: 1px solid #a9c8b843;
  object-fit: cover;
}

#statusIcons {
  font-size: 9px;
  color: #f1d28c;
  line-height: 1.5;
  display: block;
}
#statusIcons:empty {
  display: none;
}
/* Real-time battle controls stay separate from the moving actors. */
#battleMode {
  font-size: 11px;
  color: #f3d795;
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}
body.battling .battlebottom {
  left: 190px;
}
body.battling .battlebottom #commands {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 5px;
}
body.battling .battlebottom button {
  min-height: 42px;
  padding: 7px 3px;
  touch-action: none;
  user-select: none;
}
#commands .keycap {
  display: block;
  font-size: 9px;
  opacity: 0.6;
  margin-top: 2px;
  min-height: 10px;
}
#commands .cooling {
  background: #344b59;
  color: #afc6d0;
}
.battle-move {
  position: absolute;
  left: -178px;
  bottom: 10px;
  width: 162px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  pointer-events: auto;
}
.battle-move button {
  min-width: 0;
  padding: 7px 3px;
  min-height: 55px;
  touch-action: none;
  user-select: none;
}
.battle-move small {
  grid-column: 1/-1;
  font-size: 10px;
  text-align: center;
  color: #eff8f3;
  text-shadow: 0 1px 3px #163443;
}
body.battling #battleSub {
  position: fixed;
  inset: 12% 8% 12%;
  z-index: 12;
  display: grid;
  background: #163443fa;
  border: 1px solid #93c7c8;
  padding: 16px;
  border-radius: 16px;
  max-height: none;
  overflow-y: auto;
  box-shadow: 0 0 0 100vmax #102b4577;
}
#battleSub > p {
  grid-column: 1/-1;
}
