* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
    color: white;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 800px;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 20px;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 0 0 10px #00ffff, 0 0 20px #00ffff;
}

/* ゲーム画面の表示設定を修正 */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    background: linear-gradient(135deg, #0a1929, #1a3a5a, #2c5364);
    z-index: 1000;
    overflow-y: auto; /* 縦スクロールを許可 */
    padding: 10px; /* 全体にパディングを追加 */
    box-sizing: border-box;
}

.screen.active {
    display: flex;
    align-items: flex-start; /* 上揃えに変更 */
    justify-content: center;
    padding-top: 20px; /* 上部に余白 */
    padding-bottom: 20px; /* 下部に余白 */
}

#gameScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
    z-index: 100;
    overflow-y: auto;
}

#gameScreen.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ゲーム画面のヘッダー調整 */
#gameScreen header {
    width: 100%;
    text-align: center;
    margin-bottom: 15px;
}

#gameScreen h1 {
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    margin-bottom: 10px;
    text-shadow: 0 0 10px #00ffff, 0 0 20px #00ffff;
    word-wrap: break-word;
    line-height: 1.3;
    padding: 0 10px;
}

/* ゲーム画面のコンテナ調整 */
#gameScreen .container {
    padding: 15px 10px;
    max-width: 95%;
}

/* ゲームエリア内の統計情報表示を追加 */
.game-area-stats {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 10, 20, 0.8);
    border: 1px solid rgba(100, 150, 255, 0.3);
    border-radius: 8px;
    padding: 8px 12px;
    z-index: 20;
    backdrop-filter: blur(5px);
    
    /* ▼▼▼ 修正: スクロール対応を追加 ▼▼▼ */
    max-height: 70vh; /* 画面の70%まで */
    overflow-y: auto; /* 縦スクロールを有効化 */
    overflow-x: hidden; /* 横スクロールは無効 */
}

.game-area-stats.hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

/* スクロールバーのスタイリング */
.game-area-stats::-webkit-scrollbar {
    width: 4px;
}

.game-area-stats::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.game-area-stats::-webkit-scrollbar-thumb {
    background: rgba(100, 150, 255, 0.5);
    border-radius: 2px;
}

.game-area-stats::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 150, 255, 0.7);
}

.game-area-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 5px 0;
    font-size: 0.9rem;
    color: white;
}

.game-area-stat .label {
    color: #88ddff;
    margin-right: 10px;
}

.game-area-stat .value {
    font-weight: bold;
    color: #ffffff;
}

#livesCount {
    font-size: 1.1em;
}

/* 元のゲーム統計は非表示に */
.game-stats {
    display: none;
}

.game-stats div {
    flex: 1;
    min-width: 45%;
    text-align: center;
    margin-bottom: 5px;
}

/* ゲームエリアのサイズ設定を修正 */
.game-area {
    position: relative;
    width: 100%;
    height: 600px;
    max-width: 100%;
    background: rgba(0, 10, 20, 0.7);
    border: 2px solid #00ffff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}

#gameCanvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
    width: 100%;
    max-width: 400px;
}

.game-over-controls,
.game-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    width: 100%;
}

.game-over-controls button,
.game-controls button {
    flex: 1;
    min-width: 140px;
    padding: 12px 20px;
    font-size: 1rem;
}

/* ゲーム中ボタンのスタイル調整 */
.game-controls button {
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.8), rgba(245, 124, 0, 0.8));
    border: 2px solid #ff9800;
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.4);
}

.game-controls button:hover {
    background: linear-gradient(135deg, rgba(255, 167, 38, 0.9), rgba(245, 124, 0, 0.9));
    box-shadow: 0 6px 20px rgba(255, 167, 38, 0.6);
}

button {
    flex: 1;
    min-width: 120px;
    padding: 10px 15px;
    font-size: 0.9rem;
    background: linear-gradient(135deg, #00b4db, #0083b0);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 180, 219, 0.4);
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 180, 219, 0.6);
}

button:active {
    transform: translateY(1px);
}

#startBtn {
    background: linear-gradient(135deg, #00c853, #009624);
}

#pauseBtn {
    background: linear-gradient(135deg, #ff9800, #f57c00);
}

#resetBtn {
    background: linear-gradient(135deg, #ff5252, #d32f2f);
}

