:root {
  --ink: #23262f;
  --ink-soft: #626776;
  --bg: #eceef3;
  --paper: #ffffff;
  --line: #d9dce5;
  --primary: #3d4a9e;
  --primary-dark: #2a3474;
  --gold: #f2c14e;
  --c0: #e4572e;
  --c1: #f2c230;
  --c2: #2ba57e;
  --c3: #3a72d0;
  --c4: #9a5bd8;
  --c5: #6fcbef;
  --font: "Zen Kaku Gothic New", system-ui, sans-serif;
  --num: "Big Shoulders Display", "Zen Kaku Gothic New", sans-serif;
}
* { 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: var(--font); font-weight: 500; line-height: 1.7; line-break: strict; }
.hidden { display: none !important; }
.nw { white-space: nowrap; }

.g-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; max-width: 520px; 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-dark); text-decoration: none; }

main { max-width: 520px; margin: 0 auto; padding: 0 12px 24px; }
.play { position: relative; user-select: none; -webkit-user-select: none; }

.bar { display: grid; grid-template-columns: 1.1fr 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.box { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px; text-align: center; min-width: 0; }
.lbl { font-size: 11px; font-weight: 900; color: var(--ink-soft); white-space: nowrap; }
.val { font: 800 26px/1.1 var(--num); font-variant-numeric: tabular-nums; white-space: nowrap; }
.val.sm { font: 900 15px/1.7 var(--font); }

/* 盤（左上とつながった同じ色のかたまりが自分の陣地。色を選ぶと陣地が広がる） */
.board-wrap { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 8px; box-shadow: 0 8px 24px rgba(35, 38, 47, 0.08); }
.board { display: grid; grid-template-columns: repeat(var(--n, 12), 1fr); aspect-ratio: 1; border-radius: 10px; overflow: hidden; touch-action: manipulation; }
.cell { position: relative; transition: background-color 0.18s ease-out; cursor: pointer; }
.c0 { background-color: var(--c0); } .c1 { background-color: var(--c1); } .c2 { background-color: var(--c2); }
.c3 { background-color: var(--c3); } .c4 { background-color: var(--c4); } .c5 { background-color: var(--c5); }
.cell:first-child::before { content: ""; position: absolute; inset: 22%; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.9); z-index: 1; }
.progress { height: 6px; margin: 8px 2px 0; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 999px; transition: width 0.3s; }
/* 記号（色の見分けがつきにくい人向け）: 色ごとに形を重ねる */
.sym .cell::after, .sym .swatch::after { content: ""; position: absolute; left: 50%; top: 50%; width: 46%; height: 46%; transform: translate(-50%, -50%); background: rgba(255, 255, 255, 0.85); }
.sym .c0::after { clip-path: circle(50%); }
.sym .c1::after { clip-path: polygon(50% 0, 100% 100%, 0 100%); background: rgba(35, 38, 47, 0.7); }
.sym .c2::after { clip-path: inset(8%); }
.sym .c3::after { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.sym .c4::after { clip-path: polygon(35% 0, 65% 0, 65% 35%, 100% 35%, 100% 65%, 65% 65%, 65% 100%, 35% 100%, 35% 65%, 0 65%, 0 35%, 35% 35%); }
.sym .c5::after { clip-path: polygon(0 40%, 100% 40%, 100% 60%, 0 60%); background: rgba(35, 38, 47, 0.7); }
.sym .swatch::after { width: 34%; height: 34%; }
.sym .swatch .kno { opacity: 0; }
.play.solved .board { animation: glow 0.9s ease-out; }
@keyframes glow { 40% { transform: scale(1.02); } }
@media (prefers-reduced-motion: reduce) { .cell { transition: none !important; } .play.solved .board { animation: none; } }

/* 色のボタン */
.pad { display: grid; grid-template-columns: repeat(var(--k, 6), 1fr); gap: 8px; margin-top: 12px; }
.swatch { position: relative; height: 54px; border: 0; border-radius: 14px; cursor: pointer; box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.18); }
.swatch .kno { position: absolute; right: 6px; bottom: 6px; font: 800 13px/1 var(--num); color: rgba(255, 255, 255, 0.9); }
.swatch:disabled { opacity: 0.25; cursor: default; box-shadow: none; }
.swatch:not(:disabled):active { transform: translateY(2px); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18); }
.tool[aria-pressed="true"] { background: var(--primary); color: #fff; border-color: var(--primary); }

.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; }
.tools .tool { flex-direction: column; justify-content: center; gap: 3px; padding: 8px 2px; font-size: 12px; white-space: nowrap; }
.tool { display: inline-flex; align-items: center; gap: 4px; padding: 9px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); font: 900 13px/1 var(--font); cursor: pointer; }
.tool:disabled { opacity: 0.35; cursor: default; }
.kbd { margin: 8px 0 0; font-size: 12px; color: var(--ink-soft); text-align: center; }

