/* 0003 */
:root {
  --ink: #17211d;
  --paper: rgba(255, 252, 242, 0.94);
  --paper-solid: #fffaf0;
  --leaf: #5ca56c;
  --moss: #2f7351;
  --aqua: #33a6a6;
  --sun: #f4b64a;
  --coral: #ee715f;
  --berry: #7b5bb8;
  --shadow: rgba(16, 24, 21, 0.24);
  --glass: rgba(255, 255, 255, 0.72);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #a8d8ff;
  color: var(--ink);
  touch-action: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans TC", sans-serif;
}

button {
  color: inherit;
  font: inherit;
}

.game-root {
  position: fixed;
  inset: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent 34%),
    #95cdf2;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hud {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    visibility 160ms ease;
}

.hud-brand,
.hud-stats,
.goal-strip,
.story-panel,
.quiz-panel,
.equipment-panel,
.reward-toast,
.save-status,
.start-panel,
.loading-card {
  border: 1px solid rgba(255, 255, 255, 0.66);
  background: var(--paper);
  box-shadow: 0 16px 34px var(--shadow);
}

.hud-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 9px 13px;
  border-radius: 8px;
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
}

.brand-mark {
  width: 22px;
  height: 22px;
  display: inline-block;
  border-radius: 6px;
  background:
    linear-gradient(135deg, transparent 0 46%, rgba(255, 255, 255, 0.7) 47% 53%, transparent 54%),
    linear-gradient(135deg, var(--leaf), var(--aqua));
  box-shadow: 0 6px 12px rgba(51, 166, 166, 0.28);
}

.hud-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-height: 44px;
  padding: 8px;
  border-radius: 8px;
}

.stat {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  gap: 7px;
  min-width: 76px;
  padding: 6px 9px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: inset 0 0 0 1px rgba(32, 47, 41, 0.08);
}

.stat span,
.goal-strip,
.quiz-topline,
.quiz-feedback {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.stat strong {
  min-width: 28px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.stat.streak {
  background: rgba(244, 182, 74, 0.22);
}

.goal-strip {
  position: absolute;
  z-index: 5;
  top: calc(max(16px, env(safe-area-inset-top)) + 62px);
  left: 50%;
  display: flex;
  transform: translateX(-50%);
  gap: 8px;
  align-items: center;
  max-width: min(620px, calc(100vw - 32px));
  min-height: 38px;
  padding: 7px 9px;
  border-radius: 8px;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    visibility 160ms ease;
}

.goal-strip span {
  min-width: 96px;
  padding: 6px 10px;
  border-radius: 7px;
  text-align: center;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.6);
}

.story-panel {
  position: absolute;
  z-index: 5;
  top: calc(max(16px, env(safe-area-inset-top)) + 112px);
  left: max(16px, env(safe-area-inset-left));
  display: grid;
  gap: 5px;
  width: min(390px, calc(100vw - 32px));
  min-height: 82px;
  padding: 12px 14px;
  border-radius: 8px;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    visibility 160ms ease;
}

.story-panel strong {
  font-size: 15px;
  line-height: 1.25;
}

.story-panel span,
.story-panel small {
  color: #40564c;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 800;
}

.story-panel small {
  color: #6a4c1c;
}

.icon-button,
.attack-button,
.review-button {
  display: inline-grid;
  place-items: center;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.icon-button svg,
.attack-button svg,
.review-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sound-button {
  position: absolute;
  z-index: 6;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: #17372e;
  background: rgba(255, 250, 240, 0.82);
  box-shadow: 0 12px 30px var(--shadow);
}

.sound-button.is-muted::after {
  content: "";
  position: absolute;
  width: 28px;
  height: 2px;
  transform: rotate(-38deg);
  border-radius: 999px;
  background: var(--coral);
}

.gear-button {
  position: absolute;
  z-index: 6;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 58px);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: #17372e;
  background: rgba(255, 250, 240, 0.82);
  box-shadow: 0 12px 30px var(--shadow);
}

.save-button {
  position: absolute;
  z-index: 6;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 116px);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: #17372e;
  background: rgba(255, 250, 240, 0.82);
  box-shadow: 0 12px 30px var(--shadow);
}

.hud-toggle-button {
  position: absolute;
  z-index: 7;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  display: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: #17372e;
  background: rgba(255, 250, 240, 0.88);
  box-shadow: 0 12px 30px var(--shadow);
  pointer-events: auto;
}

.exit-button {
  position: absolute;
  z-index: 6;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 174px);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: #17372e;
  background: rgba(255, 250, 240, 0.82);
  box-shadow: 0 12px 30px var(--shadow);
}

.save-status {
  position: absolute;
  z-index: 7;
  right: calc(max(16px, env(safe-area-inset-right)) + 54px);
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 120px);
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.save-status.hidden {
  opacity: 0;
  transform: translateX(8px);
  pointer-events: none;
}

.nearby-prompt,
.loot-prompt {
  position: absolute;
  z-index: 7;
  left: 50%;
  bottom: max(94px, calc(env(safe-area-inset-bottom) + 82px));
  transform: translateX(-50%);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.loot-prompt {
  bottom: max(148px, calc(env(safe-area-inset-bottom) + 136px));
}

.nearby-prompt.hidden,
.loot-prompt.hidden {
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
}

.review-button {
  grid-template-columns: 22px auto;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 999px;
  color: #fffaf0;
  background: linear-gradient(135deg, var(--moss), var(--aqua));
  box-shadow: 0 16px 28px rgba(47, 115, 81, 0.3);
  font-weight: 900;
}

.loot-button {
  background: linear-gradient(135deg, var(--sun), var(--coral));
  box-shadow: 0 16px 28px rgba(238, 113, 95, 0.26);
}

.quiz-panel {
  position: absolute;
  z-index: 10;
  left: 50%;
  top: 50%;
  width: min(530px, calc(100vw - 28px));
  max-height: min(620px, calc(100vh - 36px));
  padding: 18px;
  border-radius: 8px;
  transform: translate(-50%, -50%);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  overflow: auto;
}

.quiz-panel.hidden {
  opacity: 0;
  transform: translate(-50%, calc(-50% + 18px));
  pointer-events: none;
}

.quiz-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: #315547;
}

