:root {
  --bg: #0c1518;
  --panel: rgba(9, 18, 21, 0.8);
  --panel-border: rgba(190, 214, 207, 0.18);
  --accent: #d1ba78;
  --accent-strong: #e2c98a;
  --text: #eef0e5;
  --muted: #97a8a3;
  --success: #84d39f;
  --danger: #e7a3a0;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background:
    radial-gradient(circle at top, rgba(48, 77, 84, 0.45), transparent 36%),
    linear-gradient(180deg, #142126 0%, #0a1315 100%);
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
}

#appShell,
#gameCanvas {
  width: 100%;
  height: 100%;
}

#gameCanvas {
  display: block;
  touch-action: none;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(8, 14, 15, 0.3), rgba(8, 14, 15, 0.7)),
    radial-gradient(circle at center, rgba(209, 186, 120, 0.12), transparent 45%);
  z-index: 20;
}

.panel {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.heroPanel {
  width: min(480px, 100%);
  padding: 28px;
  border-radius: 20px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 12px;
}

.heroPanel h1 {
  margin: 0;
  font-size: clamp(32px, 6vw, 52px);
  line-height: 0.95;
}

.subtitle {
  margin: 14px 0 22px;
  color: var(--muted);
  line-height: 1.5;
}

.label,
.statusText,
.metaLine,
.helpCopy {
  font-family: "Trebuchet MS", Verdana, sans-serif;
}

.label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.textInput {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 18px;
  margin-bottom: 14px;
}

.textInput:focus {
  outline: none;
  border-color: rgba(209, 186, 120, 0.6);
  box-shadow: 0 0 0 3px rgba(209, 186, 120, 0.16);
}

.characterPicker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 16px;
}

.characterOption {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: 800 15px/1 "Trebuchet MS", Verdana, sans-serif;
  cursor: pointer;
}

.characterOption input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.characterOption:has(input:checked) {
  border-color: rgba(209, 186, 120, 0.78);
  background: rgba(209, 186, 120, 0.14);
  box-shadow: inset 0 0 0 1px rgba(209, 186, 120, 0.28);
}

