* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

body {
    background: #2b1f14;
    background-image: radial-gradient(#3e2c1e 15%, transparent 16%), radial-gradient(#3e2c1e 15%, transparent 16%);
    background-size: 40px 40px;
    background-position: 0 0, 20px 20px;
    font-family: 'Hiragino Kaku Gothic ProN', 'Yu Gothic', 'Meiryo', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    color: #4a2c11;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    max-width: 540px;
    max-height: 960px;
    aspect-ratio: 9 / 16;
    background: #000;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    border-radius: 16px;
}

@media (max-width: 540px) or (max-height: 960px) {
    #game-container {
        border-radius: 0;
        width: 100vw;
        height: 100vh;
        max-width: 100%;
        max-height: 100%;
    }
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

/* 共通UIオーバーレイ */
.screen-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 24px 20px;
    background: rgba(255, 248, 240, 0.94);
    z-index: 20;
    transition: opacity 0.25s ease;
}

.hidden {
    display: none !important;
}

/* タイトル画面 */
#titleScreen {
    text-align: center;
    background: linear-gradient(180deg, #fff9e6 0%, #ffeedd 100%);
    overflow-y: auto;
}

.title-badge {
    display: inline-block;
    background: #ff5722;
    color: #fff;
    font-size: 13px;
    font-weight: bold;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.title-logo h1 {
    font-size: 32px;
    font-weight: 900;
    color: #e65100;
    text-shadow: 2px 2px 0 #ffe082;
    line-height: 1.2;
}

.title-logo h2 {
    font-size: 18px;
    font-weight: bold;
    color: #5d4037;
    margin-top: 4px;
}

.title-corgi-visual {
    width: 100%;
    max-width: 320px;
    height: 220px;
    margin: 12px 0;
    border-radius: 16px;
    overflow: hidden;
    border: 4px solid #ffcc80;
    box-shadow: 0 6px 16px rgba(139, 69, 19, 0.2);
}

.title-corgi-visual img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.instructions-box {
    background: #fff;
    border: 3px solid #ffe0b2;
    border-radius: 16px;
    padding: 12px 14px;
    width: 100%;
    max-width: 360px;
    font-size: 13px;
    line-height: 1.6;
    color: #4e342e;
    text-align: left;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.instructions-box h3 {
    text-align: center;
    color: #e65100;
    font-size: 15px;
    margin-bottom: 6px;
}

.instructions-box ul {
    list-style: none;
    padding-left: 4px;
}

.instructions-box li {
    margin-bottom: 4px;
}

.btn-main {
    background: linear-gradient(180deg, #ff9800 0%, #f57c00 100%);
    color: #fff;
    font-size: 22px;
    font-weight: 900;
    padding: 14px 40px;
    border-radius: 50px;
    border: none;
    box-shadow: 0 6px 0 #b26a00, 0 8px 18px rgba(245, 124, 0, 0.4);
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    width: 90%;
    max-width: 340px;
    margin-top: 8px;
}

.btn-main:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #b26a00;
}

/* HUD (プレイ中ヘッダー) */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 10;
    pointer-events: none;
}

.hud-pill {
    background: rgba(255, 255, 255, 0.92);
    border: 2px solid #ffb74d;
    border-radius: 20px;
    padding: 6px 14px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.12);
    font-weight: 900;
    font-size: 14px;
    color: #4e342e;
    display: flex;
    align-items: center;
    gap: 6px;
}

.hud-score {
    font-size: 16px;
    color: #e65100;
}

.hud-hp-box {
    display: flex;
    align-items: center;
    gap: 6px;
}

.hp-track {
    width: 90px;
    height: 14px;
    background: #eee;
    border-radius: 7px;
    overflow: hidden;
    border: 1px solid #ccc;
}

.hp-fill {
    width: 100%;
    height: 100%;
    background: #4cd964;
    transition: width 0.2s linear, background 0.3s ease;
}

#hudCombo {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: #ff3d00;
    color: #fff;
    padding: 4px 16px;
    border-radius: 20px;
    font-weight: 900;
    font-size: 16px;
    box-shadow: 0 4px 10px rgba(255, 61, 0, 0.4);
    display: none;
    animation: comboPulse 0.3s alternate infinite;
}

