* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #87ceeb;
  font-family: "Segoe UI", "Malgun Gothic", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

#ui {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  z-index: 10;
  pointer-events: none;
}

.stat {
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

#hint {
  position: fixed;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.35);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 10;
  pointer-events: none;
  text-align: center;
  max-width: 90vw;
}

#rotateHint {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  padding: 8px 10px 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 15;
}

#rotateHint button {
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

@media (orientation: portrait) and (max-width: 820px) {
  #rotateHint.visible {
    display: flex;
  }
}

@media (max-width: 480px) {
  .stat {
    font-size: 12px;
    padding: 5px 9px;
  }
  #hint {
    font-size: 11px;
  }
}

#message {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: rgba(0, 0, 0, 0.45);
  z-index: 20;
}

#message.hidden {
  display: none;
}

#messageText {
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  white-space: pre-line;
}

#restartBtn {
  padding: 14px 30px;
  min-height: 48px;
  font-size: 18px;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  background: #ffb703;
  color: #3a2a00;
  cursor: pointer;
  touch-action: manipulation;
}

#restartBtn.hidden {
  display: none;
}

#restartBtn:hover {
  background: #ffc733;
}
