:root {
    --bg-color: #1a1a2e;
    --primary-color: #e94560;
    --secondary-color: #16213e;
    --accent-color: #0f3460;
    --text-color: #fff;
    
    --fire-color: #ff4d4d;
    --water-color: #4d79ff;
    --wood-color: #4dff88;
    
    --card-width: 100px;
    --card-height: 140px;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-container {
    width: 100%;
    height: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at center, #2a2a4e 0%, #1a1a2e 100%);
    position: relative;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
}

/* Header & Info */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.player-info {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 300px;
}

.my-info {
    justify-content: flex-end;
    text-align: right;
}

.avatar {
    width: 50px;
    height: 50px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    border: 2px solid var(--accent-color);
}

.health-bar-container {
    flex: 1;
    height: 20px;
    background: rgba(0,0,0,0.5);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

.health-bar {
    height: 100%;
    background: linear-gradient(90deg, #ff4d4d, #e94560);
    transition: width 0.5s ease-out;
}

.health-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: bold;
    text-shadow: 1px 1px 2px black;
}

.round-info {
    text-align: center;
}

#round-number {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
}

#message-display {
    font-size: 14px;
    color: #ccc;
    min-height: 20px;
    margin-top: 5px;
}

/* Battle Field */
.battle-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px 0;
    perspective: 1000px;
}

.hand-area {
    display: flex;
    justify-content: center;
    gap: 10px;
    height: 160px;
    padding: 10px;
}

.enemy-hand .card {
    transform: scale(0.8);
}

.arena {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 50px;
    position: relative;
}

.card-slot {
    width: var(--card-width);
    height: var(--card-height);
    border: 2px dashed rgba(255,255,255,0.2);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s;
    position: relative; /* Essential for absolute positioning of effects */
}

.vs-effect {
    font-size: 48px;
    font-weight: 900;
    font-style: italic;
    background: linear-gradient(45deg, #ff0055, #ffcc00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(255,0,85,0.5);
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    from { transform: scale(1); opacity: 0.8; }
    to { transform: scale(1.1); opacity: 1; }
}

/* Cards */
.card {
    width: var(--card-width);
    height: var(--card-height);
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.4s, box-shadow 0.3s;
    cursor: pointer;
    border-radius: 10px;
}

.player-hand .card:hover {
    transform: translateY(-20px) scale(1.05);
    z-index: 10;
}

.card.selected {
    transform: translateY(-30px) scale(1.1);
    box-shadow: 0 0 15px var(--primary-color);
    border: 2px solid var(--primary-color);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    border: 2px solid #444;
}

.card-front {
    background: #222;
    transform: rotateY(0deg); /* Default for player */
}

.card-back {
    background: repeating-linear-gradient(
        45deg,
        #16213e,
        #16213e 10px,
        #0f3460 10px,
        #0f3460 20px
    );
    transform: rotateY(180deg);
    display: flex;
    justify-content: center;
    align-items: center;
}

.card-back::after {
    content: '?';
    font-size: 40px;
    color: rgba(255,255,255,0.2);
    font-weight: bold;
}

/* Card Elements */
.card[data-element="fire"] .card-front {
    background: linear-gradient(135deg, #4a1c1c, #2a0a0a);
    border-color: var(--fire-color);
}
.card[data-element="water"] .card-front {
    background: linear-gradient(135deg, #1c2c4a, #0a152a);
    border-color: var(--water-color);
}
.card[data-element="wood"] .card-front {
    background: linear-gradient(135deg, #1c4a2c, #0a2a15);
    border-color: var(--wood-color);
}

.card-icon {
    font-size: 32px;
    margin-bottom: 10px;
}
.card-value {
    font-size: 24px;
    font-weight: bold;
}
.card-element {
    font-size: 12px;
    text-transform: uppercase;
    margin-top: 5px;
    opacity: 0.8;
}

/* Card States in Arena */
.card.flipped {
    transform: rotateY(180deg);
}
.card.in-play {
    position: absolute; /* Handled by JS mostly */
    transform: rotateY(0deg);
    cursor: default;
}
.enemy-slot .card {
    /* Enemy cards in slot are flipped to front */
    transform: rotateY(0deg); 
}

/* Controls */
.game-controls {
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    background: rgba(0,0,0,0.3);
}

.action-btn {
    padding: 10px 30px;
    font-size: 18px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
}

.action-btn:hover {
    background: #ff6b81;
}

.action-btn:disabled {
    background: #555;
    cursor: not-allowed;
}

.hidden {
    display: none !important;
}

/* Modal */
.modal {
    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: 1000;
}

.modal-content {
    background: #1a1a2e;
    padding: 40px;
    border-radius: 10px;
    text-align: center;
    border: 2px solid var(--primary-color);
    box-shadow: 0 0 30px var(--primary-color);
}

.modal h2 {
    font-size: 36px;
    margin-bottom: 20px;
    color: var(--primary-color);
}

#modal-restart-btn {
    padding: 10px 20px;
    font-size: 18px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

/* Animations */
@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.shake {
    animation: shake 0.5s;
}

.damage-text {
    position: absolute;
    font-size: 32px;
    font-weight: bold;
    color: #ff4d4d;
    animation: floatUp 1s ease-out forwards;
    pointer-events: none;
    z-index: 100;
}

@keyframes floatUp {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-50px) scale(1.5); opacity: 0; }
}
