:root {
  --ink: #2b2140;
  --ink-soft: #6f6584;
  --paper: #fff3e2;
  --panel: rgba(255, 255, 255, 0.95);
  --line: #eadfce;
  --primary: #ff6b4a;
  --primary-dark: #d24a2b;
  --teal: #2bb3a3;
  --accent: #ffb547;
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: "Zen Maru Gothic", 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: right; }
.hud-goal { font-family: "Dela Gothic One", sans-serif; font-size: 22px; line-height: 1.2; }
.hud-goal small { display: block; font-family: "Zen Maru Gothic", sans-serif; font-size: 11px; font-weight: 900; color: var(--ink-soft); }
.hud-sub { font-size: 11px; font-weight: 900; color: var(--ink-soft); }
.hud-best { font-family: "Dela Gothic One", sans-serif; font-size: 18px; color: var(--primary); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--primary); color: #fff; font-size: 12px; font-weight: 900; }
.badge.practice { background: #6c7cff; }
.badge.big { font-size: 14px; padding: 4px 14px; }

.hint {
  position: absolute; left: 0; right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 84px);
  text-align: center; font-size: 14px; font-weight: 900; color: var(--ink);
  pointer-events: none; animation: breathe 1.8s ease-in-out infinite alternate;
}
@keyframes breathe { from { opacity: 0.45; } to { opacity: 0.95; } }

.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(43, 33, 64, 0.08); color: var(--ink);
  display: grid; place-items: center; cursor: pointer; z-index: 5;
}

.toast {
  position: absolute; top: 22%; left: 50%; transform: translate(-50%, -50%);
  font-family: "Dela Gothic One", sans-serif; font-size: 34px; color: var(--primary);
  text-shadow: 0 3px 0 #fff, 0 0 14px rgba(255, 255, 255, 0.9);
  pointer-events: none; white-space: nowrap; animation: toast 1.2s ease-out forwards;
}
@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); }
  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(255, 243, 226, 0.55); overflow-y: auto; z-index: 10;
}
.panel {
  width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 24px; padding: 24px 20px 20px; text-align: center;
  box-shadow: 0 18px 50px rgba(43, 33, 64, 0.16); margin: auto;
}
.logo { font-family: "Dela Gothic One", sans-serif; font-size: clamp(38px, 12.5vw, 50px); white-space: nowrap; line-height: 1.1; color: var(--ink); letter-spacing: 0.04em; }
.logo::after { content: ""; display: block; width: 72%; height: 4px; margin: 6px auto 0; background: linear-gradient(90deg, var(--primary) 50%, var(--teal) 50%); border-radius: 2px; transform: rotate(-4deg); }
.catch { font-size: 14px; font-weight: 900; color: var(--primary); margin-top: 8px; }
.day { font-size: 13px; font-weight: 900; color: var(--ink-soft); margin: 8px 0 12px; }
.theme-box { background: #fff8ee; border: 2px solid var(--accent); border-radius: 16px; padding: 10px 12px; margin: 0 0 12px; }
.theme-label { font-size: 11px; font-weight: 900; color: var(--ink-soft); letter-spacing: 0.1em; }
.theme-name { font-family: "Dela Gothic One", sans-serif; font-size: 24px; margin: 2px 0; }
.theme-desc { font-size: 12px; line-height: 1.6; }
.howto { list-style: none; padding: 12px 14px; margin: 0 0 10px; background: #f7f1ff; 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 14px; line-height: 1.7; }

.btn {
  display: block; width: 100%; margin: 8px 0; padding: 14px 12px; border: none; border-radius: 16px;
  font-family: inherit; font-size: 17px; font-weight: 900; cursor: pointer; color: var(--ink); background: #f3eee6;
}
.btn small { display: block; font-size: 11px; font-weight: 500; opacity: 0.9; 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: #000; color: #fff; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn.sub { font-size: 14px; padding: 11px; }
.share-row { margin: 14px 0 6px; }
.share-row .btn { margin: 6px 0; }

.done-box { background: #fff8ee; border: 1px solid var(--line); border-radius: 16px; padding: 12px; margin-bottom: 6px; }
.done-label { font-size: 12px; color: var(--ink-soft); font-weight: 900; }
.done-score { font-family: "Dela Gothic One", sans-serif; font-size: 30px; }
.done-rank { font-size: 14px; font-weight: 900; color: var(--primary); }
.countdown { font-size: 13px; color: var(--ink-soft); font-weight: 900; 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: 900; }

.res-ratio { font-family: "Dela Gothic One", sans-serif; font-size: 46px; line-height: 1.1; margin-top: 8px; }
.res-ratio .a { color: var(--primary); } .res-ratio .b { color: var(--teal); } .res-ratio .sep { color: var(--ink-soft); font-size: 30px; margin: 0 4px; }
.res-sub { font-size: 15px; font-weight: 900; color: var(--ink); margin-top: 6px; }
.res-best { display: inline-block; margin-top: 8px; padding: 4px 12px; border-radius: 999px; background: var(--accent); color: var(--ink); font-weight: 900; font-size: 13px; animation: pulse 0.9s ease-in-out infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.08); } }
.rank-box { margin-top: 14px; background: #f7f1ff; border-radius: 16px; padding: 12px; }
.rank-label { font-size: 12px; color: var(--ink-soft); font-weight: 900; }
.rank-name { font-family: "Dela Gothic One", sans-serif; font-size: 28px; margin: 2px 0 4px; }
.rank-desc { font-size: 13px; line-height: 1.6; color: var(--ink-soft); }

.portal-link { display: inline-block; margin-top: 12px; font-size: 12px; font-weight: 900; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px; }

/* 保存・コピーできない環境向けの案内 */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.overlay-box { width: 100%; max-width: 380px; max-height: 92vh; overflow-y: auto; background: #fff; color: var(--ink); border-radius: 20px; padding: 18px 16px 10px; text-align: center; }
#ov-msg { margin: 0 0 12px; font-weight: 800; font-size: 14px; line-height: 1.6; }
#ov-img { width: 100%; border-radius: 12px; margin-bottom: 10px; -webkit-touch-callout: default; user-select: auto; -webkit-user-select: auto; }
#ov-text { width: 100%; height: 150px; font: inherit; font-size: 13px; border: 1px solid #ddd; border-radius: 10px; padding: 8px; margin-bottom: 6px; user-select: text; -webkit-user-select: text; }

/* 日本語の改行: 1〜2文字だけが次の行に落ちないように、文節で折り返す */
.panel { line-break: strict; }

.nb { display: inline-block; } /* 意味のまとまりの途中で折り返さない */