/* 統一画面レイアウト */
.screen-container {
    max-width: 95%;
    max-height: 90vh;
    width: 100%;
    padding: 20px;
    background: rgba(0, 20, 40, 0.9);
    border-radius: 20px;
    border: 2px solid #00ffff;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    margin: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.screen-container h2 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 20px;
    color: #00ffff;
    text-shadow: 0 0 10px #00ffff;
    flex-shrink: 0;
}

/* スクロール可能なコンテンツエリア */
.screen-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    margin-bottom: 20px;
    padding: 10px;
}

/* スクロールバーのスタイリング統一 */
.screen-content::-webkit-scrollbar {
    width: 8px;
}

.screen-content::-webkit-scrollbar-track {
    background: rgba(0, 20, 40, 0.5);
    border-radius: 4px;
}

.screen-content::-webkit-scrollbar-thumb {
    background: #00ffff;
    border-radius: 4px;
}

.screen-content::-webkit-scrollbar-thumb:hover {
    background: #00aaff;
}

/* 戻るボタン */
.back-btn {
    padding: 12px 30px;
    font-size: 1.1rem;
    background: linear-gradient(135deg, #ff9800, #f57c00);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: block;
    margin: 0 auto;
    flex-shrink: 0;
}

.back-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 152, 0, 0.6);
}

/* 設定画面のスタイル調整 */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0;
    padding: 15px;
    background: rgba(0, 40, 80, 0.5);
    border-radius: 10px;
}

.setting-item label {
    font-size: 1.1rem;
    color: #88ddff;
    min-width: 100px;
}

.setting-item select {
    padding: 8px 15px;
    border: 1px solid #00ffff;
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    min-width: 120px;
}

/* 設定ボタン */
#settingsBtnFromGame {
    background: linear-gradient(135deg, #ff9800, #f57c00);
}

#settingsBtnFromGame:hover {
    background: linear-gradient(135deg, #ffa726, #f57c00);
}
/*
.instructions {
    margin-top: 20px;
    text-align: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 15px;
    border-radius: 10px;
    width: 100%;
}
*/

/* ゲームオーバー画面 */
.game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    display: none;
    text-align: center;
}

.game-over h2 {
    font-size: 2rem;
    color: #ff5252;
    margin-bottom: -5px;
    text-shadow: 0 0 10px #ff5252;
}

.game-over p {
    font-size: 1.5rem;
    margin-bottom: 20px;
}

/* ゲームオーバー画面内のボタンを非表示 */
.game-over .game-over-buttons {
    display: none;
}

.wormhole-effect {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(138,43,226,0.7) 0%, rgba(0,0,0,0) 70%);
    z-index: 5;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s;
}

/* コンテナの設定を調整 */
.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 800px;
    padding: 20px;
    position: relative;
    z-index: 101;
}

/* ライフ表示のスタイル */
#livesDisplay {
    font-weight: bold;
    font-size: 1.1em;
}

#livesCount {
    font-size: 1.2em;
    letter-spacing: 2px;
}

/* スコア内訳のスタイル */
#scoreBreakdown {
    margin: 20px 0;
    padding: 5px 20px;
    background: rgba(0, 40, 80, 0.8);
    border-radius: 10px;
    border: 2px solid #00ffff;
    min-width: 250px;
    text-align: center;
}

#scoreBreakdown h3 {
    color: #00ffff;
    margin-bottom: 15px;
    font-size: 1.3rem;
    text-shadow: 0 0 10px #00ffff;
}

#scoreBreakdown p {
    margin: 6px 0;
    font-size: 1.1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
}

#scoreBreakdown p span {
    color: #ffff00;
    font-weight: bold;
    font-size: 1.2rem;
}

#scoreBreakdown p:last-child {
    border-top: 1px solid #00ffff;
    padding-top: 12px;
    margin-top: 15px;
    font-weight: bold;
}
/* スコア表示のスタイル修正 */
.score-item {
    margin: 1px 0;
    padding: 1px 0;
    /* border-bottom: 1px solid rgba(0, 255, 255, 0.3);*/
}

.score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 5px 0;
}

.item-name {
    color: #88ddff;
    text-align: left;
    flex: 1;
}

.item-points {
    color: #ffff00;
    font-weight: bold;
    text-align: right;
    min-width: 80px;
}

.item-count, .item-distance {
    color: #ffffff;
    text-align: right;
    flex: 1;
    margin-left: auto;
    padding-right: 10px;
}

.score-item:last-child {
    /* border-bottom: 2px solid #00ffff;*/
    padding-bottom: 1px;
    margin-bottom: 1px;
}

