:root {
    --primary-bg: radial-gradient(circle at center, #2e1a47 0%, #0d0b21 100%);
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.15);
    --gold: #ffec3d;
    --gold-glow: rgba(255, 236, 61, 0.5);
    --gold-dark: #b8860b;
    --text-main: #f0f0f0;
    --accent-magic: #9b4dff;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    background: var(--primary-bg);
    background-attachment: fixed;
    color: var(--text-main);
    text-align: center;
    user-select: none;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

h1,
h2,
h3 {
    font-family: 'Cinzel', serif;
    color: var(--gold);
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.9), 0 0 10px var(--gold-glow);
    letter-spacing: 2px;
}

.flavor-text-title {
    font-family: 'Cinzel', serif;
    font-size: 16px;
    color: var(--gold);
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8), 0 0 10px var(--gold-glow);
    font-style: italic;
    margin-bottom: 30px;
    letter-spacing: 1px;
    opacity: 0.9;
}



.screen {
    display: none;
    width: 95%;
    max-width: 1400px;
    padding: 40px;
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    border-radius: 20px;
    position: relative;
    animation: fadeIn 0.8s ease-out;
}

.screen.active {
    display: block;
}

.menu {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-top: 40px;
}

button {
    background: rgba(155, 77, 255, 0.2);
    color: var(--gold);
    padding: 12px 30px;
    border: 1px solid var(--gold);
    border-radius: 30px;
    font-family: 'Cinzel', serif;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8), 0 0 5px var(--gold-glow);
    box-shadow: inset 0 0 0 0 var(--gold);
    position: relative;
    overflow: hidden;
}

button:hover {
    background: var(--gold);
    color: #0d0b21;
    box-shadow: 0 0 20px var(--gold-glow);
    transform: translateY(-3px);
}

button:active {
    transform: translateY(-1px);
}

button.cpu-btn {
    border-color: #00BCD4;
    color: #00BCD4;
}

button.cpu-btn:hover {
    background: #00BCD4;
    color: #0d0b21;
    box-shadow: 0 0 20px rgba(0, 188, 212, 0.5);
}

button.btn-green {
    border-color: #4CAF50;
    color: #4CAF50;
    width: 250px;
}

button.btn-green:hover {
    background: #4CAF50;
    color: #0d0b21;
}

button.btn-blue {
    border-color: #2196F3;
    color: #2196F3;
    width: 250px;
}

button.btn-blue:hover {
    background: #2196F3;
    color: #0d0b21;
}

button.btn-grey {
    border-color: #aaa;
    color: #aaa;
    width: 250px;
}

.input-group label {
    font-family: 'Cinzel', serif;
    color: var(--gold);
    margin-right: 10px;
}

input[type="text"] {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--gold);
    border-radius: 5px;
    padding: 10px;
    color: #fff;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: all 0.3s;
}

input[type="text"]:focus {
    box-shadow: 0 0 10px var(--gold-glow);
    background: rgba(255, 255, 255, 0.15);
}

.card-row {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    margin: 20px 0;
    min-width: 550px;
    /* Secure space for 5 cards */
}

.card {
    width: 90px;
    height: 135px;
    border: 1px solid var(--gold);
    border-radius: 10px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: rgba(0, 0, 0, 0.3);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    position: relative;
    flex-shrink: 0;
}

.card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    box-shadow: inset 0 0 20px rgba(155, 77, 255, 0);
    transition: box-shadow 0.3s;
    pointer-events: none;
}

.card:hover {
    transform: scale(1.1) rotate(2deg);
    border-color: #fff;
    box-shadow: 0 0 30px var(--gold-glow);
}

.card:hover::after {
    box-shadow: inset 0 0 20px rgba(155, 77, 255, 0.5);
}

.mini-card {
    width: 45px;
    height: 65px;
    border: 1px solid var(--gold);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: transform 0.2s;
    margin: 2px;
}

.mini-card-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    margin: 5px 0;
}

.mini-card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.mini-card:hover {
    transform: translateY(-5px);
}

.arena {
    position: relative;
    width: 100%;
    max-width: 1300px;
    height: 600px;
    margin: 10px auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.arena.mode-2p {
    height: 550px;
    margin-bottom: 30px;
}

/* Unified Players Row (Flexbox) */
#battle-players-row {
    margin-top: auto;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 30px;
    align-items: flex-end;
    padding: 0 40px 10px 40px;
}

/* Play Area Components */
.play-area {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 160px;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

/* Label Styles */
.play-area .label {
    white-space: normal;
    font-size: 16px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
    overflow: hidden;
    margin-bottom: 10px;
    width: 100%;
    text-align: center;
    word-break: break-all;
    font-weight: bold;
}

.card-slot {
    width: 90px;
    height: 135px;
    border: 2px dashed var(--gold);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Cinzel', serif;
    font-size: 32px;
    color: var(--gold);
    background: rgba(0, 0, 0, 0.2);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.4);
}