.quiz-topline .icon-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: #16372f;
  background: rgba(92, 165, 108, 0.18);
}

.quiz-panel h1 {
  margin: 18px 0 10px;
  font-size: clamp(24px, 4vw, 36px);
  line-height: 1.12;
  letter-spacing: 0;
}

.quiz-sentence {
  min-height: 24px;
  margin: 0 0 14px;
  color: #4c6159;
  font-size: 16px;
  line-height: 1.45;
}

.choice-list {
  display: grid;
  gap: 10px;
}

.choice-button {
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid rgba(23, 33, 29, 0.1);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 8px 18px rgba(19, 31, 27, 0.08);
  cursor: pointer;
  font-weight: 800;
  text-align: left;
}

.choice-button:hover,
.choice-button:focus-visible {
  outline: 3px solid rgba(51, 166, 166, 0.28);
}

.choice-button.correct {
  border-color: rgba(47, 115, 81, 0.55);
  background: rgba(92, 165, 108, 0.26);
}

.choice-button.wrong {
  border-color: rgba(238, 113, 95, 0.62);
  background: rgba(238, 113, 95, 0.18);
}

.quiz-feedback {
  min-height: 20px;
  margin: 13px 0 0;
  color: #3d5d50;
}

.equipment-panel {
  position: absolute;
  z-index: 11;
  right: max(16px, env(safe-area-inset-right));
  top: calc(max(16px, env(safe-area-inset-top)) + 116px);
  width: min(420px, calc(100vw - 28px));
  max-height: min(680px, calc(100vh - 152px));
  padding: 16px;
  border-radius: 8px;
  overflow: auto;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.equipment-panel.hidden {
  opacity: 0;
  transform: translateY(-12px);
  pointer-events: none;
}

.equipment-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.equipment-topline h1,
.equipment-panel h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.equipment-panel h2 {
  margin-top: 14px;
  font-size: 15px;
}

.equipment-topline .icon-button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(23, 33, 29, 0.08);
}

.gear-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.gear-summary span {
  min-height: 42px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.gear-slot-list,
.bag-list {
  display: grid;
  gap: 8px;
}

.gear-card {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 62px;
  padding: 9px;
  border: 1px solid rgba(23, 33, 29, 0.1);
  border-left: 5px solid var(--gear-color, #9aa4a0);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.66);
  box-shadow: 0 8px 18px rgba(19, 31, 27, 0.08);
}

.gear-card.empty {
  opacity: 0.72;
}

.gear-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: #fffaf0;
  background: var(--gear-color, #83918a);
  font-size: 20px;
  font-weight: 900;
}

.gear-card strong {
  display: block;
  margin-bottom: 2px;
  font-size: 14px;
}

.gear-card small {
  display: block;
  color: #4f6259;
  font-size: 12px;
  line-height: 1.35;
}

.gear-card button {
  min-width: 54px;
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  color: #fffaf0;
  background: #2f7351;
  cursor: pointer;
  font-weight: 900;
}

.bag-empty {
  min-height: 54px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
  color: #53675e;
  font-weight: 800;
}

.reward-toast {
  position: absolute;
  z-index: 9;
  left: 50%;
  top: calc(max(16px, env(safe-area-inset-top)) + 116px);
  max-width: min(520px, calc(100vw - 28px));
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 8px;
  transform: translateX(-50%);
  font-weight: 900;
  text-align: center;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.reward-toast.hidden {
  opacity: 0;
  transform: translate(-50%, -12px);
  pointer-events: none;
}

.loot-card {
  position: absolute;
  z-index: 12;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  gap: 8px;
  width: min(286px, calc(100vw - 36px));
  min-height: 322px;
  padding: 22px 20px 20px;
  border: 2px solid var(--loot-color, #e6a93d);
  border-radius: 8px;
  color: #17372e;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 250, 240, 0.94)),
    radial-gradient(circle at 50% 22%, var(--loot-glow, rgba(230, 169, 61, 0.28)), transparent 54%);
  box-shadow:
    0 24px 60px rgba(19, 31, 27, 0.28),
    inset 0 0 0 6px rgba(255, 255, 255, 0.38);
  text-align: center;
  transform: translate(-50%, -50%) scale(1);
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    visibility 180ms ease;
  pointer-events: auto;
}

.loot-card.hidden {
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -46%) scale(0.92);
  pointer-events: none;
}

.loot-card-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  color: #28473d;
  background: rgba(255, 255, 255, 0.64);
}

.loot-card small {
  color: #5a6b63;
  font-size: 12px;
  font-weight: 900;
}

.loot-card-icon {
  display: grid;
  place-items: center;
  width: 110px;
  height: 110px;
  margin-top: 6px;
  border-radius: 8px;
  color: #fffaf0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0)),
    var(--loot-color, #e6a93d);
  box-shadow: 0 18px 36px var(--loot-shadow, rgba(230, 169, 61, 0.28));
  font-size: 42px;
  font-weight: 1000;
}

.loot-card strong {
  max-width: 100%;
  font-size: 18px;
  line-height: 1.25;
}

.loot-card p {
  min-height: 42px;
  margin: 0;
  color: #365349;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.45;
}

.loot-card span {
  color: #7b3f31;
  font-size: 13px;
  font-weight: 900;
}

.touch-controls {
  position: absolute;
  z-index: 6;
  inset: auto max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}

.joystick {
  position: relative;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.14) 56%, rgba(23, 33, 29, 0.12)),
    rgba(255, 250, 240, 0.36);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.5),
    0 16px 30px rgba(19, 31, 27, 0.18);
  pointer-events: auto;
  touch-action: none;
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, var(--sun), var(--coral));
  box-shadow: 0 10px 22px rgba(238, 113, 95, 0.28);
}

.attack-button {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  color: #fffaf0;
  background: linear-gradient(135deg, var(--berry), var(--coral));
  box-shadow: 0 16px 32px rgba(123, 91, 184, 0.28);
  pointer-events: auto;
  touch-action: none;
}

