/* ============================================
   Dodo Island Runner - WordPress Game Plugin
   v1.1 - Full Mobile Support
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Press+Start+2P&display=swap');

:root {
    --dodo-primary: #FF6B35;
    --dodo-secondary: #004E89;
    --dodo-accent: #FFD23F;
    --dodo-dark: #1A1A2E;
    --dodo-light: #F5F0E8;
    --dodo-green: #2ECC71;
    --dodo-red: #E74C3C;
    --dodo-pink: #FF8FAB;
    --dodo-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --dodo-radius: 16px;
}

/* ---- Wrapper ---- */
#dodo-game-wrapper {
    max-width: 840px;
    margin: 30px auto;
    font-family: 'Fredoka', sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

/* ---- Header / HUD ---- */
#dodo-game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--dodo-dark);
    border-radius: var(--dodo-radius) var(--dodo-radius) 0 0;
    color: var(--dodo-light);
}

#dodo-game-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dodo-icon {
    font-size: 28px;
    animation: dodo-bounce 2s ease-in-out infinite;
}

@keyframes dodo-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.dodo-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 13px;
    color: var(--dodo-accent);
    letter-spacing: 1px;
}

#dodo-game-hud {
    display: flex;
    gap: 20px;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.hud-label {
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    color: #888;
    letter-spacing: 1px;
}

.hud-value {
    font-family: 'Press Start 2P', cursive;
    font-size: 16px;
    color: var(--dodo-accent);
    min-width: 60px;
    text-align: center;
}

/* ---- Game Container ---- */
#dodo-game-container {
    position: relative;
    background: #000;
    border-radius: 0 0 var(--dodo-radius) var(--dodo-radius);
    overflow: hidden;
    box-shadow: var(--dodo-shadow);
    /* Prevent pull-to-refresh on mobile */
    overscroll-behavior: none;
}

#dodo-game-canvas {
    display: block;
    width: 100%;
    height: auto;
    cursor: pointer;
    image-rendering: auto;
    touch-action: none;
}

/* ---- Overlay Screens ---- */
.dodo-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(26, 26, 46, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10;
    animation: fadeIn 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.overlay-content {
    text-align: center;
    color: var(--dodo-light);
    padding: 30px;
    max-width: 420px;
    width: 90%;
}

.overlay-content h2 {
    font-family: 'Press Start 2P', cursive;
    font-size: 22px;
    color: var(--dodo-accent);
    margin: 0 0 12px 0;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.3);
    line-height: 1.4;
}

.overlay-content p {
    font-size: 15px;
    color: #ccc;
    margin: 0 0 20px 0;
    line-height: 1.7;
}

.dodo-big-icon {
    font-size: 64px;
    margin-bottom: 10px;
    animation: dodo-bounce 1.5s ease-in-out infinite;
}

/* ---- Controls Info ---- */
.controls-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Desktop controls (hidden on mobile) */
.controls-desktop {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Mobile controls (hidden on desktop) */
.controls-mobile {
    display: none;
    flex-direction: column;
    gap: 8px;
}

.control-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    color: #aaa;
}

.control-item kbd {
    display: inline-block;
    padding: 3px 8px;
    font-family: 'Press Start 2P', cursive;
    font-size: 9px;
    color: var(--dodo-accent);
    background: rgba(255, 210, 63, 0.12);
    border: 1px solid rgba(255, 210, 63, 0.3);
    border-radius: 6px;
}

.control-item .touch-icon {
    font-size: 22px;
    line-height: 1;
}

.control-item span {
    color: #ddd;
}

/* ---- Buttons ---- */
.dodo-btn {
    display: inline-block;
    padding: 14px 36px;
    font-family: 'Fredoka', sans-serif;
    font-size: 17px;
    font-weight: 600;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    letter-spacing: 0.5px;
    -webkit-tap-highlight-color: transparent;
}

.dodo-btn-primary {
    background: linear-gradient(135deg, var(--dodo-primary), #FF8C5A);
    color: #fff;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.4);
}

.dodo-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(255, 107, 53, 0.5);
}

.dodo-btn-primary:active {
    transform: translateY(0) scale(0.97);
}

.dodo-btn-small {
    padding: 8px 16px;
    font-size: 13px;
    background: var(--dodo-green);
    color: #fff;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.dodo-btn-small:hover {
    background: #27AE60;
}

/* ---- Game Over Screen ---- */
#dodo-final-score-area {
    margin: 16px 0;
}

.final-score-label {
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    color: #888;
    margin-bottom: 4px;
}

.final-score-value {
    font-family: 'Press Start 2P', cursive;
    font-size: 36px;
    color: var(--dodo-accent);
    text-shadow: 2px 2px 0 rgba(0,0,0,0.3);
}

.new-record {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    color: var(--dodo-pink);
    margin-bottom: 12px;
    animation: pulse 0.6s ease-in-out infinite alternate;
}

@keyframes pulse {
    from { transform: scale(1); }
    to { transform: scale(1.08); }
}

/* ---- Name Input ---- */
#dodo-name-input-area {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}

#dodo-player-name {
    padding: 10px 14px;
    font-family: 'Fredoka', sans-serif;
    font-size: 16px; /* 16px prevents iOS zoom */
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
    color: #fff;
    outline: none;
    width: 160px;
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

#dodo-player-name:focus {
    border-color: var(--dodo-accent);
}

#dodo-player-name::placeholder {
    color: #666;
}

/* ---- Leaderboard ---- */
#dodo-leaderboard {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

#dodo-leaderboard h3 {
    font-family: 'Press Start 2P', cursive;
    font-size: 11px;
    color: var(--dodo-accent);
    margin: 0 0 12px 0;
}

#dodo-leaderboard-list {
    max-height: 160px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.leaderboard-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    font-size: 13px;
    transition: background 0.15s;
}

.leaderboard-row:nth-child(1) { background: rgba(255, 210, 63, 0.15); }
.leaderboard-row:nth-child(2) { background: rgba(192, 192, 192, 0.1); }
.leaderboard-row:nth-child(3) { background: rgba(205, 127, 50, 0.1); }
.leaderboard-row:nth-child(n+4) { background: rgba(255,255,255,0.03); }

.lb-rank {
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    color: #888;
    min-width: 30px;
}

.lb-name {
    flex: 1;
    text-align: left;
    color: #ddd;
    padding: 0 10px;
}

.lb-score {
    font-family: 'Press Start 2P', cursive;
    font-size: 11px;
    color: var(--dodo-accent);
}

/* Scrollbar */
#dodo-leaderboard-list::-webkit-scrollbar { width: 4px; }
#dodo-leaderboard-list::-webkit-scrollbar-track { background: transparent; }
#dodo-leaderboard-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

/* ---- Fullscreen & Sound Buttons ---- */
.dodo-hud-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: var(--dodo-accent);
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
    margin-left: 4px;
}

.dodo-hud-btn:hover {
    background: rgba(255, 210, 63, 0.15);
    border-color: rgba(255, 210, 63, 0.3);
    transform: scale(1.08);
}

.dodo-hud-btn:active {
    transform: scale(0.95);
}

.dodo-hud-btn svg {
    pointer-events: none;
}

#dodo-sound-btn.is-muted {
    color: #666;
    border-color: rgba(255, 255, 255, 0.06);
}

/* ---- Fullscreen Mode ---- */
#dodo-game-wrapper:fullscreen,
#dodo-game-wrapper:-webkit-full-screen,
#dodo-game-wrapper:-moz-full-screen,
#dodo-game-wrapper:-ms-fullscreen {
    max-width: 100%;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    background: #000;
    border-radius: 0;
}

#dodo-game-wrapper:fullscreen #dodo-game-header,
#dodo-game-wrapper:-webkit-full-screen #dodo-game-header {
    border-radius: 0;
    flex-shrink: 0;
}

#dodo-game-wrapper:fullscreen #dodo-game-container,
#dodo-game-wrapper:-webkit-full-screen #dodo-game-container {
    flex: 1;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#dodo-game-wrapper:fullscreen #dodo-game-canvas,