@keyframes comboPulse {
    from { transform: translateX(-50%) scale(1); }
    to { transform: translateX(-50%) scale(1.1); }
}

/* サウンドミュートボタン */

/* 言語切替ボタン (JA / EN) */
.lang-btn {
    position: absolute;
    top: 14px;
    right: 56px;
    z-index: 30;
    background: rgba(255, 255, 255, 0.92);
    border: 2px solid #ffb74d;
    border-radius: 18px;
    height: 36px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    font-weight: 900;
    color: #4e342e;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    transition: transform 0.1s ease, background 0.15s ease;
    user-select: none;
}

.lang-btn:hover {
    background: #fff8e1;
    transform: scale(1.05);
}

.lang-btn:active {
    transform: scale(0.95);
}

.sound-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 30;
    background: rgba(255, 255, 255, 0.85);
    border: 2px solid #ffb74d;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
}

/* リザルト画面 */
#resultScreen {
    text-align: center;
    background: linear-gradient(180deg, #fffbf0 0%, #ffe8d6 100%);
    overflow-y: auto;
    justify-content: flex-start;
    padding: 16px 14px 40px;
    gap: 10px;
}

.result-header {
    margin-bottom: 6px;
}

.result-badge {
    background: #d84315;
    color: #fff;
    font-weight: 900;
    font-size: 18px;
    padding: 6px 20px;
    border-radius: 30px;
    display: inline-block;
    box-shadow: 0 4px 10px rgba(216, 67, 21, 0.3);
    margin-bottom: 4px;
}

.result-bag-visual {
    width: 100%;
    max-width: 300px;
    height: 200px;
    border-radius: 16px;
    overflow: hidden;
    border: 4px solid #ffb74d;
    margin: 8px 0;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.result-bag-visual img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.result-stats-card {
    background: #ffffff;
    border: 3px solid #ffd54f;
    border-radius: 18px;
    width: 100%;
    max-width: 360px;
    padding: 14px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px dashed #ffe0b2;
    font-size: 15px;
    font-weight: bold;
    color: #5d4037;
}

.stat-row:last-child {
    border-bottom: none;
    padding-top: 10px;
}

.stat-val {
    font-size: 20px;
    color: #e65100;
    font-weight: 900;
}

.title-val {
    font-size: 16px;
    color: #c2185b;
}

.btn-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 340px;
    margin-top: 12px;
}

.btn-sub {
    background: #ffffff;
    border: 2px solid #ff9800;
    color: #e65100;
    font-weight: bold;
    font-size: 15px;
    padding: 10px;
    border-radius: 30px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
}

.btn-share {
    background: #1da1f2;
    border: none;
    color: #fff;
    box-shadow: 0 4px 0 #0d8bd9;
}

/* 🏆 全国コーギーランキング TOP 100 スタイル */
.ranking-card {
    background: #ffffff;
    border: 3px solid #ffb74d;
    border-radius: 18px;
    width: 100%;
    max-width: 360px;
    padding: 12px 14px;
    margin: 10px 0;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    text-align: left;
}

.ranking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    border-bottom: 2px dashed #ffe0b2;
    padding-bottom: 8px;
}

.ranking-title {
    font-size: 14px;
    font-weight: 900;
    color: #d84315;
}

.player-rank-badge {
    background: #fff3e0;
    border: 1px solid #ff9800;
    color: #e65100;
    font-size: 12px;
    font-weight: 900;
    padding: 3px 10px;
    border-radius: 12px;
}

