:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --glass: rgba(9, 19, 28, 0.56);
  --line: rgba(255, 255, 255, 0.16);
  --text: #f8fbff;
  --muted: #b8c8d8;
  --gold: #ffd372;
  --wind: #68f1d4;
  --danger: #ff6c76;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #78966a;
}

button {
  font: inherit;
}

#world {
  display: block;
  width: 100vw;
  height: 100vh;
  background: #78966a !important;
}

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  color: var(--text);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.45);
}

.topbar {
  position: absolute;
  top: 18px;
  left: 20px;
  right: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.brand,
.quest,
.prompt,
.materials,
.bottom-right,
.toast {
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.22);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
  padding: 12px 14px;
  border-radius: 8px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: #082422;
  font-weight: 900;
  background: radial-gradient(circle at 30% 20%, #ffffff, var(--wind) 45%, #2d9bff);
  text-shadow: none;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: 0;
}

.brand p,
.quest span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.quest {
  min-width: min(360px, 42vw);
  padding: 12px 14px;
  border-radius: 8px;
  text-align: right;
}

.quest strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
}

.meters {
  position: absolute;
  left: 50%;
  bottom: 24px;
  width: min(390px, calc(100vw - 48px));
  display: grid;
  gap: 7px;
  transform: translateX(-50%);
}

.meter {
  height: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
}

.meter span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  transition: width 0.15s ease;
}

.hp span {
  background: linear-gradient(90deg, #ff4662, #ff9d6c);
}

.stamina span {
  background: linear-gradient(90deg, #ffd35d, #fff2a8);
}

.xp span {
  background: linear-gradient(90deg, #7fc1ff, #63f7d6);
}

.materials {
  position: absolute;
  left: 50%;
  bottom: 92px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 12px;
  width: min(540px, calc(100vw - 48px));
  padding: 9px 12px;
  border-radius: 8px;
  transform: translateX(-50%);
  font-size: 12px;
  line-height: 1.25;
}

.materials span {
  white-space: nowrap;
  color: #e9f8ff;
}

.materials strong {
  color: #fff1a6;
}

.settings-gear {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.9), transparent 14px),
    linear-gradient(145deg, #324457, #121c26);
  color: #eefaff;
  font-size: 20px;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: inset 0 -6px 10px rgba(0, 0, 0, 0.2), 0 10px 22px rgba(0, 0, 0, 0.22);
  transition: transform 0.12s ease, background 0.2s ease;
}

.settings-gear:active {
  transform: translateY(1px) scale(0.96);
}

.settings-panel {
  position: fixed;
  right: 20px;
  bottom: 96px;
  width: min(260px, calc(100vw - 48px));
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(9, 19, 28, 0.92);
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 54px rgba(0, 0, 0, 0.26);
  display: none;
  z-index: 10;
  pointer-events: auto;
}

.settings-panel.open {
  display: block;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: #f8fbff;
  font-size: 13px;
  font-weight: 600;
}

.settings-close {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #f8fbff;
  cursor: pointer;
}

.settings-panel input {
  width: 100%;
  accent-color: var(--wind);
}

@media (max-width: 720px) {
  .settings-panel {
    right: 12px;
    bottom: 90px;
    width: min(88vw, 260px);
  }
}

.bottom-left {
  position: absolute;
  left: 22px;
  bottom: 22px;
  display: grid;
  gap: 12px;
  width: min(390px, calc(100vw - 44px));
}

.minimap {
  width: 160px;
  height: 160px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background: rgba(5, 18, 25, 0.55);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.28);
}

#map {
  display: block;
  width: 160px;
  height: 160px;
}

.prompt {
  min-height: 40px;
  padding: 11px 13px;
  border-radius: 8px;
  color: #e9f8ff;
  font-size: 13px;
  line-height: 1.35;
}

.bottom-right {
  position: absolute;
  right: 24px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  pointer-events: auto;
}

.mobile-controls {
  display: none;
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  pointer-events: auto;
  z-index: 2;
}

.dpad {
  display: grid;
  grid-template-columns: 52px 52px 52px;
  gap: 10px;
}

.dpad .spacer {
  visibility: hidden;
}

