:root {
  --bg1: #1b2a4a;
  --bg2: #0f1a30;
  --card: #ffffff;
  --ink: #20304d;
  --muted: #6b7a93;
  --accent: #ff8a3d;
  --accent2: #ffd23f;
  --dirt: #8b5a2b;
  --dirt-dark: #5e3c1a;
  --good: #2bb673;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  color: #f4f7ff;
  background: radial-gradient(circle at 50% 0%, var(--bg1), var(--bg2));
  background-attachment: fixed;
  display: flex;
  justify-content: center;
  padding: 20px 14px 40px;
}

.wrap { width: 100%; max-width: 460px; }

.head { text-align: center; margin-bottom: 16px; }
.head h1 { margin: 4px 0; font-size: 1.9rem; letter-spacing: .04em; }
.tagline { margin: 0; color: #c2cfe8; font-size: .9rem; }

.view { animation: fadeIn .35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card);
  color: var(--ink);
  border-radius: 18px;
  padding: 22px 20px;
  box-shadow: 0 14px 36px rgba(0,0,0,.32);
}

.lead { margin: 0 0 14px; font-weight: 700; text-align: center; }

.levels { display: grid; gap: 10px; }
.level-btn {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; padding: 14px 16px; border: 2px solid #eef1f7;
  border-radius: 14px; background: #f8fafc; color: var(--ink);
  font-size: 1rem; font-weight: 700; cursor: pointer;
  transition: transform .12s, border-color .12s, background .12s;
}
.level-btn:hover { transform: translateY(-2px); border-color: var(--accent); background: #fff7f0; }
.level-btn .lv-sub { font-size: .78rem; font-weight: 500; color: var(--muted); }

.best { margin: 18px 0 6px; }
.best dt { font-size: .8rem; color: var(--muted); margin-bottom: 6px; font-weight: 700; }
.best dd { margin: 0; }
.best-row { display: flex; justify-content: space-between; padding: 4px 2px; font-size: .9rem; border-bottom: 1px dashed #e6eaf2; }
.best-row:last-child { border-bottom: 0; }
.best-row .b-val { font-weight: 700; color: var(--accent); }

.rule { margin-top: 14px; font-size: .86rem; color: var(--muted); }
.rule summary { cursor: pointer; font-weight: 700; color: var(--ink); }
.rule ul { margin: 8px 0 0; padding-left: 1.2em; line-height: 1.6; }

.hud {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
}
.stat {
  flex: 1; background: rgba(255,255,255,.1); border-radius: 12px;
  padding: 8px 12px; text-align: center;
}
.stat-label { display: block; font-size: .72rem; color: #c2cfe8; }
.stat-val { display: block; font-size: 1.5rem; font-weight: 800; }
#timer.low { color: #ff6b6b; }

.grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  touch-action: manipulation;
}
.hole {
  position: relative; aspect-ratio: 1 / 1;
  border: none; padding: 0; cursor: pointer; background: transparent;
  border-radius: 50%;
  overflow: hidden;
}
.hole .ground {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 38%, var(--dirt-dark) 0 38%, var(--dirt) 39% 100%);
  border-radius: 50%;
  box-shadow: inset 0 -8px 14px rgba(0,0,0,.45);
}
.hole .lip {
  position: absolute; left: 8%; right: 8%; top: 30%; height: 26%;
  background: #3b2512; border-radius: 50%;
  box-shadow: inset 0 6px 10px rgba(0,0,0,.6);
}
.mole {
  position: absolute; left: 0; right: 0; bottom: 6%;
  margin: 0 auto; width: 70%;
  font-size: 0; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transform: translateY(110%);
  transition: transform .12s ease-out;
  pointer-events: none;
}
.mole .face {
  font-size: clamp(34px, 13vw, 58px);
  filter: drop-shadow(0 4px 4px rgba(0,0,0,.4));
}
.hole.up .mole { transform: translateY(0); }
.hole.bonk .mole { transform: translateY(40%) scale(.85); transition: transform .08s; }
.hole.bonk .face { animation: spin .25s; }
@keyframes spin { 50% { transform: rotate(18deg) scale(.9); } }

.float {
  position: absolute; left: 50%; top: 20%;
  transform: translateX(-50%);
  font-weight: 800; font-size: 1.1rem; pointer-events: none;
  color: var(--accent2); text-shadow: 0 1px 3px rgba(0,0,0,.6);
  animation: floatUp .7s ease-out forwards;
}
.float.minus { color: #ff6b6b; }
@keyframes floatUp {
  from { opacity: 1; transform: translate(-50%, 0); }
  to { opacity: 0; transform: translate(-50%, -34px); }
}

.result-title { text-align: center; margin: 0 0 6px; }
.result-score { text-align: center; font-size: 1.4rem; margin: 0 0 4px; }
.result-score span { font-size: 2.4rem; font-weight: 800; color: var(--accent); }
.result-best { text-align: center; color: var(--good); font-weight: 700; min-height: 1.2em; margin: 4px 0 16px; }

.actions { display: flex; gap: 10px; }
.primary, .ghost {
  flex: 1; padding: 12px; border-radius: 12px; font-size: 1rem;
  font-weight: 700; cursor: pointer; border: 2px solid transparent;
  transition: transform .12s, opacity .12s;
}
.primary { background: var(--accent); color: #fff; }
.ghost { background: transparent; color: inherit; border-color: rgba(255,255,255,.4); }
.card .ghost { color: var(--ink); border-color: #d8dee9; }
.primary:hover, .ghost:hover { transform: translateY(-2px); }
#btn-quit { flex: 0 0 auto; padding: 8px 14px; font-size: .85rem; }

.foot { text-align: center; color: #93a3c2; font-size: .76rem; margin-top: 22px; }

@media (prefers-reduced-motion: reduce) {
  .view, .mole, .hole.bonk .face, .float { animation: none; transition: none; }
}
