* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: #8fd3ef;
  font-family: 'Fredoka', system-ui, sans-serif;
  touch-action: none; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; }
#game-root { position: absolute; inset: 0; touch-action: none; }
#game-root canvas { display: block; }

/* Rotate-to-landscape nudge (small screens in portrait only) */
#rotate { display: none; }
@media (orientation: portrait) and (max-width: 900px) {
  #rotate { display: flex; position: fixed; inset: 0; z-index: 50;
    background: #8fd3ef; align-items: center; justify-content: center; text-align: center; padding: 24px; }
  .rotate-inner { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #3a2a1a; }
  .rotate-icon { font-size: 64px; animation: rotate-spin 2.2s ease-in-out infinite; }
  #rotate strong { font-size: 26px; }
  .rotate-sub { font-size: 17px; color: #4a6b78; }
}
@keyframes rotate-spin { 0%,60% { transform: rotate(0); } 80%,100% { transform: rotate(90deg); } }

#overlay { position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; pointer-events: none; }

.panel { pointer-events: auto; width: min(92vw, 600px);
  background: #f6ead0; border: 6px solid #3a2a1a; border-radius: 28px;
  box-shadow: 10px 12px 0 rgba(0,0,0,0.35); padding: 26px 32px 30px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px; }

.kicker { font-size: 20px; font-weight: 700; color: #c23b45; letter-spacing: 0.14em; }
#rank-title { font-size: 56px; font-weight: 700; color: #ffb703; line-height: 58px;
  text-shadow: 4px 4px 0 #3a2a1a; }
.flavor { font-size: 18px; font-weight: 500; color: #9a7a52; }

.stats { display: flex; gap: 48px; padding: 4px 0; }
.stat { display: flex; flex-direction: column; align-items: center; }
.stat-label { font-size: 15px; font-weight: 600; color: #9a7a52; letter-spacing: 0.12em; }
.stat-num { font-size: 44px; font-weight: 700; color: #3a2a1a; line-height: 46px; }
.stat-num.best { color: #58a05b; }

.lb-wrap { width: 100%; background: #efe4cd; border: 3px solid #d8c9a8; border-radius: 16px;
  padding: 12px 16px; display: flex; flex-direction: column; gap: 6px; }
.lb-title { font-size: 14px; font-weight: 700; color: #9a7a52; letter-spacing: 0.14em; text-align: left; }
#leaderboard { list-style: none; text-align: left; max-height: 22vh; overflow-y: auto; }
#leaderboard li { display: flex; justify-content: space-between; font-size: 18px; color: #3a2a1a; padding: 3px 2px; }
#leaderboard li span:last-child { font-weight: 700; }
#leaderboard:empty::after { content: "No scores yet — go first."; color: #9a8a6a; font-size: 15px; }

.row { display: flex; gap: 12px; justify-content: center; width: 100%; }
.panel input { flex: 1; font: inherit; font-size: 18px; padding: 10px 14px;
  border: 4px solid #3a2a1a; border-radius: 14px; text-align: center; min-width: 0; background: #fff; }

.btn { font: inherit; font-size: 20px; font-weight: 700; padding: 10px 20px;
  border: 5px solid #3a2a1a; border-radius: 16px; background: #ffd23f; color: #3a2a1a;
  cursor: pointer; box-shadow: 0 6px 0 #3a2a1a; transition: transform 0.06s, box-shadow 0.06s; white-space: nowrap; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #3a2a1a; }
.btn-primary { background: #58c15b; color: #fff7e6; flex: 1; }

.hidden { display: none !important; }

/* Responsive: shrink the game-over panel on small / short screens */
@media (max-height: 560px), (max-width: 720px) {
  .panel { width: min(94vw, 520px); max-height: 94vh; overflow-y: auto;
    padding: 16px 18px 20px; gap: 8px; border-radius: 20px; }
  .kicker { font-size: 15px; }
  #rank-title { font-size: 38px; line-height: 40px; }
  .flavor { font-size: 15px; }
  .stats { gap: 32px; }
  .stat-num { font-size: 32px; line-height: 34px; }
  .lb-wrap { padding: 8px 12px; }
  #leaderboard { max-height: 30vh; }
  #leaderboard li { font-size: 16px; }
  .btn { font-size: 17px; padding: 8px 14px; border-width: 4px; }
  .panel input { font-size: 16px; padding: 8px 10px; }
}
