body {
    margin: 0;
    overflow: hidden;
    background-color: #000;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    touch-action: none;
    user-select: none;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* UIレイヤー */
.ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
}

/* ヘッダー情報 - スマホ縦画面デフォルト */
.header {
    padding: 15px;
    font-size: 18px;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    display: flex;
    justify-content: space-between;
}

.info-box {
    display: flex;
    flex-direction: column;
}

#depth-display {
    font-size: 26px;
    color: #FFD700;
}

#popularity-display {
    font-size: 26px;
    color: #FF69B4;
    transition: color 0.2s, transform 0.1s;
}

/* 新进度条 - 地层主题设计 / 新しい進捗バー - 地層テーマデザイン */
.new-progress-track {
    position: absolute;
    right: 15px;
    top: 80px;
    bottom: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.progress-endpoint {
    font-size: 24px;  /* 从22px增加到24px提高清晰度 / 22pxから24pxに増やして視認性向上 */
    font-weight: 900;
    color: white;
    text-shadow:
        -2px -2px 4px black,
        2px -2px 4px black,
        -2px 2px 4px black,
        2px 2px 4px black,
        0 0 10px black;
    -webkit-text-stroke: 0.5px black;  /* 从1.5px减少到0.5px减少模糊 / 1.5pxから0.5pxに減らしてぼけを軽減 */
    background: rgba(0, 0, 0, 0.4);
    padding: 8px 14px;
    border-radius: 10px;
    letter-spacing: 1px;

    /* 字体渲染优化 / フォントレンダリング最適化 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    transform: translateZ(0);  /* 强制GPU加速 / GPUアクセラレーションを強制 */
}

.progress-bar-wrapper {
    position: relative;
    width: 30px;
    flex: 1;
    border-radius: 15px;
    overflow: visible;
    border: 3px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.progress-bg-layers {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom,
        #8B4513 0%,
        #A0522D 30%,
        #DC143C 50%,
        #FFD700 70%,
        #32CD32 90%,
        #228B22 100%
    );
}

.progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: linear-gradient(to bottom,
        rgba(255, 255, 255, 0.5),
        rgba(255, 255, 255, 0.3)
    );
    box-shadow: 0 2px 15px rgba(255, 255, 255, 0.6);
    transition: height 0.3s ease-out;
}

.progress-marker {
    position: absolute;
    top: 0%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: top 0.3s ease-out;
    z-index: 10;
}

.event-marker {
    position: absolute;
    top: 0%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: top 0.05s linear; /* 快速移动 */
    z-index: 9; /* 比主角标记低一层 */
}

.marker-image {
    height: 80px;  /* 固定高度 - 扩大到2倍 */
    width: auto;   /* 宽度自适应，保持宽高比 */
    display: block;
}

/* 操作ガイダンス - スマホ縦画面デフォルト */
.controls-hint {
    position: absolute;
    bottom: 8%;
    width: 100%;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    font-size: 15px;
    letter-spacing: 1px;
    pointer-events: none;
}

/* 接近终点提示 / 終点接近の表示 */
.approach-hint {
    position: absolute;
    top: 20%;
    width: 100%;
    text-align: center;
    color: #FFD700;
    font-size: 28px;
    font-weight: bold;
    letter-spacing: 2px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8),
                 0 0 20px rgba(255, 215, 0, 0.5),
                 2px 2px 4px rgba(0, 0, 0, 0.8);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { text-shadow: 0 0 10px rgba(255, 215, 0, 0.8), 0 0 20px rgba(255, 215, 0, 0.5), 2px 2px 4px rgba(0, 0, 0, 0.8); }
    50% { text-shadow: 0 0 20px rgba(255, 215, 0, 1), 0 0 30px rgba(255, 215, 0, 0.8), 2px 2px 4px rgba(0, 0, 0, 0.8); }
}

/* スクリーンオーバーレイ */
.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    backdrop-filter: blur(5px);
}

.overlay-screen h1 {
    color: #FFD700;
    font-size: 32px;
    margin-bottom: 15px;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
    text-align: center;
    line-height: 1.3;
}

.overlay-screen p {
    color: white;
    font-size: 16px;
    margin-bottom: 25px;
    text-align: center;
    line-height: 1.6;
}

.btn {
    padding: 18px 45px;
    font-size: 22px;
    font-weight: bold;
    color: white;
    background: linear-gradient(45deg, #ff4b4b, #ff8c00);
    border: none;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    transition: transform 0.1s, box-shadow 0.1s;
}

.btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

/* ダメージフラッシュ */
#flash {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: red;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.1s;
}

