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

html, body {
  width: 100%;
  height: 100%;
  background: #0b1020;
  overflow: hidden;
  font-family: "Segoe UI", "Noto Sans KR", system-ui, sans-serif;
  color: #eaf2ff;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: none;
}

#game-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  background: linear-gradient(#1a2740, #0b1020);
  display: block;
  width: min(100vw, calc((100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) * 480 / 720));
  height: min(100vh, calc(100vw * 720 / 480));
  max-width: 100vw;
  max-height: 100vh;
  aspect-ratio: 480 / 720;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
  cursor: crosshair;
  touch-action: none;
}

.hidden { display: none !important; }

#hud {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: 480px;
  max-width: 92vw;
  pointer-events: none;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
}

.hud-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 15px;
  letter-spacing: 1px;
}

.hud-item b { color: #ffd76a; font-variant-numeric: tabular-nums; }

.hud-power {
  justify-content: center;
  font-size: 13px;
  color: #9be2ff;
  min-height: 16px;
}

#touch-hint {
  position: absolute;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 20px;
  background: rgba(8, 12, 24, 0.72);
  color: #cfe0ff;
  font-size: 13px;
  letter-spacing: 1px;
  pointer-events: none;
  animation: hintFade 2.6s ease-out forwards;
}

@keyframes hintFade {
  0%   { opacity: 0; transform: translate(-50%, 8px); }
  15%  { opacity: 1; transform: translate(-50%, 0); }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}

.overlay {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(480px, 100vw);
  max-width: 100vw;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(8, 12, 24, 0.82);
  backdrop-filter: blur(3px);
  padding: max(24px, env(safe-area-inset-top, 0px)) 20px max(24px, env(safe-area-inset-bottom, 0px));
}

.overlay h1 {
  font-size: clamp(28px, 9vw, 40px);
  letter-spacing: 3px;
  color: #ffd76a;
  text-shadow: 0 0 18px rgba(255, 180, 60, 0.5);
  margin-bottom: 4px;
}

.overlay .subtitle {
  color: #9be2ff;
  margin-bottom: 20px;
  letter-spacing: 2px;
}

.instructions {
  line-height: 1.7;
  font-size: 14px;
  color: #cfe0ff;
  margin-bottom: 24px;
}

.instructions hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  margin: 12px 0;
}

.result {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 30px;
  margin-bottom: 24px;
}

.result div {
  display: flex;
  flex-direction: column;
}

.result span { font-size: 12px; color: #8fa6cc; letter-spacing: 1px; }
.result b { font-size: 24px; color: #ffd76a; }

button {
  font-size: clamp(16px, 4.5vw, 18px);
  padding: 14px 36px;
  min-height: 44px;
  border: none;
  border-radius: 30px;
  background: linear-gradient(#ffcf5c, #ff9f3c);
  color: #2a1700;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(255, 160, 40, 0.35);
  touch-action: manipulation;
}

button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }

.hint { margin-top: 14px; font-size: 12px; color: #6f86ad; }

@media (max-width: 520px) {
  .hud-row { font-size: 13px; letter-spacing: 0.5px; }
  .hud-power { font-size: 12px; min-height: 14px; }
  .instructions { font-size: 13px; line-height: 1.6; margin-bottom: 18px; }
  .result { gap: 10px 20px; margin-bottom: 18px; }
  .result b { font-size: 20px; }
  .overlay .subtitle { margin-bottom: 14px; letter-spacing: 1.5px; font-size: 13px; }
}

