/* Responsive CSS for Treasuretrap */

/* Base responsive variables */
:root {
    /* Card sizes for different screen sizes */
    --card-width-desktop: 200px;
    --card-height-desktop: 280px;
    --card-width-tablet: 160px;
    --card-height-tablet: 224px;
    --card-width-mobile: 140px;
    --card-height-mobile: 196px;
    --card-width-small: 120px;
    --card-height-small: 168px;
    --card-width-tiny: 100px;
    --card-height-tiny: 140px;
}

/* Default (Desktop) */
.card {
    width: var(--card-width-desktop);
    height: var(--card-height-desktop);
}

.inventory-slot {
    width: 120px;
    height: 160px;
}

/* Large screens (1200px and above) */
@media (min-width: 1200px) {
    .game-container {
        max-width: 1000px;
    }
    
    .card {
        width: calc(var(--card-width-desktop) * 1.1);
        height: calc(var(--card-height-desktop) * 1.1);
    }
    
    .inventory-slot {
        width: 140px;
        height: 180px;
    }
    
    .card-title {
        font-size: 1.8rem;
    }
    
    .card-value {
        font-size: 2.8rem;
    }
    
    .card-description {
        font-size: 1rem;
    }
}

/* Medium screens (tablets, 768px to 1199px) */
@media (max-width: 1199px) {
    .game-container {
        max-width: 95%;
    }
    
    .card {
        width: var(--card-width-tablet);
        height: var(--card-height-tablet);
    }
    
    .card-title {
        font-size: 1.4rem;
    }
    
    .card-value {
        font-size: 2.2rem;
    }
    
    .card-icon {
        font-size: 2.5rem;
    }
    
    .game-title {
        font-size: 2.6rem;
        white-space: nowrap;
    }
    
    .mode-card {
        width: 280px;
    }
    
    .inventory-slot {
        width: 100px;
        height: 140px;
    }
}

/* Mobile devices (767px and below) - General Mobile Styles */
@media (max-width: 767px) {
    body {
        padding: var(--spacing-sm);
    }
    
    .game-container {
        gap: var(--spacing-sm);
        padding: 10px;
        min-height: auto;
        height: auto;
    }
    
    .mode-selection {
        padding: var(--spacing-md) 0;
        min-height: auto;
        height: auto;
    }
    
    .card {
        width: var(--card-width-mobile);
        height: var(--card-height-mobile);
    }
    
    .card-area {
        gap: var(--spacing-lg);
    }
    
    .card-title {
        font-size: 1.2rem;
        margin-bottom: var(--spacing-sm);
    }
    
    .card-value {
        font-size: 1.8rem;
        margin: var(--spacing-sm) 0;
    }
    
    .card-icon {
        font-size: 2rem;
        margin-bottom: var(--spacing-sm);
    }
    
    .card-description {
        font-size: 0.9rem;
    }
    
    .special-badge, .trap-type {
        font-size: 0.8rem;
        padding: 3px;
    }
    
    .game-header h1 {
        font-size: 1.6rem;
    }
    
    .score-panel {
        gap: var(--spacing-sm);
    }
    
    .score-box p:first-child {
        font-size: 0.9rem;
    }
    
    .score-box p:last-child {
        font-size: 1.5rem;
    }
    
    .action-buttons {
        gap: var(--spacing-md);
    }
    
    .action-buttons button {
        padding: var(--spacing-md) var(--spacing-lg);
        font-size: 1.2rem;
    }
    
    .game-title {
        font-size: 2.2rem;
        white-space: nowrap;
    }
    
    .mode-card {
        width: 100%;
        max-width: 300px;
    }
    
    .inventory-slot {
        width: 100px;
        height: 135px;
    }
    
    .modal-content {
        padding: var(--spacing-lg);
    }
    
    /* Treasure maps in minigame */
    .treasure-map {
        width: 120px;
        height: 160px;
    }
    
    .status-bar {
        font-size: 0.95rem;
        padding: 12px 12px;
        display: flex;
        flex-direction: column;
        gap: 12px;
        margin-top: 10px;
        border-radius: var(--border-radius);
        background-color: rgba(0, 0, 0, 0.3);
    }
    
    .status-row {
        flex-wrap: wrap;
        justify-content: space-around;
        gap: 8px;
    }
    
    .effects-row {
        min-height: 40px;
    }
    
    .status-item {
        font-size: 0.95rem;
        text-align: center;
        padding: 4px;
        display: flex;
        justify-content: center;
        align-items: center;
        margin: 0 2px;
    }
    
    .status-label {
        margin-right: 8px;
        font-weight: normal;
    }
    
    #level-indicator, #trap-probability, #cards-drawn {
        font-weight: bold;
    }
    
    .inventory-container h3 {
        font-size: 1.6rem;
        margin-bottom: 15px;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    }
}

