/* =========================
   酒game 大排檔 主體樣式
   ========================= */

/* 頁面背景及字型設定
   - 使用 Google 字體
   - 背景漸層＋桌面背景圖
*/
body {
    margin: 0;
    padding: 0;
    font-family: 'Noto Sans TC', 'Pacifico', cursive, sans-serif;
    font-size: 20px;
    background: linear-gradient(120deg, #f8fafc 0%, #e0e7ff 100%);
    min-height: 100vh;
    text-rendering: optimizeSpeed;
    -webkit-font-smoothing: antialiased;
    background-image: url('bgPhoto/bg.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

/* 規則頁背景 */
.rules-page {
    background-image: url('bgPhoto/rules.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

/* 介紹頁背景 */
.intro-page {
    background-image: url('bgPhoto/intro.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

/* =========================
   主要內容容器
   ========================= */

/* 主內容容器（白底圓角區塊） */
.container1 {
    max-width: 600px; /* 或 700px，需大於桌子寬度 */
    margin: 30px auto;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(60, 60, 120, 0.15);
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 左對齊版本（用於介紹/規則頁） */
.container2 {
    max-width: 600px;
    margin: 30px auto;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(60, 60, 120, 0.15);
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
    align-items: left;
}

/* =========================
   桌子與卡牌區域
   ========================= */

/* 桌子與卡牌區域（圓桌與卡牌的外框） */
.table-and-cards {
    position: relative;
    width: 600px;   /* 桌子寬度 */
    height: 600px;  /* 桌子高度 */
    margin: 0 auto 24px auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 桌子圖片容器 */
.table-image-container {
    position: relative;
    width: 600px;
    height: 600px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 桌子圖片本身 */
.table-image {
    width: 600px;
    height: 600px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    z-index: 1;
}

/* 牌堆與翻開卡牌的區域（絕對定位於桌子中央） */
.deck-and-card {
    position: absolute;
    left: 50%;
    top: 40%; /* 調整此值可上下移動卡牌，50%為正中央 */
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 70px;
    z-index: 2;
    width: auto;
    pointer-events: auto;
}

/* =========================
   標題與文字樣式
   ========================= */

/* 主標題 h1 */
h1 {
    font-family: 'Pacifico', cursive;
    font-size: 2.5rem;
    color: #6366f1;
    letter-spacing: 2px;
    margin-bottom: 24px;
}

/* 副標題 h2 */
h2 {
    font-family: 'Pacifico', cursive;
    font-weight: 700;
    color: #3b3b6d;
    font-size: 1.6rem;
    margin-top: 32px;
    margin-bottom: 18px;
}

/* 重要文字高亮 */
.important {
    font-family: 'Roboto', sans-serif;
    font-size: 1.2rem;
    color: #ef4444;
    font-weight: bold;
    background: linear-gradient(90deg, #fbbf24 0%, #f87171 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* 正文段落 */
p {
    font-family: 'Noto Sans TC', sans-serif;
    font-size: 1.1rem;
    color: #222;
    margin-bottom: 16px;
}

/* 清單 */
ul, li {
    font-family: 'Noto Sans TC', sans-serif;
    font-size: 1rem;
    color: #444;
    margin-bottom: 8px;
}

/* 頁腳 */
footer {
    font-family: 'Roboto', sans-serif;
    font-size: 0.9rem;
    color: #64748b;
    margin-top: 40px;
    text-align: center;
}

/* =========================
   遊戲區域相關樣式
   ========================= */

/* 遊戲主區塊 */
.game-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 16px;
    justify-content: center;
    align-items: center;
    width: 100%;
}

/* 遊戲資訊區 */
.info-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    justify-content: center;
    width: 100%;
}

/* 遊戲設定區（checkbox） */
.settings-area {
    display: flex;
    flex-wrap: wrap;
    gap: 18px 24px;
    justify-content: center;
    align-items: center;
    margin-bottom: 4px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 4px 12px rgba(60, 60, 120, 0.08);
    width: 100%;
    max-width: 380px;
}

/* 設定標籤 */
.setting-label {
    font-size: 0.95rem;
    color: #4a5568;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

/* 設定區 checkbox 樣式 */
.setting-label input[type="checkbox"] {
    accent-color: #6366f1;
    width: 18px;
    height: 18px;
    margin-right: 4px;
}

/* 音效開關特殊樣式 */
.setting-label.sound-label {
    flex-basis: auto;
    justify-content: flex-start;
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

/* =========================
   卡牌區域樣式
   ========================= */

/* 卡牌區塊（如需用於手牌等） */
.card-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 70px;
    position: relative;
    width: 100%;
    height: 180px;
    margin: 16px 0;
}

/* 按鈕區 */
.button-area {
    display: flex;
    gap: 18px;
    justify-content: center;
    margin-top: 4px;
}

/* 抽牌按鈕 */
#draw-button {
    padding: 12px 32px;
    font-size: 1.05rem;
    background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    font-weight: 600;
    min-width: 100px;
}
#draw-button:hover {
    background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
    transform: translateY(-1px);
}

/* 結束遊戲按鈕 */
#end-button {
    background: linear-gradient(135deg, #ef4444 0%, #f87171 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 12px 20px;
    font-size: 1.05rem;
    font-family: inherit;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
}
#end-button:hover {
    background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35);
    transform: translateY(-1px);
}

/* 剩餘牌數顯示 */
#remaining {
    font-size: 1rem;
    color: #6366f1;
    font-weight: 500;
    margin-top: 8px;
    text-align: center;
    background: rgba(99, 102, 241, 0.05);
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid rgba(99, 102, 241, 0.1);
}

/* 規則顯示區 */
.rule-display {
    margin-top: 20px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 12px;
    color: #4a5568;
    font-size: 1rem;
    line-height: 1.5;
    box-shadow: 0 4px 12px rgba(60, 60, 120, 0.08);
    width: 100%;
    text-align: left;
    border-left: 4px solid #6366f1;
}

/* =========================
   牌堆樣式與動畫
   ========================= */

/* 牌堆容器 */
.deck-container {
    position: relative;
    width: 100px;
    height: 140px;
}

/* 牌堆下方指示文字 */
.deck-indicator {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    color: #6366f1;
    font-weight: 500;
    text-align: center;
}

/* 牌堆本體 */
.deck {
    position: relative;
    width: 100px;
    height: 140px;
    transition: transform 0.3s ease;
}

/* 牌堆中的每一張牌 */
.deck-card {
    position: absolute;
    width: 100px;
    height: 140px;
    background-image: url('pokers image/Poker Back.jpeg');
    background-size: 90px 130px;
    background-position: center;
    background-repeat: no-repeat;
    background-color: #fff;
    border-radius: 12px;
    border: 1px solid #6366f1;
    box-shadow: 0 2px 8px rgba(60, 60, 120, 0.15);
    transition: all 0.3s ease;
}

/* 牌堆層疊效果 */
.deck-card-1 { top: 0px; left: 0px; z-index: 5; }
.deck-card-2 { top: -2px; left: 1px; z-index: 4; }
.deck-card-3 { top: -4px; left: 2px; z-index: 3; }
.deck-card-4 { top: -6px; left: 3px; z-index: 2; }
.deck-card-5 { top: -8px; left: 4px; z-index: 1; }

/* 牌堆洗牌動畫 */
.deck.shuffling {
    animation: deckPulse 0.85s ease-in-out;
    will-change: transform;
}
.deck.shuffling .deck-card-1 { animation: shuffle1 0.8s ease-in-out; will-change: transform; }
.deck.shuffling .deck-card-2 { animation: shuffle2 0.75s ease-in-out; will-change: transform; }
.deck.shuffling .deck-card-3 { animation: shuffle3 0.85s ease-in-out; will-change: transform; }
.deck.shuffling .deck-card-4 { animation: shuffle4 0.7s ease-in-out; will-change: transform; }
.deck.shuffling .deck-card-5 { animation: shuffle5 0.8s ease-in-out; will-change: transform; }

@keyframes deckPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}
@keyframes shuffle1 {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-12px) rotate(4deg); }
    50% { transform: translateY(-8px) rotate(-3deg); }
    75% { transform: translateY(-15px) rotate(5deg); }
}
@keyframes shuffle2 {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    20% { transform: translateY(-10px) rotate(-4deg); }
    60% { transform: translateY(-12px) rotate(3deg); }
    80% { transform: translateY(-7px) rotate(-2deg); }
}
@keyframes shuffle3 {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    30% { transform: translateY(-11px) rotate(3deg); }
    70% { transform: translateY(-6px) rotate(-4deg); }
}
@keyframes shuffle4 {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    40% { transform: translateY(-9px) rotate(-3deg); }
    80% { transform: translateY(-13px) rotate(4deg); }
}
@keyframes shuffle5 {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    35% { transform: translateY(-8px) rotate(2deg); }
    65% { transform: translateY(-10px) rotate(-3deg); }
}

/* 抽牌動畫 */
.deck-card.drawing {
    animation: drawCard 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    z-index: 10 !important;
    box-shadow: 0 8px 25px rgba(60, 60, 120, 0.3) !important;
    will-change: transform, opacity;
}

@keyframes drawCard {
    0% {
        transform: scale(1) translateY(0);
        opacity: 1;
        box-shadow: 0 4px 16px rgba(60, 60, 120, 0.15);
    }
    70% {
        transform: scale(1.08) translateY(-60px);
        opacity: 0.7;
        box-shadow: 0 10px 28px rgba(60, 60, 120, 0.28);
    }
    100% {
        transform: scale(1.1) translateY(-80px);
        opacity: 0;
        box-shadow: 0 12px 32px rgba(60, 60, 120, 0.32);
    }
}

/* 牌堆高度動態調整 */
.deck.reduced .deck-card-1 { top: 1px; }
.deck.reduced .deck-card-2 { top: -1px; }
.deck.reduced .deck-card-3 { top: -3px; }
.deck.reduced .deck-card-4 { top: -5px; }
.deck.reduced .deck-card-5 { top: -7px; }

/* 牌堆逐漸減少效果 */
.deck.cards-4 .deck-card-5,
.deck.cards-3 .deck-card-4,
.deck.cards-3 .deck-card-5,
.deck.cards-2 .deck-card-3,
.deck.cards-2 .deck-card-4,
.deck.cards-2 .deck-card-5,
.deck.cards-1 .deck-card-2,
.deck.cards-1 .deck-card-3,
.deck.cards-1 .deck-card-4,
.deck.cards-1 .deck-card-5,
.deck.cards-0 .deck-card-1,
.deck.cards-0 .deck-card-2,
.deck.cards-0 .deck-card-3,
.deck.cards-0 .deck-card-4,
.deck.cards-0 .deck-card-5 {
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.5s ease, transform 0.5s ease;
}
/* 逐漸減少時的 top 微調 */
.deck.cards-3 .deck-card-1 { top: 2px; }
.deck.cards-3 .deck-card-2 { top: 0px; }
.deck.cards-3 .deck-card-3 { top: -2px; }
.deck.cards-2 .deck-card-1 { top: 3px; }
.deck.cards-2 .deck-card-2 { top: 1px; }
.deck.cards-1 .deck-card-1 { top: 4px; }
.deck.cards-0 .deck-card-1,
.deck.cards-0 .deck-card-2,
.deck.cards-0 .deck-card-3,
.deck.cards-0 .deck-card-4,
.deck.cards-0 .deck-card-5 {
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

/* =========================
   卡片翻牌動畫
   ========================= */

/* 卡牌本體 */
.card {
    width: 100px;
    height: 140px;
    perspective: 1000px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(60, 60, 120, 0.12);
    background: transparent;
    position: relative;
    overflow: visible;
    transition: box-shadow 0.3s, opacity 0.5s, transform 0.5s;
    margin: 0 auto;
    opacity: 0;
    transform: scale(0.8) translateY(10px);
    will-change: transform, opacity;
}

/* 卡牌顯示動畫 */
.card.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
}
.card.newly-drawn {
    animation: cardAppear 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes cardAppear {
    0% {
        opacity: 0;
        transform: scale(0.6) translateY(30px) rotateY(-90deg);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.05) translateY(-5px) rotateY(-45deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0) rotateY(0deg);
    }
}

/* 卡牌 hover 效果 */
.card:hover {
    box-shadow: 0 8px 32px rgba(60, 60, 120, 0.22);
    transform: scale(1.02) translateY(-2px);
}

/* 卡牌正反面 */
.front, .back {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    border-radius: 12px;
    backface-visibility: hidden;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid #6366f1;
    box-shadow: 0 4px 16px rgba(60, 60, 120, 0.15);
    will-change: transform;
}
.front {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    color: #3b3b6d;
    font-weight: bold;
    transform: rotateY(0deg);
    z-index: 2;
}
.back {
    background: none;
    color: #fff;
    font-size: 1.2rem;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: rotateY(-180deg);
    padding: 0;
    z-index: 1;
}
.back img {
    width: 90px;
    height: 130px;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(60,60,120,0.12);
}

/* 卡片翻牌效果 */
.card.flipped .front {
    transform: rotateY(180deg);
}
.card.flipped .back {
    transform: rotateY(0deg);
}

/* 卡片翻牌動畫加強效果 */
.card.flipping {
    animation: cardFlip 0.8s ease-in-out;
}
@keyframes cardFlip {
    0% {
        transform: scale(1) rotateY(0deg);
    }
    25% {
        transform: scale(1.05) rotateY(-45deg);
        box-shadow: 0 8px 25px rgba(60, 60, 120, 0.25);
    }
    50% {
        transform: scale(1.1) rotateY(-90deg);
        box-shadow: 0 12px 35px rgba(60, 60, 120, 0.35);
    }
    75% {
        transform: scale(1.05) rotateY(-135deg);
        box-shadow: 0 8px 25px rgba(60, 60, 120, 0.25);
    }
    100% {
        transform: scale(1) rotateY(-180deg);
    }
}

/* =========================
   響應式設計（手機版）
   ========================= */
@media (max-width: 700px) {
  .container1, .container2 {
    max-width: 98vw;
    padding: 10px 2vw;
  }
  .table-and-cards, .table-image-container, .table-image {
    width: 98vw !important;
    max-width: 98vw !important;
    height: auto !important;
    min-width: 0 !important;
  }
  .deck-and-card {
    flex-direction: column;
    gap: 20px;
    width: 100%;
  }
  .card, .deck-card {
    width: 70px !important;
    height: 100px !important;
  }
}