/* ==========================================================================
   Blazor 預設樣式 (保留必要部分)
   ========================================================================== */
/* Import SpeedL Design System */
@import url('./speedl-design-system.css');

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: var(--speedl-surface-primary) !important;
    color: var(--speedl-text-primary) !important;
    letter-spacing: -0.005em !important;
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* ==========================================================================
   1. 全局與基礎設置 (Global & Base Setup)
   ========================================================================== */

.page-wrapper {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--page-background-color, #111); /* 預設深灰色 */
    transition: background-color 0.5s ease-in-out;
    font-family: 'Microsoft JhengHei', '微軟正黑體', sans-serif;
}

/* ==========================================================================
   2. 遊戲主容器 (Game Container)
   ========================================================================== */
.game-container {
    position: relative; /* 關鍵：讓所有子元素的 absolute 定位相對於此 */
    width: 100%;
    height: 100%;
    margin: 0; /* 在極寬螢幕上留點邊距 */
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-color: #000; /* 當沒有背景圖或顏色時，底色為黑 */
    overflow: hidden; /* 確保所有內容都在這個框內 */
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.8);
}

/* 手機橫向時的特殊處理 */
@media (max-height: 480px) and (orientation: landscape) {
    .game-container {
        width: auto;
        height: 100%;
    }
}

/* ==========================================================================
   3. 角色立繪 (Character Sprite)
   ========================================================================== */
.character-sprite {
    position: absolute;
    bottom: 15%; /* Move the sprite up to stand on top of the dialogue box */
    height: 85%; /* Reduce height to prevent it from going off-screen */
    width: 30%; /* Set a fixed width, as aspect-ratio is removed */
    max-width: 40%;
    z-index: 10;
    transition: filter 0.4s ease-in-out, opacity 0.4s ease-in-out;
}

.character-sprite.inactive {
    filter: grayscale(100%);
    opacity: 0.7;
}
.character-sprite img {
    height: 100%;
    width: 100%;
    object-fit: contain; /* 關鍵：確保圖片完整顯示，不被裁切 */
    object-position: bottom center; /* 圖片底部對齊 */
}
.sprite-position-center { left: 50%; transform: translateX(-50%); }
.sprite-position-left   { left: 25%; transform: translateX(-50%); }
.sprite-position-right  { left: 75%; transform: translateX(-50%); }

/* ==========================================================================
   4. 對話與選擇框 (UI Elements)
   ========================================================================== */
.dialogue-box-wrapper, .choice-box-wrapper {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 2%; /* 使用百分比確保響應式 */
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    z-index: 20;
}
.dialogue-card, .choice-paper {
    width: 100%;
    max-width: 1200px; /* 與 game-container 同步 */
    background-color: rgba(0, 0, 0, 0.75) !important;
    color: #fff !important;
    border-radius: 12px !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    padding: 1.5% 2.5% !important; /* 使用百分比確保響應式 */
    backdrop-filter: blur(4px);
}
.mud-card-header { padding: 0 0 10px 0 !important; }
.dialogue-character-name {
    font-size: clamp(1.4em, 2.5vw, 1.8em) !important;
    font-weight: bold !important;
    color: #ffd700 !important;
    text-shadow: 1px 1px 2px #000;
}
.dialogue-text {
    font-size: clamp(1.1em, 2vw, 1.4em) !important;
    line-height: 1.5 !important;
}
.advance-indicator {
    position: absolute; bottom: 15px; right: 25px;
    font-size: clamp(1.5em, 3vw, 2em) !important;
    color: #ffd700;
    animation: bounce 1.2s infinite;
}
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.choice-paper {
    padding: 2.5% !important;
}
.choice-paper .mud-button {
    font-size: clamp(1em, 1.8vw, 1.2em) !important;
}

/* ==========================================================================
   5. 載入畫面 (Loading Indicator)
   ========================================================================== */
.loading-indicator {
    position: fixed; top: 0; left: 0;
    width: 100vw; height: 100vh;
    display: flex; justify-content: center; align-items: center;
    background-color: #1a1a1a;
    z-index: 100;
}

.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hover-elevate { transition: box-shadow .2s ease, transform .2s ease; }
.hover-elevate:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(0,0,0,.35); }
.max-w-50 { max-width: 420px; width: 100%; }

/* ==========================================================================
   Steam 風格樣式 (Steam-style Components)
   ========================================================================== */

/* SpeedL Store Page Styles */
.speedl-store-content {
    background: var(--speedl-surface-primary) !important;
    min-height: 100vh !important;
    padding: var(--speedl-space-xxxl) !important;
}