/* 430px+ (iPhone Pro Max and other large phones) */
@media (max-width: 480px) and (min-width: 430px) {
    .card {
        width: var(--card-width-small);
        height: var(--card-height-small);
    }
    
    .game-header h1 {
        font-size: 1.4rem;
    }
    
    .treasure-maps-container {
        gap: 15px;
    }
    
    .treasure-map {
        width: 110px;
        height: 150px;
    }
    
    .modal-content {
        max-width: 90%;
        padding: var(--spacing-md);
    }
    
    .score-panel {
        flex-wrap: wrap;
    }
    
    .score-box {
        flex: 1 0 30%;
    }
    
    .status-bar {
        font-size: 1.1rem;
        padding: 12px 8px;
    }
    
    .inventory-container h3 {
        font-size: 1.6rem;
    }
    
    .empty-slot-indicator {
        font-size: 1.2rem;
    }
}

/* 412px-429px (Pixel, Samsung Galaxy devices) */
@media (max-width: 429px) and (min-width: 412px) {
    .card {
        width: var(--card-width-small);
        height: var(--card-height-small);
    }
    
    .game-header h1 {
        font-size: 1.3rem;
    }
    
    .treasure-maps-container {
        gap: 12px;
    }
    
    .treasure-map {
        width: 105px;
        height: 145px;
    }
    
    .inventory-slots {
        gap: 8px;
    }
    
    .inventory-slot {
        width: 95px;
        height: 130px;
    }
    
    .status-bar {
        font-size: 1.1rem;
        padding: 12px 8px;
    }
    
    .empty-slot-indicator {
        font-size: 1.1rem;
    }
}

/* 390px-411px (iPhone 12-15) */
@media (max-width: 411px) and (min-width: 390px) {
    .card {
        width: var(--card-width-small);
        height: var(--card-height-small);
    }
    
    .game-header h1 {
        font-size: 1.3rem;
    }
    
    .card-area {
        gap: 15px;
    }
    
    .score-box p:last-child {
        font-size: 1.4rem;
    }
    
    .action-buttons button {
        font-size: 1.1rem;
        padding: 10px 15px;
    }
    
    .treasure-maps-container {
        gap: 10px;
    }
    
    .treasure-map {
        width: 100px;
        height: 140px;
    }
    
    .inventory-slot {
        width: 90px;
        height: 125px;
    }
    
    .status-bar {
        flex-wrap: wrap;
        font-size: 1.05rem;
        padding: 10px 5px;
        row-gap: 5px;
    }
    
    .status-item {
        flex: 1 0 auto;
        white-space: nowrap;
    }
    
    .inventory-container h3 {
        font-size: 1.5rem;
        margin-bottom: 12px;
    }
    
    .empty-slot-indicator {
        font-size: 1.1rem;
    }
}