/* 加载状态显示 / ロード状態の表示 */
.loading-status {
    width: 60%;
    margin: 20px 0;
    text-align: center;
    color: #FFD700;
    font-size: 18px;
    font-weight: bold;
}

/* 进度条容器 / プログレスバーコンテナ */
.progress-bar {
    width: 90%;
    max-width: 720px;
    height: 30px;
    background-color: rgba(0, 0, 0, 0.5);
    border: 2px solid #FFD700;
    border-radius: 15px;
    overflow: hidden;
    margin: 10px auto;
    position: relative;
}

/* ローディングバーに重ねるパーセンテージ表示 */
.loading-percent {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 18px;
    font-weight: bold;
    text-shadow:
        -1px -1px 2px black,
         1px -1px 2px black,
        -1px  1px 2px black,
         1px  1px 2px black;
    z-index: 1;
    pointer-events: none;
}

/* ローディングバーの塗りつぶし（深度マーカーの .progress-fill と分離） */
.loading-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #00A859, #FFCC29);
    width: 0%;
    transition: width 0.2s ease;
    border-radius: 13px;
}

/* 禁用按钮样式 / 無効化ボタンのスタイル */
.btn:disabled {
    background: linear-gradient(45deg, #666, #888);
    cursor: not-allowed;
    opacity: 0.6;
}

/* ポップアップテキスト（アイテム取得時） - スマホ縦画面デフォルト */
.popup-text {
    position: absolute;
    font-size: 32px;
    font-weight: bold;
    color: white;
    -webkit-text-stroke: 2px black;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.9);
    background-color: rgba(0, 0, 0, 0.6);
    padding: 8px 16px;
    border-radius: 8px;
    pointer-events: none;
    animation: floatUp 1s ease-out forwards;
    transform: translate(-50%, -50%);
}

@keyframes floatUp {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
    50% { transform: translate(-50%, -100%) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%, -150%) scale(1); opacity: 0; }
}

/* アイテム取得数表示用のスタイル - スマホ縦画面デフォルト */
#item-counts-display {
    background: rgba(0, 0, 0, 0.6);
    padding: 12px;
    border-radius: 10px;
    color: white;
    font-size: 13px;
    margin-bottom: 15px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 20px;
    text-align: left;
    border: 1px solid #555;
}
.item-count-row {
    display: flex;
    justify-content: space-between;
}

/* カーニバル演出用の特別スタイル */
#clear-screen {
    background-color: rgba(255, 255, 255, 0.1);
    backdrop-filter: none;
}
#clear-title {
    color: #FF1493;
    font-size: 42px;
    text-shadow: 2px 2px 0 #FFF, -2px -2px 0 #FFF, 2px -2px 0 #FFF, -2px 2px 0 #FFF, 0 0 20px #FF1493;
    animation: bounce 0.5s infinite alternate;
}
#rank-display {
    font-size: 24px;
    font-weight: bold;
    color: #FFD700;
    text-shadow: 2px 2px 5px #000;
    margin: 15px 0;
    padding: 8px 15px;
    background-color: rgba(0,0,0,0.5);
    border-radius: 15px;
}
.clear-text-with-bg {
    background-color: rgba(0,0,0,0.5);
    border-radius: 15px;
    padding: 8px 15px;
    display: inline-block;
    margin: 10px 0;
}
@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-10px); }
}

/* PC・タブレット横画面向けのスタイル調整 */
@media (orientation: landscape) and (min-width: 600px) {
    .header { padding: 20px; font-size: 24px; }
    #depth-display, #popularity-display { font-size: 32px; }

    /* 新进度条横屏适配 / 新しい進捗バーの横画面対応 */
    .new-progress-track { right: 25px; top: 100px; bottom: 100px; }
    .progress-endpoint { font-size: 26px; padding: 10px 18px; }
    .progress-bar-wrapper { width: 35px; }
    .marker-core { width: 24px; height: 24px; }
    .marker-pulse { width: 50px; height: 50px; }
    .overlay-screen h1 { font-size: 40px; }
    .overlay-screen p { font-size: 18px; }
    #clear-title { font-size: 56px; }
    #rank-display { font-size: 36px; margin: 20px 0; padding: 10px 20px; }
    .clear-text-with-bg { padding: 10px 20px; }
    .btn { padding: 15px 50px; font-size: 24px; }
    .popup-text { font-size: 28px; }
    #item-counts-display { font-size: 16px; gap: 10px 30px; padding: 15px; }
    .controls-hint { font-size: 18px; bottom: 10%; }
}