.center-info {
    text-align: center;
    width: 100%;
    position: relative;
    margin-top: 5px;
}

#battle-message {
    font-family: 'Cinzel', serif;
    font-size: 48px;
    font-weight: bold;
    color: var(--gold);
    text-shadow: 2px 2px 4px #000, 0 0 20px var(--gold-glow);
    margin: 0 auto 15px auto;
    z-index: 10;
    white-space: nowrap;
    animation: glowText 2s infinite alternate;
}

.pot-display {
    margin: 0 auto;
    position: relative;
    transform: scale(1.2);
    width: max-content;
    z-index: 1;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 10px 20px;
    border-radius: 20px;
    border: 1px solid var(--gold);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    font-size: 18px;
}

.pot-display .card {
    width: 80px;
    height: 120px;
    margin: 5px auto;
}

.pot-info .card {
    width: 80px;
    height: 120px;
    margin: 10px auto;
}

.battle-divider {
    width: 100%;
    height: 8px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    border-radius: 4px;
    margin: 10px 0;
}

.hand-instruction {
    text-align: center;
    color: #aaa;
    font-size: 14px;
    margin: 10px 0;
}

/* 3-Column Layout for Selection Screen */
.status-container {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin: 20px 0;
    gap: 10px;
}

.status-col {
    flex: 1;
    padding: 15px;
    background: var(--glass-bg);
    backdrop-filter: blur(5px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    min-height: 200px;
}

.status-col.center {
    flex: 1.5;
    background: rgba(255, 255, 255, 0.08);
}

.status-col h3 {
    margin-top: 0;
    font-size: 16px;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 5px;
    font-family: 'Cinzel', serif;
}

/* Player Colors (Glass Wizard Style) */
.status-col.p1 {
    background: rgba(91, 192, 222, 0.1);
    border-color: rgba(91, 192, 222, 0.3);
}

.status-col.p1 h3 {
    color: #4fc3f7;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    border-bottom-color: rgba(91, 192, 222, 0.3);
}

.status-col.p2 {
    background: rgba(255, 107, 107, 0.1);
    border-color: rgba(255, 107, 107, 0.3);
}

.status-col.p2 h3 {
    color: #ff5252;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    border-bottom-color: rgba(255, 107, 107, 0.3);
}

.status-col.p3 {
    background: rgba(255, 236, 61, 0.1);
    border-color: rgba(255, 236, 61, 0.3);
}

.status-col.p3 h3 {
    color: var(--gold);
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.9), 0 0 5px var(--gold-glow);
    border-bottom-color: rgba(255, 215, 0, 0.3);
}

.status-col.p4 {
    background: rgba(119, 221, 119, 0.1);
    border-color: rgba(119, 221, 119, 0.3);
}

.status-col.p4 h3 {
    color: #66bb6a;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    border-bottom-color: rgba(119, 221, 119, 0.3);
}

/* Player Specific Colors (Wizard Style) - Re-applying for general use */
.p1 {
    color: #4fc3f7;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.p2 {
    color: #ff5252;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.p3 {
    color: var(--gold);
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.9), 0 0 5px var(--gold-glow);
    font-weight: bold;
}

.p4 {
    color: #66bb6a;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.split-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: transparent;
    border: none;
}

.sub-status-col {
    padding: 8px;
    border-radius: 6px;
    background: var(--glass-bg);
    backdrop-filter: blur(5px);
    border: 1px solid var(--glass-border);
    flex: 1;
}

/* Specific sub-status colors */
.sub-status-col.p1 {
    background: rgba(91, 192, 222, 0.05);
    border-color: rgba(91, 192, 222, 0.3);
}

.sub-status-col.p1 h3 {
    color: #5bc0de;
}

.sub-status-col.p2 {
    background: rgba(255, 107, 107, 0.05);
    border-color: rgba(255, 107, 107, 0.3);
}

.sub-status-col.p2 h3 {
    color: #ff6b6b;
}

.sub-status-col.p3 {
    background: rgba(255, 215, 0, 0.05);
    border-color: rgba(255, 215, 0, 0.3);
}

.sub-status-col.p3 h3 {
    color: #ffd700;
}

.sub-status-col.p4 {
    background: rgba(119, 221, 119, 0.05);
    border-color: rgba(119, 221, 119, 0.3);
}

.sub-status-col.p4 h3 {
    color: #77dd77;
}

.sub-status-col h3 {
    margin-top: 0;
    font-size: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 3px;
    font-family: 'Cinzel', serif;
}

