* {
  box-sizing: border-box;
}

:root {
  --bg: #050816;
  --panel: rgba(15, 23, 42, 0.78);
  --panel-strong: rgba(15, 23, 42, 0.96);
  --text: #e5e7eb;
  --muted: #94a3b8;
  --gold: #facc15;
  --cyan: #22d3ee;
  --pink: #f472b6;
  --green: #22c55e;
  --danger: #ef4444;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 20% 20%, rgba(34, 211, 238, 0.12), transparent 34%),
    radial-gradient(circle at 80% 10%, rgba(244, 114, 182, 0.14), transparent 30%),
    radial-gradient(circle at 50% 100%, rgba(250, 204, 21, 0.10), transparent 34%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app {
  width: min(1480px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 800;
  font-size: 12px;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 64px);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.subtitle {
  max-width: 640px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 16px;
}

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

button {
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  padding: 11px 15px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.24);
}

button.primary {
  background: linear-gradient(135deg, #14b8a6, #3b82f6);
  border-color: transparent;
}

button.danger {
  color: #fecaca;
}

.game-shell {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 26px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: 0 30px 100px rgba(0,0,0,0.42);
}

.top-bar,
.bottom-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--muted);
}

.top-bar span,
.bottom-bar span {
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.055);
}

#gold {
  color: var(--gold);
}

#gameCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #020617;
  cursor: crosshair;
}

.tips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 16px;
}

.tips article {
  padding: 16px;
  border-radius: 22px;
  background: rgba(15, 23, 42, 0.62);
  border: 1px solid rgba(255,255,255,0.09);
}

.tips h3 {
  margin: 0 0 6px;
}

.tips p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 760px) {
  .hero {
    display: block;
  }

  .controls {
    justify-content: flex-start;
    margin-top: 16px;
  }

  .tips {
    grid-template-columns: 1fr;
  }
}


.dangerText {
  color: #fb7185 !important;
}

#gameCanvas {
  max-height: 78vh;
}


/* Canvas wrapper allows the mobile joystick to sit on top of the game window. */
.canvas-wrap {
  position: relative;
  width: 100%;
}

#mobileTouchLayer {
  display: none;
}

/* Mobile-only transparent in-game joystick + attack button. */
@media (max-width: 900px), (pointer: coarse) {
  html,
  body {
    overscroll-behavior: none;
  }

  body.mobile-playing {
    overflow: hidden;
    touch-action: none;
  }

  .app {
    width: 100%;
    padding: 8px 0 16px;
  }

  .hero {
    padding: 0 12px;
    margin-bottom: 10px;
  }

  .hero h1 {
    font-size: clamp(28px, 9vw, 42px);
  }

  .subtitle {
    font-size: 13px;
  }

  .controls {
    gap: 8px;
  }

  button {
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 13px;
  }

  .game-shell {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .top-bar,
  .bottom-bar {
    padding: 7px 8px;
    gap: 6px;
    font-size: 11px;
    justify-content: center;
  }

  .top-bar span,
  .bottom-bar span {
    padding: 5px 7px;
  }

  #gameCanvas {
    width: 100vw;
    height: auto;
    max-height: 62vh;
    touch-action: none;
  }

  #mobileTouchLayer {
    display: block;
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 12;
    touch-action: none;
  }

  .mobile-joystick {
    position: absolute;
    left: 22px;
    bottom: 24px;
    width: 132px;
    height: 132px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.18);
    border: 2px solid rgba(255, 255, 255, 0.18);
    box-shadow: inset 0 0 28px rgba(255,255,255,0.06), 0 10px 30px rgba(0,0,0,0.16);
    backdrop-filter: blur(4px);
    pointer-events: auto;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-joystick::before {
    content: "";
    position: absolute;
    inset: 33px;
    border-radius: 999px;
    border: 1px dashed rgba(255,255,255,0.20);
  }

  .mobile-joystick-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 54px;
    height: 54px;
    border-radius: 999px;
    transform: translate(-50%, -50%);
    background: rgba(34, 211, 238, 0.32);
    border: 2px solid rgba(255,255,255,0.42);
    box-shadow: 0 0 22px rgba(34,211,238,0.25);
    pointer-events: none;
  }

  .mobile-attack-button {
    position: absolute;
    right: 26px;
    bottom: 34px;
    width: 104px;
    height: 104px;
    border-radius: 999px;
    padding: 0;
    background: rgba(239, 68, 68, 0.20);
    border: 2px solid rgba(248, 113, 113, 0.42);
    color: rgba(255,255,255,0.88);
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 0.04em;
    box-shadow: 0 10px 30px rgba(0,0,0,0.18), inset 0 0 24px rgba(255,255,255,0.05);
    pointer-events: auto;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-attack-button:active,
  .mobile-attack-button.isPressed {
    transform: scale(0.94);
    background: rgba(239, 68, 68, 0.36);
    border-color: rgba(248, 113, 113, 0.72);
  }

  .tips {
    grid-template-columns: 1fr;
    padding: 0 12px;
  }
}

@media (max-width: 420px) {
  #gameCanvas {
    max-height: 56vh;
  }

  .mobile-joystick {
    left: 16px;
    bottom: 18px;
    width: 112px;
    height: 112px;
  }

  .mobile-joystick-knob {
    width: 46px;
    height: 46px;
  }

  .mobile-attack-button {
    right: 18px;
    bottom: 26px;
    width: 88px;
    height: 88px;
    font-size: 15px;
  }
}