.attack-button svg {
  width: 32px;
  height: 32px;
  stroke-width: 2.3;
}

.loading-screen {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(163, 215, 255, 0.94), rgba(203, 239, 213, 0.9)),
    #b9e4ff;
  transition:
    opacity 260ms ease,
    visibility 260ms ease;
}

.loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-card {
  width: min(340px, calc(100vw - 40px));
  padding: 28px;
  border-radius: 8px;
  text-align: center;
}

.loading-gem {
  display: block;
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  transform: rotate(45deg);
  border-radius: 10px;
  background: linear-gradient(135deg, var(--aqua), var(--sun));
  animation: pulse-gem 900ms ease-in-out infinite alternate;
}

.loading-card h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.loading-card p {
  margin: 8px 0 0;
  color: #466055;
  font-weight: 800;
}

.start-screen {
  position: absolute;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(41, 58, 52, 0.18), rgba(41, 58, 52, 0.36)),
    rgba(168, 216, 255, 0.72);
  transition:
    opacity 240ms ease,
    visibility 240ms ease;
}

.start-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-panel {
  width: min(520px, calc(100vw - 28px));
  max-height: min(760px, calc(100vh - 28px));
  padding: 24px;
  border-radius: 8px;
  overflow: auto;
}

.start-panel h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0;
  text-align: center;
}

.start-panel p {
  margin: 8px 0 16px;
  color: #40564c;
  font-weight: 800;
  text-align: center;
}

.name-field {
  display: grid;
  gap: 7px;
  font-weight: 900;
}

.name-field input {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(23, 33, 29, 0.12);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.start-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.start-actions button,
.load-save-button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  color: #fffaf0;
  background: linear-gradient(135deg, var(--moss), var(--aqua));
  cursor: pointer;
  font-weight: 900;
}

.start-actions button:nth-child(2) {
  background: linear-gradient(135deg, var(--berry), var(--coral));
}

.load-game-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.load-save-button {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  text-align: left;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  border: 1px solid rgba(23, 33, 29, 0.1);
}

.load-save-button strong,
.load-save-button small {
  display: block;
}

.load-save-button small {
  color: #53675e;
  margin-top: 3px;
}

.start-message {
  min-height: 20px;
  margin-bottom: 0 !important;
  color: #7b3f31 !important;
}

@keyframes pulse-gem {
  from {
    transform: translateY(0) rotate(45deg) scale(0.9);
  }
  to {
    transform: translateY(-8px) rotate(45deg) scale(1);
  }
}

@media (pointer: coarse), (max-width: 860px) {
  .touch-controls {
    display: flex;
  }

  .hud-toggle-button {
    display: grid;
  }

  .game-root.hud-collapsed .hud,
  .game-root.hud-collapsed .goal-strip,
  .game-root.hud-collapsed .story-panel {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px);
  }

  .game-root.hud-collapsed .reward-toast {
    top: calc(max(16px, env(safe-area-inset-top)) + 16px);
  }

  .game-root:not(.hud-collapsed) .hud-toggle-button {
    background: rgba(255, 250, 240, 0.98);
  }

  .sound-button {
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 86px);
  }

  .gear-button {
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 144px);
  }

  .save-button {
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 202px);
  }

  .exit-button {
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 260px);
  }

  .save-status {
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 206px);
  }
}

@media (max-width: 760px) {
  .hud {
    align-items: flex-start;
  }

  .hud-brand {
    width: 44px;
    min-width: 44px;
    padding: 11px;
  }

  .hud-brand span:last-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .hud-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(68px, 1fr));
    width: min(360px, calc(100vw - 84px));
  }

  .stat {
    min-width: 0;
    grid-template-columns: 1fr;
    gap: 0;
    padding: 5px 7px;
  }

  .stat strong {
    text-align: left;
  }

  .goal-strip {
    top: calc(max(16px, env(safe-area-inset-top)) + 104px);
    width: calc(100vw - 32px);
    overflow: hidden;
  }

  .story-panel {
    top: calc(max(16px, env(safe-area-inset-top)) + 152px);
    min-height: 74px;
  }

  .goal-strip span {
    min-width: 0;
    flex: 1 1 0;
    padding-inline: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .quiz-panel {
    padding: 15px;
  }

  .quiz-panel h1 {
    font-size: 25px;
  }

  .nearby-prompt {
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 156px);
  }

  .loot-prompt {
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 210px);
  }

  .equipment-panel {
    left: 14px;
    right: 14px;
    top: calc(max(16px, env(safe-area-inset-top)) + 150px);
    width: auto;
    max-height: calc(100vh - 176px);
  }
}

@media (max-width: 420px) {
  .hud-stats {
    grid-template-columns: repeat(2, minmax(72px, 1fr));
  }

  .goal-strip {
    top: calc(max(16px, env(safe-area-inset-top)) + 146px);
  }

  .story-panel {
    top: calc(max(16px, env(safe-area-inset-top)) + 194px);
  }

  .joystick {
    width: 114px;
    height: 114px;
  }

  .attack-button {
    width: 68px;
    height: 68px;
  }

  .gear-summary {
    grid-template-columns: 1fr;
  }

  .start-actions {
    grid-template-columns: 1fr;
  }

  .gear-card {
    grid-template-columns: 38px 1fr;
  }

  .gear-card button {
    grid-column: 1 / -1;
  }
}

/* Cinematic adventure interface */
:root {
  --night: #06101f;
  --night-soft: rgba(7, 19, 37, 0.82);
  --panel: rgba(10, 25, 45, 0.78);
  --panel-strong: rgba(8, 20, 38, 0.94);
  --line: rgba(145, 211, 255, 0.24);
  --cyan: #69e6ff;
  --cyan-deep: #159ec2;
  --gold: #ffd46b;
  --orange: #ff8e56;
  --violet: #a88cff;
  --white: #f7fbff;
  --muted: #a9c2d7;
}

body {
  color: var(--white);
  background: var(--night);
  font-family: ui-rounded, "SF Pro Rounded", "Noto Sans TC", system-ui, sans-serif;
}

