:root {
  --ink: #1d2230;
  --ink-soft: #5b6375;
  --bg: #eef1f6;
  --felt: #1d5a47;
  --felt-deep: #164a3a;
  --felt-line: rgba(255, 255, 255, 0.24);
  --card: #ffffff;
  --red: #d63a2f;
  --black: #1d2230;
  --gold: #f2c14e;
  --primary: #e2412c;
  --primary-dark: #b52f1d;
  --line: #d8dde8;
  --font: "Zen Kaku Gothic New", system-ui, sans-serif;
  --num: "Big Shoulders Display", 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.6; 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: 640px; 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(--felt); text-decoration: none; }

main { max-width: 640px; margin: 0 auto; padding: 0 8px 24px; }
.play { position: relative; background: radial-gradient(120% 80% at 50% 0%, #237058 0%, var(--felt) 55%, var(--felt-deep) 100%); border-radius: 16px; padding: 8px 6px 6px; color: #fff; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 0 2px 8px; font-size: 14px; white-space: nowrap; min-width: 0; }
.bar-left { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.bar-right { flex: none; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--gold); color: var(--ink); font-size: 12px; font-weight: 900; }
.badge.free { background: #fff; }
.cells-sub { font-weight: 900; margin-left: 6px; font-size: 12px; opacity: 0.9; }
.bar-right b { font-variant-numeric: tabular-nums; font: 800 18px/1 var(--num); }
.lbl { opacity: 0.75; font-size: 11px; font-weight: 900; }
/* 狭い画面: 上の決まりより後ろに置く（同じ強さの決まりは後ろが勝つ） */
@media (max-width: 380px) { .bar { font-size: 13px; } .bar-right b { font-size: 16px; } .badge { padding: 2px 8px; } .cells-sub { margin-left: 4px; font-size: 11px; } .bar .lbl { font-size: 10px; } }
.note { margin: 6px 0 0; min-height: 1.5em; font-size: 13px; font-weight: 900; text-align: center; color: #ffe9a6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 場 */
.table { position: relative; touch-action: none; margin: 0 auto; }
.slot { position: absolute; border: 2px solid var(--felt-line); border-radius: 9%/6.5%; display: flex; align-items: center; justify-content: center; color: rgba(255, 255, 255, 0.3); }
.slot svg { width: 46%; height: 46%; }
.slot.cell { border-style: dashed; }
.slot.found { background: rgba(0, 0, 0, 0.12); }
.slot.off { display: none; }
.slot.target { border-color: var(--gold); box-shadow: 0 0 12px var(--gold); }
.slot .k { font: 800 clamp(14px, 4.6vw, 24px)/1 var(--num); }
.col-ground { position: absolute; border-radius: 9%/6.5%; border: 2px solid rgba(255, 255, 255, 0.12); }
.col-ground.target { border-color: var(--gold); box-shadow: 0 0 12px var(--gold); }

.c { position: absolute; left: 0; top: 0; border-radius: 9%/6.5%; background: var(--card); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); transition: transform 0.18s ease-out; will-change: transform; cursor: pointer; overflow: hidden; }
.c.red { color: var(--red); }
.c.black { color: var(--black); }
.c .ix { position: absolute; left: 6%; top: 2%; display: flex; flex-direction: row; align-items: center; gap: 1px; line-height: 1; }
.c .rk { font: 800 var(--rk, 18px)/1 var(--num); letter-spacing: -0.02em; }
.c .ix svg { width: var(--sm, 11px); height: var(--sm, 11px); flex: none; }
.c .big { position: absolute; right: 7%; bottom: 6%; width: 46%; height: 46%; }
.c.drag { transition: none; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4); }
.c.hint { animation: hint 0.9s ease-in-out 2; }
.slot.hint, .col-ground.hint { animation: hintslot 0.9s ease-in-out 2; }
@keyframes hint { 50% { box-shadow: 0 0 0 4px var(--gold), 0 0 18px var(--gold); } }
@keyframes hintslot { 50% { border-color: var(--gold); box-shadow: 0 0 14px var(--gold); } }
.c.shake { animation: shake 0.3s; }
@keyframes shake { 25% { margin-left: -4px; } 75% { margin-left: 4px; } }
.c.win { animation: bounce 0.6s ease-out both; }
@keyframes bounce { 40% { transform: var(--tf) translateY(-14px); } }
@media (prefers-reduced-motion: reduce) { .c { transition: none; } .c.hint, .c.shake, .c.win, .slot.hint, .col-ground.hint { animation: none; } }

/* 操作のボタン（すばやく続けて押すので touch-action: manipulation。iPhone でもダブルタップのズームにならず、毎回押せる） */
.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 6px 0 0; touch-action: manipulation; }
.tool { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border: 0; border-radius: 12px; background: transparent; color: #fff; font: 700 11px/1.2 var(--font); cursor: pointer; touch-action: manipulation; }
.tool:active { background: rgba(255, 255, 255, 0.12); }
.tool:disabled { opacity: 0.35; cursor: default; }
/* ヒントを探しているあいだ: 押せない見た目にして、くるくる回る印 */
.tool.busy { opacity: 0.5; cursor: progress; }
.tool.busy svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .tool.busy svg { animation: none; } }

/* タイトル・結果（場を隠して全体を見せる） */
.play.menu .table, .play.menu .tools, .play.menu .bar, .play.menu .note { display: none; }
.scr { padding: 6px 0 4px; }
.card-ui { width: 100%; max-width: 400px; margin: 0 auto; background: #fff; color: var(--ink); border-radius: 18px; padding: 18px 16px 14px; text-align: center; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); }
.logo-art { display: flex; justify-content: center; gap: 6px; margin-bottom: 4px; }
.logo-art .mini { display: inline-flex; align-items: center; gap: 2px; padding: 4px 8px; border-radius: 8px; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25); font: 800 20px/1 var(--num); color: var(--black); }
.logo-art .mini.red { color: var(--red); }
.logo-art svg { width: 16px; height: 16px; }
.logo { margin: 0; font-size: 26px; font-weight: 900; letter-spacing: 0.04em; white-space: nowrap; }
.day { margin: 2px 0 10px; font-size: 13px; color: var(--ink-soft); font-weight: 900; }
.daily-box { border: 2px solid var(--felt); 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-no { font: 800 30px/1.1 var(--num); color: var(--felt); }
.daily-cells { font-size: 14px; font-weight: 900; }
.daily-cells .dots { display: inline-flex; gap: 3px; vertical-align: -2px; margin-left: 4px; }
.daily-cells .dots i { width: 13px; height: 17px; border-radius: 3px; border: 2px dashed var(--felt); }
.daily-note { margin: 4px 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 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(--felt); }
.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 var(--font); cursor: pointer; background: var(--bg); color: var(--ink); touch-action: manipulation; }
.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; background: #e3efe9; }
.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(--felt); }
.clear-time { font: 800 64px/1 var(--num); font-variant-numeric: tabular-nums; margin: 4px 0; }
.clear-sub { margin: 0; font-size: 14px; font-weight: 700; }
.best { display: inline-block; margin: 6px 4px 0; padding: 2px 12px; border-radius: 999px; background: var(--gold); font-weight: 900; font-size: 13px; }
.pstreak { display: inline-block; margin: 6px 4px 0; padding: 2px 12px; border-radius: 999px; background: #e6f6ee; color: #1f6b47; font-weight: 900; font-size: 13px; }
.rank { margin: 10px 0; padding: 8px; background: #eef4f1; border-radius: 14px; }
.rank-lbl { font-size: 11px; font-weight: 900; color: var(--ink-soft); }
.rank-bar { display: flex; justify-content: center; gap: 4px; margin: 4px 0 2px; }
.rank-bar i { width: 18px; height: 10px; border-radius: 3px; background: #c9d6cf; }
.rank-bar i.on { background: var(--felt); }
.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; }
.next-day { margin: 4px 0 6px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }

.toast { position: absolute; left: 50%; bottom: 70px; transform: translateX(-50%); z-index: 1300; width: max-content; max-width: calc(100% - 24px); padding: 10px 18px; border-radius: 16px; background: rgba(20, 24, 36, 0.92); color: #fff; font-weight: 900; font-size: 14px; text-align: center; pointer-events: none; }

/* 下の解説（ポータルと同じ決まり: 行間 1.85・段落の間は1行分・見出しは前を広く後ろを狭く） */
.guide { margin-top: 24px; background: #fff; border-radius: 18px; padding: 22px 20px 12px; font-size: 15px; line-height: 1.85; }
.guide p { margin: 0 0 1em; }
.guide h2 { font-size: 19px; margin: 32px 0 12px; padding-left: 10px; border-left: 5px solid var(--felt); line-height: 1.4; }
.guide h2:first-child { margin-top: 0; }
.guide h3 { font-size: 16px; margin: 22px 0 6px; line-height: 1.5; }
.guide ul, .guide ol { margin: 0 0 1em; }
.guide ul { padding-left: 1.3em; }
.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(--felt); }
.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(--felt); }
.g-foot { max-width: 640px; margin: 0 auto; padding: 12px 16px 28px; font-size: 12px; text-align: center; }
.g-foot a { color: var(--ink-soft); }
.card-ui .mg-box { background: #eef4f1; border-color: transparent; }

/* 遊んでいるあいだ（html.freecell-play）: ページが指でずれない・サイトの見出しを隠して場を大きく */
html.freecell-play, html.freecell-play body { overscroll-behavior: none; }
html.freecell-play .g-head { display: none; }
html.freecell-play main { padding: 4px 4px 24px; }
