:root {
    --primary-color: #00f3ff;
    --secondary-color: #ff0055;
    --bg-color: #0a0a12;
    --card-width: 140px;
    --card-height: 200px;
    --font-main: 'Rajdhani', sans-serif;
    --font-display: 'Orbitron', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: #fff;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.background-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #1a1a2e 0%, #000 100%);
    z-index: -1;
}

.game-container {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-rows: 70px 180px 1fr 240px;
    /* More space for player area */
    /* Nav, Opponent, Board, Player */
    padding: 0;
    position: relative;
    gap: 20px;
    /* Add gap between sections */
}

/* ... (skipping unchanged nav styles) ... */



/* Navigation */
.cyber-nav {
    grid-row: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    background: rgba(0, 0, 0, 0.8);
    border-bottom: 1px solid rgba(0, 243, 255, 0.2);
    backdrop-filter: blur(10px);
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 15px;
    text-decoration: none;
    color: var(--primary-color);
}

.observer-eye svg {
    width: 50px;
    height: 25px;
}

.brand-text {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 2px;
    font-size: 1.1rem;
}

.nav-links {
    display: flex;
    gap: 20px;
    align-items: center;
}

.nav-item {
    font-family: var(--font-display);
    color: #fff;
    text-decoration: none;
    font-size: 0.9rem;
    letter-spacing: 1px;
    opacity: 0.7;
    transition: all 0.3s;
    text-transform: uppercase;
    background: transparent;
    border: none;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.nav-item:hover {
    opacity: 1;
    color: var(--primary-color);
    text-shadow: 0 0 10px var(--primary-color);
}

.btn-reset {
    border: 1px solid var(--primary-color);
    padding: 5px 15px;
    border-radius: 4px;
    color: var(--primary-color);
    opacity: 1;
}

.btn-reset:hover {
    background: rgba(0, 243, 255, 0.1);
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.3);
}

/* Header / Opponent Area */
.game-header {
    grid-row: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.opponent-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.opponent-info {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 25px;
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.opponent-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid var(--secondary-color);
    overflow: hidden;
    box-shadow: 0 0 15px rgba(255, 0, 85, 0.3);
}

.opponent-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-name {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: #fff;
    letter-spacing: 1px;
}

.opponent-hand {
    display: flex;
    justify-content: center;
    height: 100px;
    /* Visible part of cards */
    margin-top: -10px;
}

.opponent-hand .card-back {
    width: 80px;
    height: 115px;
    background-image: url('assets/card-back.png');
    background-size: cover;
    border-radius: 6px;
    margin-left: -50px;
    /* Fan effect */
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.opponent-hand .card-back:first-child {
    margin-left: 0;
}

/* Deck Area (Left Side) */
.deck-info {
    position: absolute;
    left: 40px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.deck-pile {
    position: relative;
    width: 100px;
    height: 140px;
}

.deck-pile .card-back {
    width: 100%;
    height: 100%;
    background-image: url('assets/card-back.png');
    background-size: cover;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}

#deck-count {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: #fff;
    text-shadow: 0 0 5px #000;
    z-index: 10;
}

.trump-card-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100px;
    height: 140px;
    z-index: -1;
}

.trump-card-container .card {
    transform: rotate(90deg) translateX(40px);
    width: 100px;
    height: 140px;
}

/* Game Board */
.game-board {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.battle-area {
    display: flex;
    justify-content: center;
    gap: 30px;
    width: 100%;
    max-width: 1000px;
    min-height: 220px;
}

.battle-pair {
    position: relative;
    width: var(--card-width);
    height: var(--card-height);
}

.battle-pair .card.attack {
    position: absolute;
    top: 0;
    left: 0;
    transform: rotate(-5deg);
}

.battle-pair .card.defense {
    position: absolute;
    top: 20px;
    left: 20px;
    transform: rotate(5deg);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.6);
    z-index: 5;
}

.game-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-display);
    font-size: 3rem;
    color: #fff;
    text-shadow: 0 0 20px var(--primary-color);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 100;
    background: rgba(0, 0, 0, 0.85);
    padding: 30px 60px;
    border-radius: 15px;
    border: 1px solid var(--primary-color);
    text-align: center;
}

.game-message.visible {
    opacity: 1;
}

/* Player Hand */
.player-hand-container {
    display: flex;
    flex-direction: row;
    /* Side-by-side layout */
    align-items: center;
    justify-content: center;
    padding-bottom: 30px;
    position: relative;
    gap: 40px;
    /* Space between hand and button */
}

.game-controls {
    margin-bottom: 0;
    position: static;
    /* Remove absolute positioning */
    order: 2;
    /* Place button after hand */
}

