body {
    background: #e8eef3;
    font-family: 'Zen Maru Gothic', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0;
    padding: 10px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    color: #333;
    min-height: 100dvh;
    box-sizing: border-box;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}
.back-btn {
    align-self: flex-start;
    text-decoration: none;
    color: #2e7d32;
    font-weight: bold;
    font-size: 0.85rem;
    margin: 0 0 8px 4px;
}
.game-container {
    background: #fff;
    padding: 10px 12px 14px;
    border-radius: 18px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 560px;
    text-align: center;
    box-sizing: border-box;
}
h1 { font-size: 1.15rem; color: #d84315; margin: 2px 0 2px; }
#message { font-size: 0.95rem; color: #444; margin: 4px 0 6px; min-height: 1.4em; }
#message.warn { color: #d84315; }
.hud {
    display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px 8px;
    font-size: 0.78rem; color: #555; margin: 0 2px 6px;
}
.hud b { color: #222; font-size: 0.95rem; }
.canvas-wrap { position: relative; width: 100%; }
#raceCanvas {
    display: block; width: 100%; margin: 0 auto; border-radius: 14px;
    touch-action: none; -ms-touch-action: none;
    background: #b9c2cb; cursor: crosshair;
}
#result {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    background: rgba(255,255,255,0.94); border-radius: 16px; padding: 14px 22px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.2); pointer-events: none; min-width: 60%;
}
#result.hidden { display: none; }
#result .time { font-size: 1.6rem; color: #d84315; margin: 0; }
#result .sub { font-size: 0.85rem; color: #555; margin: 4px 0 0; }
#result .goal { font-size: 1.1rem; margin: 6px 0 0; color: #455a64; }
#result .goal.clear { color: #2e7d32; font-size: 1.4rem; }
.target { font-size: 0.9rem; color: #2e7d32; margin: 0 0 4px; }
.buttons { display: flex; gap: 10px; justify-content: center; margin-top: 10px; }
.main-btn {
    font-family: inherit; font-size: 1.1rem; font-weight: bold; border: none; border-radius: 30px;
    padding: 12px 22px; color: #fff; cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,0.18);
    flex: 1; max-width: 220px;
}
.main-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.18); }
.main-btn:disabled { opacity: 0.4; cursor: default; }
.run-color { background: #ff7043; }
.redraw-color { background: #78909c; }
.main-btn.solo { flex: 1; max-width: 320px; font-size: 1.3em; background: #ff7043; }
.seo-text-box { margin-top: 24px; max-width: 560px; font-size: 0.85rem; color: #555; line-height: 1.7; padding: 0 8px; }
.seo-text-box h2 { font-size: 1rem; color: #333; }

.stage-tabs { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; margin: 4px 0 6px; }
.stage-tab {
  border: none; border-radius: 999px; padding: 4px 8px; font-size: 0.75rem; line-height: 1.3;
  font-family: inherit; background: #eceff1; color: #37474f; cursor: pointer; white-space: nowrap;
}
.stage-tab.active { background: #ff7043; color: #fff; font-weight: 700; }
.stage-name { margin: 0 0 2px; font-size: 0.9rem; color: #546e7a; text-align: center; }