.mini-card-row.vertical-wrap {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-content: flex-start;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes glowText {
    from {
        text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8), 0 0 10px var(--gold-glow);
    }

    to {
        text-shadow: 0 0 25px var(--gold), 0 0 10px #fff;
    }
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0px);
    }
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

/* Modal */
#cpu-settings-modal>div {
    background: rgba(20, 15, 35, 0.95) !important;
    backdrop-filter: blur(20px) !important;
    border: 1px solid var(--gold) !important;
    color: var(--text-main) !important;
    border-radius: 20px !important;
    padding: 30px !important;
}

/* Rule Screen Spacing */
#rule-container {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--gold);
    border-radius: 10px;
    padding: 20px;
    height: 450px;
    width: 700px;
    max-width: 100%;
    margin-bottom: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.rule-slide {
    display: none;
    text-align: center;
    animation: fadeIn 0.5s;
    width: 100%;
}

.rule-slide.active {
    display: block;
}

.rule-slide h3 {
    color: var(--gold);
    border-bottom-color: var(--gold);
}

.rule-slide p,
.rule-slide li {
    font-size: 15px;
    line-height: 1.6;
}

/* Sealed Card Display */
.sealed-area {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    opacity: 0.8;
}

.sealed-badge {
    font-family: 'Cinzel', serif;
    font-size: 10px;
    color: #ff5252;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: 1px solid #ff5252;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 82, 82, 0.1);
    text-shadow: 0 0 5px rgba(255, 82, 82, 0.5);
}

.sealed-card {
    filter: grayscale(1) sepia(1) hue-rotate(250deg) brightness(0.7);
    border-color: #9b4dff;
    box-shadow: 0 0 10px rgba(155, 77, 255, 0.3);
}

.sealed-card:hover {
    transform: none;
    /* Disable hover effect for sealed cards */
    border-color: #9b4dff;
    box-shadow: 0 0 10px rgba(155, 77, 255, 0.3);
}

/* Round Confirmation Styles */
.confirm-container {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    animation: fadeIn 0.5s ease-out;
}

.confirm-btn {
    padding: 12px 30px;
    font-size: 18px;
    background: linear-gradient(135deg, #4caf50, #2e7d32);
    border: 2px solid #81c784;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.confirm-btn:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.6);
}

.confirm-btn.confirmed {
    background: #444;
    border-color: #666;
    color: #999;
    cursor: default;
    filter: grayscale(1);
}

.confirm-waiting {
    font-family: 'Cinzel', serif;
    font-size: 16px;
    color: #ffeb3b;
    text-shadow: 0 0 10px rgba(255, 235, 59, 0.5);
    background: rgba(0, 0, 0, 0.4);
    padding: 5px 15px;
    border-radius: 20px;
    display: none;
    /* Hidden until confirmed */
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 236, 61, 0.7); }
    50% { transform: scale(1.05); box-shadow: 0 0 20px 10px rgba(255, 236, 61, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 236, 61, 0); }
}

/* Audio Control Sliding Tab */
.audio-control-wrapper {
    position: fixed;
    top: 20px;
    right: -200px;
    display: flex;
    align-items: center;
    z-index: 2000;
    transition: right 0.3s ease;
}

.audio-control-wrapper:hover {
    right: 0;
}

.audio-control-tab {
    background: rgba(0, 0, 0, 0.7);
    color: var(--text-main);
    padding: 15px 8px;
    border-radius: 8px 0 0 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-right: none;
    cursor: pointer;
    box-shadow: -2px 0 10px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.audio-control-tab span {
    writing-mode: vertical-rl;
    text-orientation: upright;
    letter-spacing: 2px;
    font-size: 0.9rem;
    color: var(--gold);
    font-weight: bold;
}

.audio-control-panel {
    background: rgba(0, 0, 0, 0.7);
    padding: 15px;
    border-radius: 0 0 0 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-right: none;
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 200px;
    box-sizing: border-box;
}

.audio-control-panel label {
    font-size: 0.9rem;
    color: var(--text-main);
    width: 55px;
}

.audio-control-panel input[type="range"] {
    accent-color: var(--gold);
    width: 100px;
}


/* Toasts */
.toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 10000; pointer-events: none; }
.toast { background: var(--glass-bg); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); color: var(--gold); padding: 12px 25px; border-radius: 30px; border: 1px solid var(--gold); box-shadow: 0 0 15px var(--gold-glow); animation: slideIn 0.3s ease forwards, fadeOut 0.3s ease 2.7s forwards; font-weight: bold; letter-spacing: 1px; }
.toast.error { border-color: #ff4757; color: #ff4757; box-shadow: 0 0 15px rgba(255, 71, 87, 0.5); }
.toast.success { border-color: var(--gold); color: var(--gold); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }
