:root {
  --bg1: #fef3c7;
  --bg2: #fdba74;
  --card: rgba(255, 255, 255, 0.82);
  --text: #7c2d12;
  --muted: #9a3412;
  --line: rgba(124, 45, 18, 0.12);
  --accent: #f97316;
  --accent-2: #fb923c;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  background: linear-gradient(180deg, var(--bg1), var(--bg2));
  color: var(--text);
}

body {
  padding: max(16px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
}

.app {
  max-width: 520px;
  margin: 0 auto;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 16px;
  box-shadow: 0 18px 40px rgba(124, 45, 18, 0.16);
  backdrop-filter: blur(10px);
}

.hero {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
}

.badge {
  display: inline-block;
  margin: 0 0 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: #ffedd5;
  color: #c2410c;
  font-size: 13px;
  font-weight: 700;
}

.hero h1,
.overlay-card h2 {
  margin: 0;
  font-size: 32px;
  line-height: 1.1;
}

.subtitle,
#overlayText {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 16px;
}

.score-box,
.preview-card {
  min-width: 92px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 20px;
  padding: 12px;
  text-align: center;
}

.score-box span,
.small-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.score-box strong {
  font-size: 28px;
}

.preview-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}

.fruit-preview {
  width: 52px;
  height: 52px;
  margin: 0 auto;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 18px rgba(124, 45, 18, 0.18), inset 0 0 0 1px rgba(124, 45, 18, 0.08);
  background-size: cover;
  background-position: center;
}

.game-wrap {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  background: linear-gradient(180deg, #fffbeb, #fde68a 44%, #fdba74 100%);
  border: 2px solid rgba(255,255,255,0.45);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
}

.top-guide {
  position: absolute;
  top: 52px;
  width: 2px;
  height: 42px;
  background: rgba(220, 38, 38, 0.7);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.35);
  border-radius: 999px;
  transform: translateX(-50%);
  pointer-events: none;
}

.top-guide::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #dc2626;
  transform: translateX(-50%);
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(124, 45, 18, 0.18);
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  width: 100%;
  background: rgba(255,255,255,0.95);
  border-radius: 28px;
  padding: 24px 18px;
  text-align: center;
  box-shadow: 0 20px 48px rgba(124, 45, 18, 0.2);
}

.actions {
  margin-top: 14px;
}

.primary-btn,
.ghost-btn {
  width: 100%;
  border: 0;
  border-radius: 18px;
  padding: 15px;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

.primary-btn {
  color: white;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
}

.ghost-btn {
  color: var(--text);
  background: rgba(255,255,255,0.42);
  border: 1px solid rgba(124, 45, 18, 0.1);
}

@media (max-width: 460px) {
  .hero {
    flex-direction: column;
  }

  .score-box {
    width: 100%;
  }

  .hero h1,
  .overlay-card h2 {
    font-size: 28px;
  }
}
