:root {
  --ink: #23222f;
  --ink-soft: #636175;
  --bg: #ecebf1;
  --paper: #ffffff;
  --line: #d9d8e4;
  --primary: #4a3f8f;
  --primary-dark: #312966;
  --gold: #f2c14e;
  --night: #24223d;
  --night-cell: #34315a;
  --lamp: #ffd166;
  --lamp-core: #fff3c4;
  --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.15fr 0.85fr 1fr; gap: 8px; margin-bottom: 10px; }
.box { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 6px 8px; text-align: center; min-width: 0; }
.lbl { font-size: 11px; font-weight: 900; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.val { font: 800 26px/1.1 var(--num); font-variant-numeric: tabular-nums; white-space: nowrap; }
.val small { font-size: 17px; color: var(--ink-soft); }

/* 盤（夜の窓のような暗いマスに、丸い明かりがともる） */
.board-wrap { background: var(--night); border-radius: 18px; padding: 10px; box-shadow: 0 10px 28px rgba(36, 34, 61, 0.25); }
.board { display: grid; grid-template-columns: repeat(var(--n, 7), 1fr); gap: 6px; aspect-ratio: 1; touch-action: manipulation; }
.cell { position: relative; border: 0; padding: 0; border-radius: 10px; background: var(--night-cell); cursor: pointer; outline: none; }
.cell::before { content: ""; position: absolute; inset: 20%; border-radius: 50%; background: #4a4672; transition: background-color 0.16s, box-shadow 0.16s, transform 0.16s; }
.cell.on::before { background: radial-gradient(circle at 42% 38%, var(--lamp-core) 0 22%, var(--lamp) 60%, #f0a83a 100%); box-shadow: 0 0 14px 3px rgba(255, 209, 102, 0.55); transform: scale(1.06); }
.cell.on { background: #4a4170; }
/* 押したマスの印（もう一度押すと消える） */
.cell.mark::after { content: ""; position: absolute; right: 9%; bottom: 9%; width: 16%; height: 16%; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.75); }
.cell.cur { box-shadow: inset 0 0 0 3px #9fd3ff; }
.cell.hint { animation: hint 0.9s ease-in-out 3; box-shadow: inset 0 0 0 3px #7ee0b0; }
@keyframes hint { 50% { box-shadow: inset 0 0 0 6px #7ee0b0; } }
.play.solved .board-wrap { animation: dark 1s ease-out; }
@keyframes dark { 40% { transform: scale(1.02); background: #161528; } }
@media (prefers-reduced-motion: reduce) { .cell::before { transition: none !important; } .play.solved .board-wrap, .cell.hint { animation: none; } }

.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 .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 28px/1.3 var(--font); letter-spacing: 0.04em; 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-par { font-size: 13px; font-weight: 900; color: var(--ink-soft); margin-top: 2px; }
.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-moves span { font: 900 20px/1 var(--font); margin-left: 4px; }
.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; }
@media (max-width: 360px) { .board { gap: 4px; } .board-wrap { padding: 8px; } .cell { border-radius: 8px; } }