.primaryButton {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 15px 16px;
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  color: #1b1608;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

.primaryButton:hover {
  filter: brightness(1.05);
}

.statusText {
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.helpCopy {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  padding: 18px;
  z-index: 10;
}

.hudPanel {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 14px;
  min-width: 180px;
}

.rightPanel {
  position: absolute;
  top: 18px;
  right: 18px;
}

.coordPanel {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: max-content;
  max-width: calc(100% - 36px);
  padding: 10px 16px;
  border-radius: 14px;
}

.coordReadout {
  color: #f8edd0;
  font: 800 15px/1.2 "Trebuchet MS", Verdana, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.38);
}

.coordFpsReadout {
  color: rgba(238, 240, 229, 0.78);
  font: 700 12px/1.15 "Trebuchet MS", Verdana, sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mapOverlay {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 14px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(8, 12, 12, 0.78);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.42);
  pointer-events: none;
}

.mapOverlay[hidden] {
  display: none;
}

.mapOverlay canvas {
  width: min(72vw, 520px);
  height: min(72vw, 520px);
  image-rendering: pixelated;
}

.mapReadout {
  color: #f8edd0;
  font: 800 13px/1 "Trebuchet MS", Verdana, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.statusBadge {
  color: var(--success);
  font: 700 14px/1.2 "Trebuchet MS", Verdana, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.swordButton,
.growButton {
  position: absolute;
  bottom: 22px;
  width: 86px;
  height: 86px;
  display: grid;
  place-items: center;
  border: 3px solid rgba(255, 255, 255, 0.78);
  border-radius: 10px;
  background: rgba(73, 73, 73, 0.34);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  cursor: pointer;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.swordButton {
  right: 22px;
}

.growButton {
  right: 122px;
  border-color: rgba(159, 219, 112, 0.78);
  background: rgba(38, 77, 36, 0.42);
}

.swordButton::before,
.growButton::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.08);
  opacity: 0;
  transition: opacity 0.08s ease;
}

.swordButton.is-active::before,
.swordButton:active::before,
.growButton.is-active::before,
.growButton:active::before {
  opacity: 1;
}

.swordButtonIcon {
  position: relative;
  width: 12px;
  height: 58px;
  border-radius: 8px 8px 2px 2px;
  background: linear-gradient(90deg, #aeb8c0 0%, #f8fbff 42%, #8f9ba6 100%);
  transform: rotate(42deg);
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.3);
}

.swordButtonIcon::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 40px;
  height: 8px;
  border-radius: 6px;
  background: linear-gradient(180deg, #f3d47b, #a97920);
  transform: translateX(-50%);
}

.swordButtonIcon::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -17px;
  width: 10px;
  height: 24px;
  border-radius: 5px;
  background: linear-gradient(90deg, #6d3f1d, #c08a3c, #5a3217);
  transform: translateX(-50%);
}

.swordButtonIcon.fistIcon {
  width: 38px;
  height: 30px;
  border-radius: 12px 12px 14px 14px;
  background: linear-gradient(180deg, #9d6c42, #633a22);
  transform: rotate(-12deg);
  box-shadow:
    -16px -9px 0 -5px #8b5b36,
    -5px -12px 0 -5px #a87547,
    6px -12px 0 -5px #8b5b36,
    17px -8px 0 -5px #704427,
    0 0 14px rgba(255, 219, 151, 0.24);
}

.swordButtonIcon.fistIcon::before {
  left: auto;
  right: -9px;
  bottom: 2px;
  width: 18px;
  height: 15px;
  border-radius: 10px;
  background: #80502e;
  transform: rotate(24deg);
}

.swordButtonIcon.fistIcon::after {
  left: 8px;
  bottom: -18px;
  width: 19px;
  height: 22px;
  border-radius: 8px;
  background: linear-gradient(180deg, #7b4c2d, #4f2e1c);
  transform: rotate(8deg);
}

.growButtonIcon {
  position: relative;
  width: 18px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(180deg, #7c4d2d, #4c2e1b);
}

.growButtonIcon::before,
.growButtonIcon::after {
  content: "";
  position: absolute;
  top: 8px;
  width: 34px;
  height: 22px;
  border-radius: 100% 0;
  background: linear-gradient(180deg, #8fd45b, #2f7b2f);
}

.growButtonIcon::before {
  right: 10px;
  transform: rotate(-30deg);
}

.growButtonIcon::after {
  left: 10px;
  transform: scaleX(-1) rotate(-30deg);
}

.mobileJoystick {
  position: absolute;
  left: 22px;
  bottom: 22px;
  width: 118px;
  height: 118px;
  display: none;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  background: rgba(12, 20, 18, 0.28);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.mobileJoystick::before {
  content: "";
  position: absolute;
  inset: 22px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
}

.mobileJoystickKnob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(226, 201, 138, 0.86), rgba(132, 112, 55, 0.8));
  border: 2px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
  transform: translate(-50%, -50%);
}

@media (max-width: 720px) {
  .heroPanel {
    padding: 22px;
  }

  .rightPanel {
    top: auto;
    right: auto;
    left: 18px;
    bottom: 18px;
  }

  .coordPanel {
    top: 18px;
    right: 18px;
    left: auto;
    transform: none;
  }

  .swordButton {
    right: 18px;
    bottom: 18px;
    width: 78px;
    height: 78px;
  }

  .growButton {
    right: 108px;
    bottom: 18px;
    width: 78px;
    height: 78px;
  }
}

@media (pointer: coarse) {
  .rightPanel {
    display: none;
  }

  .mobileJoystick {
    display: block;
  }
}

@media (pointer: coarse) and (max-width: 720px) {
  .mobileJoystick {
    left: 18px;
    bottom: 18px;
    width: 106px;
    height: 106px;
  }

  .mobileJoystickKnob {
    width: 44px;
    height: 44px;
  }
}
