:root {
  --ink: #2b2140;
  --ink-soft: #6f6584;
  --bg: #f4f1ff;
  --card: #ffffff;
  --line: #ddd5ef;
  --thick: #2b2140;
  --primary: #6c5ce7;
  --primary-dark: #4b3cc4;
  --accent: #ff6b4a;
  --sel: #d9d1ff;
  --peer: #efebff;
  --same: #c4b8ff;
  --given: #2b2140;
  --user: #4b3cc4;
  --wrong: #e53935;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Zen Maru Gothic", system-ui, sans-serif; font-weight: 500; line-height: 1.6; }
.hidden { display: none !important; }

.g-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; max-width: 560px; margin: 0 auto; font-size: 13px; font-weight: 900; }
.g-brand { color: var(--ink-soft); text-decoration: none; }
.g-title { flex: 1; text-align: center; }
.g-head [data-mg-account] a { color: var(--primary); text-decoration: none; }

main { max-width: 560px; margin: 0 auto; padding: 0 12px 24px; }
.play { position: relative; user-select: none; -webkit-user-select: none; }
.bar { display: flex; justify-content: space-between; align-items: center; padding: 4px 2px 8px; font-size: 14px; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--primary); color: #fff; font-size: 12px; font-weight: 900; }
.badge.free { background: var(--accent); }
.level { font-weight: 900; margin-left: 4px; }
.bar-right b { font-variant-numeric: tabular-nums; }
.lbl { color: var(--ink-soft); font-size: 12px; font-weight: 900; }