.player-rank-badge.rank-gold {
    background: linear-gradient(135deg, #ffd700 0%, #ffb300 100%);
    color: #3e2723;
    border-color: #ffa000;
    box-shadow: 0 2px 6px rgba(255, 179, 0, 0.4);
    animation: goldShine 1.5s infinite alternate;
}

@keyframes goldShine {
    from { transform: scale(1); filter: brightness(1); }
    to { transform: scale(1.05); filter: brightness(1.15); }
}

.player-rank-badge.rank-top3 {
    background: linear-gradient(135deg, #ffe082 0%, #ffca28 100%);
    color: #3e2723;
    border-color: #ffb300;
}

.player-rank-badge.rank-top10 {
    background: #ffccbc;
    color: #bf360c;
    border-color: #ff8a65;
}

.player-rank-badge.rank-out {
    background: #eeeeee;
    color: #757575;
    border-color: #bdbdbd;
}

.ranking-name-edit {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: bold;
    color: #5d4037;
}

.ranking-name-edit input {
    flex: 1;
    padding: 4px 8px;
    border: 1.5px solid #ffb74d;
    border-radius: 8px;
    font-size: 13px;
    font-weight: bold;
    color: #3e2723;
    background: #fffdf9;
    outline: none;
}

.ranking-name-edit input:focus {
    border-color: #ff5722;
    background: #fff;
}

.btn-save-name {
    background: #ff9800;
    color: #fff;
    border: none;
    padding: 4px 10px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 12px;
    cursor: pointer;
    box-shadow: 0 2px 0 #cc7a00;
}

.btn-save-name:active {
    transform: translateY(1px);
    box-shadow: none;
}

.ranking-controls {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.rank-tab-btn {
    flex: 1;
    background: #fff8e1;
    border: 1px solid #ffe082;
    color: #795548;
    font-size: 11px;
    font-weight: bold;
    padding: 5px 4px;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s ease;
}

.rank-tab-btn:hover,
.rank-tab-btn.active {
    background: #ff9800;
    color: #fff;
    border-color: #f57c00;
}

.ranking-list-container {
    max-height: 220px;
    overflow-y: auto;
    background: #fffdfa;
    border: 1.5px solid #ffe0b2;
    border-radius: 10px;
    padding: 4px;
    scroll-behavior: smooth;
}

.ranking-list-container::-webkit-scrollbar {
    width: 6px;
}
.ranking-list-container::-webkit-scrollbar-thumb {
    background: #ffb74d;
    border-radius: 3px;
}

.rank-row {
    display: flex;
    align-items: center;
    padding: 5px 6px;
    border-bottom: 1px solid #f3ece4;
    font-size: 12px;
    transition: background 0.1s ease;
}

.rank-row:last-child {
    border-bottom: none;
}

.rank-row:hover {
    background: #fffde7;
}

.rank-row-player {
    background: #fff3e0 !important;
    border: 2px solid #ff9800;
    border-radius: 8px;
    margin: 2px 0;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.25);
    font-weight: bold;
}

.col-rank {
    width: 38px;
    text-align: center;
    font-weight: 900;
    flex-shrink: 0;
}

.rank-num {
    color: #8d6e63;
    font-size: 12px;
}

.rank-medal {
    font-size: 12px;
    font-weight: 900;
    padding: 1px 4px;
    border-radius: 4px;
}
.rank-medal.gold {
    color: #d84315;
    background: #fff8e1;
    border: 1px solid #ffd54f;
}
.rank-medal.silver {
    color: #455a64;
    background: #eceff1;
    border: 1px solid #b0bec5;
}
.rank-medal.bronze {
    color: #5d4037;
    background: #efebe9;
    border: 1px solid #bcaaa4;
}

.col-info {
    flex: 1;
    min-width: 0;
    padding: 0 6px;
}

.rank-name-line {
    display: flex;
    align-items: center;
    gap: 4px;
}

.rank-dog-name {
    font-weight: bold;
    color: #3e2723;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge-you {
    background: #e91e63;
    color: #fff;
    font-size: 9px;
    font-weight: 900;
    padding: 1px 4px;
    border-radius: 4px;
    flex-shrink: 0;
}

.rank-title-sub {
    font-size: 10px;
    color: #8d6e63;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.col-score {
    text-align: right;
    flex-shrink: 0;
    display: flex;
    align-items: baseline;
    gap: 2px;
}

.col-score .score-val {
    font-size: 13px;
    font-weight: 900;
    color: #e65100;
}

.col-score .score-unit {
    font-size: 10px;
    color: #8d6e63;
}

/* タイトル画面アクションボタン群 (同じサイズ・比率で統一) */
.title-actions {
    display: flex;
    gap: 12px;
    width: 100%;
    max-width: 380px;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

.title-actions .title-btn {
    flex: 1;
    height: 52px;
    margin: 0 !important;
    padding: 0 10px !important;
    font-size: 16px !important;
    font-weight: 900 !important;
    border-radius: 50px !important;
    display: inline-flex !important;
    justify-content: center !important;
    align-items: center !important;
    text-align: center !important;
    box-sizing: border-box !important;
    box-shadow: 0 5px 0 #b26a00, 0 6px 14px rgba(245, 124, 0, 0.35) !important;
    border: none !important;
    cursor: pointer !important;
    transition: transform 0.1s ease, box-shadow 0.1s ease !important;
    text-decoration: none !important;
    white-space: nowrap !important;
    max-width: 185px !important;
    width: auto !important;
}

.title-actions .btn-main {
    background: linear-gradient(180deg, #ff9800 0%, #f57c00 100%) !important;
    color: #fff !important;
}

.title-actions .btn-viewer {
    background: linear-gradient(180deg, #ffa726 0%, #fb8c00 100%) !important;
    color: #fff !important;
}

.title-actions .title-btn:active {
    transform: translateY(4px) !important;
    box-shadow: 0 1px 0 #b26a00 !important;
}

/* ゲーム内広告枠スタイル */
.game-ad-slot {
    width: 100%;
    max-width: 380px;
    margin: 12px auto 0;
    text-align: center;
}

.game-ad-wrapper {
    width: 100%;
    background: rgba(255, 255, 255, 0.92);
    border: 2px dashed #ffb74d;
    border-radius: 16px;
    padding: 10px 8px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}

.game-ad-wrapper .ad-label {
    font-size: 10px;
    font-weight: bold;
    color: #8d6e63;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.game-ad-wrapper .admax-pc {
    display: block;
    max-width: 100%;
}

.game-ad-wrapper .admax-sp {
    display: none;
    max-width: 100%;
}

@media (max-width: 768px) {
    .game-ad-wrapper .admax-pc {
        display: none !important;
    }
    .game-ad-wrapper .admax-sp {
        display: block !important;
    }
}

/* ========================================================
   シェアモーダル (各SNS・コピー対応)
   ======================================================== */
.share-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.68);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.share-modal-card {
    background: #ffffff;
    border-radius: 24px;
    border: 3px solid #ffb74d;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
    width: 100%;
    max-width: 440px;
    max-height: 92vh;
    overflow-y: auto;
    padding: 18px 16px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: modalPopIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPopIn {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.share-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px dashed #ffe0b2;
    padding-bottom: 8px;
}

.share-modal-title {
    font-size: 18px;
    font-weight: 900;
    color: #e65100;
    letter-spacing: 0.5px;
}

.btn-close-modal {
    background: #f5f5f5;
    border: 1px solid #ccc;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 16px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: background 0.15s ease, transform 0.15s ease;
}

.btn-close-modal:hover {
    background: #ffebee;
    color: #d32f2f;
    transform: scale(1.1);
}

.share-preview-box {
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 12px;
    padding: 10px 12px;
    max-height: 120px;
    overflow-y: auto;
}

.share-preview-box pre {
    margin: 0;
    font-size: 12px;
    line-height: 1.45;
    color: #5d4037;
    white-space: pre-wrap;
    word-break: break-all;
    font-family: inherit;
}

.share-toast {
    background: #2e7d32;
    color: #ffffff;
    font-size: 13px;
    font-weight: bold;
    padding: 8px 14px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.35);
    animation: toastFade 0.2s ease-out;
}

@keyframes toastFade {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.share-services-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.share-srv-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 10px;
    border: none;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
    user-select: none;
    -webkit-user-select: none;
}

.share-srv-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.06);
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.22);
}

.share-srv-btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.srv-icon {
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.srv-line-icon {
    font-size: 13px;
    font-weight: 900;
    letter-spacing: -0.5px;
}

/* 各サービス専用カラー */
.srv-x {
    background: #0f1419;
    color: #ffffff;
}

.srv-line {
    background: #06c755;
    color: #ffffff;
}

.srv-bsky {
    background: #0085ff;
    color: #ffffff;
}

.srv-threads {
    background: #111111;
    color: #ffffff;
}

.srv-copy {
    background: linear-gradient(135deg, #ff9800, #f57c00);
    color: #ffffff;
    grid-column: span 2;
}

.srv-native {
    background: #6d4c41;
    color: #ffffff;
    grid-column: span 2;
}

.btn-modal-close {
    background: #eee;
    color: #555;
    border: none;
    border-radius: 12px;
    padding: 10px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 4px;
}

.btn-modal-close:hover {
    background: #e0e0e0;
}
