@import url('https://fonts.googleapis.com/css2?family=Bai+Jamjuree:wght@400;500;600;700&family=Archivo+Black&display=swap');

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  min-height: 100vh;
  background: linear-gradient(160deg, #050403 0%, #0b0a07 35%, #16120b 70%, #0b0906 100%);
  color: #e9e4d8;
  font-family: 'Bai Jamjuree', 'Segoe UI', system-ui, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 600px 400px at 20% 30%, rgba(242, 193, 78, 0.07) 0%, transparent 70%),
    radial-gradient(ellipse 500px 350px at 80% 70%, rgba(212, 160, 23, 0.05) 0%, transparent 70%),
    radial-gradient(ellipse 400px 300px at 50% 85%, rgba(250, 237, 200, 0.04) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.game-shell {
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 12px;
  position: relative;
  z-index: 1;
}

/* ── Touch Controls ─────────────────────────────────────────────────── */
.touch-controls {
  position: fixed;
  inset: auto 0 0 0;
  bottom: env(safe-area-inset-bottom, 0);
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 20px 22px;
  pointer-events: none;
  z-index: 5;
}

body.touch-device .touch-controls {
  display: flex;
}

.touch-cluster {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  pointer-events: auto;
}

.touch-btn {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 1.5px solid rgba(242, 193, 78, 0.3);
  background: rgba(12, 10, 6, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #faedc8;
  font-size: 24px;
  font-family: inherit;
  display: grid;
  place-items: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  transition: transform 0.08s ease, background 0.12s ease;
}

.touch-btn.pressed {
  transform: scale(0.9);
  background: rgba(242, 193, 78, 0.35);
  border-color: rgba(242, 193, 78, 0.7);
}

.touch-jump { width: 76px; height: 76px; font-size: 30px; background: rgba(242, 193, 78, 0.2); border-color: rgba(242, 193, 78, 0.5); }
.touch-dash { background: rgba(212, 160, 23, 0.18); border-color: rgba(212, 160, 23, 0.45); }
.touch-attack { background: rgba(250, 237, 200, 0.14); border-color: rgba(250, 237, 200, 0.4); }
.touch-special { background: rgba(167, 139, 250, 0.18); border-color: rgba(167, 139, 250, 0.48); color: #f5d0fe; }

#gameCanvas {
  width: min(calc(100vw - 24px), calc((100vh - 24px) * 16 / 9), 1280px);
  height: auto;
  max-height: calc(100vh - 24px);
  aspect-ratio: 16 / 9;
  display: block;
  border-radius: 16px;
  border: 2px solid rgba(242, 193, 78, 0.22);
  box-shadow:
    0 0 0 1px rgba(242, 193, 78, 0.08),
    0 25px 80px -12px rgba(0, 0, 0, 0.7),
    0 8px 36px -8px rgba(212, 160, 23, 0.2),
    inset 0 1px 0 rgba(250, 237, 200, 0.08);
  image-rendering: pixelated;
  transition: box-shadow 0.4s ease;
}

#gameCanvas:hover {
  box-shadow:
    0 0 0 1px rgba(242, 193, 78, 0.14),
    0 30px 90px -12px rgba(0, 0, 0, 0.75),
    0 8px 44px -8px rgba(212, 160, 23, 0.3),
    inset 0 1px 0 rgba(250, 237, 200, 0.1);
}

@media (max-width: 768px) {
  .game-shell {
    padding: 4px;
  }
  #gameCanvas {
    width: min(calc(100vw - 8px), calc((100vh - 8px) * 16 / 9));
    max-height: calc(100vh - 8px);
    border-radius: 10px;
  }
  .touch-controls {
    padding: 0 8px 14px;
  }
  .touch-cluster {
    gap: 8px;
  }
  .touch-btn {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
  .touch-jump {
    width: 60px;
    height: 60px;
    font-size: 25px;
  }
}

@media (max-height: 520px) {
  .touch-controls {
    padding: 0 14px 12px;
  }
  .touch-cluster {
    gap: 10px;
  }
  .touch-btn {
    width: 52px;
    height: 52px;
    font-size: 21px;
  }
  .touch-jump {
    width: 64px;
    height: 64px;
    font-size: 26px;
  }
}
