@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap");

:root {
  --bg: #131313;
  --primary: #f2f2f2;
  --accent: #9d9d9d;
  --highlight: #f79d2a;
  --panel: #1b1b1b;
  --minimap-size: 160px;
  --spell-slot-size: 54px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Press Start 2P", monospace;
  background: var(--bg);
  color: var(--primary);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 32px 12px;
  gap: 20px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.game-shell {
  width: min(96vw, 1200px);
  position: relative;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-radius: 8px;
  background: rgba(20, 20, 20, 0.6);
  border: 1px solid #2b2b2b;
  font-size: 0.6rem;
  letter-spacing: 1px;
}

.home-link {
  font-size: 0.55rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--accent);
  padding: 6px 12px;
  border: 1px solid #353535;
  border-radius: 4px;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.home-link:hover,
.home-link:focus-visible {
  outline: none;
  border-color: var(--primary);
  background: var(--primary);
  color: #121212;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.status .label {
  color: var(--accent);
}

.spellbar {
  position: absolute;
  right: 18px;
  top: calc(16px + var(--minimap-size) + 6px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  z-index: 6;
}

.spell-slot {
  position: relative;
  width: var(--spell-slot-size);
  min-height: var(--spell-slot-size);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(12, 12, 16, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 160ms ease, opacity 160ms ease, border-color 160ms ease;
  color: rgba(160, 160, 160, 0.9);
}

.spell-slot--empty {
  opacity: 0.45;
}

.spell-slot--filled {
  opacity: 1;
  border-color: rgba(255, 255, 255, 0.2);
}

.spell-slot__key {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 0.45rem;
  letter-spacing: 1px;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: rgba(255, 255, 255, 0.82);
  text-transform: uppercase;
}

.spell-slot--filled .spell-slot__key {
  color: rgba(255, 255, 255, 0.95);
  background: rgba(0, 0, 0, 0.7);
}

.spell-slot__rune {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spell-slot__icon {
  width: calc(var(--spell-slot-size) * 0.68);
  height: calc(var(--spell-slot-size) * 0.68);
  filter: drop-shadow(0 0 6px currentColor);
  transition: transform 180ms ease, opacity 180ms ease;
}

.controls {
  color: var(--accent);
  text-align: right;
}

.hud-btn {
  font-family: inherit;
  font-size: 0.55rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.08);
  color: var(--primary);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.hud-btn:hover,
.hud-btn:focus-visible {
  outline: none;
  background: var(--primary);
  color: #111111;
  border-color: var(--primary);
  transform: translateY(-1px);
}

.pause-btn {
  margin-right: 12px;
  background: rgba(247, 157, 42, 0.28);
  border-color: rgba(247, 157, 42, 0.55);
  color: #ffe4b5;
}

.pause-btn--active {
  background: var(--primary);
  color: #111111;
  border-color: rgba(247, 157, 42, 0.9);
}

.pause-btn--active:hover,
.pause-btn--active:focus-visible {
  background: #ffe6b3;
  color: #111111;
}

.info-btn {
  margin-left: auto;
}

.playfield {
  position: relative;
  margin-top: 18px;
  border: 2px solid #2d2d2d;
  border-radius: 10px;
  overflow: hidden;
  background: radial-gradient(circle at center, #1d1d1d 0%, #131313 70%, #0d0d0d 100%);
  box-shadow: inset 0 0 0 2px #242424;
}

#game-canvas {
  width: 100%;
  height: auto;
  display: block;
}

#minimap {
  position: absolute;
  top: 16px;
  right: 16px;
  width: var(--minimap-size);
  height: var(--minimap-size);
  border: 2px solid rgba(255, 255, 255, 0.15);
  background: rgba(10, 10, 10, 0.65);
  border-radius: 12px;
  display: none;
}

.show-minimap #minimap {
  display: block;
}

.joystick {
  position: absolute;
  left: 20px;
  bottom: 20px;
  width: 96px;
  height: 96px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  background: rgba(20, 20, 20, 0.45);
  display: none;
  touch-action: none;
}

.joystick-thumb {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(247, 157, 42, 0.4);
  transform: translate(-50%, -50%);
}

.attack-btn {
  position: absolute;
  right: 24px;
  bottom: 30px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(247, 157, 42, 0.3);
  box-shadow: 0 0 14px rgba(247, 157, 42, 0.35);
  display: none;
}

.start-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 12, 12, 0.72);
  backdrop-filter: blur(3px);
  z-index: 10;
}

.start-overlay--hidden {
  display: none;
}

.start-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 20px;
  padding: 30px 34px 34px;
  max-width: min(90vw, 520px);
  background: linear-gradient(145deg, rgba(18, 18, 22, 0.96) 0%, rgba(12, 12, 16, 0.92) 100%);
  border: 2px solid rgba(244, 153, 44, 0.95);
  border-radius: 18px;
  box-shadow: 0 22px 40px rgba(0, 0, 0, 0.55);
  color: #f5f5f5;
  text-align: left;
  line-height: 1.6;
}

.start-card__header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.start-title {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #f49a28;
}

.start-subtitle {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(244, 188, 96, 0.95);
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.start-card__body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 0.7rem;
  color: rgba(244, 244, 244, 0.9);
}

.start-lede {
  margin: 0;
  color: rgba(244, 244, 244, 0.8);
}

.start-emphasis {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #ffffff;
}

.start-copy {
  margin: 0;
  color: rgba(244, 244, 244, 0.75);
}

.attack-btn:active {
  background: rgba(247, 157, 42, 0.6);
}