/* 総合得点表示のスタイル */
.score-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 15px 0;
    padding: 12px 0;
    border-bottom: 2px solid #00ffff;
    font-weight: bold;
}

.total-label {
    color: #00ffff;
    font-size: 1.2rem;
}

.total-points {
    color: #ffff00;
    font-size: 1.3rem;
    font-weight: bold;
    text-shadow: 0 0 10px #ffff00;
}

/* 採掘テキストのスタイル */
.mining-text {
    position: absolute;
    font-family: 'Arial', sans-serif;
    font-size: 16px;
    font-weight: bold;
    pointer-events: none;
    z-index: 1000;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
    animation: floatUp 2s ease-out forwards;
}

.mining-normal {
    color: #C0C0C0;
    text-shadow: 0 0 10px rgba(192, 192, 192, 0.7);
}

.mining-rare {
    color: #FFD700;
    font-size: 18px;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.9);
    animation: floatUpGlow 2s ease-out forwards;
}

/* 浮き上がりアニメーション */
@keyframes floatUp {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    70% {
        opacity: 1;
    }
    100% {
        transform: translateY(-60px) scale(1.2);
        opacity: 0;
    }
}

/* レア鉱石用の特別なアニメーション */
@keyframes floatUpGlow {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
        text-shadow: 0 0 10px rgba(255, 215, 0, 0.7);
    }
    50% {
        transform: translateY(-30px) scale(1.3);
        text-shadow: 0 0 20px rgba(255, 215, 0, 1);
    }
    100% {
        transform: translateY(-60px) scale(1.1);
        opacity: 0;
        text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    }
}

/* コンボ表示のアニメーション */
@keyframes comboPop {
    0% {
        transform: translateX(-50%) scale(0.5);
        opacity: 0;
    }
    50% {
        transform: translateX(-50%) scale(1.2);
        opacity: 1;
    }
    100% {
        transform: translateX(-50%) scale(1);
        opacity: 0;
    }
}

.mining-combo {
    pointer-events: none;
    font-family: 'Arial', sans-serif;
}

