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

body {
    background-color: #001f3f;
    color: #e0f7fa;
    font-family: 'Poppins', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    position: relative;
    margin: 0;
}

/* Dynamic background reflecting the puzzle image */
#dynamic-blur-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-size: cover;
    background-position: center;
    /* Scale up slightly to prevent blur from showing sharp edges */
    transform: scale(1.1);
    filter: blur(25px) brightness(0.35);
    z-index: 0;
    transition: background-image 0.8s ease;
}

#ambient-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, rgba(0,255,255,0.2) 0%, rgba(255,215,0,0.1) 60%, rgba(0,0,0,0) 100%);
    z-index: 1;
    pointer-events: none;
    animation: pulseGlow 4s infinite alternate;
}

@keyframes pulseGlow {
    from { opacity: 0.7; }
    to { opacity: 1; }
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 450px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
}

header {
    width: 100%;
    text-align: center;
    margin-bottom: 15px;
}

.summer-badge {
    display: inline-block;
    background-color: #ff8c00;
    color: white;
    font-weight: bold;
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 2px;
    margin-bottom: 5px;
    border: 1px solid #ffa500;
    box-shadow: 0 0 8px rgba(255, 140, 0, 0.8);
}

h1 {
    font-family: 'Poppins', sans-serif;
    font-weight: 800;
    font-size: 34px;
    color: #00ffff;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.6), 0 0 20px rgba(0, 191, 255, 0.4);
    margin-bottom: 5px;
    letter-spacing: 1px;
}

.subtitle {
    font-size: 12px;
    color: #e0f7fa;
    font-style: italic;
    margin-bottom: 10px;
    opacity: 0.8;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 360px;
    margin: 0 auto;
    padding: 0 5px;
}

#level-indicator {
    font-size: 14px;
    color: #e0f7fa;
    letter-spacing: 1px;
}

#level-indicator span {
    font-weight: 600;
    color: #00ffff;
    text-shadow: 0 0 5px rgba(0, 255, 255, 0.5);
}

.time-bar-container {
    width: 360px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    margin: 15px auto 0 auto;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
}

#time-fill {
    height: 100%;
    width: 100%;
    background: #00ffcc;
    box-shadow: 0 0 10px #00ffcc;
    transition: width 1s linear, background-color 0.5s;
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.progress-label {
    font-size: 10px;
    text-transform: uppercase;
    color: #00ffff;
    letter-spacing: 1px;
}

.progress-bar {
    width: 120px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
}

#tease-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #00bfff, #00ffff);
    box-shadow: 0 0 10px #00ffff;
    transition: width 0.5s ease-out;
}

/* 3:4 ASPECT RATIO */
#board-container {
    position: relative;
    /* 3:4 Base dimensions */
    width: 360px;
    height: 480px;
    /* Allows dynamic scaling on very small phones while preserving 3:4 */
    max-width: 95vw;
    max-height: calc(95vw * (4/3));
    border-radius: 12px;
    box-shadow: 0 0 30px rgba(0, 191, 255, 0.4), 0 0 0 1px rgba(0, 255, 255, 0.3);
    overflow: hidden;
    background: #000;
}

#image-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    z-index: 1;
}

#game-board {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    /* 3 columns x 4 rows = 12 cards for fast/dopamine hit gameplay */
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(4, 1fr);
    z-index: 2;
    gap: 2px;
    padding: 2px;
}

.card {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: pointer;
    perspective: 1000px;
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 6px;
}

.card-front {
    background: rgba(0, 30, 60, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 255, 255, 0.2);
    font-size: 32px;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.8);
    box-shadow: inset 0 0 20px rgba(0, 191, 255, 0.1);
}

.card-front:hover {
    background: rgba(0, 191, 255, 0.2);
    border-color: rgba(0, 255, 255, 0.6);
}

.card-front span {
    animation: heartbeat 2s infinite;
    opacity: 0.3;
}

@keyframes heartbeat {
    0% { transform: scale(1); }
    15% { transform: scale(1.15); }
    30% { transform: scale(1); }
    45% { transform: scale(1.15); }
    60% { transform: scale(1); }
}

.card-back {
    background: rgba(0, 60, 90, 0.9);
    color: white;
    transform: rotateY(180deg);
    border: 1px solid #00ffff;
    font-size: 35px;
    box-shadow: 0 0 15px rgba(0, 191, 255, 0.5);
}

.card.matched {
    opacity: 0;
    pointer-events: none;
    transform: scale(1.1);
}

#overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    top: auto;
    width: 100%;
    height: 60%;
    background: linear-gradient(to top, rgba(10, 0, 5, 0.95) 0%, rgba(10, 0, 5, 0.8) 40%, transparent 100%);
    backdrop-filter: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    z-index: 10;
    border-radius: 0 0 12px 12px;
    padding-bottom: 25px;
    opacity: 0;
    transition: opacity 0.8s ease;
}

#overlay:not(.hidden) {
    opacity: 1;
}

.hidden {
    display: none !important;
}

h2#overlay-title {
    font-family: 'Poppins', sans-serif;
    font-weight: 800;
    font-size: 32px;
    color: #00ffff;
    text-shadow: 0 0 20px #00bfff, 0 0 40px #00bfff;
    margin-bottom: 5px;
}

#overlay-text {
    font-size: 14px;
    color: #e0f7fa;
    margin-bottom: 20px;
    font-style: italic;
    text-align: center;
    padding: 0 20px;
}

button {
    padding: 12px 28px;
    font-size: 16px;
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(45deg, #ff8c00, #ff4500);
    color: white;
    border: 1px solid #ffd700;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    box-shadow: 0 0 20px rgba(255, 140, 0, 0.5);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    margin: 8px 0;
    width: 85%;
}

button:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 10px 25px rgba(255, 140, 0, 0.8);
    background: linear-gradient(45deg, #ffa500, #ff8c00);
}

#try-again-btn {
    background: linear-gradient(45deg, #111, #333);
    border-color: #555;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
}

#try-again-btn:hover {
    background: linear-gradient(45deg, #222, #555);
}

#patreon-btn {
    background: linear-gradient(45deg, #f96854, #ff8c7a);
    border-color: #ffd2cc;
    box-shadow: 0 0 20px rgba(249, 104, 84, 0.4);
}

#patreon-btn:hover {
    box-shadow: 0 10px 25px rgba(249, 104, 84, 0.7);
}

/* --- TITLE SCREEN STYLES --- */
#home-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
    transition: opacity 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.home-bg-slider {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-size: cover;
    background-position: center;
    transition: background-image 2s ease-in-out;
    filter: brightness(0.55) blur(3px);
}

.home-vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(ellipse at center, rgba(0,0,0,0) 0%, rgba(0,31,63,0.8) 100%);
    pointer-events: none;
}

.title-screen-content {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px;
    background: rgba(0, 15, 30, 0.45);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 255, 255, 0.2);
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5), inset 0 0 20px rgba(0, 191, 255, 0.1);
    max-width: 90%;
    width: 400px;
    animation: slideUpFade 1s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes slideUpFade {
    0% { opacity: 0; transform: translateY(30px); }
    100% { opacity: 1; transform: translateY(0); }
}

.summer-badge-title {
    display: inline-block;
    background: linear-gradient(45deg, #ff8c00, #ff0055);
    color: white;
    font-weight: bold;
    font-size: 11px;
    padding: 4px 12px;
    border-radius: 20px;
    letter-spacing: 2px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 215, 0, 0.5);
    box-shadow: 0 0 15px rgba(255, 140, 0, 0.6);
}

.main-title {
    font-family: 'Poppins', sans-serif;
    font-weight: 800;
    font-size: 42px;
    margin: 0 0 15px 0;
    text-shadow: 0 0 20px #00bfff, 0 0 40px #00bfff, 0 5px 5px rgba(0,0,0,0.8);
    line-height: 1.1;
    color: #fff;
}

.title-subtitle {
    color: #e0f7fa;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 35px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    opacity: 0.9;
}

.title-buttons {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.btn-primary {
    width: 100%;
    padding: 16px 0;
    font-size: 22px;
    border-radius: 40px;
    animation: pulseBtn 2s infinite alternate;
    margin: 0;
}

.btn-secondary {
    width: 100%;
    padding: 14px 0;
    font-size: 16px;
    background: rgba(0, 30, 60, 0.6);
    border: 1px solid #00ffff;
    color: #00ffff;
    margin: 0;
}

.btn-secondary:hover {
    background: rgba(0, 191, 255, 0.3);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.4);
    transform: translateY(-2px);
}

.title-footer {
    display: flex;
    justify-content: center;
    gap: 10px;
    font-size: 12px;
    color: #888;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.title-footer span {
    color: #ffcc00;
}

@media (max-width: 480px) {
    .main-title { font-size: 34px; }
    .title-screen-content { padding: 30px 20px; }
}
