:root {
  --paper: #f6f7f0;
  --ink: #324c39;
  --muted: #6e7b65;
  --line: #dfe3d7;
  --font: -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
  --table-width: min(748px, calc(73.3333svh - 73.333px), calc(100vw - 328px));
}
* { box-sizing: border-box; }
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 13px var(--font); -webkit-font-smoothing: antialiased; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
button:focus-visible, a:focus-visible { outline: 3px solid #9fb866; outline-offset: 4px; }
button:disabled { cursor: default; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.site-header { height: 64px; max-width: 1200px; margin: auto; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; gap: 16px; }
.brand { display: flex; gap: 12px; align-items: center; }
h1 { font-size: 21px; letter-spacing: .5px; margin: 0; font-weight: 700; }
.brand-marimo { position: relative; display: block; width: 32px; height: 32px; border-radius: 47% 52% 48% 51%; background: #78984d; box-shadow: inset -4px -4px #6c8c43; transform: rotate(-9deg); flex-shrink: 0; }
.brand-marimo i { position: absolute; left: 10px; top: 15px; width: 3px; height: 4px; border-radius: 50%; background: #30462b; }
.brand-marimo i + i { left: 22px; }
.header-actions { display: flex; align-items: center; gap: 20px; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; display: grid; place-items: center; background: transparent; }
.icon-button:hover { background: #e9eddf; }
.icon-button svg { width: 17px; height: 17px; }
.help-button, .pause-button { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 34px; font-size: 12px; background: transparent; padding: 6px 10px; border: 1px solid #a9b29f; border-radius: 8px; white-space: nowrap; }
.help-button:hover, .pause-button:hover { background: #e9eddf; }
.help-button > span { width: 20px; height: 20px; border: 1px solid #a9b29f; border-radius: 50%; display: grid; place-items: center; }
.pause-button > span:first-child { font-size: 17px; }
main { margin: 18px auto; padding: 0 16px; }
footer { margin: 24px auto 0; padding: 16px 0; text-align: center; font-size: 12px; line-height: 1.8; color: var(--muted); }
footer a, footer a:visited { color: #527244; text-decoration: underline; text-underline-offset: 3px; }
footer a:hover { color: #324c39; }
.game-layout { display: grid; width: fit-content; max-width: 100%; margin: auto; grid-template-columns: var(--table-width) 240px; grid-template-rows: auto 1fr; gap: 22px 32px; align-items: start; }
.table-column { width: 100%; min-width: 0; grid-column: 1; grid-row: 1 / 3; }
.table-shell { position: relative; overflow: hidden; border-radius: 100px 100px 26px 26px; background: #d5e3c9; border: 7px solid #52704b; box-shadow: 0 5px 0 #3d5c3b, 0 12px 28px -18px #47623c60; touch-action: pinch-zoom; }
canvas { display: block; width: 100%; height: auto; aspect-ratio: 11 / 15; }
.score-panel { grid-column: 2; grid-row: 1; padding-top: 8px; }
.label { font-size: 12px; color: var(--muted); }
.score-heading { display: flex; align-items: center; justify-content: space-between; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: #b4bda5; }
.live-dot.active { background: #92a94d; box-shadow: 0 0 0 4px #e7edda; }
.score { display: block; font-size: 45px; font-weight: 500; letter-spacing: -1px; margin: 4px 0 13px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.best-score { display: flex; align-items: center; justify-content: space-between; }
.best-score output { font-size: 16px; font-variant-numeric: tabular-nums; }
.remaining-balls { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.balls-label { display: flex; justify-content: space-between; align-items: center; }
.balls-label > span:last-child { font-size: 12px; color: var(--muted); }
.marimo-lives { display: flex; gap: 15px; margin: 16px 0 0; }
.mini-marimo { display: inline-block; width: 30px; height: 30px; background: url('./marimo.svg') center / contain no-repeat; transition: opacity .3s; }
.mini-marimo.lost { opacity: .19; filter: grayscale(1); }
.mission-card { margin-top: 22px; padding: 15px; border: 1px solid #dce3ca; border-radius: 10px; background: #eef2e4; }
.mission-card h2, .guide-panel h2 { font-size: 13px; margin: 0; font-weight: 600; }
.mission-card p { font-size: 11px; line-height: 1.8; margin: 8px 0; color: var(--muted); }
.mission-card strong { color: #4c6b38; white-space: nowrap; }
.mission-card.upgraded { background: #eee7f6; border-color: #c1a8dc; }
.mission-card #upgrade-status { font-size: 10px; color: #83713a; }
.mission-card.upgraded #upgrade-status { color: #77539c; }
.flowers { display: flex; gap: 18px; font-size: 25px; line-height: 1.2; color: #c6d0ae; }
.flowers span { transition: color .25s; }
.flowers span.bloomed { color: #ba862d; }
.combo-box { position: relative; padding-top: 18px; margin-top: 2px; }
.combo-box > output { position: absolute; right: 0; top: 12px; font-size: 24px; color: #56753b; }
.combo-box > span:not(.label) { display: block; font-size: 11px; color: var(--muted); margin-top: 10px; line-height: 1.7; }
.combo-track { background: #e0e6d5; height: 4px; border-radius: 4px; margin-top: 10px; overflow: hidden; }
.combo-track i { display: block; width: 0; height: 100%; background: #94ad5d; border-radius: 4px; transition: width .1s linear; }
.guide-panel { grid-column: 2; grid-row: 2; border-top: 1px solid var(--line); padding-top: 18px; }
.control-row { display: flex; gap: 13px; align-items: center; margin: 15px 0; }
.key-pair { display: flex; gap: 4px; flex-shrink: 0; }
kbd { font-family: var(--font); display: inline-grid; place-items: center; background: #fdfdf8; width: 28px; height: 31px; border-radius: 5px; border: 1px solid #d9dfcd; box-shadow: 0 2px 0 #dfe4d5; font-size: 15px; }
.space-key { width: 60px; font-size: 9px; }
.control-row > span { font-size: 11px; }
.touch-note, .scoring-note { font-size: 11px; color: var(--muted); line-height: 1.9; margin: 12px 0; }
.launch-button { isolation: isolate; overflow: hidden; position: relative; width: 100%; margin-top: 7px; min-height: 60px; display: flex; align-items: center; gap: 12px; border-radius: 8px; background: #e5edbd; text-align: left; padding: 12px 15px; user-select: none; touch-action: none; }
.launch-button:hover { background: #dce7ac; }
.launch-button strong { font-size: 12px; font-weight: 600; display: block; }
.launch-button small { display: block; font-size: 10px; color: #68794e; margin-top: 6px; }
.launch-symbol { font-size: 26px; color: #6c8452; }
.launch-meter { position: absolute; inset: 0 auto 0 0; z-index: -1; width: 0; background: #c7d98c; transition: width .05s; }
.launch-button.unavailable { opacity: .55; }
.game-overlay { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: calc(100% - 32px); max-width: 380px; text-align: center; padding: 25px 22px 23px; background: #f8f9eff2; backdrop-filter: blur(6px); border: 1px solid #fff; border-radius: 15px; box-shadow: 0 12px 45px #385b3220; }
.game-overlay h2 { font-size: 22px; margin: 0 0 15px; }
.game-overlay p { font-size: 12px; color: var(--muted); line-height: 2; margin: 0 0 20px; }
.start-button { background: #3f603e; color: #f9faef; border-radius: 7px; padding: 14px 18px; width: 100%; font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.start-button:hover { background: #527448; }
.start-button > span { font-size: 18px; }
.overlay-footnote { display: block; font-size: 11px; color: var(--muted); margin-top: 14px; }
.board-message { position: absolute; top: 57%; left: 50%; transform: translate(-50%, -50%); font-size: 13px; white-space: nowrap; color: #3e653c; text-align: center; background: #f7fae4ed; padding: 11px 16px; border-radius: 25px; pointer-events: none; opacity: 0; transition: opacity .2s; }
.board-message.visible { opacity: 1; }
.pause-overlay { position: absolute; inset: 0; background: #edf2e1dc; backdrop-filter: blur(7px); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.pause-overlay > span { font-size: 38px; color: #7b945d; }
.pause-overlay h2 { font-weight: 500; font-size: 24px; }
.pause-overlay button { padding: 13px 30px; border-radius: 6px; background: #426640; color: white; font-size: 13px; }
/* Block accidental gestures across control gaps as well as on the buttons. */
.mobile-controls { display: none; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.mobile-controls button { flex: 1; min-width: 0; min-height: 92px; border: 1px solid #d9e0cc; border-radius: 8px; background: #e9efdb; font-size: 36px; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.mobile-controls #mobile-launch { font-size: 24px; background: #e0e9b8; }
.mobile-controls #mobile-launch.unavailable { opacity: .55; }
.mobile-controls button:active, .mobile-controls button.pressed { background: #c6d79c; }
/* Keep touch controls available on wide tablets and devices with a mouse attached. */
@media (max-width: 760px), (any-pointer: coarse) {
  .mobile-controls { display: flex; gap: 8px; margin-top: 12px; }
  .control-row, .launch-button { display: none; }
}
dialog { color: var(--ink); background: #f8f9f1; border: 1px solid #dfe5d2; border-radius: 16px; width: min(460px, 90vw); max-height: 90svh; overflow-y: auto; padding: 30px; box-shadow: 0 20px 100px #203a3033; }
dialog::backdrop { background: #263a2f55; backdrop-filter: blur(5px); }
.dialog-close { position: absolute; right: 14px; top: 10px; font-size: 25px; background: none; color: #849276; }
dialog h2 { font-size: 21px; margin: 8px 0 18px; }
dialog > p { font-size: 12px; line-height: 2; color: var(--muted); }
dialog ul { padding: 0; list-style: none; margin: 23px 0; }
dialog li { display: flex; flex-direction: column; gap: 5px; padding: 11px 0; border-bottom: 1px solid #e2e6d9; }
dialog li strong { font-size: 12px; font-weight: 600; }
dialog li span { font-size: 11px; color: var(--muted); line-height: 1.8; }
.dialog-note { font-size: 11px; margin: 20px 0; }
dialog .start-button { justify-content: center; }
@media (max-width: 760px) {
  :root { --table-width: min(100%, calc(73.3333svh - 158.4px)); }
  .site-header { height: 54px; padding: 0 12px; }
  h1 { font-size: 17px; letter-spacing: 0; }
  .brand { gap: 8px; }
  .brand-marimo { width: 27px; height: 27px; }
  .brand-marimo i { top: 13px; left: 8px; }
  .brand-marimo i + i { left: 18px; }
  .header-actions { gap: 12px; }
  .pause-button { min-width: 24px; justify-content: center; }
  #pause-label { display: none; }
  .help-button { font-size: 11px; gap: 5px; }
  .help-button > span { display: none; }
  .icon-button { width: 30px; height: 30px; }
  main { margin: 10px auto 18px; padding: 0 8px; max-width: 640px; }
  .game-layout { display: flex; flex-direction: column; width: 100%; gap: 10px; align-items: center; }
  .score-panel { display: grid; grid-template-columns: 1.2fr 1fr 1fr; align-items: center; width: var(--table-width); max-width: 100%; gap: 12px; padding: 0 5px; }
  .label, .balls-label > span:last-child { font-size: 10px; }
  .score { font-size: clamp(20px, 6.5vw, 27px); margin: 3px 0 0; }
  .best-score { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
  .best-score output { font-size: 17px; }
  .remaining-balls { margin: 0; padding: 0; border: 0; }
  .balls-label > span:last-child { display: none; }
  .marimo-lives { gap: 9px; margin-top: 11px; }
  .mini-marimo { width: 23px; height: 23px; }
  .mission-card, .combo-box { display: none; }
  .table-column { width: var(--table-width); max-width: 100%; }
  .table-shell { border-radius: 80px 80px 22px 22px; border-width: 6px; }
  .guide-panel { width: var(--table-width); max-width: 100%; border: 0; padding: 0; }
  .guide-panel h2, .control-row, .touch-note, .scoring-note, .launch-button { display: none; }
  .game-overlay { padding: 22px 16px; }
  .game-overlay h2 { font-size: 19px; }
  .game-overlay p { font-size: 11px; }
  .start-button { font-size: 12px; }
  .board-message { font-size: 11px; padding: 9px 13px; }
}
@media (max-height: 720px) and (min-width: 761px) {
  .game-layout { gap: 14px 26px; }
  .score-panel { padding-top: 0; }
  .remaining-balls { margin-top: 12px; padding-top: 10px; }
  .mission-card { margin-top: 14px; padding: 10px 14px; }
  .combo-box { padding-top: 10px; }
  .combo-box > output { top: 5px; }
  .guide-panel { padding-top: 12px; }
  .guide-panel h2, .touch-note, .scoring-note { display: none; }
  .control-row { margin: 12px 0; }
}
@media (min-width: 761px) {
  .game-layout { row-gap: 12px; }
  .score-panel { padding-top: 4px; }
  .score { margin: 2px 0 8px; }
  .remaining-balls { margin-top: 12px; padding-top: 10px; }
  .marimo-lives { margin-top: 10px; }
  .mission-card { margin-top: 12px; padding: 10px 15px; }
  .mission-card p { margin: 5px 0; line-height: 1.6; }
  .combo-box { padding-top: 10px; }
  .combo-box > output { top: 5px; }
  .combo-box > span:not(.label) { margin-top: 6px; }
  .combo-track { margin-top: 6px; }
  .guide-panel { padding-top: 10px; }
  .control-row { margin: 9px 0; }
  .launch-button { margin-top: 4px; min-height: 52px; padding: 9px 15px; }
  .launch-button small { margin-top: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

.ranking-panel { max-width: 740px; margin: 32px auto 0; padding: 22px; border: 1px solid var(--line); border-radius: 16px; }
.ranking-panel h2 { margin: 0 0 16px; font-size: 18px; }
.ranking-panel p { line-height: 1.6; }
#ranking-status, #ranking-entry-status { color: var(--muted); font-size: 12px; }
.ranking-entry { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
/* Keep text inputs large enough to avoid focus zoom on iOS. */
.ranking-entry input { flex: 1; min-width: 120px; width: 100%; max-width: 280px; border: 1px solid #a9b29f; border-radius: 6px; background: #fff; padding: 10px; font: inherit; font-size: 16px; color: var(--ink); }
#ranking-submit { padding: 10px 16px; border-radius: 6px; background: #dde8c4; }
#ranking-submit:disabled { opacity: .55; }
#ranking-list { padding-left: 30px; margin: 16px 0; }
#ranking-list li { padding: 9px 4px; border-bottom: 1px solid var(--line); }
#ranking-list li span { display: inline-block; max-width: 70%; overflow-wrap: anywhere; }
#ranking-list li strong { float: right; font-variant-numeric: tabular-nums; }

.table-shell.showing-overlay { min-height: var(--overlay-height, 640px); touch-action: manipulation; }
.overlay-ad { min-height: 300px; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }
.overlay-ad .adsbygoogle { display: block; min-height: 300px; width: 100%; }
.ad-label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 10px; }

#ranking-form { margin: 0 0 20px; text-align: left; }
#ranking-form label { font-size: 12px; }
#ranking-form .ranking-entry { flex-direction: column; }
#ranking-form .ranking-entry input { max-width: none; }
#ranking-form p { margin: 8px 0 0; line-height: 1.6; }
#ranking-entry-status:empty { display: none; }