.achievement-banner {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translate(-50%, -40px);
  padding: 14px 24px;
  border-radius: 8px;
  font-size: 0.55rem;
  letter-spacing: 1.2px;
  color: #ffffff;
  background: rgba(10, 10, 10, 0.92);
  border: 2px solid rgba(244, 197, 64, 0.8);
  text-shadow: 0 2px 0 rgba(12, 12, 12, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 180ms ease;
  z-index: 20;
  box-shadow: 0 10px 16px rgba(0, 0, 0, 0.4);
}

.achievement-banner--visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.info-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.78);
  z-index: 1200;
  transition: opacity 160ms ease;
  opacity: 1;
}

.info-overlay--hidden {
  pointer-events: none;
  opacity: 0;
}

.info-card {
  width: min(560px, 92vw);
  max-height: min(80vh, 680px);
  background: #121212;
  border: 2px solid rgba(247, 157, 42, 0.55);
  border-radius: 12px;
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.55);
  display: grid;
  grid-template-rows: auto 1fr;
}

.info-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.info-card__header h2 {
  font-size: 1rem;
  color: var(--highlight);
}

.info-card__close {
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 120ms ease, color 120ms ease;
}

.info-card__close:hover,
.info-card__close:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, 0.12);
  color: #ffdf94;
}

.info-card__body {
  padding: 22px 26px 26px;
  overflow-y: auto;
  display: grid;
  gap: 20px;
  font-size: 0.6rem;
  letter-spacing: 0.6px;
  color: var(--accent);
}

.info-card__body p,
.info-card__body li {
  line-height: 1.7;
}

.info-tagline {
  font-size: 0.66rem;
  color: var(--primary);
}

.info-section h3 {
  font-size: 0.62rem;
  margin-bottom: 8px;
  color: var(--highlight);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.info-section ul {
  list-style: none;
  display: grid;
  gap: 10px;
}

.info-section li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.guide-icon {
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  vertical-align: middle;
  flex-shrink: 0;
}

.guide-icon svg {
  width: 26px;
  height: 26px;
}

.guide-text {
  flex: 1;
  color: var(--accent);
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 12, 12, 0.85);
  transition: opacity 150ms ease;
  z-index: 1000;
}

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

.overlay-card {
  background: #181818;
  border: 2px solid #353535;
  border-radius: 12px;
  padding: 28px 36px;
  display: grid;
  gap: 14px;
  text-align: center;
  color: var(--primary);
}

.overlay-card h1 {
  color: var(--highlight);
  font-size: 1.4rem;
}

.final-scoreboard {
  display: grid;
  grid-template-columns: repeat(2, auto auto);
  gap: 10px 18px;
  justify-content: center;
  font-size: 0.8rem;
  letter-spacing: 1px;
}

.final-scoreboard .label {
  color: var(--accent);
}

.share-preview {
  display: none;
  margin-top: 8px;
  background: #111;
  border: 1px dashed #3a3a3a;
  border-radius: 6px;
  padding: 10px;
}

.share-preview canvas {
  width: 100%;
  height: auto;
  display: block;
}

.btn {
  font-family: inherit;
  font-size: 0.7rem;
  color: var(--primary);
  background: transparent;
  border: 2px solid var(--primary);
  padding: 12px 18px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.btn:hover,
.btn:focus-visible {
  outline: none;
  background: var(--primary);
  color: #181818;
}

.start-card .start-btn {
  align-self: flex-end;
  padding: 14px 32px;
  font-size: 0.78rem;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  background: rgba(244, 153, 44, 0.95);
  border: 0;
  border-radius: 999px;
  color: #0f0f11;
  box-shadow: 0 12px 24px rgba(244, 153, 44, 0.32);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.start-card .start-btn:hover,
.start-card .start-btn:focus-visible {
  background: rgba(255, 181, 78, 0.98);
  box-shadow: 0 16px 32px rgba(244, 153, 44, 0.4);
  transform: translateY(-2px);
  outline: none;
}

.start-card .start-btn:active {
  transform: translateY(0);
  box-shadow: 0 10px 20px rgba(244, 153, 44, 0.32);
}

.credits {
  text-align: center;
  font-size: 0.55rem;
  color: var(--accent);
  letter-spacing: 1px;
}

.credits a {
  color: var(--primary);
  text-decoration: none;
}

.credits a:hover,
.credits a:focus-visible {
  text-decoration: underline;
  outline: none;
}

@media (max-width: 760px) {
  :root {
    --minimap-size: 140px;
    --spell-slot-size: 48px;
  }

  .game-shell {
    width: 100%;
  }

  .hud {
    font-size: 0.45rem;
    gap: 6px;
    padding: 12px 14px;
  }

  .home-link {
    font-size: 0.45rem;
    padding: 4px 10px;
  }

  .controls {
    width: 100%;
    text-align: center;
    font-size: 0.45rem;
  }

  .spellbar {
    position: static;
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 6px 0 0;
    padding: 0;
  }

  .spell-slot {
    width: var(--spell-slot-size);
    min-height: var(--spell-slot-size);
  }

  .spell-slot__key {
    font-size: 0.42rem;
    padding: 2px 4px;
  }

  .spell-slot__icon {
    width: calc(var(--spell-slot-size) * 0.68);
    height: calc(var(--spell-slot-size) * 0.68);
  }

  .joystick,
  .attack-btn {
    display: block;
  }

  body {
    padding: 16px 8px;
  }

  .overlay-card {
    width: min(92vw, 360px);
    padding: 20px;
    gap: 10px;
  }

  .final-scoreboard {
    grid-template-columns: repeat(2, auto auto);
    gap: 8px 12px;
    font-size: 0.7rem;
  }

  .btn {
    font-size: 0.55rem;
    padding: 10px 14px;
  }

  .share-preview {
    padding: 6px;
  }
}

@media (max-width: 760px) and (orientation: landscape) {
  .status {
    display: none;
  }

  .overlay-card {
    width: min(90vw, 420px);
  }
}