/* タイトル・結果（盤を隠して全体を見せる） */
.play.menu .bar, .play.menu .board-wrap, .play.menu .pad, .play.menu .tools, .play.menu .kbd { display: none; }
.card-ui { width: 100%; max-width: 420px; margin: 0 auto; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 20px 16px 16px; text-align: center; box-shadow: 0 10px 30px rgba(43, 42, 51, 0.1); }
.logo { margin: 0; font: 900 30px/1.3 var(--font); letter-spacing: 0.06em; white-space: nowrap; }
.day { margin: 2px 0 12px; font-size: 13px; color: var(--ink-soft); font-weight: 900; }
.daily-box { border: 2px solid var(--primary); border-radius: 16px; padding: 12px; margin-bottom: 10px; }
.daily-lbl { font-size: 11px; font-weight: 900; color: var(--ink-soft); letter-spacing: 0.1em; }
.daily-name { font: 900 24px/1.4 var(--font); color: var(--primary-dark); }
.daily-note { margin: 4px 0 8px; font-size: 12px; color: var(--ink-soft); }
.done { font-size: 14px; font-weight: 900; margin-top: 6px; }
.free-lbl { font-size: 12px; font-weight: 900; color: var(--ink-soft); margin: 6px 0 4px; }
.free-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.howto { list-style: none; margin: 12px 0 0; padding: 10px 12px; background: var(--bg); border-radius: 12px; text-align: left; font-size: 13px; font-weight: 700; }
.howto li { display: flex; align-items: baseline; gap: 6px; padding: 3px 0; }
.howto .num { flex: none; font-weight: 900; color: var(--primary); }
.stats { font-size: 12px; color: var(--ink-soft); font-weight: 700; margin: 10px 0 0; }

.btn { display: block; width: 100%; margin: 8px 0; padding: 13px 10px; border: 0; border-radius: 14px; font: 900 16px/1.2 var(--font); cursor: pointer; background: var(--bg); color: var(--ink); }
.btn small { display: block; font-size: 11px; font-weight: 700; color: var(--ink-soft); margin-top: 3px; }
.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: 15px; padding: 10px 2px; }
.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-dark); }
.clear-moves { font: 800 64px/1 var(--num); font-variant-numeric: tabular-nums; margin: 6px 0; }
.clear-sub { margin: 0; font-size: 14px; font-weight: 700; }
.best { display: inline-block; margin: 8px 0 0; padding: 2px 12px; border-radius: 999px; background: var(--gold); font-weight: 900; font-size: 13px; }
.rank { margin: 12px 0; padding: 8px; background: var(--bg); border-radius: 14px; }
.rank-lbl { font-size: 11px; font-weight: 900; color: var(--ink-soft); }
.rank-name { font: 900 22px/1.4 var(--font); }
.c-note { margin: 8px 0; padding: 8px 10px; border-radius: 12px; background: #fff6dd; font-size: 13px; font-weight: 700; text-align: left; }
.share { margin: 8px 0; }

.toast { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 40; max-width: calc(100% - 24px); padding: 10px 18px; border-radius: 16px; background: rgba(43, 42, 51, 0.92); color: #fff; font-weight: 900; font-size: 14px; text-align: center; pointer-events: none; }

/* 下の解説（ポータルと同じ決まり: 行間 1.85・段落の間は1行分・見出しは前を広く後ろを狭く） */
.guide { margin-top: 28px; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 22px 20px 12px; font-size: 15px; line-height: 1.85; }
.guide p { margin: 0 0 1em; }
.guide h2 { font: 900 19px/1.4 var(--font); margin: 32px 0 12px; padding-left: 10px; border-left: 5px solid var(--primary); }
.guide h2:first-child { margin-top: 0; }
.guide h3 { font-size: 16px; margin: 22px 0 6px; line-height: 1.5; }
.guide ul { padding-left: 1.3em; margin: 0 0 1em; }
.guide li { margin: 6px 0; }
.guide .steps { list-style: none; padding: 0; }
.guide .steps li { display: flex; align-items: baseline; gap: 6px; }
.guide .steps .num { flex: none; font-weight: 900; color: var(--primary); }
.guide details { border-top: 1px solid var(--line); padding: 12px 0; }
.guide details p { margin: 8px 0 4px; }
.guide summary { font-weight: 900; cursor: pointer; }
.guide a { color: var(--primary-dark); }
.g-foot { max-width: 520px; margin: 0 auto; padding: 14px 16px 28px; font-size: 12px; text-align: center; }
.g-foot a { color: var(--ink-soft); }

.card-ui .mg-box { background: var(--bg); border-color: transparent; }
.daily-par { font-size: 13px; font-weight: 900; color: var(--ink-soft); margin-top: 2px; }
.clear-moves span { font: 900 20px/1 var(--font); margin-left: 4px; }
