/* ========================================
   NINJA RUNNER
   Common Styles
======================================== */

:root {
    /* 広告枠の高さを一元管理 */
    --ad-height: 60px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #0d0f18;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ========================================
   App / Game Wrapper
   （広告枠の高さぶんを差し引いた領域にゲームを収める）
======================================== */

#main-wrapper {
    width: 100%;
    height: calc(100% - var(--ad-height) - env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* プレイ画面の直上コントロールバー (スコア・ポーズ) */
.top-control-bar {
    width: 100%;
    max-width: 800px;
    height: 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px; /* 左端・右端に適度な隙間を設置 */
    background: transparent;
    color: #ffffff;
    font-weight: bold;
    font-size: 20px;
    z-index: 10;
}

.hud-left {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

/* 距離表示の幅を固定化し、桁数変化による右側要素の横揺れを防止 */
#scoreText {
    display: inline-block;
    min-width: 75px;
    text-align: left;
    font-variant-numeric: tabular-nums; /* 数字の等幅表示 */
}

/* ダンゴ表示アイコン（カクつき防止のため軽量表示に最適化） */
.dango-hud-icon {
    font-size: 22px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6));
    opacity: 1;
    transition: opacity 0.15s ease-out;
    will-change: opacity;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: transform 0.1s, background 0.2s;
}

.icon-btn:active {
    transform: scale(0.92);
    background: rgba(255, 255, 255, 0.4);
}

/* ゲーム表示枠 */
#game-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    display: flex;
    justify-content: center;
    align-items: center;
}

canvas {
    background-color: #1a1c29;
    touch-action: none;
    display: block;
    border: none;
    outline: none;
}

.ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.modal-screen {
    background: rgba(13, 15, 24, 0.92);
    padding: 28px;
    border-radius: 16px;
    text-align: center;
    pointer-events: auto;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    max-width: 90%;
    width: 320px;
    z-index: 20;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

h1 {
    font-size: 30px;
    margin-bottom: 8px;
    color: #ff3e3e;
    letter-spacing: 2px;
}

.title-warning {
    color: #ffca28;
}

.title-danger {
    color: #ff5252;
}

.high-score {
    font-size: 15px;
    color: #ffca28;
    margin-bottom: 16px;
    font-weight: bold;
}

/* ========================================
   Title Screen（スタート画面専用）
======================================== */

.title-screen {
    background: rgba(13, 15, 24, 0.94);
    padding: 36px 28px 24px;
    border-radius: 20px;
    text-align: center;
    pointer-events: auto;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    max-width: 92%;
    width: 340px;
    z-index: 20;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.65);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.title-logo {
    display: flex;
    flex-direction: column;
    line-height: 1;
    margin-bottom: 20px;
}

.title-logo-main {
    font-size: 42px;
    font-weight: 900;
    letter-spacing: 4px;
    background: linear-gradient(135deg, #ff8a65, #ff3e3e 45%, #d32f2f);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 4px 10px rgba(255, 62, 62, 0.45));
}

.title-logo-sub {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 10px;
    color: #ffffff;
    margin-top: 2px;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.title-highscore {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px 28px;
    background: rgba(255, 202, 40, 0.08);
    border: 1px solid rgba(255, 202, 40, 0.3);
    border-radius: 12px;
}

.title-highscore-label {
    font-size: 11px;
    letter-spacing: 2px;
    color: #ffca28;
    font-weight: bold;
    margin-bottom: 2px;
}

.title-highscore-value {
    font-size: 26px;
    font-weight: 900;
    color: #ffffff;
}

.title-desc {
    margin-bottom: 22px;
}

.btn-play {
    font-size: 20px;
    padding: 14px 36px;
}

.mrs-games-link {
    display: block;
    margin-top: 22px;
    padding-top: 14px;
    width: 100%;
    font-size: 11px;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.45);
    text-decoration: underline;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    transition: color 0.15s;
}

.mrs-games-link:active {
    color: rgba(255, 255, 255, 0.75);
}

.final-score {
    font-size: 22px;
    font-weight: bold;
    color: #fff;
    margin-bottom: 6px;
}

p {
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 20px;
    color: #cccccc;
}

.pause-desc {
    margin-bottom: 24px;
}

.btn-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    width: 100%;
}

.btn {
    background: linear-gradient(135deg, #ff3e3e, #d32f2f);
    color: white;
    border: none;
    padding: 12px 36px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 62, 62, 0.4);
    transition: transform 0.1s;
    width: 100%;
    max-width: 220px;
}

.btn-secondary {
    background: linear-gradient(135deg, #455a64, #263238);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.btn:active {
    transform: scale(0.95);
}

.hidden {
    display: none !important;
}

/* ========================================
   Fixed Advertisement
======================================== */

.ad-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    min-height: var(--ad-height);

    display: flex;
    justify-content: center;
    align-items: center;

    background-color: #000000;

    z-index: 1000;
    overflow: hidden;

    padding-top: 1px;
    padding-bottom: calc(1px + env(safe-area-inset-bottom));

    border-top: 1px solid #333;
}
