:root {
  --ink: #1f2d38;
  --ink-soft: #5b6a75;
  --bg: #eaf0f2;
  --paper: #fffefa;
  --line: #ccd8dd;
  --primary: #24566b;
  --primary-dark: #173d4d;
  --accent: #d0472f;
  --gold: #f2c14e;
  --cell: #ffffff;
  --black: #22313b;
  --word: #d9edf3;
  --sel: #ffd66b;
  --keyc: #e9862f;
  --ok: #2e7d4f;
  --font: "Zen Maru Gothic", system-ui, sans-serif;
  --cs: 56px;
  --key: clamp(36px, 5.2dvh, 46px);
}
* { 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; -webkit-touch-callout: none; }

.bar { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-bottom: 6px; }
.box { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 3px 6px; text-align: center; min-width: 0; display: flex; flex-direction: column; justify-content: center; min-height: 44px; }
.lbl { font-size: 10px; font-weight: 900; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.val { font: 900 18px/1.2 var(--font); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* いまのカギ */
.clue-bar { display: flex; align-items: stretch; gap: 4px; margin-bottom: 6px; touch-action: manipulation; }
.cb-arrow { flex: none; width: 36px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--primary); display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.cb-main { flex: 1; min-width: 0; min-height: 52px; display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 0; border-radius: 12px; background: var(--primary); color: #fff; text-align: left; font: 900 15px/1.4 var(--font); cursor: pointer; }
.cb-tag { flex: none; padding: 1px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.2); font-size: 12px; }
.cb-text { flex: 1; min-width: 0; }

/* 盤 */
.grid-wrap { display: flex; justify-content: center; touch-action: manipulation; }
.grid { display: grid; gap: 2px; padding: 2px; background: var(--black); border-radius: 8px; grid-template-columns: repeat(var(--w), var(--cs)); }
.cell { position: relative; width: var(--cs); height: var(--cs); background: var(--cell); border: 0; padding: 0; margin: 0; display: flex; align-items: center; justify-content: center; font: 900 calc(var(--cs) * 0.56)/1 var(--font); color: var(--ink); cursor: pointer; border-radius: 3px; }
.cell.bk { background: var(--black); cursor: default; }
.cell.word { background: var(--word); }
.cell.sel { background: var(--sel); }
.cell .n { position: absolute; left: 3px; top: 1px; font: 900 calc(var(--cs) * 0.2)/1 var(--font); color: var(--ink-soft); }
.cell .kmark { position: absolute; right: 2px; bottom: 2px; width: calc(var(--cs) * 0.3); height: calc(var(--cs) * 0.3); border-radius: 50%; background: var(--keyc); color: #fff; font: 900 calc(var(--cs) * 0.17)/calc(var(--cs) * 0.3) var(--font); text-align: center; }
.cell.kc::after { content: ""; position: absolute; inset: 3px; border: 2px solid var(--keyc); border-radius: 4px; opacity: 0.7; pointer-events: none; }
.cell.lock { color: var(--primary); }
.cell.lock::before { content: ""; position: absolute; left: 3px; bottom: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.cell.ng { color: var(--accent); background: #ffe2dc; }
.cell.ng.sel { background: #ffc9bd; }
.grid.solved .cell:not(.bk) { background: #e3f3e8; color: var(--ok); }
.grid.solved .cell.kc { background: #ffe9d2; color: #b45a12; }
.grid.pop .cell:not(.bk) { animation: pop 0.5s both; animation-delay: calc(var(--i) * 25ms); }
@keyframes pop { 40% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* 今日の言葉（色のマスの字） */
.keyword { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 6px 0 0; min-height: 34px; }
.keyword .kw-lbl { font-size: 11px; font-weight: 900; color: #a95511; margin-right: 2px; }
.keyword .kw { position: relative; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--keyc); background: #fff; display: flex; align-items: center; justify-content: center; font: 900 16px/1 var(--font); color: #a95511; }
.keyword .kw i { position: absolute; top: -7px; right: -6px; font: 900 9px/14px var(--font); font-style: normal; width: 14px; height: 14px; border-radius: 50%; background: var(--keyc); color: #fff; text-align: center; }
.keyword.done .kw { background: var(--keyc); color: #fff; }

/* キーボード（五十音表の並び）。押す操作は touch-action: manipulation の下 */
.keys { margin-top: 8px; touch-action: manipulation; }
.kb { display: grid; gap: 4px; }
.key { height: var(--key); min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); font: 900 17px/1 var(--font); cursor: pointer; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 2px 0 var(--line); touch-action: manipulation; }
.key:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--line); }
.key:disabled { opacity: 0.35; cursor: default; }
.key.gap { visibility: hidden; }
.kb-note { grid-column: 1 / -1; font-size: 12px; font-weight: 900; color: var(--ink-soft); text-align: center; line-height: 1.4; padding: 2px 0; }
.kb-fn { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 4px; margin-top: 4px; }
.key.fn { font-size: 14px; background: #f3f6f8; }
.key.fn small { font-size: 10px; font-weight: 700; color: var(--ink-soft); margin-top: 2px; }
.key.fn[aria-pressed="true"] { background: var(--primary); color: #fff; border-color: var(--primary); }
.key.fn[aria-pressed="true"] small { color: #d4e6ee; }

.tools { display: grid; grid-template-columns: 1.3fr 1.2fr 1fr; gap: 6px; margin-top: 8px; touch-action: manipulation; }
.tool { display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 10px 2px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); font: 900 13px/1 var(--font); cursor: pointer; white-space: nowrap; overflow: hidden; }
.tool:disabled { opacity: 0.35; cursor: default; }
.tool.arm { background: #fff1c9; border-color: #e7c35a; }
.note { margin: 6px 0 0; min-height: 1.6em; font-size: 13px; font-weight: 900; color: var(--primary-dark); text-align: center; line-height: 1.5; }
.note.warn { color: var(--accent); }

/* カギの一覧 */
.clue-list { margin-top: 10px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px; touch-action: manipulation; }
.clue-list h3 { margin: 4px 0 2px; font-size: 13px; color: var(--primary-dark); }
.clue-list ol { list-style: none; margin: 0 0 6px; padding: 0; }
.clue-list li { display: flex; gap: 8px; padding: 4px 6px; border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer; line-height: 1.5; }
.clue-list li b { flex: none; min-width: 1.4em; color: var(--primary); }
.clue-list li.cur { background: var(--word); }
.clue-list li.full { color: var(--ink-soft); }

/* タイトル・結果（盤を隠して全体を見せる） */
.play.menu .bar, .play.menu .clue-bar, .play.menu .grid-wrap, .play.menu .keyword, .play.menu .keys, .play.menu .tools, .play.menu .note, .play.menu .clue-list { display: none; }
.card-ui { width: 100%; max-width: 420px; margin: 0 auto; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 18px 16px 16px; text-align: center; box-shadow: 0 10px 30px rgba(20, 50, 70, 0.08); }
.logo-art { display: grid; grid-template-columns: repeat(4, 38px); grid-template-rows: repeat(2, 38px); gap: 2px; padding: 2px; background: var(--black); border-radius: 6px; width: max-content; margin: 0 auto; }
.logo-art .lc { display: flex; align-items: center; justify-content: center; border-radius: 3px; background: #fff; font: 900 21px/1 var(--font); color: var(--primary-dark); }
.logo-art .lc.bk { background: var(--black); }
.logo-art .lc.kc { background: #ffe9d2; color: #a95511; box-shadow: inset 0 0 0 2px var(--keyc); }
.logo { margin: 8px 0 0; font: 900 26px/1.3 var(--font); letter-spacing: 0.03em; white-space: nowrap; color: var(--primary-dark); }
.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: 12px; margin-bottom: 10px; }
.daily-lbl { font-size: 11px; font-weight: 900; color: var(--ink-soft); letter-spacing: 0.1em; }
.daily-name { font: 900 18px/1.4 var(--font); color: var(--primary-dark); }
.daily-note { margin: 6px 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; }

.list-h { margin: 0; font: 900 24px/1.4 var(--font); color: var(--primary-dark); }
.list-sub { margin: 2px 0 10px; font-size: 12px; color: var(--ink-soft); font-weight: 700; }
.qlist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; touch-action: manipulation; }
.qlist button { width: 100%; padding: 8px 0 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font: 900 15px/1.1 var(--font); color: var(--ink); cursor: pointer; }
.qlist button small { display: block; margin-top: 3px; font-size: 10px; letter-spacing: -1px; color: #b07d00; min-height: 1em; }

.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: 14px; padding: 10px 2px; background: #dfeaee; }
.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-time { font: 900 52px/1.1 var(--font); font-variant-numeric: tabular-nums; margin: 6px 0; }
.clear-sub { margin: 0; font-size: 14px; font-weight: 700; }
.c-key { margin: 10px auto 0; padding: 10px 12px; max-width: 320px; border: 2px solid var(--keyc); border-radius: 14px; background: #fff7ee; }
.c-key:empty { display: none; }
.c-key .ck-lbl { font-size: 11px; font-weight: 900; color: #a95511; }
.c-key .ck-word { font: 900 28px/1.3 var(--font); color: #8a430c; letter-spacing: 0.05em; }
.c-key .ck-word small { font-size: 14px; margin-left: 6px; color: var(--ink-soft); letter-spacing: 0; }
.c-key .ck-text { font-size: 13px; font-weight: 700; }
.c-detail { list-style: none; margin: 8px auto 0; padding: 8px 12px; max-width: 300px; background: var(--bg); border-radius: 12px; text-align: left; font-size: 13px; font-weight: 700; }
.c-detail li { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; }
.c-detail li b { font-weight: 900; }
.c-detail li.tot { border-top: 1px solid var(--line); margin-top: 3px; padding-top: 4px; }
.best { display: inline-block; margin: 8px 4px 0; padding: 2px 12px; border-radius: 999px; background: var(--gold); font-weight: 900; font-size: 13px; }
.pstreak { display: inline-block; margin: 8px 4px 0; padding: 2px 12px; border-radius: 999px; background: #e3f1e6; color: #23603a; 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 24px/1.4 var(--font); color: var(--primary-dark); }
.rank-basis { font-size: 11px; font-weight: 700; color: var(--ink-soft); }
.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; }

/* 解いた盤の言葉（結果の下） */
.memo { margin: 12px 0 4px; text-align: left; }
.memo:empty { display: none; }
.memo h3 { margin: 0 0 6px; font-size: 14px; font-weight: 900; color: var(--primary-dark); text-align: center; }
.memo .mini { display: grid; gap: 2px; padding: 2px; background: var(--black); border-radius: 6px; width: max-content; margin: 0 auto 10px; }
.memo .mini span { width: 30px; height: 30px; background: #fff; display: flex; align-items: center; justify-content: center; font: 900 16px/1 var(--font); border-radius: 2px; }
.memo .mini span.bk { background: var(--black); }
.memo .mini span.kc { background: #ffe9d2; color: #8a430c; }
.memo dl { margin: 0; padding: 4px 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.memo .w { display: grid; grid-template-columns: 3.6em auto 1fr; gap: 0 8px; padding: 5px 0; border-top: 1px dashed var(--line); align-items: baseline; }
.memo .w:first-child { border-top: 0; }
.memo .w .t { font-size: 11px; font-weight: 900; color: var(--ink-soft); white-space: nowrap; }
.memo dt { font: 900 16px/1.3 var(--font); white-space: nowrap; }
.memo dt small { display: block; font: 700 11px/1.3 var(--font); color: var(--ink-soft); }
.memo dd { margin: 0; font-size: 12px; font-weight: 700; line-height: 1.5; }

.toast { position: absolute; left: 50%; top: 2px; transform: translate(-50%, 0); z-index: 40; width: max-content; max-width: calc(100% - 24px); padding: 10px 18px; border-radius: 16px; background: rgba(31, 45, 56, 0.93); color: #fff; font-weight: 900; font-size: 15px; text-align: center; pointer-events: none; }
.toast.mini { font-size: 13px; padding: 6px 14px; border-radius: 12px; white-space: nowrap; }
.toast.big { font: 900 28px/1.3 var(--font); padding: 14px 30px; background: rgba(46, 125, 79, 0.94); }
.toast.bad { background: rgba(208, 71, 47, 0.94); }

/* 下の解説（ポータルと同じ決まり） */
.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: 370px) { main { padding: 0 6px 24px; } .key { font-size: 15px; } .cb-main { font-size: 14px; } }
@media (prefers-reduced-motion: reduce) { .grid.pop .cell:not(.bk) { animation: none; } }

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