/* ================================
   Demo Page Styles
   ================================ */

.demo-page {
    background: linear-gradient(135deg, #1a1512 0%, #2d2520 50%, #1a1512 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Demo Header */
.demo-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid rgba(212, 165, 116, 0.2);
    position: sticky;
    top: 0;
    z-index: 100;
}

.demo-back {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-cream);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s ease;
}

.demo-back:hover {
    color: var(--color-gold);
}

.demo-title {
    font-family: 'Unbounded', sans-serif;
    font-size: 1.5rem;
    color: var(--color-gold);
    margin: 0;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

/* ================================
   Tutorial Overlay
   ================================ */

.tutorial-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.tutorial-overlay.hidden {
    display: none;
}

.tutorial-modal {
    background: linear-gradient(145deg, #2d2520, #1a1512);
    border: 2px solid var(--color-gold);
    border-radius: 16px;
    padding: 2.5rem;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(212, 165, 116, 0.1);
}

.tutorial-step h2 {
    font-family: 'Unbounded', sans-serif;
    color: var(--color-gold);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.tutorial-step p,
.tutorial-step li {
    color: var(--color-cream);
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.tutorial-step ul,
.tutorial-step ol {
    padding-left: 1.25rem;
    margin-bottom: 1rem;
}

.tutorial-step strong {
    color: var(--color-gold);
}

.tutorial-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(212, 165, 116, 0.2);
}

.tutorial-dots {
    display: flex;
    gap: 0.5rem;
}

.tutorial-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(212, 165, 116, 0.3);
    transition: all 0.3s ease;
}

.tutorial-dot.active {
    background: var(--color-gold);
    transform: scale(1.2);
}

/* ================================
   Game Container
   ================================ */

.game-container {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 70px);
    padding: 1rem;
    gap: 1rem;
}

/* Player Areas */
.player-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.opponent-area {
    order: 3;
}

.center-area {
    order: 2;
}

.player-side {
    order: 1;
}

.player-label {
    font-family: 'Unbounded', sans-serif;
    font-size: 1rem;
    color: var(--color-gold);
    text-align: center;
    padding: 0.5rem;
    background: rgba(212, 165, 116, 0.1);
    border-radius: 8px;
}

.player-zones {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.zone-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(212, 165, 116, 0.7);
    text-align: center;
    margin-bottom: 0.5rem;
}

/* Placemat Layout */
.placemat {
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    padding: 1rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.placemat-top-row,
.placemat-bottom-row {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 1rem;
}

.wild-zone,
.discard-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.wild-slot {
    width: 60px;
}

.discard-slot {
    width: 60px;
}

.empty-slot {
    width: 60px;
    height: 84px;
    border: 2px dashed rgba(212, 165, 116, 0.3);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.2);
}

/* Card Slots */
.card-slot {
    position: relative;
    width: 80px;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.card-slot img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    /* Image protection */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.legend-slot {
    cursor: pointer;
}

.legend-slot:hover {
    transform: translateY(-5px);
}

.legend-slot.selected {
    box-shadow: 0 0 0 3px var(--color-gold), 0 0 20px rgba(212, 165, 116, 0.5);
    transform: translateY(-8px);
}

.legend-slot.targetable {
    animation: pulse-target 1s ease-in-out infinite;
}

@keyframes pulse-target {

    0%,
    100% {
        box-shadow: 0 0 0 2px rgba(255, 100, 100, 0.5);
    }

    50% {
        box-shadow: 0 0 0 4px rgba(255, 100, 100, 0.8), 0 0 15px rgba(255, 100, 100, 0.4);
    }
}

.legend-slot.defeated {
    opacity: 0.4;
    filter: grayscale(1);
    pointer-events: none;
}

.legend-slot.defeated img {
    filter: brightness(0.5);
}

/* Legends Zone */
.legends-zone {
    flex: 1;
    max-width: 300px;
}

.legend-slots {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

/* HP Bar */
.hp-bar {
    position: absolute;
    bottom: 25px;
    left: 5px;
    right: 5px;
    height: 6px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 3px;
    overflow: hidden;
}

.hp-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    transition: width 0.5s ease;
    border-radius: 3px;
}

.hp-fill.low {
    background: linear-gradient(90deg, #f44336, #ff9800);
}

.hp-text {
    position: absolute;
    bottom: 5px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.65rem;
    color: white;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    font-weight: 600;
}

/* Deck/Stake Zones */
.deck-zone,
.stake-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.deck-slot,
.stake-slot {
    width: 60px;
}

.deck-count {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: var(--color-gold);
    color: #1a1512;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}

/* ================================
   Center Area
   ================================ */

.center-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    border: 1px solid rgba(212, 165, 116, 0.15);
}

.turn-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.turn-text {
    font-family: 'Unbounded', sans-serif;
    font-size: 1.1rem;
    color: var(--color-gold);
}

.attacks-left {
    font-size: 0.85rem;
    color: var(--color-cream);
    opacity: 0.8;
}

/* Die */
.die-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.die {
    width: 60px;
    height: 60px;
    background: linear-gradient(145deg, #fff, #e0e0e0);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s ease;
}

.die.rolling {
    animation: roll-die 0.5s ease-in-out;
}

@keyframes roll-die {
    0% {
        transform: rotate(0deg) scale(1);
    }

    25% {
        transform: rotate(90deg) scale(1.1);
    }

    50% {
        transform: rotate(180deg) scale(1);
    }

    75% {
        transform: rotate(270deg) scale(1.1);
    }

    100% {
        transform: rotate(360deg) scale(1);
    }
}

.die-face {
    font-size: 2rem;
}

/* Action Log */
.action-log {
    width: 100%;
    max-width: 400px;
    max-height: 80px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    padding: 0.75rem;
}

.log-entry {
    font-size: 0.8rem;
    color: var(--color-cream);
    padding: 0.25rem 0;
    border-bottom: 1px solid rgba(212, 165, 116, 0.1);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry.success {
    color: #8BC34A;
}

.log-entry.fail {
    color: #ff9800;
}

.log-entry.damage {
    color: #f44336;
}

/* ================================
   Game Over Modal
   ================================ */

.game-over-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
}

.game-over-content {
    background: linear-gradient(145deg, #2d2520, #1a1512);
    border: 3px solid var(--color-gold);
    border-radius: 20px;
    padding: 3rem;
    text-align: center;
    max-width: 400px;
    animation: modal-pop 0.5s ease;
}

@keyframes modal-pop {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.game-over-content h2 {
    font-family: 'Unbounded', sans-serif;
    font-size: 2rem;
    color: var(--color-gold);
    margin-bottom: 1rem;
}

.game-over-content p {
    color: var(--color-cream);
    margin-bottom: 2rem;
}

.game-over-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ================================
   Responsive
   ================================ */

/* Mobile-first: vertical layout */
.game-container {
    flex-direction: column;
}

.placemat {
    background: rgba(212, 165, 116, 0.05);
    border: 1px solid rgba(212, 165, 116, 0.2);
}

.placemat-top-row,
.placemat-bottom-row {
    flex-wrap: wrap;
}

.legend-slots {
    flex-wrap: wrap;
}

/* Tablet and up */
@media (min-width: 768px) {
    .game-container {
        flex-direction: column;
        padding: 1.5rem;
        gap: 1.5rem;
    }

    .placemat-top-row,
    .placemat-bottom-row {
        gap: 1.5rem;
    }

    .card-slot {
        width: 90px;
    }

    .wild-slot,
    .discard-slot,
    .empty-slot {
        width: 70px;
    }

    .empty-slot {
        height: 98px;
    }

    .deck-slot,
    .stake-slot {
        width: 70px;
    }
}

/* Desktop: horizontal layout */
@media (min-width: 1024px) {
    .game-container {
        flex-direction: row;
        align-items: stretch;
        padding: 2rem;
        min-height: calc(100vh - 70px);
    }

    .player-area {
        flex: 1;
        justify-content: center;
    }

    .opponent-area {
        order: 3;
    }

    .center-area {
        order: 2;
        flex: 0 0 auto;
        min-width: 220px;
        align-self: center;
    }

    .player-side {
        order: 1;
    }

    /* No rotation - keep cards right-side up */

    .placemat-top-row,
    .placemat-bottom-row {
        gap: 1rem;
        flex-wrap: nowrap;
    }

    .legend-slots {
        gap: 0.75rem;
        flex-wrap: nowrap;
    }

    .card-slot {
        width: 100px;
    }

    .wild-slot,
    .discard-slot,
    .empty-slot {
        width: 75px;
    }

    .empty-slot {
        height: 105px;
    }

    .deck-slot,
    .stake-slot {
        width: 75px;
    }

    .action-log {
        max-height: 150px;
    }

    /* On desktop, ensure consistent placemat row ordering */
    /* Player (now on left): swap rows so Legends/Discard is on bottom (closer to center) */
    .player-side .placemat {
        flex-direction: column-reverse;
    }
}

/* Large desktop */
@media (min-width: 1400px) {
    .card-slot {
        width: 120px;
    }

    .wild-slot,
    .discard-slot,
    .empty-slot {
        width: 90px;
    }

    .empty-slot {
        height: 126px;
    }

    .deck-slot,
    .stake-slot {
        width: 90px;
    }
}