/* 盤面 */
.board-wrap { position: relative; }
.board { display: grid; grid-template-columns: repeat(9, 1fr); aspect-ratio: 1; width: 100%; background: var(--card); border: 3px solid var(--thick); border-radius: 10px; overflow: hidden; touch-action: manipulation; }
.cell { position: relative; display: flex; align-items: center; justify-content: center; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--card); color: var(--user); font: 700 min(7.4vw, 30px)/1 "Zen Maru Gothic", sans-serif; padding: 0; cursor: pointer; }
.cell:nth-child(9n) { border-right: 0; }
.cell:nth-child(9n+3), .cell:nth-child(9n+6) { border-right: 2px solid var(--thick); }
.cell.r2, .cell.r5 { border-bottom: 2px solid var(--thick); }
.cell.r8 { border-bottom: 0; }
.cell.given { color: var(--given); font-weight: 900; }
.cell.peer { background: var(--peer); }
.cell.same { background: var(--same); }
.cell.sel { background: var(--sel); box-shadow: inset 0 0 0 2px var(--primary); }
.cell.wrong { color: var(--wrong); }
.cell.flash { animation: flash 0.5s ease-out; }
@keyframes flash { from { background: #fff3a8; } }
.notes { position: absolute; inset: 2px; display: grid; grid-template-columns: repeat(3, 1fr); font-size: min(2.6vw, 11px); line-height: 1; color: var(--ink-soft); font-weight: 700; }
.notes span { display: flex; align-items: center; justify-content: center; }

/* 操作 */
.tools { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 10px 0 8px; }
.tool { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border: 0; border-radius: 12px; background: transparent; color: var(--ink); font: 700 11px/1.2 "Zen Maru Gothic", system-ui, sans-serif; cursor: pointer; }
.tool:active { background: var(--peer); }
.tool[aria-pressed="true"] { background: var(--primary); color: #fff; }
.tool[aria-pressed="true"] b { color: #fff; }
.tool b { color: var(--primary); }
.pad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; }
.num-btn { position: relative; padding: 10px 0 14px; border: 0; border-radius: 12px; background: var(--card); color: var(--primary-dark); font: 900 min(7vw, 28px)/1 "Zen Maru Gothic", sans-serif; box-shadow: 0 2px 0 var(--line); cursor: pointer; }
.num-btn small { position: absolute; left: 0; right: 0; bottom: 3px; font-size: 10px; color: var(--ink-soft); font-weight: 700; }
.num-btn:active { transform: translateY(2px); box-shadow: none; }
.num-btn.done { opacity: 0.3; }
.kbd { font-size: 11px; color: var(--ink-soft); text-align: center; margin: 8px 0 0; }
@media (pointer: coarse) { .kbd { display: none; } }

/* 盤面の上に重ねる画面 */
.scr { position: absolute; inset: 0; z-index: 5; display: flex; align-items: flex-start; justify-content: center; padding: 6px; background: rgba(244, 241, 255, 0.93); overflow-y: auto; border-radius: 10px; }
.card { width: 100%; max-width: 380px; background: var(--card); border-radius: 18px; padding: 16px; text-align: center; box-shadow: 0 10px 30px rgba(43, 33, 64, 0.12); margin: auto; line-break: strict; }
.logo { margin: 0; font-size: 26px; font-weight: 900; letter-spacing: 0.04em; }
.day { margin: 2px 0 10px; font-size: 13px; color: var(--ink-soft); font-weight: 900; }
.daily-box { border: 2px solid var(--primary); border-radius: 16px; padding: 10px 12px; margin-bottom: 10px; }
.daily-lbl { font-size: 11px; font-weight: 900; color: var(--ink-soft); letter-spacing: 0.1em; }
.daily-lv { font-size: 22px; font-weight: 900; color: var(--primary); }
.daily-note { margin: 2px 0 6px; font-size: 12px; color: var(--ink-soft); }
.done { font-size: 14px; font-weight: 900; margin-top: 4px; }
.free-lbl { font-size: 12px; font-weight: 900; color: var(--ink-soft); margin: 4px 0 2px; }
.free-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.stats { font-size: 12px; color: var(--ink-soft); font-weight: 700; margin: 8px 0 0; }

.btn { display: block; width: 100%; margin: 6px 0; padding: 12px 10px; border: 0; border-radius: 14px; font: 900 16px/1.2 "Zen Maru Gothic", system-ui, sans-serif; cursor: pointer; background: #f1eefb; color: var(--ink); }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 4px 0 var(--primary-dark); }
.btn.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--primary-dark); }
.btn.lv { margin: 0; font-size: 14px; padding: 11px 4px; }
.btn.sub { font-size: 14px; }
.btn.ghost { background: transparent; border: 2px solid var(--line); color: var(--ink-soft); font-size: 14px; }
.btn.x { background: #000; color: #fff; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn:disabled { opacity: 0.5; cursor: default; }

.clear-lbl { font-size: 13px; font-weight: 900; color: var(--primary); }
.clear-time { font-size: 52px; font-weight: 900; line-height: 1.1; font-variant-numeric: tabular-nums; }
.clear-sub { margin: 0; font-size: 14px; font-weight: 700; }
.best { display: inline-block; margin: 6px 0 0; padding: 2px 12px; border-radius: 999px; background: #ffd166; font-weight: 900; font-size: 13px; }
.rank { margin: 10px 0; padding: 8px; background: var(--peer); border-radius: 14px; }
.rank-lbl { font-size: 11px; font-weight: 900; color: var(--ink-soft); }
.rank-name { font-size: 24px; font-weight: 900; }
.share { margin: 8px 0; }
.c-note { margin: 8px 0; padding: 8px 10px; border-radius: 12px; background: #fff6dd; font-size: 13px; font-weight: 700; text-align: left; }

.toast { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 9; padding: 10px 18px; border-radius: 999px; background: rgba(43, 33, 64, 0.9); color: #fff; font-weight: 900; font-size: 15px; pointer-events: none; white-space: nowrap; }

/* タイトル・クリアの画面: 盤面と操作を隠して、カードを全部見せる */
.play.menu .board, .play.menu .tools, .play.menu .pad, .play.menu .kbd, .play.menu .bar { display: none; }
.play.menu .scr { position: static; background: none; padding: 4px 0 0; overflow: visible; }
.nb { display: inline-block; }

/* 下の解説 */
.guide { margin-top: 28px; background: var(--card); border-radius: 18px; padding: 18px 18px 8px; font-size: 15px; line-break: strict; }
.guide h2 { font-size: 19px; margin: 18px 0 8px; padding-left: 10px; border-left: 5px solid var(--primary); }
.guide h2:first-child { margin-top: 0; }
.guide h3 { font-size: 16px; margin: 14px 0 4px; }
.guide ul, .guide ol { padding-left: 1.3em; }
.guide .steps { list-style: none; padding: 0; }
.guide .steps li { display: flex; align-items: baseline; gap: 6px; margin: 6px 0; }
.guide .steps .num { flex: none; font-weight: 900; color: var(--primary); }
.guide details { border-top: 1px solid var(--line); padding: 8px 0; }
.guide summary { font-weight: 900; cursor: pointer; }
.guide a { color: var(--primary); }
.g-foot { max-width: 560px; margin: 0 auto; padding: 12px 16px 28px; font-size: 12px; text-align: center; }
.g-foot a { color: var(--ink-soft); }

/* /js/account.js の入れ物（白いカードの中） */
.card .mg-box { background: var(--peer); border-color: transparent; }

/* 解説の余白と行間（ポータルと同じ決まり: 行間 1.85・段落の間は1行分・見出しは前を広く後ろを狭く） */
.guide { line-height: 1.85; padding: 22px 20px 12px; }
.guide p { margin: 0 0 1em; }
.guide h2 { margin: 32px 0 12px; line-height: 1.4; }
.guide h2:first-child { margin-top: 0; }
.guide h3 { margin: 22px 0 6px; line-height: 1.5; }
.guide ul, .guide ol { margin: 0 0 1em; }
.guide li { margin: 6px 0; }
.guide details { padding: 12px 0; }
.guide details p { margin: 8px 0 4px; }

