:root {
    --bg-color: #d4a373;
    --primary-color: #2a9d8f;
    --primary-hover: #21867a;
    --secondary-color: #e76f51;
    --secondary-hover: #d25f43;
    --accent-color: #f4a261;
    --danger-color: #e63946;
    --text-color: #fdf8f5;
    --glass-bg: rgba(24, 28, 20, 0.75);
    --glass-border: rgba(255, 255, 255, 0.15);
    --card-bg: #fff;
    --card-back: linear-gradient(135deg, #2b1f1a, #1a1412);
    --card-border: #4a362d;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    background-image: url('kaktüs_bg.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Oyun ekranında scroll'u engelle */
}

#app {
    width: 100%;
    max-width: 800px;
    height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* --- Genel UI Bileşenleri --- */

.screen {
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.screen.active {
    display: flex;
}

#game-screen.active {
    display: block;
}

.hidden {
    display: none !important;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.5s ease-out;
}

.glass-panel-small {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 20px;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 10px;
    color: var(--primary-color);
    text-shadow: 0 0 20px rgba(42, 157, 143, 0.4);
}

p {
    color: #cbd5e1;
    margin-bottom: 24px;
    font-weight: 300;
}

.input-group {
    margin-bottom: 15px;
}

input {
    width: 100%;
    padding: 15px 20px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
    color: white;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s;
}

input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(42, 157, 143, 0.3);
}

.settings-group {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px !important;
}

.settings-group label {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-color);
}

select {
    padding: 10px 15px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 1rem;
    outline: none;
    cursor: pointer;
    transition: all 0.3s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23FFFFFF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 12px auto;
    padding-right: 40px;
}

select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(42, 157, 143, 0.3);
}

select option {
    background: #2b1f1a;
    color: white;
}

select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

button {
    width: 100%;
    padding: 15px 20px;
    border-radius: 12px;
    border: none;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.primary-btn {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(42, 157, 143, 0.4);
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(42, 157, 143, 0.6);
}

.secondary-btn {
    background: var(--secondary-color);
    color: white;
    margin-top: 10px;
    box-shadow: 0 4px 14px 0 rgba(231, 111, 81, 0.4);
}

.secondary-btn:hover {
    background: var(--secondary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(231, 111, 81, 0.6);
}

/* --- Oyun İçi --- */

#game-screen {
    position: relative;
    padding: 10px;
    width: 100%;
    height: 100%;
}

#opponents-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.opponent {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: scale(0.65);
    pointer-events: auto;
    margin: 0;
}

.opponent-top {
    top: 70px;
    left: 50%;
    transform: translateX(-50%) scale(0.65);
    transform-origin: top center;
}

.opponent-left {
    top: 50%;
    left: -40px;
    transform: translateY(-50%) rotate(90deg) scale(0.65);
    transform-origin: center center;
    flex-direction: column-reverse;
}

.opponent-right {
    top: 50%;
    right: -40px;
    transform: translateY(-50%) rotate(-90deg) scale(0.65);
    transform-origin: center center;
    flex-direction: column-reverse;
}

.opponent .player-name {
    font-size: 1.2rem;
    margin-bottom: 5px;
    background: rgba(0,0,0,0.5);
    padding: 2px 10px;
    border-radius: 10px;
}

.opponent-left .player-name, .opponent-right .player-name {
    margin-bottom: 0;
    margin-top: 5px;
}

#center-area {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
}

#my-area {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.player-info {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 300px;
    margin-bottom: 10px;
    align-items: center;
}

#my-name {
    font-size: 1.2rem;
    font-weight: 500;
}

.kaktus-btn {
    width: auto;
    padding: 10px 20px;
    background: linear-gradient(45deg, #1b4332, #2d6a4f, #40916c);
    color: white;
    border: 2px solid #52b788;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(45, 106, 79, 0.5);
    animation: kaktusPulse 1.5s infinite;
    font-size: 1rem;
    font-weight: 800;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.kaktus-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 20px rgba(82, 183, 136, 0.7);
}

/* --- Kartlar --- */

.card-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding-left: 0;
}


.card-slot {
    width: 70px;
    height: 100px;
    border-radius: 8px;
    perspective: 1000px;
    position: relative;
    transition: transform 0.2s;
}

.card-slot:hover {
    z-index: 10;
}

.card-slot.selected {
    z-index: 10;
    transform: translateY(-15px);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.8);
}

.scoreboard {
    background: rgba(0,0,0,0.4);
    border-radius: 10px;
    padding: 15px;
    margin-top: 15px;
}

.scoreboard table {
    width: 100%;
    border-collapse: collapse;
}

