/* styles.css - Modern styling for La Chouine */

:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #3498db;
    --success-color: #27ae60;
    --error-color: #e74c3c;
    --warning-color: #f39c12;
    --table-green: #1a5f3a;
    --table-green-light: #2d7a4f;
    --card-bg: #ffffff;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.2);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
}

h1 {
    color: white;
    font-size: 2rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.game-container {
    background: var(--table-green);
    border-radius: 15px;
    padding: 20px;
    box-shadow: var(--shadow-lg);
    max-width: 1300px;
    width: 100%;
    position: relative;
}

/* Header */
.game-header {
    display: grid;
    grid-template-columns: 1fr 1fr auto 1fr;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    gap: 15px;
}

.score-display {
    color: white;
    font-size: 1rem;
    justify-self: start;
}

.score-display div {
    margin: 3px 0;
}

.game-info {
    color: white;
    text-align: center;
    justify-self: center;
}

.game-info div {
    margin: 3px 0;
    font-size: 0.95rem;
}

.game-deck-info {
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: center;
}

.game-controls {
    justify-self: end;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.main-buttons {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.game-controls button {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    margin: 0;
    white-space: nowrap;
}

.game-controls button:hover:not(.disabled) {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.game-controls button.disabled {
    background: #95a5a6;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Seed Controls */
.seed-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.seed-display-group {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    font-size: 0.9rem;
}

.seed-display-group label {
    font-weight: bold;
}

#seed-display {
    background: rgba(0, 0, 0, 0.3);
    padding: 5px 10px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    min-width: 100px;
    text-align: center;
}

#copy-seed-btn {
    background: var(--success-color);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

#copy-seed-btn:hover {
    background: #229954;
    transform: scale(1.1);
}

.seed-input-group {
    display: flex;
    gap: 5px;
}

#seed-input {
    flex: 1;
    padding: 8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.9);
}

#seed-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

#replay-seed-btn {
    background: var(--warning-color);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    white-space: nowrap;
}

#replay-seed-btn:hover {
    background: #e67e22;
    transform: translateY(-2px);
}

/* Game Message */
#game-message {
    color: white;
    font-size: 0.95rem;
    font-weight: bold;
    text-align: center;
    min-height: 1.2em;
    margin-top: 5px;
    white-space: pre-line;
    line-height: 1.3;
}

#game-message.success {
    color: #2ecc71;
}

#game-message.error {
    color: #e74c3c;
}

#game-message.info {
    color: #3498db;
}

/* Game Table Layout */
.game-table {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 15px;
    min-height: 420px;
}

/* AI Section */
.ai-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ai-hand {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 10px;
}

