:root {
  --ink: #2b2140;
  --ink-soft: #6b6283;
  --panel: rgba(255, 255, 255, 0.94);
  --primary: #ff6b4a;
  --primary-dark: #d94a2c;
  --accent: #ffc53d;
  --line: #e7e1f0;
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #7cc6f2;
  color: var(--ink);
  font-family: "M PLUS Rounded 1c", system-ui, sans-serif;
  font-weight: 500;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: fixed;
  inset: 0;
  max-width: 560px;
  margin: 0 auto;
  overflow: hidden;
}

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

.hidden { display: none !important; }

/* HUD */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  pointer-events: none;
}
.hud-left { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.hud-center { text-align: center; }
.hud-right { justify-self: end; text-align: center; }
.count {
  font-family: "Dela Gothic One", sans-serif;
  font-size: 56px;
  line-height: 1;
  color: #fff;
  text-shadow: 0 3px 0 rgba(43, 33, 64, 0.35);
  transition: transform 0.12s;
}
.count.pop { transform: scale(1.25); }
.hud-sub {
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px rgba(43, 33, 64, 0.4);
}
.next-label {
  font-family: "Dela Gothic One", sans-serif;
  font-size: 12px;
  color: #fff;
  letter-spacing: 0.1em;
  text-shadow: 0 1px 2px rgba(43, 33, 64, 0.4);
}
#next {
  width: 60px; height: 60px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 14px;
}
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.badge.practice { background: #5b7cfa; }
.badge.big { font-size: 14px; padding: 4px 14px; }

/* ボタン */
.round-btn {
  position: absolute;
  right: 18px;
  bottom: calc(env(safe-area-inset-bottom) + 22px);
  width: 64px; height: 64px;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 5px 0 rgba(43, 33, 64, 0.25);
  display: grid; place-items: center;
  cursor: pointer;
}
.round-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(43, 33, 64, 0.25); }
.icon-btn {
  position: absolute;
  left: 14px;
  bottom: calc(env(safe-area-inset-bottom) + 22px);
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink);
  display: grid; place-items: center;
  cursor: pointer;
  z-index: 5;
}

.toast {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: "Dela Gothic One", sans-serif;
  font-size: 34px;
  color: #fff;
  text-shadow: 0 3px 0 var(--primary-dark), 0 0 18px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  white-space: nowrap;
  animation: toast 1.1s ease-out forwards;
}
@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  70% { opacity: 1; transform: translate(-50%, -55%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(1); }
}

/* 画面 */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(43, 33, 64, 0.25);
  overflow-y: auto;
  z-index: 10;
}
.panel {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border-radius: 24px;
  padding: 26px 20px 20px;
  text-align: center;
  box-shadow: 0 10px 0 rgba(43, 33, 64, 0.18);
  margin: auto;
}
.logo {
  font-family: "Dela Gothic One", sans-serif;
  font-size: 46px;
  line-height: 1.1;
  color: var(--primary);
  text-shadow: 0 4px 0 var(--accent);
}
.day { font-size: 14px; font-weight: 800; color: var(--ink-soft); margin: 6px 0 14px; }
.howto {
  list-style: none;
  padding: 12px 14px;
  margin: 0 0 10px;
  background: #f6f2fb;
  border-radius: 14px;
  text-align: left;
  font-size: 14px;
}
.howto li { display: flex; align-items: baseline; gap: 6px; padding: 3px 0; }
.howto .num { flex: none; font-family: "Dela Gothic One", sans-serif; color: var(--primary); }
.note { font-size: 12px; color: var(--ink-soft); margin: 0 0 16px; line-height: 1.6; }

.btn {
  display: block;
  width: 100%;
  margin: 8px 0;
  padding: 14px 12px;
  border: none;
  border-radius: 16px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  color: var(--ink);
  background: #fff;
}
.btn small { display: block; font-size: 11px; font-weight: 500; opacity: 0.85; margin-top: 2px; }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 5px 0 var(--primary-dark); }
.btn.primary:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--primary-dark); }
.btn.ghost { background: transparent; border: 2px solid var(--line); color: var(--ink-soft); font-size: 15px; }
.btn.x { background: #111; color: #fff; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn.sub { background: #f1edf7; font-size: 14px; padding: 11px; }
.share-row { margin: 14px 0 6px; }
.share-row .btn { margin: 6px 0; }

.done-box { background: #fff4e6; border-radius: 16px; padding: 12px; margin-bottom: 6px; }
.done-label { font-size: 12px; color: var(--ink-soft); font-weight: 800; }
.done-score { font-family: "Dela Gothic One", sans-serif; font-size: 34px; color: var(--primary); }
.done-type { font-size: 14px; font-weight: 800; }
.countdown { font-size: 13px; color: var(--ink-soft); font-weight: 800; margin: 6px 0 4px; }
.countdown .cd { font-family: "Dela Gothic One", sans-serif; color: var(--ink); letter-spacing: 0.05em; }
.stats-line { font-size: 13px; color: var(--ink-soft); margin-top: 10px; font-weight: 800; }

.res-score { font-family: "Dela Gothic One", sans-serif; color: var(--primary); line-height: 1; margin-top: 4px; }
.res-score #res-count { font-size: 84px; }
.res-score .unit { font-size: 28px; margin-left: 4px; }
.res-sub { font-size: 15px; font-weight: 800; color: var(--ink-soft); margin-top: 4px; }
.res-best {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent);
  font-weight: 800;
  font-size: 13px;
  animation: pulse 0.9s ease-in-out infinite alternate;
}
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.08); } }
.type-box { margin-top: 14px; background: #f6f2fb; border-radius: 16px; padding: 12px; }
.type-label { font-size: 12px; color: var(--ink-soft); font-weight: 800; }
.type-name { font-family: "Dela Gothic One", sans-serif; font-size: 24px; margin: 2px 0 4px; }
.type-desc { font-size: 13px; line-height: 1.6; color: var(--ink-soft); }
