:root {
  --ink: #2f2a22;
  --ink-soft: #6d6455;
  --bg: #f3eedf;
  --paper: #fffdf6;
  --line: #e2d8bf;
  --primary: #3f7a3a;
  --primary-dark: #2b5a28;
  --gold: #f5b82e;
  --grass: #7cbf4f;
  --grass-dark: #5f9e3a;
  --grass-hi: #9ad468;
  --soil: #e9d3a8;
  --soil-dark: #d8bd8a;
  --font: "Zen Maru Gothic", system-ui, sans-serif;
  --num: "Mochiy Pop One", "Zen Maru Gothic", 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; -webkit-touch-callout: none; }

.bar { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 6px; }
.box { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 5px 6px; 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 { display: flex; align-items: center; justify-content: center; gap: 4px; font: 400 22px/1.2 var(--num); font-variant-numeric: tabular-nums; white-space: nowrap; }
.val.sm { font: 900 14px/1.6 var(--font); }
.val .ico { width: 20px; height: 20px; }
.gold-box.ok { background: #fff3c4; border-color: var(--gold); }
.gold-box.ng { opacity: 0.6; }
.note { margin: 0 0 6px; min-height: 1.6em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; font-weight: 900; color: var(--primary-dark); text-align: center; }
.note.warn { color: #b3402e; }

/* 畑（土の上に草の生えたマス。掘ると土が見える） */
.field-wrap { background: #6b4a2b; border-radius: 14px; padding: 4px; box-shadow: 0 8px 22px rgba(80, 55, 25, 0.25); touch-action: none; }
.field-wrap.shake { animation: shake 0.35s; }
@keyframes shake { 20% { transform: translateX(-5px); } 45% { transform: translateX(5px); } 70% { transform: translateX(-3px); } }
.field { display: grid; grid-template-columns: repeat(var(--w, 9), 1fr); gap: 2px; margin: 0 auto; touch-action: none; }
.c { position: relative; aspect-ratio: 1; border-radius: 5px; background: linear-gradient(160deg, var(--grass-hi), var(--grass) 55%, var(--grass-dark)); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12); cursor: pointer; display: flex; align-items: center; justify-content: center; font: 400 clamp(13px, 4.4vw, 20px)/1 var(--num); }
.c.o { background: var(--soil); box-shadow: inset 0 1px 2px rgba(110, 80, 40, 0.25); cursor: default; }
.c.o.z { background: #f1e2c2; }
.c svg { width: 74%; height: 74%; pointer-events: none; }
.c.o.tap { cursor: pointer; }
.c.cur { outline: 3px solid #fff; outline-offset: -3px; }
.c.press { filter: brightness(1.12); }
.c.start::after { content: ""; position: absolute; inset: 8%; border-radius: 50%; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9); animation: pulse 1.2s ease-in-out infinite; pointer-events: none; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.35); } }
.c.gold:not(.o) { background: linear-gradient(160deg, #ffe58a, #f5c443 55%, #d9a21f); }
.c.gold:not(.o) svg.g { animation: twinkle 1.6s ease-in-out infinite; }
@keyframes twinkle { 50% { transform: scale(1.12) rotate(-6deg); } }
.c.gold.o { background: #fff0b3; }
.c.gold.o::before { content: ""; position: absolute; right: 2px; top: 2px; width: 30%; height: 30%; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 1.5px #fff; }
.c.hit { background: #e8a08f; }
.c.hit svg { animation: pop 0.4s ease-out; }
@keyframes pop { 0% { transform: translateY(40%) scale(0.6); } 70% { transform: translateY(-8%) scale(1.08); } }
.c.mole-end { background: #cfe7b8; }
.c.wrong-flag { background: #f6c9bd; }
.c.hint { animation: hint 0.9s ease-in-out 3; box-shadow: inset 0 0 0 3px #ffffff, 0 0 0 2px #2b8be0; z-index: 1; }
.c.hint-ng { animation: hint 0.9s ease-in-out 3; box-shadow: inset 0 0 0 3px #ff6b5a; z-index: 1; }
@keyframes hint { 50% { transform: scale(1.12); } }
.c.dug { animation: dug 0.25s ease-out var(--dd, 0ms) both; }
@keyframes dug { 0% { transform: scale(0.82); filter: brightness(1.2); } }
.n1 { color: #2b6fd6; } .n2 { color: #2e8b3e; } .n3 { color: #d63b2b; } .n4 { color: #6a3fb5; }
.n5 { color: #a8481c; } .n6 { color: #1f8a8a; } .n7 { color: #333; } .n8 { color: #777; }
@media (prefers-reduced-motion: reduce) {
  .c.start::after, .c.gold:not(.o) svg.g, .c.hint, .c.hint-ng, .c.dug, .c.hit svg, .field-wrap.shake { animation: none; }
}

.tools { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 6px; margin-top: 10px; }
.tool { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 8px 2px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); font: 900 12px/1 var(--font); cursor: pointer; white-space: nowrap; }
.tool:disabled { opacity: 0.35; cursor: default; }
.tool.mode { flex-direction: row; gap: 0; padding: 4px; }
.tool.mode span { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 8px 4px; border-radius: 9px; font-size: 15px; color: var(--ink-soft); }
.tool.mode svg { width: 22px; height: 22px; }
.tool.mode .m-dig { background: var(--primary); color: #fff; }
.tool.mode[aria-pressed="true"] .m-dig { background: transparent; color: var(--ink-soft); }
.tool.mode[aria-pressed="true"] .m-flag { background: #e8493f; color: #fff; }
.kbd { margin: 8px 0 0; font-size: 12px; color: var(--ink-soft); text-align: center; }

/* タイトル・結果（畑を隠して全体を見せる） */
.play.menu .bar, .play.menu .note, .play.menu .field-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: 18px 16px 16px; text-align: center; box-shadow: 0 10px 30px rgba(80, 60, 30, 0.1); }
.logo-art { display: flex; justify-content: center; align-items: flex-end; gap: 6px; }
.logo-art svg { width: 34px; height: 34px; }
.logo-art svg.lm { width: 46px; height: 46px; }
.logo { margin: 0; font: 400 28px/1.3 var(--num); letter-spacing: 0.04em; 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 22px/1.4 var(--font); color: var(--primary-dark); }
.daily-gold { display: flex; align-items: flex-start; gap: 6px; margin: 6px 0 0; padding: 6px 8px; border-radius: 10px; background: #fff3c4; font-size: 12px; font-weight: 700; text-align: left; }
.daily-gold svg { flex: none; width: 22px; height: 22px; }
.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; }

.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; background: #e8f3dc; }
.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: 400 56px/1.1 var(--num); font-variant-numeric: tabular-nums; margin: 6px 0; }
.clear-sub { margin: 0; font-size: 14px; 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; }
.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; }
.pstreak { display: inline-block; margin: 8px 4px 0; padding: 2px 12px; border-radius: 999px; background: #e6f6ee; color: #1f6b47; font-weight: 900; font-size: 13px; }

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

/* 下の解説（ポータルと同じ決まり: 行間 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) { main { padding: 0 8px 24px; } .c { border-radius: 4px; } }
.tools.two { grid-template-columns: 3fr 1fr; }

/* 遊んでいるあいだ（html.hata-play）: ページが指でずれない・サイトの見出しを隠して畑を大きく */
html.hata-play, html.hata-play body { overscroll-behavior: none; }
html.hata-play .g-head { display: none; }
html.hata-play main { padding: 6px 6px 24px; }
/* 金のかぶを開いて、まわりの旗が数字とそろった */
.c.gold.o.lit { background: #ffe58a; box-shadow: 0 0 0 2px var(--gold), 0 0 10px rgba(245, 184, 46, 0.8); z-index: 1; }
.gold-box.ok .val { color: #8a5a00; }
/* 縦が足りない画面（.play.compact）: 帯と文字を詰め、道具の列を畑の上に置く */
.play.compact .bar { gap: 6px; margin-bottom: 3px; }
.play.compact .box { padding: 2px 6px; }
.play.compact .lbl { font-size: 10px; }
.play.compact .val { font-size: 18px; }
.play.compact .val.sm { font-size: 12px; line-height: 1.5; }
.play.compact .note { margin-bottom: 3px; font-size: 12px; min-height: 1.4em; }
.play.compact .tools { margin: 0 0 5px; }
.play.compact .tools .tool { padding: 4px 2px; }
.play.compact .tool.mode span { padding: 5px 4px; font-size: 14px; }
.play.compact .tool.mode svg { width: 18px; height: 18px; }
.play.compact .kbd { display: none; }
/* 金のかぶ: 残りが少ないのに、まわりの旗の数がそろっていない */
.gold-box.urge { border-color: var(--gold); animation: urge 0.9s ease-in-out infinite; }
@keyframes urge { 50% { background: #fff0b3; box-shadow: 0 0 0 3px rgba(245, 184, 46, 0.6); } }
@media (prefers-reduced-motion: reduce) { .gold-box.urge { animation: none; background: #fff0b3; } }
/* 畑の枠は畑の幅に合わせる（縮めたときに左右の土が広く余らないように） */
.field-wrap { width: fit-content; max-width: 100%; margin: 0 auto; }
