:root {
  --bg1: #dff6ff;
  --bg2: #fef6d8;
  --grass: #8fd36a;
  --ground: #6a4b2e;
  --panel: rgba(255,255,255,.9);
  --text: #2b2b2b;
  --accent: #ff7f50;
  --accent2: #7c5cff;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg1) 0%, #cfefff 45%, var(--bg2) 100%);
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}
canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.hud {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  top: calc(12px + var(--safe-top));
  left: calc(12px + var(--safe-left));
  right: calc(12px + var(--safe-right));
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.hud-left, .hud-right {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.pill {
  min-width: 88px;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 25px rgba(0,0,0,.08);
  font-weight: 700;
  font-size: clamp(14px, 2vw, 18px);
  text-align: center;
}
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(20px + var(--safe-top)) calc(18px + var(--safe-right)) calc(20px + var(--safe-bottom)) calc(18px + var(--safe-left));
  background: linear-gradient(180deg, rgba(219,247,255,.78), rgba(255,249,226,.88));
}
.overlay.hidden { display: none; }
.card {
  width: min(760px, 100%);
  max-height: calc(100vh - 40px - var(--safe-top) - var(--safe-bottom));
  overflow: auto;
  background: rgba(255,255,255,.94);
  border-radius: 28px;
  padding: 22px;
  box-shadow: 0 18px 60px rgba(0,0,0,.14);
  text-align: center;
}

.gameover-card {
  overflow: auto;
}

.panel-box {
  margin-top: 16px;
  text-align: left;
  background: rgba(255,255,255,.7);
  padding: 14px;
  border-radius: 18px;
}

.panel-title {
  font-weight: 700;
  margin-bottom: 10px;
}

.input-label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
}

input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid #e7e7e7;
  font-size: 16px;
  outline: none;
}

.full-width {
  width: 100%;
  margin-top: 10px;
}

.gameover-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 16px;
}

.leaderboard-list {
  max-height: min(260px, 34vh);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
}

@media (orientation: landscape) and (min-width: 760px) {
  .gameover-grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}
h1, h2 {
  margin: 0 0 10px;
  line-height: 1.1;
}
h1 { font-size: clamp(30px, 5vw, 48px); }
h2 { font-size: clamp(24px, 4vw, 34px); }
p {
  margin: 10px 0;
  font-size: clamp(15px, 2.2vw, 18px);
  line-height: 1.45;
}
.small {
  opacity: .82;
  font-size: clamp(13px, 1.8vw, 15px);
}
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}
button {
  appearance: none;
  border: none;
  border-radius: 18px;
  padding: 16px 18px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(180deg, #ff9f73, var(--accent));
  color: #fff;
  box-shadow: 0 8px 18px rgba(255,127,80,.32);
}
button.secondary {
  background: linear-gradient(180deg, #9785ff, var(--accent2));
  box-shadow: 0 8px 18px rgba(124,92,255,.28);
}
.inline-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 14px;
}
.hint-bar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(12px + var(--safe-bottom));
  z-index: 5;
  background: rgba(255,255,255,.92);
  border-radius: 999px;
  padding: 10px 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.09);
  font-weight: 700;
  font-size: clamp(13px, 2vw, 17px);
  pointer-events: none;
}
.rotate-note {
  display: none;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: #fff7e1;
  font-weight: 700;
}
.logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}
.fg-logo {
  width: min(220px, 60vw);
  height: auto;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,.08));
}
.splash-card {
  position: relative;
  overflow: hidden;
}
.splash-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 25%, rgba(255,255,255,.9), transparent 30%),
    radial-gradient(circle at 80% 20%, rgba(255,216,77,.22), transparent 25%);
}
.splash-bunny {
  width: 108px;
  height: auto;
  margin: 4px auto 12px;
  display: block;
  animation: hop 1.8s ease-in-out infinite;
}
@keyframes hop {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.panel-box {
  margin-top: 16px;
  text-align: left;
  background: rgba(255,255,255,.7);
  padding: 14px;
  border-radius: 18px;
}
.panel-title {
  font-weight: 700;
  margin-bottom: 10px;
}
.input-label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
}
.leaderboard-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
}
.leaderboard-list {
  max-height: 220px;
  overflow: auto;
}
input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid #e7e7e7;
  font-size: 16px;
  outline: none;
}
.full-width {
  width: 100%;
  margin-top: 10px;
}
@media (orientation: portrait) and (max-width: 1024px) {
  .rotate-note { display: block; }
}
@media (max-width: 640px) {
  .controls { grid-template-columns: 1fr; }
  .card { padding: 18px; border-radius: 24px; }
  .pill { min-width: 74px; padding: 8px 12px; }
  .hint-bar {
    max-width: calc(100vw - 24px - var(--safe-left) - var(--safe-right));
    text-align: center;
  }
}