/* 375px-389px (iPhone X, XS, 11 Pro) */
@media (max-width: 389px) and (min-width: 375px) {
    .card {
        width: 110px;
        height: 154px;
    }
    
    .game-header {
        padding: 10px 8px;
    }
    
    .game-header h1 {
        font-size: 1.2rem;
        margin-bottom: 8px;
        white-space: nowrap;
    }
    
    .game-title {
        font-size: 2.2rem;
    }
    
    .card-area {
        gap: 12px;
    }
    
    .score-box p:first-child {
        font-size: 0.8rem;
    }
    
    .score-box p:last-child {
        font-size: 1.3rem;
    }
    
    .action-buttons button {
        font-size: 1rem;
        padding: 8px 12px;
    }
    
    .treasure-maps-container {
        gap: 8px;
    }
    
    .treasure-map {
        width: 95px;
        height: 135px;
    }
    
    .modal-content {
        max-width: 95%;
        padding: 15px;
    }
    
    .inventory-slot {
        width: 85px;
        height: 120px;
    }
    
    .status-bar {
        flex-wrap: wrap;
        font-size: 1rem;
        padding: 10px 5px;
    }
    
    .streak-container, .highest-streak-container {
        grid-column: span 2;
        margin: 0 auto;
    }
    
    .streak-multiplier {
        font-size: 0.8rem;
    }
    
    .status-item:last-child {
        grid-column: span 2;
    }
    
    .inventory-container h3 {
        font-size: 1.4rem;
        margin-bottom: 10px;
    }
}

/* 360px-374px (Small Androids) */
@media (max-width: 374px) and (min-width: 360px) {
    .card {
        width: 105px;
        height: 147px;
    }
    
    /* Make game header more compact */
    .game-header {
        padding: 8px 5px;
    }
    
    /* Ensure title is visible */
    .game-header h1 {
        font-size: 1.1rem;
        margin-bottom: 8px;
        white-space: nowrap;
    }
    
    /* Reorganize control buttons into two rows */
    .game-controls {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        max-width: 100%;
    }
    
    /* Slightly smaller buttons but still touch-friendly */
    .game-controls .control-button {
        width: 30px;
        height: 30px;
        font-size: 0.85rem;
        margin-bottom: 5px;
    }
    
    .game-title {
        font-size: 2rem;
    }
    
    .card-title {
        font-size: 1rem;
    }
    
    .card-value {
        font-size: 1.4rem;
    }
    
    .card-icon {
        font-size: 1.4rem;
    }
    
    .card-description {
        font-size: 0.75rem;
    }
    
    .score-box p:first-child {
        font-size: 0.75rem;
    }
    
    .score-box p:last-child {
        font-size: 1.2rem;
    }
    
    .action-buttons button {
        font-size: 0.95rem;
        padding: 8px 10px;
    }
    
    .treasure-maps-container {
        gap: 5px;
    }
    
    .treasure-map {
        width: 90px;
        height: 130px;
    }
    
    .inventory-slot {
        width: 80px;
        height: 115px;
    }
    
    .status-bar {
        padding: 10px 5px;
        font-size: 0.95rem;
    }
    
    .streak-container, .highest-streak-container {
        font-size: 0.8rem;
        margin: 0 auto;
    }
    
    .streak-multiplier {
        font-size: 0.75rem;
    }
    
    .status-item:last-child {
        grid-column: span 2;
    }
    
    .inventory-container h3 {
        font-size: 1.3rem;
        margin-bottom: 8px;
    }
}