.mobile-key,
.mobile-action {
  width: 52px;
  height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 18px;
  color: white;
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.82), transparent 16px),
    linear-gradient(145deg, #324457, #121c26);
  box-shadow: inset 0 -6px 12px rgba(0, 0, 0, 0.2), 0 10px 22px rgba(0, 0, 0, 0.22);
  font-weight: 800;
  font-size: 16px;
  text-align: center;
  touch-action: none;
  pointer-events: auto;
}

.mobile-key.active,
.mobile-action:active {
  transform: translateY(1px) scale(0.96);
}

.action-buttons {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  gap: 10px;
}

.mobile-action.levelup {
  grid-column: span 3;
  width: 100%;
  min-width: 180px;
}

@media (max-width: 900px) {
  .mobile-controls {
    display: flex;
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  .mobile-controls {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    left: 12px;
    right: 12px;
    bottom: 12px;
    padding: 0;
    gap: 10px;
  }

  .dpad {
    grid-template-columns: repeat(6, 52px);
    grid-template-rows: 52px;
    gap: 10px;
  }

  .dpad .spacer {
    visibility: hidden;
    width: 52px;
    height: 52px;
  }

  .action-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
  }

  .mobile-action.levelup {
    grid-column: auto;
    width: auto;
    min-width: 52px;
  }
}

.skill {
  width: 54px;
  height: 54px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  color: white;
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.85), transparent 18px),
    linear-gradient(145deg, #324457, #121c26);
  box-shadow: inset 0 -6px 12px rgba(0, 0, 0, 0.22), 0 10px 24px rgba(0, 0, 0, 0.24);
  font-weight: 800;
  cursor: pointer;
}

.skill.anemo {
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.9), transparent 18px),
    linear-gradient(145deg, #5df3d2, #156a95);
}

.skill.glide {
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.9), transparent 18px),
    linear-gradient(145deg, #ffc857, #6f4cd5);
}

.skill.guide {
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.92), transparent 18px),
    linear-gradient(145deg, #ffe57a, #2db5a7);
}

.skill:active,
.skill.active {
  transform: translateY(1px) scale(0.98);
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 130px;
  max-width: min(520px, calc(100vw - 36px));
  min-height: 42px;
  padding: 12px 16px;
  border-radius: 8px;
  opacity: 0;
  transform: translateX(-50%) translateY(12px);
  transition: 0.25s ease;
  text-align: center;
  font-size: 14px;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.start {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #172633;
  color: var(--text);
}

.start-inner {
  width: min(620px, 100%);
  text-align: center;
}

.eyebrow {
  color: #19333d;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.start h2 {
  margin-top: 10px;
  font-size: clamp(42px, 8vw, 92px);
  line-height: 0.92;
  letter-spacing: 0;
}

.start p:not(.eyebrow) {
  max-width: 520px;
  margin: 20px auto 26px;
  color: #eefaff;
  font-size: 17px;
  line-height: 1.55;
}

.start button {
  min-width: 168px;
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  color: #08282d;
  background: linear-gradient(90deg, #fff1a6, #71f0d2);
  box-shadow: 0 18px 42px rgba(5, 21, 29, 0.32);
  font-weight: 900;
  cursor: pointer;
}

.start.hidden {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
  background: none !important;
  transition: opacity 0.45s ease;
}

@media (max-width: 720px) {
  .topbar {
    left: 12px;
    right: 12px;
  }

  .brand {
    min-width: 0;
    padding: 10px;
  }

  .quest {
    min-width: 0;
    max-width: 46vw;
    padding: 10px;
  }

  h1 {
    font-size: 14px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .meters {
    left: 50%;
    bottom: 96px;
    transform: translateX(-50%);
    width: min(340px, calc(100vw - 28px));
  }

  .materials {
    bottom: 142px;
    width: min(360px, calc(100vw - 24px));
    font-size: 11px;
  }

  .bottom-left {
    left: 12px;
    bottom: 12px;
  }

  .minimap {
    width: 124px;
    height: 124px;
  }

  #map {
    width: 124px;
    height: 124px;
  }

  .bottom-right {
    right: 12px;
    bottom: 12px;
    gap: 8px;
    padding: 9px;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 132px;
  }

  .skill {
    width: 46px;
    height: 46px;
  }
}