.cyber-btn {
    background: rgba(0, 243, 255, 0.1);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    font-family: var(--font-display);
    padding: 15px 40px;
    /* Larger button */
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 2px;
    border-radius: 8px;
    backdrop-filter: blur(5px);
    white-space: nowrap;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.cyber-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: #000;
    box-shadow: 0 0 20px var(--primary-color);
}

.cyber-btn:disabled {
    border-color: #444;
    color: #444;
    background: transparent;
    cursor: not-allowed;
}

.player-hand {
    display: flex;
    justify-content: center;
    height: var(--card-height);
    width: auto;
    /* Allow natural width */
    order: 1;
    /* Place hand before button */
}

.card {
    width: var(--card-width);
    height: var(--card-height);
    /* Premium Dark Matte Base with Tech Grid - Opaque */
    background-color: #1a1a20;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 19px, rgba(255, 255, 255, 0.03) 20px),
        repeating-linear-gradient(90deg, transparent, transparent 19px, rgba(255, 255, 255, 0.03) 20px);

    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    /* Softer transition */
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.4s ease, border-color 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    margin-left: -35px;
    /* Reduced overlap (was -50px) */
    transform-origin: bottom center;
    overflow: hidden;
    /* Keep portrait inside */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.player-hand .card:first-child {
    margin-left: 0;
}

.player-hand .card:hover {
    /* Softer lift and scale */
    transform: translateY(-30px) scale(1.1) rotate(0deg) !important;
    z-index: 100 !important;
    box-shadow: 0 0 30px rgba(0, 243, 255, 0.4);
    border-color: var(--primary-color);
}

.player-hand .card:active {
    transform: translateY(-25px) scale(1.05) rotate(0deg) !important;
    transition: transform 0.1s;
}

/* Card Design - Calmer, Emphasis on Rank/Suit */
.card-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 12px;
    z-index: 2;
}

.card-corner {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    z-index: 5;
    /* Ensure text is above portrait */
}

.card-corner.top-left {
    align-self: flex-start;
}

.card-corner.bottom-right {
    align-self: flex-end;
    transform: rotate(180deg);
}

.rank-text {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
}

.suit-text {
    font-size: 1.5rem;
    margin-top: -5px;
}

.card-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

.center-suit {
    font-size: 6rem;
    opacity: 0.15;
    filter: drop-shadow(0 0 10px currentColor);
}

.center-portrait {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Improved Mask: Clear top, fade bottom */
    mask-image: linear-gradient(to bottom, black 40%, transparent 95%);
    -webkit-mask-image: linear-gradient(to bottom, black 40%, transparent 95%);
    opacity: 0.9;
    /* Brighter */
    /* Removed mix-blend-mode overlay for clearer face */
    filter: contrast(1.1) saturate(1.1);
}

/* Colors & Glows */
.card.red {
    color: #ff2a6d;
    border-bottom: 2px solid rgba(255, 42, 109, 0.3);
}

.card.red .rank-text,
.card.red .suit-text {
    text-shadow: 0 0 10px rgba(255, 42, 109, 0.5);
}

.card.black {
    color: #00f3ff;
    /* Cyan for black suits looks cooler in cyberpunk */
    border-bottom: 2px solid rgba(0, 243, 255, 0.3);
}

.card.black .rank-text,
.card.black .suit-text {
    text-shadow: 0 0 10px rgba(0, 243, 255, 0.5);
}