/* Playing Area */
.playing-area {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.trump-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.trump-label {
    color: white;
    font-weight: bold;
    font-size: 0.85rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* Trump card in header should be smaller */
.game-deck-info .trump-area .card {
    width: 50px;
    height: 71px;
}

.game-deck-info .trump-area .card-rank,
.game-deck-info .trump-area .card-suit {
    font-size: 1.8rem;
}

.trump-area #exchange-seven-btn {
    margin-top: 5px;
    padding: 5px 8px;
    font-size: 0.75rem;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.trump-area #exchange-seven-btn:hover:not(.disabled) {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.trump-area #exchange-seven-btn.disabled {
    background: #95a5a6;
    cursor: not-allowed;
    opacity: 0.6;
}

.trick-area {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 25px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    min-height: 140px;
}

.trick-card {
    min-width: 70px;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.talon-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.talon-label {
    color: white;
    font-weight: bold;
    font-size: 0.85rem;
}

.talon-display {
    width: 50px;
    height: 71px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px dashed rgba(255, 255, 255, 0.4);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.4rem;
    font-weight: bold;
}

/* Human Section */
.human-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.human-hand {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Card Styles */
.card {
    width: 70px;
    height: 100px;
    background: var(--card-bg);
    border-radius: 6px;
    box-shadow: var(--shadow);
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: default;
}

.card.clickable {
    cursor: pointer;
}

.card.clickable:hover {
    transform: translateY(-10px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.card.legal-play {
    border: 3px solid var(--success-color);
    box-shadow: 0 0 15px var(--success-color);
}

.card.illegal-play {
    border: 3px solid var(--error-color);
    box-shadow: 0 0 15px var(--error-color);
}

.card-front {
    width: 100%;
    height: 100%;
    padding: 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: white;
    border-radius: 6px;
}

.card-corner {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
}

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

.card-rank {
    font-size: 2.5rem;
    font-weight: bold;
    line-height: 1;
}

.card-suit {
    font-size: 2.5rem;
    line-height: 1;
}

.card-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

/* Card Back */
.card-back-only {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 2px solid white;
}

.card-back-pattern {
    width: 100%;
    height: 100%;
    background:
        repeating-linear-gradient(
            45deg,
            rgba(255, 255, 255, 0.1),
            rgba(255, 255, 255, 0.1) 10px,
            rgba(255, 255, 255, 0.2) 10px,
            rgba(255, 255, 255, 0.2) 20px
        );
    border-radius: 6px;
}

/* Animations */
@keyframes cardDeal {
    from {
        opacity: 0;
        transform: translateY(-100px) rotate(-20deg);
    }
    to {
        opacity: 1;
        transform: translateY(0) rotate(0);
    }
}

@keyframes cardPlay {
    from {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    to {
        transform: scale(1);
    }
}

/* Animation applied only to newly drawn cards */
.card.new-card {
    animation: cardDeal 0.5s ease-out;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .game-container {
        padding: 20px;
    }

    h1 {
        font-size: 2rem;
    }

    .card {
        width: 70px;
        height: 100px;
    }

    .card-rank {
        font-size: 2rem;
    }

    .card-suit {
        font-size: 2rem;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    h1 {
        font-size: 1.5rem;
        margin-bottom: 10px;
    }

    .game-container {
        padding: 15px;
    }

    .game-header {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .score-display,
    .game-info,
    .game-deck-info,
    .game-controls {
        justify-self: center;
        text-align: center;
        width: 100%;
        max-width: 100%;
    }

    .game-controls {
        align-items: center;
    }

    .main-buttons {
        width: 100%;
        justify-content: center;
    }

    .main-buttons button {
        flex: 1;
        min-width: 0;
    }

    /* Compact deck info on mobile */
    .game-deck-info {
        flex-direction: row;
        justify-content: center;
        gap: 20px;
        padding: 8px 0;
        border-top: 1px solid rgba(255, 255, 255, 0.2);
        border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    }

    .game-deck-info .trump-area .card {
        width: 45px;
        height: 64px;
    }

    .game-deck-info .trump-area .card-rank,
    .game-deck-info .trump-area .card-suit {
        font-size: 1.6rem;
    }

    .talon-display {
        width: 45px;
        height: 64px;
        font-size: 1.2rem;
    }

    .trump-area #exchange-seven-btn {
        padding: 4px 6px;
        font-size: 0.7rem;
        margin-top: 3px;
    }

    .seed-controls,
    .seed-input-group {
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
    }

    #seed-input {
        min-width: 0;
        flex: 1 1 auto;
    }

    #replay-seed-btn {
        flex-shrink: 0;
        padding: 6px 12px;
        width: auto;
    }

    .card {
        width: 60px;
        height: 85px;
    }

    .card-rank,
    .card-suit {
        font-size: 1.8rem;
    }

    .human-hand {
        gap: 10px;
    }

    .trick-area {
        gap: 20px;
        padding: 15px;
    }

    /* Optimisation des seed controls */
    .seed-controls {
        gap: 5px;
    }

    .seed-display-group {
        font-size: 0.85rem;
    }

    #seed-display {
        min-width: 80px;
        padding: 4px 8px;
        font-size: 0.85rem;
    }

    #seed-input {
        padding: 6px;
        font-size: 0.85rem;
    }

    #replay-seed-btn,
    #copy-seed-btn {
        padding: 6px 10px;
        font-size: 0.85rem;
    }

    /* Game message optimisation */
    #game-message {
        font-size: 0.85rem;
    }
}

/* Orientation paysage mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .game-table {
        min-height: auto;
    }

    h1 {
        font-size: 1.2rem;
        margin-bottom: 5px;
    }

    .game-header {
        gap: 10px;
    }
}

/* Très petits écrans (≤360px) */
@media (max-width: 360px) {
    .card {
        width: 50px;
        height: 71px;
    }

    .card-rank,
    .card-suit {
        font-size: 1.5rem;
    }

    .human-hand,
    .ai-hand {
        gap: 8px;
    }

    h1 {
        font-size: 1.3rem;
    }

    .game-container {
        padding: 10px;
    }

    #game-message {
        font-size: 0.8rem;
    }

    .main-buttons button {
        padding: 6px 8px;
        font-size: 0.85rem;
    }

    #replay-seed-btn {
        padding: 5px 10px;
        font-size: 0.85rem;
    }
}

/* Trick winner highlight */
@keyframes winnerGlow {
    0%, 100% {
        box-shadow: 0 0 10px var(--success-color);
    }
    50% {
        box-shadow: 0 0 25px var(--success-color);
    }
}

.card.winner {
    animation: winnerGlow 1s ease-in-out infinite;
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}