.game-root {
  background: #071426;
  isolation: isolate;
}

.cinematic-vignette {
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(3, 8, 18, 0.28), transparent 22%, transparent 66%, rgba(3, 8, 18, 0.42)),
    radial-gradient(ellipse at center, transparent 46%, rgba(2, 7, 16, 0.34) 100%);
  mix-blend-mode: multiply;
}

.damage-flash {
  position: absolute;
  z-index: 18;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  box-shadow: inset 0 0 120px 36px rgba(255, 53, 77, 0.84);
}

.damage-flash.active {
  animation: damage-flash 420ms ease-out;
}

.combat-text-layer {
  position: absolute;
  z-index: 8;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.combat-float {
  position: absolute;
  left: 50%;
  top: 44%;
  color: #fff3b0;
  font-size: clamp(20px, 2.6vw, 36px);
  font-weight: 1000;
  letter-spacing: 0.02em;
  text-shadow: 0 3px 0 #632e14, 0 0 18px rgba(255, 209, 93, 0.7);
  animation: combat-float 850ms cubic-bezier(0.17, 0.76, 0.36, 1) forwards;
}

.hud-brand,
.hud-stats,
.goal-strip,
.story-panel,
.quiz-panel,
.equipment-panel,
.reward-toast,
.save-status,
.start-panel,
.loading-card,
.target-panel,
.energy-panel,
.objective-compass {
  border: 1px solid var(--line);
  color: var(--white);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.07), transparent 44%),
    var(--panel);
  box-shadow:
    0 18px 50px rgba(0, 7, 19, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px) saturate(1.25);
  -webkit-backdrop-filter: blur(16px) saturate(1.25);
}

.hud {
  top: max(18px, env(safe-area-inset-top));
  left: max(22px, env(safe-area-inset-left));
  right: max(22px, env(safe-area-inset-right));
  align-items: flex-start;
}

.hud-brand {
  min-height: 60px;
  padding: 9px 18px 9px 11px;
  border-radius: 16px 4px 16px 4px;
  border-left: 3px solid var(--cyan);
}

.brand-mark {
  width: 39px;
  height: 39px;
  border-radius: 11px 2px 11px 2px;
  transform: rotate(45deg);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.82), transparent 34%),
    linear-gradient(135deg, #13b4da, #78f1ff 48%, #ffd36c 50%, #fc945e);
  box-shadow: 0 0 24px rgba(105, 230, 255, 0.48);
}

.brand-copy {
  display: grid;
  gap: 0;
  line-height: 1.05;
}

.brand-copy small {
  color: var(--cyan);
  font-size: 9px;
  letter-spacing: 0.18em;
}

.brand-copy strong {
  font-size: 17px;
  letter-spacing: 0.05em;
}

.hud-stats {
  min-height: 60px;
  gap: 5px;
  padding: 7px;
  border-radius: 4px 16px 4px 16px;
}

.stat {
  position: relative;
  min-width: 80px;
  min-height: 44px;
  padding: 5px 10px;
  border-radius: 8px 2px 8px 2px;
  color: var(--white);
  background: rgba(255, 255, 255, 0.055);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.045);
}

.stat span {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.13em;
}

.stat strong {
  font-size: 15px;
}

.stat i,
.story-panel .quest-progress,
.target-panel > i,
.loading-card > i {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 5px;
  height: 3px;
  overflow: hidden;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.09);
}

.stat i b,
.story-panel .quest-progress b,
.target-panel > i b,
.loading-card > i b {
  display: block;
  width: 50%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan-deep), var(--cyan));
  box-shadow: 0 0 12px rgba(105, 230, 255, 0.75);
  transition: width 240ms ease;
}