/* Responsive */
@media (max-width: 768px) {
    :root {
        --card-width: 70px;
        --card-height: 100px;
    }

    body {
        overflow-y: auto;
        overflow-x: hidden;
    }

    .game-container {
        grid-template-rows: auto auto 1fr auto;
        gap: 10px;
        padding: 10px;
        min-height: 100vh;
        height: auto;
    }

    /* Navigation */
    .cyber-nav {
        flex-wrap: wrap;
        padding: 10px 15px;
        gap: 10px;
    }

    .nav-brand {
        gap: 8px;
    }

    .observer-eye svg {
        width: 35px;
        height: 18px;
    }

    .brand-text {
        font-size: 0.9rem;
        letter-spacing: 1px;
    }

    .nav-links {
        flex-wrap: wrap;
        gap: 10px;
        width: 100%;
        justify-content: center;
    }

    .nav-item {
        font-size: 0.75rem;
        padding: 5px 10px;
    }

    .btn-reset {
        padding: 5px 12px;
    }

    /* Header / Opponent Area */
    .game-header {
        padding: 10px 0;
    }

    .opponent-area {
        gap: 8px;
    }

    .opponent-info {
        padding: 8px 15px;
        gap: 10px;
    }

    .opponent-avatar {
        width: 40px;
        height: 40px;
    }

    .player-name {
        font-size: 0.9rem;
        letter-spacing: 0.5px;
    }

    .opponent-hand {
        height: 70px;
        margin-top: -5px;
    }

    .opponent-hand .card-back {
        width: 40px;
        height: 55px;
        margin-left: -25px;
        border-radius: 4px;
    }

    .opponent-hand .card-back:first-child {
        margin-left: 0;
    }

    /* Deck Area - Move to top right on mobile */
    .deck-info {
        position: absolute;
        right: 10px;
        top: 80px;
        left: auto;
        transform: none;
        flex-direction: row;
        gap: 10px;
        align-items: center;
    }

    .deck-pile {
        width: 60px;
        height: 85px;
    }

    #deck-count {
        font-size: 1rem;
    }

    .trump-card-container {
        width: 60px;
        height: 85px;
        position: relative;
    }

    .trump-card-container .card {
        transform: rotate(90deg) translateX(25px);
        width: 60px;
        height: 85px;
    }

    /* Game Board */
    .game-board {
        padding: 10px 0;
        min-height: 150px;
    }

    .battle-area {
        gap: 15px;
        flex-wrap: wrap;
        justify-content: center;
        min-height: 120px;
        padding: 10px;
    }

    .battle-pair {
        width: var(--card-width);
        height: var(--card-height);
    }

    .battle-pair .card.defense {
        top: 15px;
        left: 15px;
    }

    .game-message {
        font-size: 1.5rem;
        padding: 20px 30px;
        border-radius: 10px;
        max-width: 90%;
    }

    /* Player Hand */
    .player-hand-container {
        flex-direction: column;
        gap: 15px;
        padding: 15px 10px;
        align-items: center;
    }

    .player-hand {
        height: var(--card-height);
        width: 100%;
        overflow-x: auto;
        overflow-y: visible;
        justify-content: flex-start;
        padding: 0 10px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .player-hand::-webkit-scrollbar {
        display: none;
    }

    .card {
        margin-left: -20px;
        flex-shrink: 0;
    }

    .player-hand .card:first-child {
        margin-left: 0;
    }

    .player-hand .card:hover,
    .player-hand .card:active {
        transform: translateY(-20px) scale(1.08) rotate(0deg) !important;
    }

    .player-hand .card:active {
        transition: transform 0.1s;
    }

    .card-content {
        padding: 8px;
    }

    .rank-text {
        font-size: 1rem;
    }

    .suit-text {
        font-size: 0.85rem;
        margin-top: -3px;
    }

    .center-suit {
        font-size: 3.5rem;
    }

    .game-controls {
        order: 2;
        width: 100%;
        display: flex;
        justify-content: center;
    }

    .cyber-btn {
        padding: 12px 30px;
        font-size: 1rem;
        letter-spacing: 1px;
        width: auto;
        min-width: 150px;
    }

    .cyber-btn:active {
        transform: scale(0.95);
        transition: transform 0.1s;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    :root {
        --card-width: 60px;
        --card-height: 85px;
    }

    .game-container {
        gap: 8px;
        padding: 8px;
    }

    .cyber-nav {
        padding: 8px 10px;
    }

    .nav-links {
        gap: 8px;
    }

    .nav-item {
        font-size: 0.7rem;
        padding: 4px 8px;
    }

    .opponent-info {
        padding: 6px 12px;
    }

    .opponent-avatar {
        width: 35px;
        height: 35px;
    }

    .player-name {
        font-size: 0.8rem;
    }

    .opponent-hand .card-back {
        width: 35px;
        height: 48px;
        margin-left: -20px;
    }

    .deck-info {
        right: 8px;
        top: 70px;
        gap: 8px;
    }

    .deck-pile {
        width: 50px;
        height: 70px;
    }

    .trump-card-container {
        width: 50px;
        height: 70px;
    }

    .trump-card-container .card {
        transform: rotate(90deg) translateX(20px);
        width: 50px;
        height: 70px;
    }

    #deck-count {
        font-size: 0.9rem;
    }

    .battle-area {
        gap: 10px;
        min-height: 100px;
    }

    .battle-pair .card.defense {
        top: 10px;
        left: 10px;
    }

    .game-message {
        font-size: 1.2rem;
        padding: 15px 20px;
    }

    .player-hand-container {
        padding: 10px 5px;
        gap: 10px;
    }

    .card {
        margin-left: -15px;
    }

    .card-content {
        padding: 6px;
    }

    .rank-text {
        font-size: 0.9rem;
    }

    .suit-text {
        font-size: 0.75rem;
    }

    .center-suit {
        font-size: 2.5rem;
    }

    .cyber-btn {
        padding: 10px 25px;
        font-size: 0.9rem;
        min-width: 120px;
    }

    .cyber-btn:active {
        transform: scale(0.95);
        transition: transform 0.1s;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .game-container {
        grid-template-rows: auto auto 1fr auto;
    }

    .game-header {
        padding: 5px 0;
    }

    .opponent-hand {
        height: 60px;
    }

    .battle-area {
        min-height: 100px;
    }

    .player-hand-container {
        padding: 10px;
    }
}