* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #1a1a2e;
    overflow: hidden;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

#game-canvas {
    display: block;
    background: #87CEEB;
    max-width: 100%;
    max-height: 100%;
    touch-action: none;
}

.btn-mute {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 30;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-mute:hover {
    background: rgba(0, 0, 0, 0.6);
}

/* --- スクリーン共通 --- */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    background: rgba(26, 26, 46, 0.75);
    touch-action: auto;
    pointer-events: auto;
}

/* --- ログイン画面 --- */
.login-content,
.nickname-content,
.profile-content {
    background: rgba(26, 26, 46, 0.95);
    border-radius: 20px;
    padding: 30px 25px;
    text-align: center;
    color: #fff;
    max-width: 360px;
    width: 90%;
    pointer-events: auto;
    touch-action: auto;
    position: relative;
    z-index: 20;
}

.login-subtitle {
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.btn-social {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 240px;
    margin: 10px auto;
    padding: 12px 0;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.1s;
    pointer-events: auto;
    position: relative;
    z-index: 20;
}

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

.btn-google {
    background: #fff;
    color: #333;
}

.btn-twitter {
    background: #000;
    color: #fff;
}

.btn-guest {
    display: block;
    width: 240px;
    margin: 15px auto 0;
    padding: 10px 0;
    font-size: 0.9rem;
    color: rgba(255,255,255,0.7);
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 50px;
    cursor: pointer;
    pointer-events: auto;
    position: relative;
    z-index: 20;
}

.btn-guest:hover { color: #fff; border-color: #fff; }

.auth-message {
    color: #ff6b6b;
    font-size: 0.85rem;
    margin-top: 10px;
}

/* --- ニックネーム画面 --- */
.nickname-subtitle {
    color: rgba(255,255,255,0.7);
    font-size: 0.85rem;
    margin-bottom: 15px;
}

.nickname-input {
    display: block;
    width: 200px;
    margin: 0 auto 15px;
    padding: 10px 15px;
    font-size: 1.1rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 10px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    text-align: center;
    outline: none;
    pointer-events: auto;
    touch-action: auto;
    position: relative;
    z-index: 20;
}

.nickname-input:focus {
    border-color: #E60012;
}

/* --- プロフィール --- */
.profile-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #E60012;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: bold;
    color: #fff;
    background-size: cover;
    background-position: center;
}

.profile-avatar-large {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: #E60012;
    margin: 0 auto 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: #fff;
    background-size: cover;
    background-position: center;
}

.profile-name {
    font-size: 1rem;
    color: #fff;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: rgba(255,255,255,0.7);
    padding: 5px;
    pointer-events: auto;
    position: relative;
    z-index: 20;
}

.profile-name-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 15px;
}

.profile-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 20px;
}

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: #FFD700;
}

.stat-label {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.6);
}

.link-section {
    margin-bottom: 15px;
    padding: 15px;
    border: 1px dashed rgba(255,255,255,0.3);
    border-radius: 12px;
}

.link-subtitle {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.6);
    margin-bottom: 10px;
}

.btn-small-social {
    width: 180px;
    padding: 8px 0;
    font-size: 0.85rem;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.85rem;
    background: #E60012;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    pointer-events: auto;
    position: relative;
    z-index: 20;
}

.btn-danger {
    display: block;
    width: 200px;
    margin: 10px auto;
    padding: 10px 0;
    font-size: 0.9rem;
    color: #ff6b6b;
    background: transparent;
    border: 1px solid #ff6b6b;
    border-radius: 50px;
    cursor: pointer;
    pointer-events: auto;
    position: relative;
    z-index: 20;
}

/* --- 色選択 --- */
.color-picker {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 15px 0;
    flex-wrap: wrap;
}

.color-option {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.2s;
    pointer-events: auto;
    position: relative;
    z-index: 20;
}

