* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #080d18;
  color: #fff8d3;
  font-family: Arial, Helvetica, sans-serif;
  touch-action: none;
}

#shell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 20%, rgba(246, 220, 117, 0.15), transparent 34%),
    linear-gradient(180deg, #101927, #060911);
}

canvas {
  width: min(100vw, calc(100vh * 1.5));
  height: min(100vh, calc(100vw / 1.5));
  max-width: 100vw;
  max-height: 100vh;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.panel {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(740px, calc(100vw - 24px));
  max-height: calc(100vh - 30px);
  overflow-y: auto;
  transform: translate(-50%, -50%);
  padding: 22px;
  border: 2px solid rgba(246, 220, 117, 0.55);
  border-radius: 12px;
  background: rgba(8, 13, 24, 0.96);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
  text-align: center;
  z-index: 20;
}

.hidden {
  display: none !important;
}

h1,
h2,
h3 {
  margin: 0 0 10px;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 5.5vw, 52px);
  color: #ffd166;
  text-shadow: 0 0 16px rgba(255, 209, 102, 0.4);
}

h2 {
  font-size: clamp(22px, 4.5vw, 34px);
  color: #64dfdf;
}

p {
  margin: 8px 0;
  font-weight: 700;
}

.hero-preview-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 10px 0 14px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(255, 209, 102, 0.08);
  border: 1px dashed rgba(255, 209, 102, 0.35);
  text-align: left;
}

.hero-preview-row img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(255, 209, 102, 0.4));
  flex-shrink: 0;
}

.hero-preview-row .hero-trait {
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  font-size: 14px;
  color: #ffe8a1;
}

.pickers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

label {
  display: grid;
  gap: 6px;
  text-align: left;
  font-weight: 800;
  font-size: 14px;
}

select,
button {
  min-height: 44px;
  border: 2px solid rgba(255, 248, 211, 0.52);
  border-radius: 8px;
  background: #f6dc75;
  color: #101927;
  font: 800 16px Arial, Helvetica, sans-serif;
  cursor: pointer;
  transition: transform 0.1s ease, background-color 0.15s ease;
}

select:hover,
button:hover {
  background: #ffea8a;
  transform: translateY(-1px);
}

select:active,
button:active {
  transform: translateY(1px);
}

select {
  padding: 0 12px;
  background: #101927;
  color: #fff8d3;
}

.btn-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.btn-secondary {
  background: #48cae4;
  color: #080d18;
}

.btn-secondary:hover {
  background: #64dfdf;
}

.btn-help {
  background: #ff9f1c;
  color: #080d18;
}

.btn-help:hover {
  background: #ffb703;
}

.power-guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin: 16px 0;
  text-align: left;
}

.power-card {
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(246, 220, 117, 0.3);
}

.power-card h3 {
  font-size: 15px;
  color: #ffd166;
  margin-bottom: 6px;
}

.power-card p {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  margin: 0;
  color: rgba(255, 248, 211, 0.9);
}

.power-card .danger-warning {
  margin-top: 6px;
  color: #ff6b6b;
  font-weight: 800;
  font-size: 12px;
}

.help,
.credits {
  font-size: 13px;
  line-height: 1.4;
  color: rgba(255, 248, 211, 0.82);
  margin-top: 12px;
}

.high-score-badge {
  display: inline-block;
  margin: 4px 0 10px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(255, 215, 0, 0.18);
  border: 1px solid #ffd700;
  font-weight: 900;
  color: #ffd700;
  font-size: 14px;
}

#hud {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}

#hud span,
#hud button {
  padding: 6px 12px;
  border: 1px solid rgba(246, 220, 117, 0.42);
  border-radius: 8px;
  background: rgba(8, 13, 24, 0.82);
  font-weight: 900;
  font-size: 14px;
  color: #fff8d3;
  white-space: nowrap;
}

#hud button {
  pointer-events: auto;
  min-height: auto;
  padding: 6px 12px;
  background: #2a3b5c;
  border-color: #64dfdf;
  color: #64dfdf;
  cursor: pointer;
}

#auraHud {
  background: rgba(100, 223, 223, 0.28) !important;
  border-color: #64dfdf !important;
  color: #64dfdf !important;
  font-weight: 900;
  animation: auraPulse 0.8s infinite alternate ease-in-out;
}

@keyframes auraPulse {
  from { box-shadow: 0 0 6px rgba(100, 223, 223, 0.4); transform: scale(1); }
  to { box-shadow: 0 0 16px rgba(100, 223, 223, 0.9); transform: scale(1.04); }
}

#touch {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(10px, env(safe-area-inset-bottom));
  display: none;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  padding: 0 10px;
  z-index: 10;
}

#touch button {
  min-height: 52px;
  opacity: 0.92;
  font-size: 22px;
}

@media (max-width: 760px), (pointer: coarse) {
  #touch {
    display: grid;
  }

  #hud {
    justify-content: flex-start;
    overflow-x: auto;
  }

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