/* Small screens (320px-359px) */
@media (max-width: 359px) and (min-width: 320px) {
    :root {
        --spacing-xs: 2px;
        --spacing-sm: 5px;
        --spacing-md: 10px;
    }
    
    body {
        padding: 5px;
    }
    
    .mode-selection {
        padding: var(--spacing-sm) 0;
        min-height: auto;
        height: auto;
    }
    
    .title-container {
        margin-bottom: var(--spacing-md);
    }
    
    .recent-scores-display {
        margin-top: 15px;
        width: 95%;
    }
    
    .quick-links {
        margin-top: 10px;
    }
    
    .card {
        width: 90px;
        height: 126px;
    }
    
    .card-area {
        gap: 8px;
    }
    
    .card-title {
        font-size: 0.9rem;
    }
    
    .card-value {
        font-size: 1.2rem;
    }
    
    .card-icon {
        font-size: 1.2rem;
    }
    
    .card-description, .special-badge, .trap-type {
        font-size: 0.7rem;
    }
    
    /* Make game header more compact */
    .game-header {
        padding: 5px 3px;
    }
    
    /* Ensure title is visible */
    .game-header h1 {
        font-size: 1rem;
        margin-bottom: 6px;
        white-space: nowrap;
    }
    
    /* Reorganize control buttons into two rows */
    .game-controls {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
        max-width: 100%;
    }
    
    /* Smaller buttons but still touch-friendly */
    .game-controls .control-button {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
        margin-bottom: 4px;
    }
    
    .score-panel {
        flex-direction: column;
        gap: 5px;
        margin-bottom: 8px;
    }
    
    .score-box {
        width: 100%;
        padding: 5px;
    }
    
    .score-box:last-child {
        margin-bottom: 5px;
    }
    
    .action-buttons button {
        font-size: 0.9rem;
        padding: 5px 8px;
    }
    
    .status-bar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        padding: 10px;
        margin-top: 10px;
    }
    
    .streak-container, .highest-streak-container {
        font-size: 0.8rem;
        margin: 8px auto 0;
        grid-column: span 2;
        padding: 4px 10px;
        background-color: rgba(0, 0, 0, 0.2);
        border-radius: 10px;
        justify-content: center;
        order: -1;
    }
    
    .game-title {
        font-size: 1.8rem;
    }
    
    .mode-card {
        padding: 10px;
    }
    
    .modal-content {
        padding: 10px;
    }
    
    .inventory-container h3 {
        font-size: 1.2rem;
    }
    
    .inventory-slots {
        gap: 5px;
    }
    
    .inventory-slot {
        width: 70px;
        height: 100px;
    }
    
    .notification-container {
        width: 90%;
    }
    
    .treasure-map {
        width: 80px;
        height: 120px;
    }
}

/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 600px) {
    .gameplay-container {
        flex-direction: row;
        align-items: center;
        justify-content: space-around;
    }
    
    .card-area {
        flex: 0 0 45%;
    }
    
    .game-controls-container {
        flex: 0 0 45%;
    }
    
    .inventory-container {
        margin-top: 10px;
    }
    
    .score-panel {
        justify-content: space-around;
    }
    
    .score-box {
        flex: 0 0 30%;
    }
}

/* Height-based adjustments for very short screens */
@media (max-height: 700px) and (orientation: portrait) {
    .card {
        width: var(--card-width-small);
        height: var(--card-height-small);
    }
    
    .game-header {
        height: 40px;
    }
    
    .score-box {
        padding: var(--spacing-xs);
    }
    
    .inventory-slot {
        width: 90px;
        height: 125px;
    }
    
    .modal-content {
        max-height: 85vh;
        overflow-y: auto;
    }
}

