body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1a1a1a;
    color: #f0f0f0;
    background-image: url('images/background.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    margin: 0;
    padding: 10px;
}

h1, h2, h3 {
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

/* Header & Navigation */
header {
    background-color: rgba(0, 0, 0, 0.6);
    padding: 10px 0;
    margin: -10px -10px 10px -10px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo {
    height: 100px;
    aspect-ratio: 21 / 9;
    object-fit: contain;
}

/* Site header title */
.site-title {
    color: #d4af37;
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

nav a {
    color: #ccc;
    text-decoration: none;
    font-size: 1.2rem;
    margin: 0 15px;
    font-weight: bold;
    transition: color 0.2s;
}


/* Typography & Layout */
main {
    max-width: 900px;
    margin: 0 auto;
}

p, li {
    line-height: 1.6;
    font-size: 1.1rem;
    margin-bottom: 15px;
}

ul {
    padding-left: 25px;
}

.card {
    background-color: white;
    width: 100px;
    height: 140px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    display: inline-flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 8px;
    margin: 8px;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    user-select: none;
    color: black;
    font-weight: bold;
    box-sizing: border-box;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
    z-index: 10;
}

.card-corner {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    font-size: 1.2rem;
    position: absolute;
}

.card-corner.top-left {
    top: 8px;
    left: 8px;
}

.card-corner.bottom-right {
    bottom: 8px;
    right: 8px;
}

.card-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
}

.suit.red { color: #d40000; }
.suit.black { color: #1a1a1a; }

/* Stats Bar */
.stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 15px 20px;
    border-radius: 12px;
    margin-bottom: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#health {
    font-size: 1.5rem;
    color: #ff5555;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    flex: 1;
}

#highScore {
    font-size: 1.3rem;
    color: #d4af37;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    text-align: center;
    flex: 1;
}

#deck {
    font-size: 1.2rem;
    color: #ccc;
}

.deck-container {
    flex: 1;
    text-align: right;
}

#game h3 {
    text-align: center;
}

/* Game Zones */
#hand, #shield, #sword, #discard {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    padding: 10px 15px;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.zone-title {
    color: #ccc;
    font-size: 0.9rem;
    font-weight: bold;
    text-transform: uppercase;
    margin: 0 0 5px 0;
    padding: 0;
    text-align: center;
    width: 100%;
}

.card-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}

#hand, #discard {
    width: 464px;
    margin-left: auto;
    margin-right: auto;
}
/* Buttons */
button {
    background-color: #333;
    color: white;
    border: 1px solid #555;
    padding: 10px 20px;
    font-size: 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-right: 10px;
}

button:hover { background-color: #444; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.selected {
    background-color: #d4af37; /* Gold */
    color: black;
    border-color: #fff;
    font-weight: bold;
}

.game-log {
    margin: 15px auto;
    padding: 12px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 1px solid #555;
    border-radius: 8px;
    max-width: 600px;
    text-align: center;
    min-height: 24px;
    color: #fff;
    font-size: 1rem;
    line-height: 1.4;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    #hand {
        width: auto;
        flex-wrap: nowrap;
        padding: 10px 5px;
    }

    #hand .card-container {
        flex-wrap: nowrap;
        width: 100%;
    }

    #hand .card {
        flex: 1 1 0;
        width: auto;
        height: auto;
        aspect-ratio: 5 / 7;
        margin: 3px;
        min-width: 0;
    }

    .card-corner { font-size: 0.8rem; }
    .card-center { font-size: 2rem; }

    #shield .card, #sword .card {
        width: 70px;
        height: 98px;
    }
    #shield .card-container, #sword .card-container {
        margin: auto;
    }
}

/* Intro Text */
.intro-text {
    text-align: center;
    font-size: 1.2rem;
    color: #e0e0e0;
    margin: 20px auto;
    max-width: 800px;
    line-height: 1.6;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

/* Instructions Section */
.instructions-container {
    background-color: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 30px;
    margin-top: 50px;
    margin-bottom: 30px;
    color: #ddd;
}

.instructions-container h2 {
    color: #d4af37;
    border-bottom: 1px solid #555;
    padding-bottom: 10px;
    margin-top: 0;
}

.instructions-container h3 {
    color: #fff;
    margin-top: 20px;
    margin-bottom: 10px;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    margin-top: 30px;
    background-color: rgba(0, 0, 0, 0.6);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

footer a {
    color: #ccc;
    text-decoration: none;
    margin: 0 10px;
}

footer a:hover {
    color: white;
    text-decoration: underline;
}

footer p {
    font-size: 0.9rem;
    margin: 10px 0 0 0;
    color: #aaa;
}

/* Endgame Screen */
.endgame-screen {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: env(safe-area-inset-top, 16px) env(safe-area-inset-right, 16px) env(safe-area-inset-bottom, 16px) env(safe-area-inset-left, 16px);
}

.endgame-content {
    background-color: rgba(20, 20, 20, 0.98);
    border: 2px solid #d4af37;
    border-radius: 16px;
    padding: 40px 30px;
    max-width: 500px;
    width: 90%;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    text-align: center;
    box-sizing: border-box;
}

.endgame-content h2 {
    color: #d4af37;
    font-size: 2.5rem;
    margin: 0 0 30px 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.endgame-scores {
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.score-item:last-child {
    margin-bottom: 0;
}

.score-label {
    color: #ccc;
    font-weight: 600;
}

.score-value {
    color: #d4af37;
    font-weight: bold;
    font-size: 1.5rem;
}

.endgame-button {
    background-color: #d4af37;
    color: black;
    border: none;
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
    box-sizing: border-box;
}

.endgame-button:hover {
    background-color: #e6c547;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(212, 175, 55, 0.3);
}

.endgame-button:active {
    transform: translateY(0);
}

@media (max-width: 600px) {
    .endgame-content {
        padding: 30px 20px;
        max-width: 95%;
    }

    .endgame-content h2 {
        font-size: 2rem;
    }

    .score-item {
        font-size: 1.1rem;
    }

    .score-value {
        font-size: 1.3rem;
    }

    .endgame-button {
        padding: 12px 30px;
        font-size: 1rem;
    }
}