.speedl-store-header h1 {
    color: var(--speedl-text-primary) !important;
    font-weight: 700 !important;
    font-size: 2.5rem !important;
    margin-bottom: var(--speedl-space-xxxl) !important;
    background: linear-gradient(135deg, var(--speedl-blue), var(--speedl-purple)) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

.speedl-store-filters {
    background: var(--speedl-glass-medium) !important;
    border-radius: var(--speedl-radius-xxlarge) !important;
    padding: var(--speedl-space-xxxl) !important;
    margin-bottom: var(--speedl-space-xxxl) !important;
    border: 1px solid var(--speedl-border-medium) !important;
}

/* SpeedL 遊戲卡片樣式 */
.speedl-game-card {
    background: var(--speedl-glass-light) !important;
    border-radius: var(--speedl-radius-rounded) !important;
    border: 1px solid var(--speedl-border-light) !important;
    transition: all var(--speedl-transition-slow) !important;
    cursor: pointer !important;
    overflow: hidden !important;
}

.speedl-game-card:hover {
    transform: translateY(-8px) scale(1.02) !important;
    background: var(--speedl-glass-medium) !important;
    border-color: var(--speedl-blue-medium) !important;
    box-shadow: var(--speedl-shadow-xlarge), 0 12px 32px var(--speedl-blue-light) !important;
}

/* Legacy color variables for backward compatibility */
:root {
    --steam-blue: var(--speedl-gold);
    --steam-green: var(--speedl-gold);
    --steam-dark-blue: var(--speedl-gray-1);
    --steam-medium-blue: var(--speedl-gray-2);
    --steam-light-blue: var(--speedl-text-primary);
    --steam-text-muted: var(--speedl-text-secondary);
    --steam-border: var(--speedl-border-light);
}

/* MudBlazor 元件的 Steam 風格覆寫 */
.mud-input.mud-input-outlined .mud-input-outlined-border {
    border-color: var(--steam-border) !important;
}

.mud-input.mud-input-outlined:hover .mud-input-outlined-border {
    border-color: var(--steam-blue) !important;
}

.mud-input.mud-input-outlined.mud-input-focused .mud-input-outlined-border {
    border-color: var(--steam-blue) !important;
}

.mud-input-label {
    color: var(--steam-text-muted) !important;
}

.mud-input-text {
    color: var(--steam-light-blue) !important;
}

.mud-select .mud-input-text {
    color: var(--steam-light-blue) !important;
}

/* Steam 按鈕樣式 */
.steam-btn-primary {
    background: var(--steam-green) !important;
    color: var(--steam-dark-blue) !important;
    border: none !important;
    font-weight: 600 !important;
    transition: all 0.2s ease !important;
}

.steam-btn-primary:hover {
    background: #beee11 !important;
    transform: translateY(-1px) !important;
}

.steam-btn-secondary {
    background: transparent !important;
    color: var(--steam-blue) !important;
    border: 1px solid var(--steam-blue) !important;
    transition: all 0.2s ease !important;
}

.steam-btn-secondary:hover {
    background: var(--steam-blue) !important;
    color: var(--steam-dark-blue) !important;
}

/* 輪播樣式優化 */
.mud-carousel-item {
    border-radius: 12px;
    overflow: hidden;
}

/* 評分星星樣式 */
.mud-rating .mud-rating-item .mud-icon-root {
    color: #ffd700 !important;
}

/* Chip 樣式優化 */
.mud-chip.mud-chip-outlined {
    background: rgba(102, 192, 244, 0.1) !important;
    border-color: var(--steam-blue) !important;
    color: var(--steam-blue) !important;
}

.mud-chip.mud-chip-outlined.mud-selected {
    background: var(--steam-blue) !important;
    color: var(--steam-dark-blue) !important;
}

/* Switch 樣式優化 */
.mud-switch .mud-switch-span {
    background: var(--steam-border) !important;
}

.mud-switch.mud-checked .mud-switch-span {
    background: linear-gradient(135deg, var(--speedl-yellow), var(--speedl-amber)) !important;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4) !important;
}

/* ==========================================================================
   SpeedL Modern Apple-Inspired Content Cards (Cupertino Design Language)
   ========================================================================== */

.speedl-btn-primary {
    background: linear-gradient(145deg, rgba(0, 122, 255, 0.9), rgba(88, 86, 214, 0.9)) !important;
    border: none !important;
    border-radius: 24px !important;
    color: white !important;
    font-weight: 500 !important;
    text-transform: none !important;
    padding: 12px 24px !important;
    font-size: 0.95rem !important;
    letter-spacing: 0.01em !important;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    box-shadow: 
        0 8px 32px rgba(0, 122, 255, 0.25),
        0 2px 8px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
}

.speedl-btn-primary:hover {
    transform: translateY(-4px) scale(1.02) !important;
    box-shadow: 
        0 16px 48px rgba(0, 122, 255, 0.35),
        0 8px 24px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
    background: linear-gradient(145deg, rgba(0, 122, 255, 1), rgba(88, 86, 214, 1)) !important;
}

.speedl-content-tile {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 28px !important;
    overflow: hidden !important;
    transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1) !important;
    backdrop-filter: blur(40px) saturate(150%) !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    position: relative !important;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.12),
        0 2px 16px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
}

.speedl-content-tile::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 1px !important;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent) !important;
    opacity: 0 !important;
    transition: opacity 0.4s ease !important;
}

.speedl-content-tile:hover {
    transform: translateY(-16px) rotateX(3deg) rotateY(2deg) !important;
    border-color: var(--speedl-gold) !important;
    box-shadow: 
        0 32px 80px rgba(0, 0, 0, 0.5),
        0 16px 40px rgba(184, 134, 11, 0.4),
        0 0 60px rgba(184, 134, 11, 0.2),
        inset 0 2px 0 rgba(184, 134, 11, 0.3) !important;
    background: var(--speedl-gray-2) !important;
}