/* Increase touch targets for better accessibility on touch devices */
@media (hover: none) and (pointer: coarse) {
    /* Ensure all interactive elements meet 44px minimum touch target */
    button, .inventory-slot, .treasure-map, .discard-card-icon, .effect-icon {
        min-height: 44px;
        min-width: 44px;
    }
    
    .action-buttons button {
        min-height: 48px;
        min-width: 120px;
        padding: 12px 20px;
        font-size: 1.1rem;
    }
    
    .game-controls-container {
        gap: 15px;
    }
    
    /* Improve touch targets for small interactive elements */
    .discard-card-icon {
        width: 44px;
        height: 44px;
        font-size: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background-color: rgba(255, 0, 0, 0.8);
        color: white;
        border: 2px solid white;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        top: -5px;
        right: -5px;
    }
    
    /* Effect icons touch targets */
    .effect-icon {
        padding: 8px;
        border-radius: 8px;
        background-color: rgba(0, 0, 0, 0.1);
        margin: 4px;
        cursor: pointer;
        transition: background-color 0.2s ease;
    }
    
    .effect-icon:hover, .effect-icon:active {
        background-color: rgba(0, 0, 0, 0.2);
    }
    
    /* Settings and modal close buttons */
    .close-button, #settings-button, .modal-close {
        min-height: 44px;
        min-width: 44px;
        padding: 10px;
    }
    
    /* Gallery and store navigation buttons */
    .gallery-tab, .store-section button {
        min-height: 44px;
        padding: 10px 16px;
    }
    
    /* Ensure adequate spacing between interactive elements */
    .inventory-slots {
        gap: 12px;
    }
    
    .active-effects-container .effect-icon {
        margin: 6px;
    }
    
    /* Purchase buttons in store */
    .purchase-button {
        min-height: 44px;
        min-width: 100px;
        padding: 10px 16px;
    }
    
    /* Control buttons (stats, gallery, etc.) */
    .control-button {
        min-height: 44px;
        min-width: 44px;
        padding: 8px;
    }
    
    /* Card mobile label improvements */
    .card-mobile-label {
        background-color: rgba(0, 0, 0, 0.9);
        color: white;
        padding: 8px 12px;
        border-radius: 6px;
        font-size: 0.9rem;
        min-height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    }
    
    /* Improve card interaction areas */
    .inventory-card-container {
        padding: 4px;
        border-radius: 8px;
        transition: background-color 0.2s ease;
    }
    
    .inventory-card-container:active {
        background-color: rgba(255, 255, 255, 0.1);
    }
    
    /* Better modal and overlay interactions */
    .modal-content {
        padding: 20px;
        margin: 10px;
        border-radius: 12px;
    }
    
    /* Notification close buttons */
    .notification .close-btn {
        min-height: 32px;
        min-width: 32px;
        padding: 4px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Settings slider improvements */
    input[type="range"] {
        min-height: 44px;
        -webkit-appearance: none;
        appearance: none;
    }
    
    input[type="range"]::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
        -webkit-appearance: none;
        appearance: none;
    }
    
    input[type="range"]::-moz-range-thumb {
        width: 24px;
        height: 24px;
        border: none;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Create a style for active effects container that works better on small screens */
@media (max-width: 480px) {
    .active-effects-container {
        flex-wrap: wrap;
        justify-content: center;
        margin-top: 5px;
    }
    
    .status-bar {
        padding: 8px 10px;
    }
    
    .stats-row {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    
    .status-item {
        margin: 2px 4px;
        font-size: 0.9rem;
    }
    
    .active-effects-container::before {
        font-size: 0.7rem;
        top: -15px;
    }
}

/* Extra small screens (less than 320px) */
@media (max-width: 319px) {
    /* Make game header even more compact */
    .game-header {
        padding: 4px 2px;
    }
    
    /* Ensure title is visible */
    .game-header h1 {
        font-size: 0.9rem;
        margin-bottom: 5px;
        white-space: nowrap;
    }
    
    /* Reorganize control buttons into two rows */
    .game-controls {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 5px;
        max-width: 100%;
    }
    
    /* Even smaller buttons but still touch-friendly */
    .game-controls .control-button {
        width: 26px;
        height: 26px;
        font-size: 0.75rem;
        margin-bottom: 3px;
    }
    
    /* Reduce card size further */
    .card {
        width: 85px;
        height: 119px;
    }
    
    /* Smaller game title */
    .game-title {
        font-size: 1.6rem;
    }
}

/* Improve status item spacing across all screen sizes */
.status-item {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Better spacing for streak container globally */
.streak-container, .highest-streak-container {
    font-size: 0.8rem;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 3px 5px;
}

#streak-value {
    margin: 0 4px;
}

/* Small Screens */
.streak-container, .highest-streak-container {
    grid-column: span 2;
    margin: 0 auto;
}

.streak-multiplier {
    font-size: 0.8rem;
}