/* 詳細統計のスタイル */
.detailed-stats {
    margin-top: 20px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.detailed-stats h3 {
    margin: 0 0 10px 0;
    color: #00ffff;
    font-size: 0.8em;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.7em;
}

.stat-label {
    color: #cccccc;
}

.stat-value {
    color: #ffffff;
    font-weight: bold;
}

/* 鉱石統計のスタイル修正 */
.mining-stats .ore-count {
    display: none; /* 総数を非表示 */
}

.ore-common,
.ore-rare,
.ore-epic {
    font-size: 1em; /* 他の数値と同じサイズに */
    font-weight: bold;
}

.ore-common {
    color: #888888; /* 鉄鉱石 - 灰色 */
}

.ore-rare {
    color: #C0C0C0; /* 銀鉱石 - 銀色 */
}

.ore-epic {
    color: #FFD700; /* 金鉱石 - 金色 */
}

/* 鉱石アイコンの点滅アニメーション修正 */
.ore-icon-blink {
    animation: oreBlink 0.5s ease-in-out;
}

/* 点滅アニメーションを各鉱石要素に適用できるように修正 */
.ore-common.ore-icon-blink,
.ore-rare.ore-icon-blink,
.ore-epic.ore-icon-blink {
    animation: oreBlink 0.5s ease-in-out;
    display: inline-block;
}

.ore-common.ore-pulse,
.ore-rare.ore-pulse,
.ore-epic.ore-pulse {
    animation: orePulse 2s ease-in-out infinite;
}

/* 鉱石種類別の点滅色修正 */
.ore-common.ore-blink-common {
    animation: oreBlink 0.6s ease-in-out, orePulseCommon 3s infinite;
}

.ore-rare.ore-blink-rare {
    animation: oreBlink 0.6s ease-in-out, orePulseRare 2.5s infinite;
}

.ore-epic.ore-blink-epic {
    animation: oreBlink 0.6s ease-in-out, orePulseEpic 2s infinite;
}

/* レアドロップフラッシュエフェクト */
.mining-flash {
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.5s ease-out;
}

.mining-flash-rare {
    animation: rareFlash 1s ease-out;
}

.mining-flash-epic {
    animation: epicFlash 1s ease-out;
}

@keyframes rareFlash {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    50% {
        opacity: 0.2;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(1.2);
    }
}

@keyframes epicFlash {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    25% {
        opacity: 0.4;
        transform: scale(1);
    }
    50% {
        opacity: 0.2;
        transform: scale(1.1);
    }
    75% {
        opacity: 0.1;
        transform: scale(1.2);
    }
    100% {
        opacity: 0;
        transform: scale(1.3);
    }
}

/* エピック画面シェイク */
.epic-screen-shake {
    animation: epicShake 0.5s ease-in-out;
}

@keyframes epicShake {
    0%, 100% {
        transform: translateX(0) translateY(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px) translateY(-3px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px) translateY(3px);
    }
}

/* 光の輪エフェクト */
.epic-light-ring {
    opacity: 1;
    transform: scale(1);
    transition: all 1s ease-out;
}

/* 鉱石アイコンの点滅アニメーション */
@keyframes oreBlink {
    0% {
        transform: scale(1);
        color: inherit;
        text-shadow: 0 0 0px currentColor;
    }
    25% {
        transform: scale(1.2);
        color: #FFD700;
        text-shadow: 0 0 10px #FFD700;
    }
    50% {
        transform: scale(1.3);
        color: #FFFFFF;
        text-shadow: 0 0 15px #FFFFFF, 0 0 20px #FFD700;
    }
    75% {
        transform: scale(1.2);
        color: #FFD700;
        text-shadow: 0 0 10px #FFD700;
    }
    100% {
        transform: scale(1);
        color: inherit;
        text-shadow: 0 0 0px currentColor;
    }
}

@keyframes orePulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.ore-icon-blink {
    animation: oreBlink 0.6s ease-in-out;
    display: inline-block;
}

.ore-pulse {
    animation: orePulse 2s ease-in-out infinite;
}

/* 鉱石種類別の点滅色 */
.ore-blink-common {
    animation: oreBlink 0.6s ease-in-out, orePulseCommon 3s infinite;
}

.ore-blink-rare {
    animation: oreBlink 0.6s ease-in-out, orePulseRare 2.5s infinite;
}

.ore-blink-epic {
    animation: oreBlink 0.6s ease-in-out, orePulseEpic 2s infinite;
}

@keyframes orePulseCommon {
    0%, 100% {
        color: #888888;
        text-shadow: 0 0 5px #888888;
    }
    50% {
        color: #AAAAAA;
        text-shadow: 0 0 10px #AAAAAA;
    }
}

@keyframes orePulseRare {
    0%, 100% {
        color: #C0C0C0;
        text-shadow: 0 0 5px #C0C0C0;
    }
    50% {
        color: #E8E8E8;
        text-shadow: 0 0 15px #E8E8E8;
    }
}

@keyframes orePulseEpic {
    0%, 100% {
        color: #FFD700;
        text-shadow: 0 0 5px #FFD700;
    }
    50% {
        color: #FFFF80;
        text-shadow: 0 0 20px #FFFF80, 0 0 30px #FFD700;
    }
}

/* ゲーム開始前モーダルのスタイル */
.pre-game-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.pre-game-content {
    background: linear-gradient(135deg, #1a2a3a, #0d1b2a);
    border: 2px solid #00ffff;
    border-radius: 15px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    color: white;
}

.pre-game-content h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #00ffff;
    font-size: 1.5rem;
}

.effects-group {
    margin-bottom: 1.5rem;
}

.effects-group h3 {
    color: #ffd700;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.effect-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border-left: 4px solid;
}

.consumable-effect {
    border-left-color: #ff6b6b;
}

.upgrade-effect {
    border-left-color: #4ecdc4;
}

.effect-icon {
    font-size: 1.5rem;
    margin-right: 0.75rem;
}

.effect-info {
    flex: 1;
}

.effect-name {
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.effect-description {
    font-size: 0.9rem;
    opacity: 0.8;
}

.effect-auto {
    background: #4ecdc4;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
}

.effect-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.pre-game-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #00ffff;
    color: #000;
}

.btn-primary:hover {
    background: #00cccc;
}

.btn-secondary {
    background: #ffd700;
    color: #000;
}

.btn-secondary:hover {
    background: #e6c200;
}

.btn-outline {
    background: transparent;
    color: #00ffff;
    border: 1px solid #00ffff;
}

.btn-outline:hover {
    background: rgba(0, 255, 255, 0.1);
}

.no-effects {
    text-align: center;
    opacity: 0.7;
    font-style: italic;
}