/* まいにち神経衰弱 */
:root {
  --ink: #1f2a30;
  --ink-soft: #58656c;
  --bg: #eef1ec;
  --paper: #ffffff;
  --line: #d3dbd6;
  --primary: #1f6f73;
  --primary-dark: #154d52;
  --back: #1f4e5a;
  --back2: #2b6676;
  --face: #fffdf6;
  --accent: #f2a541;
  --ok: #2f9e5b;
  --ng: #d2483b;
  --gold: #f2c14e;
  --font: "Zen Kaku Gothic New", system-ui, sans-serif;
  --num: "Martian Mono", ui-monospace, "Zen Kaku Gothic New", monospace;
}
* { 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: 560px; margin: 0 auto; font-size: 13px; font-weight: 900; }
.g-brand { color: var(--ink-soft); text-decoration: none; white-space: nowrap; }
.g-title { flex: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-head [data-mg-account] a { color: var(--primary-dark); 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: grid; grid-template-columns: 1.2fr 1fr 1fr auto; gap: 8px; }
.box { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 4px 8px; text-align: center; min-width: 0; }
.lbl { font-size: 12px; font-weight: 900; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.val { font: 700 22px/1.25 var(--num); font-variant-numeric: tabular-nums; white-space: nowrap; }
.val small { font: 900 13px/1 var(--font); color: var(--ink-soft); margin-left: 2px; }
.val small.of { font: 700 13px/1 var(--num); margin-left: 0; }
.menu-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 4px 6px; color: var(--ink); font: 900 11px/1.2 var(--font); cursor: pointer; }
.menu-btn span { color: var(--ink-soft); }

/* カードの盤（画面の高さに収まる幅にする） */
.board-wrap { position: relative; margin: 10px auto 0; width: min(100%, calc((100vh - 240px) * var(--cols, 5) / var(--rows, 6) * 0.84)); width: min(100%, calc((100svh - 240px) * var(--cols, 5) / var(--rows, 6) * 0.84)); min-width: min(100%, 250px); }
.board { display: grid; grid-template-columns: repeat(var(--cols, 5), 1fr); gap: var(--gap, 7px); touch-action: manipulation; perspective: 900px; }
.card { position: relative; aspect-ratio: 5 / 6; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 10px; -webkit-appearance: none; appearance: none; touch-action: manipulation; }
.card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.card .in { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 0.26s ease; border-radius: inherit; }
.card .back, .card .face { position: absolute; inset: 0; border-radius: inherit; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: grid; place-items: center; }
/* 裏: 深い青緑に、小さな丸の並びと丸の印（オリジナルの模様） */
.card .back { background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.16) 0 1.6px, transparent 2.2px) 0 0 / 9px 9px, linear-gradient(160deg, var(--back2), var(--back)); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.9), inset 0 0 0 4.5px var(--back), 0 2px 0 rgba(0, 0, 0, 0.18); }
.card .back::after { content: ""; width: 30%; aspect-ratio: 1; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.6); box-shadow: 0 0 0 4px rgba(31, 78, 90, 0.9), 0 0 0 6px rgba(255, 255, 255, 0.22); }
.card .face { transform: rotateY(180deg); background: var(--face); border: 2px solid #e2ddd0; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.12); }
.card .face svg { width: 80%; height: 80%; display: block; }
.card.up .in { transform: rotateY(180deg); }
.card.lift .in { transform: translateY(-4px) rotateY(24deg); }
.card.lift .back { animation: wait 0.9s ease-in-out infinite; }
@keyframes wait { 50% { filter: brightness(1.3); } }
.card.got .face { border-color: #8fd0a8; background: #f4fbf5; }
.card.got.pop .in { animation: got 0.45s ease-out; }
@keyframes got { 0% { transform: rotateY(180deg) scale(1); } 45% { transform: rotateY(180deg) scale(1.1); } 100% { transform: rotateY(180deg) scale(1); } }
.card.got { cursor: default; }
.card.miss .face { border-color: var(--ng); }
.card.peek .face { border: 2px dashed var(--accent); background: #fff7e6; }
.card .retry { position: absolute; right: -5px; top: -5px; width: 24px; height: 24px; border-radius: 50%; background: var(--ng); color: #fff; display: grid; place-items: center; z-index: 2; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }
.peek-bar { position: absolute; left: 0; right: 0; bottom: -10px; height: 5px; border-radius: 99px; background: var(--line); overflow: hidden; }
.peek-bar i { display: block; height: 100%; background: var(--accent); transform-origin: left center; }
.peek-bar.run i { animation: peekbar linear forwards; animation-duration: var(--ms, 3000ms); }
@keyframes peekbar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) { .card .in { transition: none; } .card.lift .back, .card.got.pop .in { animation: none; } }

.tools { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.peek-btn { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 10px; border: 2px solid var(--accent); border-radius: 14px; background: #fff7e6; color: var(--ink); font: 900 15px/1.25 var(--font); cursor: pointer; text-align: left; min-height: 50px; touch-action: manipulation; }
.peek-btn svg { color: #c27712; flex: none; }
.peek-btn small { display: block; font-size: 11px; font-weight: 700; color: var(--ink-soft); }
.peek-btn:disabled { opacity: 0.45; cursor: default; }
.kbd { flex: 1; margin: 0; font-size: 12px; font-weight: 700; color: var(--ink-soft); line-height: 1.5; min-width: 0; }

/* タイトル・結果（盤を隠して全体を見せる） */
.play.menu .bar, .play.menu .board-wrap, .play.menu .tools { 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(29, 36, 51, 0.1); }
.logo { margin: 0; font: 900 clamp(24px, 8vw, 32px)/1.3 var(--font); letter-spacing: 0.04em; }
.logo span { display: inline-block; 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: 12px; 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: 13px; color: var(--ink-soft); }
.done { font-size: 15px; font-weight: 900; margin-top: 6px; }
.t-note { margin: 8px 0 0; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.free-box { border: 1px solid var(--line); border-radius: 16px; padding: 10px 10px 2px; margin-top: 10px; }
.free-lbl { font-size: 15px; font-weight: 900; }
.free-lbl small { display: block; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.lv-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.btn.lv { font: 700 18px/1.2 var(--num); padding: 10px 4px; }
.btn.lv small { font-family: var(--font); }
.howto { list-style: none; margin: 12px 0 0; padding: 10px 12px; background: var(--bg); border-radius: 12px; text-align: left; font-size: 14px; 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: 13px; color: var(--ink-soft); font-weight: 700; margin: 10px 0 0; }

.btn { display: block; width: 100%; margin: 8px 0; padding: 14px 10px; border: 0; border-radius: 14px; font: 900 17px/1.2 var(--font); cursor: pointer; background: var(--bg); color: var(--ink); }
.btn small { display: block; font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-top: 4px; }
.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.sub { font-size: 16px; }
.btn.ghost { background: transparent; border: 2px solid var(--line); color: var(--ink-soft); font-size: 15px; }
.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-big { margin: 6px 0; }
.clear-big b { font: 700 64px/1 var(--num); font-variant-numeric: tabular-nums; }
.clear-big span { font: 900 20px/1 var(--font); margin-left: 4px; }
.clear-sub { margin: 0; font-size: 15px; font-weight: 700; }
.ops { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 6px 0 0; padding: 0; }
.ops li { background: var(--bg); border-radius: 12px; padding: 6px 2px; font-size: 12px; font-weight: 900; color: var(--ink-soft); white-space: nowrap; }
.ops b { display: block; font: 700 22px/1.2 var(--num); color: var(--ink); }
.best { display: block; width: max-content; margin: 10px auto 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: 12px; font-weight: 900; color: var(--ink-soft); }
.rank-name { font: 900 22px/1.4 var(--font); }
.rank-basis { font-size: 11px; font-weight: 700; color: var(--ink-soft); }
/* 結果の内訳（届いたレベル・1問の平均・時間がかかった種類・前回との差） */
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 12px 0 0; }
.facts div { background: var(--bg); border-radius: 12px; padding: 6px 4px; min-width: 0; }
.facts dt { font-size: 11px; font-weight: 900; color: var(--ink-soft); }
.facts dd { margin: 0; font-size: 15px; font-weight: 900; line-height: 1.35; }
.facts dd small { font-size: 12px; 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; }

.toast { position: fixed; left: 50%; bottom: 14%; transform: translateX(-50%); z-index: 40; max-width: calc(100% - 24px); padding: 10px 18px; border-radius: 16px; background: rgba(29, 36, 51, 0.92); color: #fff; font-weight: 900; font-size: 15px; 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; }

.clear-big.miss b { color: var(--ink-soft); }
.card-ui .mg-box { background: var(--bg); border-color: transparent; }
@media (max-width: 360px) {
  .bar { gap: 6px; }
  .box { padding: 4px 5px; }
  .val { font-size: 19px; }
  .board { --gap: 5px; }
}