.scoreboard th, .scoreboard td {
    padding: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.scoreboard th {
    font-weight: 600;
    color: var(--primary-light);
}

@media (max-width: 600px) {
    .card-slot {
        width: 55px;
        height: 80px;
    }
    #center-area {
        gap: 10px;
        transform: translate(-50%, -30%);
    }
    #opponents-area {
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        gap: 15px;
        top: 10px;
        width: 100%;
    }
    .opponent-left, .opponent-right, .opponent-top {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        transform: none !important;
        flex-direction: column !important;
        margin: 0;
        width: 100%;
    }
    .opponent .card-slot {
        width: 45px;
        height: 65px;
    }
    .opponent .card-grid {
        flex-wrap: nowrap;
        gap: 5px;
    }
    .opponent .player-name {
        font-size: 0.9rem;
        margin-bottom: 3px;
        margin-top: 0;
    }
    #game-info {
        top: auto !important;
        bottom: -65px !important;
    }
    .player-name {
        font-size: 1rem;
    }
    .active-turn {
        box-shadow: 0 0 10px 3px rgba(245, 158, 11, 0.8) !important;
        border-radius: 8px;
        border: 2px solid #f59e0b;
        padding: 5px;
        background: rgba(0,0,0,0.3);
    }
}

@media (min-width: 500px) {
    .card-slot {
        width: 90px;
        height: 130px;
        border-radius: 12px;
    }
}

.card {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    position: absolute;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1), box-shadow 0.3s;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

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

/* Yüzler */
.card-front, .card-back {
    width: 100%;
    height: 100%;
    position: absolute;
    backface-visibility: hidden;
    border-radius: inherit;
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    /* border: 1px solid var(--card-border); */
}

.card-back {
    background-image: url('./assets/back.png');
}

.card-front {
    transform: rotateY(180deg);
}

.card.face-up {
    transform: rotateY(180deg);
}

.card.face-up:hover {
    transform: rotateY(180deg) translateY(-5px);
}

/* Merkez Destesi ve Iskarta */
#main-deck .card {
    box-shadow: -2px 2px 0 #334155, -4px 4px 0 #1e293b, -6px 6px 5px rgba(0,0,0,0.5);
}

#discard-pile {
    position: relative;
}

#discard-pile .card {
    position: absolute;
    top: 0;
    left: 0;
    transform: rotateY(180deg); /* Açık duracak */
    pointer-events: none; /* Altındaki slot tıklanabilsin diye */
}

/* Animasyonlar ve State'ler */
.selected {
    box-shadow: 0 0 20px var(--accent-color) !important;
    border: 2px solid var(--accent-color);
    transform: translateY(-10px) !important;
}

.selectable {
    animation: glow 1.5s infinite alternate;
    z-index: 2001;
    position: relative;
}

@keyframes glow {
    from { box-shadow: 0 0 5px var(--primary-color); }
    to { box-shadow: 0 0 20px var(--primary-color); }
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

@keyframes kaktusPulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(82, 183, 136, 0.6); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 12px rgba(82, 183, 136, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(82, 183, 136, 0); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-color);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: 500;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: opacity 0.3s, transform 0.3s;
}

.toast.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px) !important;
    pointer-events: none;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
}

#players-list {
    list-style: none;
    margin: 20px 0;
    text-align: left;
}

#players-list li {
    padding: 10px;
    background: rgba(0,0,0,0.2);
    margin-bottom: 5px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
}

.ready-badge {
    color: var(--primary-color);
    font-weight: bold;
}

.swapped-card-highlight {
    animation: swappedGlow 2s ease-out;
    box-shadow: 0 0 25px rgba(230, 57, 70, 0.9) !important;
    border: 2px solid rgba(230, 57, 70, 0.9);
    transform: translateY(-10px);
    z-index: 20;
}

@keyframes swappedGlow {
    0% { box-shadow: 0 0 5px rgba(230, 57, 70, 0); transform: translateY(0); }
    50% { box-shadow: 0 0 35px rgba(230, 57, 70, 1); transform: translateY(-15px); }
    100% { box-shadow: 0 0 25px rgba(230, 57, 70, 0.9); transform: translateY(-10px); }
}

/* Rules Button and Modal */
.info-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
}
.info-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}
.rules-panel {
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    text-align: left;
}
.rules-panel h2 {
    text-align: center;
    margin-bottom: 20px;
}
.rules-content p, .rules-content ul {
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 10px;
}
.rules-content ul {
    padding-left: 20px;
}
.rules-content li {
    margin-bottom: 5px;
}