.hp-stat i b {
  background: linear-gradient(90deg, #ff526f, #ffab6b);
  box-shadow: 0 0 12px rgba(255, 82, 111, 0.65);
}

.stat.streak {
  color: #2a1900;
  background: linear-gradient(135deg, rgba(255, 214, 107, 0.94), rgba(255, 137, 76, 0.92));
}

.stat.streak span {
  color: rgba(40, 21, 0, 0.7);
}

.goal-strip {
  top: calc(max(18px, env(safe-area-inset-top)) + 72px);
  min-height: 34px;
  padding: 4px 6px;
  border-radius: 3px 3px 12px 12px;
  background: rgba(7, 19, 37, 0.72);
}

.goal-strip span {
  color: #d9ecfa;
  background: transparent;
  font-size: 10px;
  letter-spacing: 0.09em;
}

.goal-strip span + span {
  border-left: 1px solid rgba(255, 255, 255, 0.12);
}

.story-panel {
  top: calc(max(18px, env(safe-area-inset-top)) + 82px);
  left: max(22px, env(safe-area-inset-left));
  width: min(430px, calc(100vw - 44px));
  min-height: 120px;
  padding: 14px 17px 17px;
  border-radius: 3px 18px 3px 18px;
  border-left: 3px solid var(--gold);
}

.story-kicker {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 2px;
}

.story-kicker span {
  color: var(--gold) !important;
  font-size: 9px !important;
  letter-spacing: 0.18em;
}

.story-kicker em {
  color: var(--cyan);
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
}

.story-panel > strong {
  font-size: 17px;
  letter-spacing: 0.03em;
}

.story-panel > span,
.story-panel > small {
  color: var(--muted);
  font-size: 11px;
}

.story-panel > small {
  color: #f5d998;
}

.story-panel .quest-progress {
  bottom: 9px;
}

.target-panel {
  position: absolute;
  z-index: 6;
  top: calc(max(18px, env(safe-area-inset-top)) + 118px);
  left: 50%;
  width: min(360px, calc(100vw - 40px));
  min-height: 52px;
  padding: 10px 14px 15px;
  border-radius: 4px 4px 15px 15px;
  transform: translateX(-50%);
  transition: opacity 180ms ease, transform 180ms ease;
}

.target-panel.hidden {
  opacity: 0;
  transform: translate(-50%, -8px);
  pointer-events: none;
}

.target-panel > div {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 900;
}

.target-panel > div span {
  color: #ffc2c8;
  letter-spacing: 0.06em;
}

.target-panel > i b {
  background: linear-gradient(90deg, #ff425f, #ff9f64);
  box-shadow: 0 0 13px rgba(255, 66, 95, 0.68);
}

.energy-panel {
  position: absolute;
  z-index: 6;
  left: max(22px, env(safe-area-inset-left));
  bottom: max(24px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 210px;
  padding: 8px 14px 8px 8px;
  border-radius: 36px 5px 5px 36px;
}

.energy-orb {
  display: flex;
  justify-content: center;
  align-items: baseline;
  width: 48px;
  height: 48px;
  border: 2px solid rgba(143, 235, 255, 0.75);
  border-radius: 50%;
  padding-top: 12px;
  color: #05233a;
  background: conic-gradient(var(--cyan) var(--energy, 0%), rgba(255, 255, 255, 0.14) 0);
  box-shadow: 0 0 24px rgba(105, 230, 255, 0.3), inset 0 0 0 5px rgba(8, 28, 49, 0.8);
  font-weight: 1000;
}

.energy-orb small {
  font-size: 8px;
}

.energy-panel > div:last-child {
  display: grid;
  gap: 2px;
}

.energy-panel strong {
  color: var(--cyan);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.energy-panel > div:last-child span {
  color: var(--muted);
  font-size: 10px;
}

.energy-panel.ready {
  animation: energy-ready 1.2s ease-in-out infinite alternate;
}

.objective-compass {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  gap: 0;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  transform: translateX(-50%);
  background: rgba(7, 19, 37, 0.64);
}

.objective-compass span {
  display: block;
  color: var(--cyan);
  font-size: 22px;
  line-height: 1;
  text-shadow: 0 0 12px var(--cyan);
  transition: transform 180ms ease;
}

.objective-compass small {
  color: var(--muted);
  font-size: 8px;
  letter-spacing: 0.12em;
}

.desktop-controls {
  position: absolute;
  z-index: 5;
  right: calc(max(22px, env(safe-area-inset-right)) + 60px);
  bottom: max(24px, env(safe-area-inset-bottom));
  display: flex;
  gap: 9px;
  color: rgba(225, 239, 250, 0.72);
  font-size: 9px;
  pointer-events: none;
}

.desktop-controls span {
  display: flex;
  align-items: center;
  gap: 4px;
}

kbd {
  min-width: 25px;
  padding: 4px 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-bottom-color: rgba(255, 255, 255, 0.42);
  border-radius: 5px;
  color: var(--white);
  background: rgba(4, 12, 24, 0.64);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
  font-family: inherit;
  font-size: 9px;
  font-weight: 800;
  text-align: center;
}

.sound-button,
.gear-button,
.save-button,
.exit-button,
.hud-toggle-button {
  width: 43px;
  height: 43px;
  border: 1px solid var(--line);
  border-radius: 12px 3px 12px 3px;
  color: #dff8ff;
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(0, 8, 20, 0.32), inset 0 1px rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
}

.icon-button:hover,
.review-button:hover,
.attack-button:hover,
.dash-button:hover,
.skill-button:hover {
  filter: brightness(1.14);
  transform: translateY(-1px);
}

.review-button {
  min-height: 52px;
  padding: 11px 22px;
  border: 1px solid rgba(135, 239, 255, 0.62);
  color: #052235;
  background: linear-gradient(135deg, #91f3ff, #38bddb);
  box-shadow: 0 0 30px rgba(72, 218, 244, 0.4);
  letter-spacing: 0.05em;
}

.loot-button {
  border-color: rgba(255, 221, 122, 0.68);
  background: linear-gradient(135deg, #ffe391, #ff9b55);
  box-shadow: 0 0 30px rgba(255, 186, 82, 0.38);
}

.quiz-panel {
  width: min(620px, calc(100vw - 28px));
  padding: 25px;
  border-radius: 4px 26px 4px 26px;
  border-top: 3px solid var(--cyan);
  background:
    radial-gradient(circle at 100% 0, rgba(50, 187, 222, 0.18), transparent 44%),
    var(--panel-strong);
}

.quiz-panel::before {
  content: "WORD CRYSTAL LINK";
  display: block;
  margin-bottom: 14px;
  color: rgba(105, 230, 255, 0.5);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.24em;
}

.quiz-topline {
  color: var(--cyan);
}

.quiz-topline .icon-button {
  color: var(--cyan);
  background: rgba(105, 230, 255, 0.1);
}

.quiz-panel h1 {
  color: var(--white);
  text-shadow: 0 0 28px rgba(105, 230, 255, 0.16);
}

.quiz-sentence {
  color: #bfd3e3;
}

.choice-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}

.choice-button {
  position: relative;
  min-height: 68px;
  padding: 13px 16px 13px 45px;
  border: 1px solid rgba(151, 199, 229, 0.18);
  border-radius: 4px 14px 4px 14px;
  color: #eaf7ff;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.05);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.choice-button::before {
  content: attr(data-key);
  position: absolute;
  left: 13px;
  top: 50%;
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border: 1px solid rgba(105, 230, 255, 0.45);
  border-radius: 7px 2px 7px 2px;
  color: var(--cyan);
  transform: translateY(-50%);
  font-size: 10px;
}

.choice-button:hover,
.choice-button:focus-visible {
  outline: none;
  border-color: rgba(105, 230, 255, 0.7);
  background: rgba(105, 230, 255, 0.12);
  transform: translateY(-2px);
}

.choice-button.correct {
  color: #eaffee;
  border-color: rgba(92, 255, 153, 0.72);
  background: rgba(39, 192, 104, 0.22);
  box-shadow: 0 0 24px rgba(70, 234, 139, 0.16);
}

.choice-button.wrong {
  color: #ffe7e9;
  border-color: rgba(255, 82, 111, 0.72);
  background: rgba(255, 64, 93, 0.18);
}

.quiz-feedback {
  color: #c5dfef;
}

.equipment-panel,
.loot-card {
  color: var(--white);
  background:
    radial-gradient(circle at 100% 0, rgba(168, 140, 255, 0.17), transparent 42%),
    var(--panel-strong);
}

.gear-card,
.gear-summary span,
.bag-empty {
  color: #eaf7ff;
  background: rgba(255, 255, 255, 0.07);
}

.gear-card small,
.bag-empty {
  color: var(--muted);
}

.reward-toast {
  border-color: rgba(255, 218, 105, 0.4);
  border-radius: 4px 14px 4px 14px;
  color: #fff1b5;
  background: rgba(28, 26, 20, 0.88);
  text-shadow: 0 0 12px rgba(255, 212, 107, 0.3);
}

.action-cluster {
  position: relative;
  display: grid;
  grid-template-columns: 54px 82px;
  grid-template-rows: 48px 58px;
  gap: 8px;
  align-items: end;
  justify-items: end;
  pointer-events: auto;
}

.attack-button {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: end;
  display: grid;
  place-items: center;
  gap: 0;
  width: 82px;
  height: 82px;
  border: 2px solid rgba(255, 223, 142, 0.76);
  color: #1e1604;
  background:
    radial-gradient(circle at 34% 28%, #fff4b5, transparent 24%),
    linear-gradient(135deg, #ffd46b, #ff754f);
  box-shadow: 0 0 34px rgba(255, 142, 86, 0.36), inset 0 0 0 5px rgba(255, 255, 255, 0.13);
}

.attack-button small,
.skill-button small {
  font-size: 8px;
  font-weight: 1000;
  letter-spacing: 0.08em;
}

.dash-button,
.skill-button {
  border: 1px solid rgba(166, 225, 255, 0.42);
  color: #e9f9ff;
  background: rgba(11, 32, 55, 0.88);
  box-shadow: 0 10px 24px rgba(0, 8, 20, 0.28), inset 0 1px rgba(255, 255, 255, 0.09);
  font-weight: 1000;
  pointer-events: auto;
}

.dash-button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.skill-button {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 15px 4px 15px 4px;
}

.skill-button.ready {
  border-color: var(--cyan);
  color: #041a2c;
  background: linear-gradient(135deg, #9cf4ff, #42c8e8);
  box-shadow: 0 0 30px rgba(105, 230, 255, 0.65);
  animation: energy-ready 800ms ease-in-out infinite alternate;
}

.chapter-intro {
  position: absolute;
  z-index: 24;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  transition: opacity 480ms ease, visibility 480ms ease;
}

.chapter-intro.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.chapter-intro-backdrop {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(3, 9, 19, 0.98), rgba(3, 12, 25, 0.84) 52%, rgba(3, 9, 19, 0.42)),
    radial-gradient(circle at 72% 46%, rgba(48, 201, 232, 0.23), transparent 35%);
  backdrop-filter: blur(8px);
}

.chapter-intro-backdrop::before,
.chapter-intro-backdrop::after {
  content: "";
  position: absolute;
  width: 46vw;
  height: 46vw;
  border: 1px solid rgba(105, 230, 255, 0.17);
  transform: rotate(45deg);
}

.chapter-intro-backdrop::before {
  right: -16vw;
  top: -20vw;
}

.chapter-intro-backdrop::after {
  right: 3vw;
  bottom: -32vw;
}

.chapter-intro-content {
  position: relative;
  width: min(720px, calc(100vw - 44px));
  padding: 34px 38px;
  border-left: 3px solid var(--cyan);
  text-align: left;
}

.chapter-intro-content::before {
  content: "";
  position: absolute;
  left: -3px;
  top: 0;
  width: 160px;
  height: 3px;
  background: linear-gradient(90deg, var(--cyan), transparent);
}

.chapter-intro-content > p:first-child {
  margin: 0 0 7px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 1000;
  letter-spacing: 0.28em;
}

.chapter-intro-content h1 {
  margin: 0;
  font-size: clamp(38px, 7vw, 78px);
  line-height: 1;
  letter-spacing: 0.04em;
  text-shadow: 0 0 42px rgba(105, 230, 255, 0.18);
}

.chapter-intro-content > span {
  display: inline-block;
  margin-top: 12px;
  padding: 6px 10px;
  color: #14200c;
  background: var(--gold);
  font-size: 11px;
  font-weight: 1000;
  letter-spacing: 0.1em;
}

.chapter-intro-content blockquote {
  max-width: 640px;
  margin: 30px 0 12px;
  color: #d8eaf6;
  font-size: clamp(17px, 2.2vw, 24px);
  font-weight: 800;
  line-height: 1.55;
}

.chapter-intro-content > p:not(:first-child) {
  color: var(--muted);
  font-size: 13px;
}

.chapter-intro-content button {
  min-width: 180px;
  min-height: 50px;
  margin-top: 20px;
  border: 1px solid rgba(160, 242, 255, 0.82);
  border-radius: 3px 14px 3px 14px;
  color: #052235;
  background: linear-gradient(135deg, #a5f6ff, #3ac5e5);
  box-shadow: 0 0 30px rgba(70, 211, 239, 0.3);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 1000;
}

.loading-screen {
  background:
    radial-gradient(circle at 50% 42%, rgba(42, 201, 234, 0.18), transparent 34%),
    linear-gradient(145deg, #06101f, #0a2039 58%, #101827);
}

.loading-card {
  width: min(390px, calc(100vw - 40px));
  padding: 34px;
  border-radius: 4px 24px 4px 24px;
  background: rgba(7, 19, 37, 0.72);
}

.loading-card > small {
  color: var(--cyan);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.2em;
}

.loading-card h1 {
  margin-top: 8px;
}

.loading-card p {
  color: var(--muted);
}

.loading-card > i {
  position: relative;
  display: block;
  height: 4px;
  margin-top: 22px;
}

.loading-card > i b {
  width: 30%;
  animation: loading-line 1.7s ease-in-out infinite;
}

.loading-gem {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: 13px 3px 13px 3px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.9), transparent 32%),
    linear-gradient(135deg, #1db9df, #7eeeff 48%, #ffd36c 50%, #f47958);
  box-shadow: 0 0 38px rgba(105, 230, 255, 0.48);
}

.start-screen {
  place-items: center start;
  padding: clamp(24px, 5vw, 76px);
  background:
    linear-gradient(90deg, rgba(3, 9, 19, 0.98) 0%, rgba(5, 17, 33, 0.86) 46%, rgba(5, 17, 33, 0.25) 100%),
    radial-gradient(circle at 72% 30%, rgba(105, 230, 255, 0.2), transparent 25%),
    linear-gradient(145deg, #071426, #173c52 55%, #7e5536);
}

.start-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(transparent 65%, rgba(2, 7, 15, 0.7)),
    repeating-linear-gradient(90deg, transparent 0 11vw, rgba(255, 255, 255, 0.015) 11vw calc(11vw + 1px));
}

.start-world {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.start-world::before {
  content: "";
  position: absolute;
  right: 8vw;
  top: 17%;
  width: min(36vw, 470px);
  aspect-ratio: 1;
  border: 1px solid rgba(153, 236, 255, 0.3);
  transform: rotate(45deg);
  box-shadow:
    0 0 0 24px rgba(105, 230, 255, 0.02),
    0 0 0 64px rgba(105, 230, 255, 0.018),
    0 0 80px rgba(105, 230, 255, 0.18);
}

.start-world span {
  position: absolute;
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d8f9ff;
  box-shadow: 0 0 18px 3px rgba(105, 230, 255, 0.75);
  animation: start-particle 5s ease-in-out infinite alternate;
}

.start-world span:nth-child(1) { left: 58%; top: 24%; animation-delay: -1s; }
.start-world span:nth-child(2) { left: 82%; top: 68%; animation-delay: -2.8s; }
.start-world span:nth-child(3) { left: 71%; top: 48%; animation-delay: -4s; }
.start-world span:nth-child(4) { left: 91%; top: 30%; animation-delay: -0.4s; }

.start-panel {
  position: relative;
  z-index: 2;
  width: min(570px, calc(100vw - 28px));
  max-height: min(820px, calc(100vh - 36px));
  padding: 29px 32px;
  border-radius: 4px 28px 4px 28px;
  border-left: 3px solid var(--cyan);
  text-align: left;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), transparent 44%),
    rgba(5, 16, 32, 0.82);
}

.start-emblem {
  position: absolute;
  top: 34px;
  right: 38px;
}

.start-emblem .loading-gem {
  width: 62px;
  height: 62px;
  margin: 0;
}

.start-eyebrow {
  margin: 0 0 8px !important;
  color: var(--cyan) !important;
  font-size: 9px;
  letter-spacing: 0.24em;
  text-align: left !important;
}

.start-panel h1 {
  display: grid;
  margin: 0 90px 0 0;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.03;
  letter-spacing: 0.04em;
  text-align: left;
  text-shadow: 0 0 32px rgba(105, 230, 255, 0.16);
}

.start-panel h1 small {
  color: #ffd875;
  font-size: 14px;
  letter-spacing: 0.2em;
}

.start-tagline {
  margin: 15px 0 18px !important;
  color: #d6e9f6 !important;
  text-align: left !important;
}

.start-features {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 22px;
}

.start-features span {
  padding: 6px 9px;
  border: 1px solid rgba(105, 230, 255, 0.18);
  border-radius: 9px 2px 9px 2px;
  color: var(--muted);
  background: rgba(105, 230, 255, 0.06);
  font-size: 9px;
  font-weight: 900;
}

.name-field {
  color: #dff3ff;
  font-size: 11px;
  letter-spacing: 0.08em;
}

.name-field input {
  min-height: 54px;
  border: 1px solid rgba(143, 213, 255, 0.27);
  border-radius: 3px 14px 3px 14px;
  color: var(--white);
  background: rgba(255, 255, 255, 0.07);
  outline: none;
}

.name-field input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(105, 230, 255, 0.1);
}

.name-field input::placeholder {
  color: rgba(184, 211, 229, 0.5);
}

.start-actions button,
.load-save-button {
  min-height: 56px;
  border: 1px solid rgba(123, 229, 255, 0.52);
  border-radius: 3px 14px 3px 14px;
  color: #062235;
  background: linear-gradient(135deg, #a2f4ff, #3cc4e2);
  box-shadow: 0 0 24px rgba(62, 200, 228, 0.2);
}

.start-actions button {
  display: grid;
  place-items: center;
  line-height: 1.1;
}

.start-actions button small {
  font-size: 8px;
  letter-spacing: 0.16em;
}

.start-actions button:nth-child(2) {
  border-color: rgba(180, 151, 255, 0.52);
  color: #f3edff;
  background: linear-gradient(135deg, #725cc5, #a260b9);
}

.load-save-button {
  color: #eaf7ff;
  background: rgba(255, 255, 255, 0.07);
}

.load-save-button small {
  color: var(--muted);
}

@keyframes damage-flash {
  0% { opacity: 0; }
  18% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes combat-float {
  0% { opacity: 0; transform: translate(-50%, 12px) scale(0.72); }
  18% { opacity: 1; transform: translate(-50%, 0) scale(1.15); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--drift, 0px)), -90px) scale(0.9); }
}

@keyframes energy-ready {
  from { filter: brightness(1); }
  to { filter: brightness(1.28); }
}

@keyframes loading-line {
  0% { width: 8%; transform: translateX(0); }
  50% { width: 54%; transform: translateX(55%); }
  100% { width: 8%; transform: translateX(1100%); }
}

@keyframes start-particle {
  from { transform: translateY(12px) scale(0.7); opacity: 0.35; }
  to { transform: translateY(-24px) scale(1.35); opacity: 1; }
}

@media (pointer: coarse), (max-width: 860px) {
  .desktop-controls,
  .energy-panel {
    display: none;
  }

  .objective-compass {
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 124px);
    width: 52px;
    height: 52px;
  }

  .touch-controls {
    align-items: flex-end;
  }

  .story-panel {
    top: calc(max(16px, env(safe-area-inset-top)) + 112px);
  }

  .target-panel {
    top: auto;
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 192px);
  }
}

@media (max-width: 760px) {
  .hud {
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
  }

  .hud-brand {
    width: 48px;
    min-width: 48px;
    height: 48px;
    min-height: 48px;
    padding: 8px;
  }

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

  .brand-copy {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
  }

  .hud-stats {
    grid-template-columns: repeat(3, minmax(62px, 1fr));
    width: min(350px, calc(100vw - 72px));
    min-height: 48px;
    padding: 5px;
  }

  .stat {
    min-height: 35px;
  }

  .stat:nth-child(4),
  .stat:nth-child(5) {
    display: none;
  }

  .goal-strip {
    top: calc(max(16px, env(safe-area-inset-top)) + 58px);
  }

  .story-panel {
    top: calc(max(16px, env(safe-area-inset-top)) + 100px);
    left: 12px;
    width: min(380px, calc(100vw - 72px));
    min-height: 104px;
  }

  .story-panel > span {
    display: none;
  }

  .choice-list {
    grid-template-columns: 1fr;
  }

  .choice-button {
    min-height: 54px;
  }

  .start-screen {
    place-items: center;
    padding: 14px;
  }

  .start-panel {
    padding: 25px 22px;
  }

  .start-emblem {
    top: 28px;
    right: 27px;
  }

  .start-emblem .loading-gem {
    width: 48px;
    height: 48px;
  }

  .chapter-intro-content {
    padding: 25px 24px;
  }
}

@media (max-width: 420px) {
  .start-panel h1 {
    margin-right: 64px;
    font-size: 32px;
  }

  .start-panel h1 small {
    font-size: 11px;
  }

  .start-features span:nth-child(3) {
    display: none;
  }

  .story-panel {
    min-height: 96px;
  }

  .story-panel > small {
    font-size: 9px;
  }

  .joystick {
    width: 104px;
    height: 104px;
  }

  .action-cluster {
    grid-template-columns: 45px 72px;
    grid-template-rows: 42px 50px;
  }

  .attack-button {
    width: 72px;
    height: 72px;
  }

  .dash-button {
    width: 42px;
    height: 42px;
  }

  .skill-button {
    width: 48px;
    height: 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

/* Generated equipment artwork */
.gear-art {
  color: transparent !important;
  background-color: #071426 !important;
  background-image: url("../assets/equipment-atlas-0001.png") !important;
  background-repeat: no-repeat !important;
  background-size: 200% 200% !important;
  box-shadow:
    0 12px 28px rgba(0, 7, 20, 0.34),
    inset 0 0 0 2px var(--gear-color, var(--loot-color, rgba(105, 230, 255, 0.56))) !important;
}

.gear-art.slot-weapon { background-position: 0 0 !important; }
.gear-art.slot-armor { background-position: 100% 0 !important; }
.gear-art.slot-boots { background-position: 0 100% !important; }
.gear-art.slot-charm { background-position: 100% 100% !important; }

.loot-card-icon.gear-art {
  width: 166px;
  height: 166px;
  border-radius: 20px 5px 20px 5px;
  border: 2px solid var(--loot-color, #69e6ff);
  font-size: 0;
}

.weather-panel {
  position: absolute;
  z-index: 6;
  top: calc(max(18px, env(safe-area-inset-top)) + 218px);
  left: max(22px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 176px;
  min-height: 52px;
  padding: 7px 14px 7px 8px;
  border: 1px solid rgba(145, 211, 255, 0.26);
  border-radius: 28px 6px 6px 28px;
  color: var(--white);
  background: rgba(7, 20, 38, 0.76);
  box-shadow: 0 14px 34px rgba(0, 7, 19, 0.28), inset 0 1px rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
  pointer-events: none;
}

.weather-panel > span {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(105, 230, 255, 0.5);
  border-radius: 50%;
  color: #b7f6ff;
  background: rgba(73, 205, 234, 0.12);
  box-shadow: 0 0 18px rgba(105, 230, 255, 0.18);
  font-size: 21px;
}

.weather-panel > div {
  display: grid;
  gap: 1px;
}

.weather-panel small {
  color: #72dff3;
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.weather-panel strong {
  font-size: 11px;
  letter-spacing: 0.05em;
}

.weather-panel[data-weather="storm"] > span,
.weather-panel[data-weather="sandstorm"] > span {
  border-color: rgba(255, 194, 91, 0.72);
  color: #ffe18e;
  background: rgba(255, 166, 64, 0.16);
  box-shadow: 0 0 20px rgba(255, 177, 62, 0.32);
}

.weather-panel.weather-changed {
  animation: weather-arrival 650ms cubic-bezier(0.18, 0.8, 0.25, 1);
}

.gear-card {
  grid-template-columns: 64px 1fr auto;
  min-height: 84px;
}

.gear-icon.gear-art {
  width: 64px;
  height: 64px;
  border-radius: 14px 4px 14px 4px;
  font-size: 0;
}

@media (max-width: 420px) {
  .gear-card {
    grid-template-columns: 54px 1fr;
  }

  .gear-icon.gear-art {
    width: 54px;
    height: 54px;
  }

  .loot-card-icon.gear-art {
    width: 138px;
    height: 138px;
  }
}

@keyframes weather-arrival {
  0% { opacity: 0; transform: translateX(-18px) scale(0.94); }
  55% { opacity: 1; transform: translateX(4px) scale(1.02); }
  100% { transform: translateX(0) scale(1); }
}

@media (pointer: coarse), (max-width: 860px) {
  .weather-panel {
    top: auto;
    left: 50%;
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 190px);
    min-width: 0;
    padding-right: 9px;
    transform: translateX(-50%);
  }

  .weather-panel small {
    display: none;
  }

  .weather-panel.weather-changed {
    animation: weather-arrival-mobile 650ms cubic-bezier(0.18, 0.8, 0.25, 1);
  }
}

@keyframes weather-arrival-mobile {
  0% { opacity: 0; transform: translate(-50%, 12px) scale(0.92); }
  100% { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
