/* ===================================
   WORDFLIES GAME PLAY EXTENDED STYLES
   ===================================
   This file contains additional styles for the game play interface including:
   - Mobile viewport and responsive styles
   - Tutorial overlay styles
   - Share section styles
   - Pangram styles
   - Rank up animation styles
   =================================== */

/* ===================================
   BASE OVERLAY STYLES
   =================================== */

/* Base overlay class - MUST be hidden by default */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: none; /* Hidden by default - IMPORTANT */
    align-items: center;
    justify-content: center;
    z-index: 9999;
    overflow-y: auto;
    padding: 20px;
}

/* Show overlay when active */
.overlay.show,
.overlay.active {
    display: flex;
}

/* Overlay content container */
.overlay-content {
    background: linear-gradient(135deg, rgba(30, 27, 75, 0.98) 0%, rgba(49, 46, 129, 0.98) 100%);
    color: white;
    padding: 40px;
    border-radius: 20px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(100, 255, 218, 0.2);
    position: relative;
    animation: overlaySlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes overlaySlideIn {
    from {
        transform: translateY(-30px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* ===================================
   MOBILE VIEWPORT & RESPONSIVE STYLES
   =================================== */

/* Additional mobile-specific fixes */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .game-info-section {
        padding-bottom: calc(2px + env(safe-area-inset-bottom)) !important;
    }
}

/* Use dynamic viewport calculations for better fit */
@media (max-width: 768px) {
    :root {
        --mobile-button-height: 42px;
        --mobile-input-height: 44px;
        --mobile-score-height: 45px;
        --mobile-controls-height: 120px;
        --mobile-total-ui: calc(var(--mobile-score-height) + var(--mobile-input-height) + var(--mobile-controls-height) + 40px);
    }
    
    .canvas-wrapper {
        height: calc(100vh - var(--mobile-total-ui) - env(safe-area-inset-bottom, 0px)) !important;
        height: calc(100dvh - var(--mobile-total-ui) - env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* Handle Galaxy S24 and similar tall phones */
@media screen and (max-height: 932px) and (max-width: 430px) {
    :root {
        --mobile-button-height: 40px;
        --mobile-input-height: 42px;
        --mobile-score-height: 42px;
        --mobile-controls-height: 110px;
        --mobile-total-ui: calc(var(--mobile-score-height) + var(--mobile-input-height) + var(--mobile-controls-height) + 35px);
    }
    
    .game-canvas-container {
        padding: 1px !important;
    }
    .mobile-score-top {
        margin-bottom: 1px !important;
        height: var(--mobile-score-height) !important;
    }
    .word-input-container {
        height: var(--mobile-input-height) !important;
    }
    .control-buttons,
    .game-control-buttons {
        margin: 0 !important;
    }
    .game-info-section {
        height: var(--mobile-controls-height) !important;
    }
}

/* Prevent any scrolling on mobile */
@media (max-width: 768px) {
    html, body {
        position: fixed;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }
}

/* ===================================
   TUTORIAL OVERLAY STYLES
   =================================== */

/* Main tutorial overlay container */
.tutorial-overlay {
    z-index: 10000;
}

/* Tutorial content box */
.tutorial-content {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.98) 0%, rgba(168, 85, 247, 0.98) 100%);
    backdrop-filter: blur(30px);
    border-radius: 24px;
    padding: 0;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    position: relative;
    animation: tutorialSlideIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes tutorialSlideIn {
    from {
        transform: translateY(-100px) scale(0.8);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Tutorial header section */
.tutorial-header {
    background: rgba(255, 255, 255, 0.1);
    padding: 30px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.tutorial-title {
    color: #ffffff;
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tutorial-stars {
    font-size: 1.5rem;
    animation: starFloat 3s ease-in-out infinite;
}

@keyframes starFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.star {
    display: inline-block;
    margin: 0 5px;
    animation: starSpin 4s linear infinite;
}

.star:nth-child(2) {
    animation-delay: 0.5s;
}

.star:nth-child(3) {
    animation-delay: 1s;
}

@keyframes starSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Tutorial body content */
.tutorial-body {
    padding: 30px;
    color: #ffffff;
}

.tutorial-section {
    margin-bottom: 25px;
}

.tutorial-section h3 {
    color: #64ffda;
    font-size: 1.3rem;
    margin-bottom: 15px;
    font-weight: 600;
}

.tutorial-icon {
    font-size: 1.5rem;
    margin-right: 8px;
    vertical-align: middle;
}

/* Tutorial lists */
.tutorial-list {
    list-style: none;
    padding-left: 0;
}

.tutorial-list li {
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.6;
}

.tutorial-list li:before {
    content: "→";
    position: absolute;
    left: 0;
    color: #64ffda;
    font-weight: bold;
}

.tutorial-list strong {
    color: #ffffff;
    font-weight: 600;
}

/* Rank progression display */
.rank-progression {
    background: rgba(255, 255, 255, 0.1);
    padding: 12px 20px;
    border-radius: 12px;
    margin-top: 10px;
    text-align: center;
}

.rank-item {
    color: #64ffda;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Controls grid */
.controls-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 15px;
}

.control-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.control-item:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.control-icon {
    font-size: 1.5rem;
    width: 30px;
    text-align: center;
}

.control-desc {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
}

/* Tutorial tips section */
.tutorial-tips {
    background: rgba(100, 255, 218, 0.1);
    border: 1px solid rgba(100, 255, 218, 0.3);
    border-radius: 12px;
    padding: 15px;
    margin-top: 20px;
}

.tip {
    margin: 0;
    color: #ffffff;
    font-size: 0.95rem;
    line-height: 1.5;
}

.tip strong {
    color: #64ffda;
}

/* Tutorial footer */
.tutorial-footer {
    background: rgba(255, 255, 255, 0.1);
    padding: 25px 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.dont-show-again {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    font-size: 0.9rem;
    user-select: none;
}

.dont-show-again input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #64ffda;
}

.start-game-btn {
    background: linear-gradient(135deg, #64ffda 0%, #4ade80 100%);
    color: #1e1b4b;
    padding: 12px 30px;
    font-size: 1.1rem;
    font-weight: 700;
    border: none;
    position: relative;
    overflow: hidden;
    text-shadow: none;
}

.start-game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(100, 255, 218, 0.4);
}

.start-game-btn .btn-glow {
    background: rgba(255, 255, 255, 0.3);
}

/* Mobile Responsive Tutorial */
@media (max-width: 768px) {
    .tutorial-content {
        width: 95%;
        max-height: 85vh;
        margin: 20px auto;
    }
    
    .tutorial-title {
        font-size: 1.8rem;
    }
    
    .tutorial-header,
    .tutorial-body {
        padding: 20px;
    }
    
    .tutorial-section h3 {
        font-size: 1.1rem;
    }
    
    .controls-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .tutorial-footer {
        padding: 20px;
        flex-direction: column;
        text-align: center;
    }
    
    .start-game-btn {
        width: 100%;
        max-width: 250px;
    }
}

/* ===================================
   SHARE SECTION STYLES
   =================================== */

.share-section {
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    margin: 20px 0;
}

.share-section h5 {
    font-weight: 600;
    letter-spacing: 0.5px;
}

.share-section .btn {
    min-width: 100px;
    padding: 8px 16px;
    font-weight: 500;
    border-radius: 20px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.share-section .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.share-section .btn-info {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border: none;
    color: white;
}

.share-section .btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
}

.share-section .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.share-section .btn-primary {
    background: linear-gradient(135deg, #1DA1F2, #0A84FF);
    border: none;
}

#shareFeedback {
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===================================
   PANGRAM STYLES
   =================================== */

.pangrams-section {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(255, 193, 7, 0.1));
    border-radius: 8px;
    padding: 10px;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.pangram-list {
    max-height: 120px;
    overflow-y: auto;
}

.pangram-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    margin-bottom: 4px;
    animation: pangramGlow 2s ease-in-out infinite;
}

.pangram-entry .word {
    color: #333;
    font-weight: bold;
}

.pangram-entry .points {
    color: #333;
}

@keyframes pangramGlow {
    0%, 100% { 
        box-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
    }
    50% { 
        box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
    }
}

/* ===================================
   RANK UP ANIMATION STYLES
   =================================== */

.rank-up-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: rankUpFadeIn 0.5s ease-out;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

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

.rank-up-content {
    text-align: center;
    animation: rankUpBounce 1s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.95) 0%, rgba(147, 51, 234, 0.95) 100%);
    padding: 40px 60px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 0 100px rgba(124, 58, 237, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

@keyframes rankUpBounce {
    0% {
        transform: scale(0) translateY(-50px);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) translateY(0);
        opacity: 1;
    }
    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.rank-up-title {
    font-size: 3rem;
    font-weight: 800;
    color: #64ffda;
    text-shadow: 0 0 20px rgba(100, 255, 218, 0.8),
                 0 0 40px rgba(100, 255, 218, 0.6),
                 0 0 60px rgba(100, 255, 218, 0.4);
    margin-bottom: 10px;
    animation: rankUpGlow 2s ease-in-out infinite;
}

@keyframes rankUpGlow {
    0%, 100% {
        text-shadow: 0 0 20px rgba(100, 255, 218, 0.8),
                     0 0 40px rgba(100, 255, 218, 0.6),
                     0 0 60px rgba(100, 255, 218, 0.4);
    }
    50% {
        text-shadow: 0 0 30px rgba(100, 255, 218, 1),
                     0 0 60px rgba(100, 255, 218, 0.8),
                     0 0 90px rgba(100, 255, 218, 0.6);
    }
}

.rank-up-subtitle {
    font-size: 1.5rem;
    color: #ffffff;
    font-weight: 600;
    opacity: 0;
    animation: rankUpSubtitleFade 0.5s ease-out 0.5s forwards;
}

@keyframes rankUpSubtitleFade {
    to {
        opacity: 1;
    }
}

.rank-stars {
    font-size: 2rem;
    margin: 20px 0;
    opacity: 0;
    animation: rankUpStarsFade 0.5s ease-out 0.7s forwards;
}

@keyframes rankUpStarsFade {
    to {
        opacity: 1;
    }
}

.rank-star {
    display: inline-block;
    margin: 0 10px;
    animation: starRotate 3s linear infinite;
}

.rank-star:nth-child(2) {
    animation-delay: 0.3s;
}

.rank-star:nth-child(3) {
    animation-delay: 0.6s;
}

@keyframes starRotate {
    from {
        transform: rotate(0deg) scale(1);
    }
    50% {
        transform: rotate(180deg) scale(1.3);
    }
    to {
        transform: rotate(360deg) scale(1);
    }
}

/* Mobile responsive rank animation */
@media (max-width: 768px) {
    .rank-up-title {
        font-size: 2.5rem;
    }
    
    .rank-up-subtitle {
        font-size: 1.2rem;
    }
    
    .rank-stars {
        font-size: 1.5rem;
    }
}