:root {
    --bg-color: #1a1a1d;
    --card-bg: #2d2d35;
    --card-border: #4a4a55;
    --accent-color: #d4af37;
    /* Gold */
    --accent-hover: #f7d55e;
    --text-color: #e0e0e0;
    --card-width: 120px;
    --card-height: 170px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body {
    font-family: 'Noto Sans TC', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

.game-container {
    width: 100%;
    max-width: 1400px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 10px;
    background: radial-gradient(circle at center, #2a2a30 0%, #111 100%);
}

/* Header */
.game-header {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 2px solid var(--accent-color);
    height: 80px;
}

.logo {
    height: 50px;
    margin-right: 20px;
}

.game-info h1 {
    color: var(--accent-color);
    font-size: 1.5rem;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

/* Battle Field Grid */
.battle-field {
    flex: 1;
    display: grid;
    grid-template-columns: 200px 1fr 200px;
    grid-template-rows: 1fr 80px 220px;
    grid-template-areas:
        "summon summon summon"
        ". controls ."
        "deck hand graveyard";
    gap: 10px;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

/* Summoning Zone (Top) */
.summoning-zone {
    grid-area: summon;
    border: 2px solid rgba(212, 175, 55, 0.3);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: auto;
}

.zone-label {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 5px;
    width: 100%;
    text-align: center;
    border-bottom: 1px solid #444;
}

.summoned-cards-container {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    padding: 10px;
}

/* Hand Area (Middle) */
.hand-area {
    grid-area: hand;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    perspective: 1000px;
}

/* Deck (Bottom Left) */
.deck-area {
    grid-area: deck;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Graveyard (Bottom Right) */
.graveyard-area {
    grid-area: graveyard;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Card Slot (Deck/Graveyard) */
.card-slot {
    width: var(--card-width);
    height: var(--card-height);
    border: 2px dashed var(--card-border);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
}

.card-slot:hover {
    border-color: var(--accent-color);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
}

.card-slot .label {
    margin-top: 10px;
    font-weight: bold;
    color: #888;
}

.card-count {
    position: absolute;
    top: -10px;
    right: -10px;
    background: var(--accent-color);
    color: #000;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    z-index: 5;
}

.deck .card-back {
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(45deg,
            #3a2c0f,
            #3a2c0f 10px,
            #5c4619 10px,
            #5c4619 20px);
    border-radius: 8px;
    position: absolute;
    top: 0;
    left: 0;
    border: 2px solid #8c6b26;
}

/* Card Styles */
.card {
    width: var(--card-width);
    height: var(--card-height);
    background: var(--card-bg);
    border: 2px solid var(--accent-color);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 10px;
    cursor: pointer;
    position: relative;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    background-image: linear-gradient(135deg, #2d2d35 0%, #1a1a1d 100%);
    font-size: 0.9rem;
    font-weight: bold;
    color: #fff;
    gap: 10px;
}

.card i {
    font-size: 2.5rem;
    color: var(--accent-color);
    margin-bottom: 5px;
}

.card:hover {
    transform: translateY(-20px) scale(1.1);
    z-index: 100;
    box-shadow: 0 10px 25px rgba(212, 175, 55, 0.6);
}

/* Summoned Card Style */
.card.summoned {
    border-color: #00ff00;
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.4);
    transform: scale(0.9);
}

.card.summoned:hover {
    transform: scale(1.0);
}

/* Controls */
.game-controls {
    grid-area: controls;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    z-index: 10;
}

.action-btn {
    background: linear-gradient(to bottom, #d4af37, #8c6b26);
    color: #000;
    border: none;
    padding: 10px 40px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: 0 5px 15px rgba(212, 175, 55, 0.3);
}

.action-btn:hover {
    transform: scale(1.05);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: #2d2d35;
    padding: 30px;
    border-radius: 15px;
    border: 2px solid var(--accent-color);
    width: 90%;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.2);
}

.modal-content h2 {
    color: var(--accent-color);
    margin-bottom: 20px;
}

#result-text {
    width: 100%;
    height: 150px;
    background: #1a1a1d;
    color: #fff;
    border: 1px solid #444;
    border-radius: 5px;
    padding: 10px;
    margin-bottom: 20px;
    resize: none;
    font-size: 1rem;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.modal-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}

#copy-btn {
    background: #444;
    color: #fff;
}

#copy-btn:hover {
    background: #555;
}

.line-btn {
    background: #00b900;
    color: #fff;
}

.line-btn:hover {
    background: #00d900;
}

.close-btn {
    background: transparent;
    border: 1px solid #666;
    color: #888;
}

.close-btn:hover {
    color: #fff;
    border-color: #fff;
}

/* Animations */
@keyframes drawFromDeck {
    from {
        opacity: 0;
        transform: translate(-500px, 500px) rotate(-45deg) scale(0.2);
    }

    to {
        opacity: 1;
        transform: translate(0, 0) rotate(0) scale(1);
    }
}

@keyframes summonPop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.5) rotate(5deg);
        box-shadow: 0 0 50px rgba(212, 175, 55, 0.8);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes discardToGraveyard {
    to {
        opacity: 0;
        transform: translate(500px, 500px) rotate(90deg) scale(0.2);
    }
}

.card.drawing {
    animation: drawFromDeck 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.27) forwards;
}

.card.discarding {
    animation: discardToGraveyard 0.5s ease-in forwards;
}

.card.summoning {
    animation: summonPop 0.5s ease-out;
}