.speedl-content-tile:hover::before {
    opacity: 1 !important;
}

.speedl-media-preview {
    position: relative !important;
    overflow: hidden !important;
    border-radius: 20px 20px 0 0 !important;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.05)) !important;
}

.speedl-media-preview::after {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.1) 100%) !important;
    opacity: 0 !important;
    transition: opacity 0.4s ease !important;
}

.speedl-content-tile:hover .speedl-media-preview::after {
    opacity: 1 !important;
}

.speedl-media-preview img {
    transition: all 0.8s cubic-bezier(0.23, 1, 0.32, 1) !important;
    filter: brightness(0.95) saturate(1.1) !important;
}

.speedl-content-tile:hover .speedl-media-preview img {
    transform: scale(1.08) !important;
    filter: brightness(1.05) saturate(1.2) !important;
}

.speedl-content-body {
    padding: 24px !important;
    flex-grow: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, transparent 100%) !important;
}

.speedl-content-headline {
    color: rgba(255, 255, 255, 0.95) !important;
    font-weight: 600 !important;
    font-size: 1.1rem !important;
    line-height: 1.35 !important;
    margin-bottom: 12px !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    letter-spacing: -0.01em !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
}

.speedl-author-info {
    color: rgba(255, 255, 255, 0.75) !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    display: flex !important;
    align-items: center !important;
    margin-bottom: 8px !important;
    letter-spacing: 0.005em !important;
}

.speedl-author-info .mud-icon {
    color: var(--speedl-gold) !important;
    filter: drop-shadow(0 2px 4px rgba(184, 134, 11, 0.5)) !important;
}

.speedl-timestamp-info {
    color: rgba(255, 255, 255, 0.65) !important;
    font-size: 0.85rem !important;
    font-weight: 400 !important;
    display: flex !important;
    align-items: center !important;
    margin-bottom: 8px !important;
}

.speedl-timestamp-info .mud-icon {
    color: rgba(142, 142, 147, 0.8) !important;
}

.speedl-engagement-metrics {
    color: rgba(255, 255, 255, 0.6) !important;
    font-size: 0.8rem !important;
    font-weight: 400 !important;
    display: flex !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    margin-top: auto !important;
    gap: 8px !important;
}

.speedl-engagement-metrics .mud-icon {
    color: rgba(142, 142, 147, 0.7) !important;
}

.speedl-action-toolbar {
    padding: 16px 24px !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
    background: rgba(0, 0, 0, 0.05) !important;
    display: flex !important;
    justify-content: space-between !important;
    backdrop-filter: blur(20px) !important;
}

.speedl-action-btn {
    text-transform: none !important;
    font-weight: 500 !important;
    font-size: 0.9rem !important;
    border-radius: 16px !important;
    padding: 8px 16px !important;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
    backdrop-filter: blur(10px) !important;
    letter-spacing: 0.01em !important;
}

.speedl-action-btn:hover {
    background: var(--speedl-gold-light) !important;
    color: var(--speedl-gold-bright) !important;
    transform: translateY(-3px) scale(1.05) !important;
    box-shadow: 0 8px 20px rgba(184, 134, 11, 0.4) !important;
}

.speedl-action-btn.primary {
    background: linear-gradient(135deg, var(--speedl-gold-medium), var(--speedl-bronze-medium)) !important;
    color: rgba(255, 255, 255, 0.95) !important;
    border: 2px solid var(--speedl-gold) !important;
    font-weight: 600 !important;
    box-shadow: 0 4px 16px rgba(184, 134, 11, 0.4) !important;
}

.speedl-action-btn.secondary {
    background: rgba(255, 255, 255, 0.05) !important;
    color: rgba(255, 255, 255, 0.8) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* Responsive Design with Apple-style breakpoints */
@media (max-width: 1024px) {
    .speedl-content-tile {
        margin-bottom: 20px !important;
        border-radius: 24px !important;
    }
    
    .speedl-content-body {
        padding: 20px !important;
    }
    
    .speedl-action-toolbar {
        padding: 12px 20px !important;
    }
}

@media (max-width: 768px) {
    .speedl-content-tile {
        border-radius: 20px !important;
    }
    
    .speedl-media-preview {
        border-radius: 16px 16px 0 0 !important;
        height: 180px !important;
    }
    
    .speedl-content-headline {
        font-size: 1rem !important;
    }
    
    .speedl-author-info {
        font-size: 0.85rem !important;
    }
    
    .speedl-engagement-metrics {
        font-size: 0.75rem !important;
    }
}

@media (max-width: 480px) {
    .speedl-content-tile {
        border-radius: 16px !important;
    }
    
    .speedl-content-body {
        padding: 16px !important;
        gap: 10px !important;
    }
    
    .speedl-action-toolbar {
        padding: 12px 16px !important;
    }
    
    .speedl-action-btn {
        font-size: 0.85rem !important;
        padding: 6px 12px !important;
    }
}