#dodo-game-wrapper:-webkit-full-screen #dodo-game-canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

/* Tablet */
@media (max-width: 768px) {
    #dodo-game-wrapper {
        margin: 15px auto;
        max-width: 100%;
    }

    #dodo-game-header {
        padding: 10px 16px;
    }

    .dodo-title {
        font-size: 11px;
    }

    #dodo-game-hud {
        gap: 14px;
    }

    .hud-value {
        font-size: 14px;
        min-width: 50px;
    }

    .controls-desktop { display: none; }
    .controls-mobile { display: flex; }
}

/* Phone */
@media (max-width: 480px) {
    #dodo-game-wrapper {
        margin: 0;
        border-radius: 0;
    }

    #dodo-game-header {
        flex-direction: column;
        gap: 6px;
        padding: 8px 12px;
        border-radius: 0;
        position: relative;
    }

    .dodo-hud-btn {
        position: absolute;
        top: 8px;
        width: 32px;
        height: 32px;
    }

    #dodo-fullscreen-btn {
        right: 12px;
    }

    #dodo-sound-btn {
        right: 50px;
    }

    #dodo-game-logo {
        gap: 8px;
    }

    .dodo-icon {
        font-size: 22px;
    }

    .dodo-title {
        font-size: 9px;
    }

    #dodo-game-hud {
        gap: 16px;
    }

    .hud-label {
        font-size: 7px;
    }

    .hud-value {
        font-size: 13px;
        min-width: 45px;
    }

    #dodo-game-container {
        border-radius: 0;
    }

    .overlay-content {
        padding: 16px 12px;
    }

    .overlay-content h2 {
        font-size: 16px;
        margin-bottom: 8px;
    }

    .overlay-content p {
        font-size: 13px;
        margin-bottom: 14px;
    }

    .dodo-big-icon {
        font-size: 48px;
        margin-bottom: 6px;
    }

    .controls-info {
        padding: 10px;
        margin-bottom: 18px;
    }

    .control-item {
        font-size: 12px;
        gap: 6px;
    }

    .dodo-btn {
        padding: 12px 30px;
        font-size: 15px;
    }

    .final-score-value {
        font-size: 28px;
    }

    .new-record {
        font-size: 10px;
    }

    #dodo-name-input-area {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    #dodo-player-name {
        width: 200px;
        text-align: center;
    }

    .dodo-btn-small {
        padding: 10px 24px;
        font-size: 14px;
    }

    #dodo-leaderboard h3 {
        font-size: 10px;
    }

    .leaderboard-row {
        padding: 5px 10px;
        font-size: 12px;
    }

    .lb-rank { font-size: 9px; }
    .lb-score { font-size: 10px; }
}

/* Very small phones */
@media (max-width: 360px) {
    .dodo-title { font-size: 8px; }
    .hud-value { font-size: 11px; }
    .overlay-content h2 { font-size: 14px; }
    .dodo-big-icon { font-size: 40px; }
    .final-score-value { font-size: 24px; }
}

/* Landscape phone */
@media (max-height: 450px) and (orientation: landscape) {
    .dodo-overlay {
        align-items: flex-start;
        padding-top: 10px;
    }

    .overlay-content {
        padding: 10px;
    }

    .overlay-content h2 {
        font-size: 14px;
        margin-bottom: 6px;
    }

    .dodo-big-icon {
        font-size: 32px;
        margin-bottom: 4px;
    }

    .overlay-content p {
        font-size: 11px;
        margin-bottom: 8px;
    }

    .controls-info {
        padding: 6px;
        margin-bottom: 10px;
    }

    .dodo-btn {
        padding: 8px 24px;
        font-size: 14px;
    }

    #dodo-final-score-area { margin: 8px 0; }
    .final-score-value { font-size: 22px; }
    #dodo-name-input-area { margin-bottom: 8px; }
    #dodo-leaderboard { margin-top: 10px; padding-top: 8px; }
    #dodo-leaderboard-list { max-height: 80px; }
}

/* iOS safe area support */
@supports (padding: max(0px)) {
    #dodo-game-wrapper {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
}