.color-option:hover { transform: scale(1.15); }
.color-option.selected { border-color: #FFD700; transform: scale(1.2); }

/* --- ホーム画面 --- */
.home-content {
    text-align: center;
    color: #fff;
    padding: 20px;
}

.game-title {
    font-size: 3rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 3px 3px 0 #E60012, -1px -1px 0 #0033A0;
    margin-bottom: 20px;
    line-height: 1.2;
}

.home-komyaku {
    display: block;
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
}


.best-score-display {
    font-size: 1.2rem;
    color: #FFD700;
    margin-bottom: 20px;
}

/* --- ボタン --- */
.btn-primary {
    display: block;
    width: 200px;
    margin: 10px auto;
    padding: 14px 0;
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #E60012, #C5000F);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.1s;
    box-shadow: 0 4px 10px rgba(230, 0, 18, 0.4);
    pointer-events: auto;
    position: relative;
    z-index: 20;
}

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

.btn-secondary {
    display: block;
    width: 200px;
    margin: 10px auto;
    padding: 12px 0;
    font-size: 1rem;
    font-weight: bold;
    color: #E60012;
    background: #fff;
    border: 2px solid #E60012;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.1s;
    pointer-events: auto;
    position: relative;
    z-index: 20;
}

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

.btn-link {
    display: inline-block;
    margin-top: 15px;
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
    text-decoration: underline;
    pointer-events: auto;
    position: relative;
    z-index: 20;
}

/* --- ゲームオーバー画面 --- */
.gameover-content,
.ranking-content {
    background: rgba(26, 26, 46, 0.95);
    border-radius: 20px;
    padding: 30px 25px;
    text-align: center;
    color: #fff;
    max-width: 360px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    pointer-events: auto;
    touch-action: auto;
    position: relative;
    z-index: 20;
}

.gameover-content h2,
.ranking-content h2 {
    font-size: 1.8rem;
    margin-bottom: 15px;
    color: #FFD700;
}

.gameover-player {
    margin-bottom: 15px;
}

.gameover-komyaku-canvas {
    width: 60px;
    height: 60px;
    margin: 0 auto 5px;
}

.gameover-player-name {
    font-size: 1.1rem;
    font-weight: bold;
}

.score-display {
    margin-bottom: 15px;
}

.score-display p {
    font-size: 1.3rem;
    margin: 5px 0;
}

#new-record-badge {
    display: inline-block;
    background: #FFD700;
    color: #1a1a2e;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    animation: pulse 0.5s infinite alternate;
}

@keyframes pulse {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

/* --- ランキング --- */
.ranking-section {
    margin: 15px 0;
}

.ranking-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.tab {
    padding: 8px 20px;
    border: 1px solid rgba(255,255,255,0.3);
    background: transparent;
    color: #fff;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    pointer-events: auto;
    position: relative;
    z-index: 20;
}

.tab.active {
    background: #E60012;
    border-color: #E60012;
}

.ranking-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.ranking-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-size: 0.9rem;
}

.ranking-item .rank {
    width: 30px;
    font-weight: bold;
    color: #FFD700;
}

.ranking-item .name {
    flex: 1;
    text-align: left;
}

.ranking-item .score {
    font-weight: bold;
}

.gameover-buttons {
    margin-top: 12px;
}

.btn-gameover {
    width: 180px;
    padding: 11px 0;
    font-size: 1.05rem;
    margin: 6px auto;
}

.gameover-buttons-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 8px;
}

.btn-outline-small {
    padding: 7px 16px;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.7);
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 50px;
    cursor: pointer;
    pointer-events: auto;
    position: relative;
    z-index: 20;
    transition: color 0.2s, border-color 0.2s;
}

.btn-outline-small:hover { color: #fff; border-color: #fff; }

/* --- 導線ナビ --- */
.home-nav-links,
.gameover-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 12px 0;
}

.nav-chip {
    display: inline-block;
    padding: 6px 12px;
    font-size: 0.8rem;
    color: #fff;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 20px;
    text-decoration: none;
    transition: background 0.2s;
    pointer-events: auto;
    position: relative;
    z-index: 20;
}

.nav-chip:hover {
    background: rgba(255,255,255,0.3);
}

/* --- 広告スロット --- */
.ad-gameover-slot,
.ad-home-slot {
    margin: 12px auto;
    max-width: 300px;
    min-height: 50px;
    overflow: hidden;
    border-radius: 8px;
}

.ad-gameover-slot ins,
.ad-home-slot ins {
    background: transparent;
}

/* --- スクショモード --- */
.btn-dismiss {
    display: block;
    width: 200px;
    margin: 10px auto 0;
    padding: 8px 0;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.6);
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 50px;
    cursor: pointer;
    pointer-events: auto;
    position: relative;
    z-index: 20;
}

.btn-dismiss:hover { color: #fff; border-color: #fff; }

.floating-retry {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 15;
}

.btn-floating {
    padding: 10px 24px;
    font-size: 0.95rem;
    font-weight: bold;
    color: #fff;
    background: rgba(230, 0, 18, 0.85);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    pointer-events: auto;
    transition: transform 0.1s;
}

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

/* --- レスポンシブ --- */
@media (max-width: 480px) {
    .game-title {
        font-size: 2.2rem;
    }
    .gameover-content,
    .ranking-content,
    .login-content,
    .nickname-content,
    .profile-content {
        padding: 20px 15px;
    }
}
