
/* The document never scrolls; only shop/ranking lists scroll inside the game. */
html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    overscroll-behavior: none;
}
body {
    position: fixed;
    inset: 0;
}
#game-root {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--game-width, 100%);
    height: 100vh;
    height: 100dvh;
    height: var(--game-height, 100dvh);
    transform: translate(var(--game-left, 0px), var(--game-top, 0px));
    overflow: hidden;
}
#game-canvas > canvas {
    display: block;
    width: 100%;
    height: 100%;
}
#shop-modal > div, #rank-modal > div {
    max-height: 100%;
}
@media (min-width: 640px) {
    #shop-modal > div, #rank-modal > div {
        max-height: calc(var(--game-height, 100dvh) * 0.85);
    }
}
#shop-grid, #rank-list {
    overscroll-behavior: contain;
}

/* 定義排行榜專用的滑動與淡入淡出動畫 */
.sync-status-button { display: block; flex-shrink: 0; margin: 12px auto 0; padding: 6px 12px; color: #4b5563; font-size: 13px; text-decoration: underline; }
.sync-diagnostics { position: absolute; inset: 0; z-index: 150; display: flex; align-items: center; justify-content: center; padding: 12px; background: #0009; }
.sync-card { position: relative; width: min(420px, 100%); max-height: 100%; overflow: auto; padding: 24px; border-radius: 18px; background: white; color: #1f2937; text-align: left; }
.sync-card h2 { margin-bottom: 12px; font-size: 21px; font-weight: bold; }
.sync-card p { font-size: 13px; line-height: 1.6; color: #6b7280; }
.sync-card dl { margin: 12px 0; font-size: 13px; }
.sync-card dl > div { display: flex; justify-content: space-between; gap: 16px; padding: 5px 0; }
.sync-card dd { max-width: 65%; text-align: right; overflow-wrap: anywhere; }
.sync-retry { display: block; width: 100%; margin-top: 16px; padding: 10px; border-radius: 10px; background: #2563eb; color: white; font-weight: bold; }
.sync-retry:disabled { opacity: .5; }
.sync-update { display: block; margin: 14px auto 0; color: #2563eb; text-align: center; text-decoration: underline; font-size: 14px; }
.player-popover {
    position: absolute;
    z-index: 100;
    box-sizing: border-box;
    width: min(360px, calc(100% - 16px));
    max-height: calc(100% - 16px);
    overflow-y: auto;
    padding: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    background: #fff;
    color: #1f2937;
    box-shadow: 0 12px 36px #0003;
    text-align: left;
}
.profile-header { display: grid; grid-template-columns: 144px minmax(0, 1fr); align-items: center; gap: 12px; }
.profile-identity { min-width: 0; }
.player-popover h3 { margin: 0 20px 4px 0; font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }
.profile-close { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; font-size: 24px; color: #6b7280; }
.profile-tag { font-size: 12px; color: #6b7280; }
.profile-player-icon { display: block; width: 144px; height: 144px; max-width: 100%; object-fit: contain; border-radius: 14px; background: #f3f4f6; }
.profile-section h4 { margin: 12px 0 6px; color: #6b7280; font-size: 12px; font-weight: 600; }
.profile-stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
.profile-stat { min-width: 0; padding: 9px 10px; border-radius: 10px; background: #f3f4f6; }
.profile-stat dt { min-height: 1.25em; font-size: 12px; line-height: 1.25; color: #6b7280; overflow-wrap: anywhere; }
.profile-stat dd { margin: 3px 0 0; font-size: 23px; line-height: 1.1; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
@media (max-height: 520px) {
    .profile-header { grid-template-columns: 112px minmax(0, 1fr); }
    .profile-player-icon { width: 112px; height: 112px; }
}
.name-display:focus-visible, .edit-name:focus-visible { outline: 2px solid #3b82f6; outline-offset: 3px; }

.rank-slide-enter-right { animation: slideInRight 0.3s ease-out forwards; }
.rank-slide-enter-left { animation: slideInLeft 0.3s ease-out forwards; }
.rank-item-move { transition: transform 0.4s ease-in-out; }
.rank-item-fade-in { animation: fadeIn 0.4s ease-out forwards; }
.rank-item-fade-out { animation: fadeOut 0.3s ease-out forwards; }
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.9); }
}

/* --- 動畫 --- */
@keyframes fade {
    0%   { opacity: 0; transform: translate(-50%, 20px); }
    10%  { opacity: 1; transform: translate(-50%, 0); }
    80%  { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, -20px); }
}

/* --- 隱藏橫向捲軸 --- */
.shop-tabs::-webkit-scrollbar {
    display: none;
}
.shop-tabs {
    scrollbar-width: none;
}

/* --- 背景漸層 (保留以利 JS 隨機切換) --- */
.bg-gradient-0 { background: linear-gradient(to bottom, #fffce0, #ffe0b2); }
.bg-gradient-1 { background: linear-gradient(to bottom, #e0f7fa, #80deea); }
.bg-gradient-2 { background: linear-gradient(to bottom, #fce4ec, #ffd7e5); }
.bg-gradient-3 { background: linear-gradient(to bottom, #e8f5e9, #a5d6a7); }
.bg-gradient-4 { background: linear-gradient(to bottom, #ffffe0, #fff59d); }
.bg-gradient-5 { background: linear-gradient(to bottom, #f3e5f5, #ecccf1); }
