:root {
    --bg-gradient: linear-gradient(135deg, #38bdf8 0%, #f472b6 25%, #facc15 50%, #34d399 75%, #a78bfa 100%);
    --primary: #ff5a5f;
    --primary-hover: #ff3d4a;
    --secondary: #3b82f6;
    --secondary-hover: #2563eb;
    --success: #22c55e;
    --card-bg: rgba(255, 255, 255, 0.9);
    --text-color: #1f2937;
    --font-family: "Comic Sans MS", "Trebuchet MS", "Bubblegum Sans", sans-serif;
    --shadow: 0 14px 30px rgba(76, 29, 149, 0.18);
    --box-gradient: linear-gradient(135deg, rgba(255,255,255,0.98), rgba(255,247,155,0.82), rgba(191,219,254,0.9));
    --bright-panel: linear-gradient(135deg, #fef08a 0%, #f9a8d4 30%, #7dd3fc 65%, #86efac 100%);
    --collect-gradient: linear-gradient(135deg, #a7f3d0 0%, #7dd3fc 30%, #f9a8d4 65%, #fcd34d 100%);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

body {
    position: relative;
    font-family: var(--font-family);
    background: var(--bg-gradient);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-color);
    overflow-x: hidden;
    padding: 10px;
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

body::before {
    background:
        radial-gradient(circle at 12% 18%, rgba(255,255,255,0.6) 0 7%, transparent 8%),
        radial-gradient(circle at 82% 22%, rgba(255,255,255,0.6) 0 7%, transparent 8%),
        radial-gradient(circle at 18% 84%, rgba(255,255,255,0.5) 0 7%, transparent 8%),
        radial-gradient(circle at 86% 80%, rgba(255,255,255,0.5) 0 7%, transparent 8%);
}

body::after {
    background-image:
        url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="140" height="140" viewBox="0 0 140 140"><g fill="rgba(255,255,255,0.12)"><circle cx="35" cy="35" r="18"/><circle cx="92" cy="60" r="22"/><circle cx="60" cy="105" r="16"/><circle cx="108" cy="105" r="18"/></g></svg>');
    background-repeat: repeat;
    opacity: 0.8;
}

#game-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 900px;
    background: linear-gradient(135deg, rgba(255,255,255,0.92), rgba(254,240,138,0.8), rgba(191,219,254,0.9), rgba(253,186,116,0.8));
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 20px;
    position: relative;
    min-height: 580px;
    display: flex;
    flex-direction: column;
    border: 4px solid rgba(255, 255, 255, 0.85);
}

/* Header & Audio */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.exit-btn {
    background: linear-gradient(135deg, #ef4444, #f97316);
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    border-radius: 999px;
    padding: 8px 16px;
    box-shadow: 0 6px 14px rgba(239, 68, 68, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.exit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(239, 68, 68, 0.3);
}

#sound-toggle {
    background: #fff;
    border: 2px solid #ddd;
    font-size: 20px;
    padding: 8px 12px;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    transition: transform 0.2s;
}
#sound-toggle:active { transform: scale(0.9); }

/* Screens */
.screen {
    display: none;
    flex-direction: column;
    flex: 1;
    animation: fadeIn 0.4s ease-in-out;
}
.screen.active {
    display: flex;
}

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

/* Typography & Titles */
.title-container {
    text-align: center;
    margin-bottom: 25px;
}
h1, h2 {
    font-size: 3.5rem;
    margin-bottom: 8px;
}
h1 {
    color: #ff1744;
    font-weight: 900;
    letter-spacing: 1px;
    text-shadow: 1px 1px 0 #ffffff, 2px 2px 0 #facc15, 3px 3px 0 #fb923c, 4px 4px 0 #ec4899, 5px 5px 0 rgba(76, 29, 149, 0.35);
    filter: drop-shadow(0 5px 3px rgba(76, 29, 149, 0.22));
}
h1 span {
    display: inline-block;
    line-height: 1.05;
    vertical-align: middle;
}
h1 span:nth-child(1) { font-size: 3.25rem; }
h1 span:nth-child(2) { font-size: 3.6rem; }
h1 span:nth-child(3) { font-size: 3.35rem; }
h1 span:nth-child(4) { font-size: 3.75rem; }
h1 span:nth-child(5) { font-size: 3.45rem; }
h1 span:nth-child(6) { font-size: 3.65rem; }
h1 span:nth-child(7) { font-size: 3.3rem; }
h1 span:nth-child(8) { font-size: 3.55rem; }
h1 span:nth-child(9) { font-size: 3.8rem; }
h1 span:nth-child(10) { font-size: 3.4rem; }
h1 span:nth-child(11) { font-size: 3.7rem; }
h1 span:nth-child(12) { font-size: 3.2rem; }
h1 span:nth-child(13) { font-size: 3.5rem; }
h1 span:nth-child(14) { font-size: 3.8rem; }
h1 span:nth-child(15) { font-size: 3.35rem; }
h1 span:nth-child(16) { font-size: 3.65rem; }
h1 span:nth-child(1), h1 span:nth-child(9) { color: #ff1744; }
h1 span:nth-child(2), h1 span:nth-child(10) { color: #ff6d00; }
h1 span:nth-child(3), h1 span:nth-child(11) { color: #ffd600; }
h1 span:nth-child(4), h1 span:nth-child(12) { color: #00c853; }
h1 span:nth-child(5), h1 span:nth-child(13) { color: #00b8d4; }
h1 span:nth-child(6), h1 span:nth-child(14) { color: #2979ff; }
h1 span:nth-child(7), h1 span:nth-child(15) { color: #651fff; }
h1 span:nth-child(8), h1 span:nth-child(16) { color: #d500f9; }
h2 {
    color: #ff4757;
    text-shadow: 2px 2px 0px #ffeb3b;
}
.subtitle {
    font-size: 1.2rem;
    color: #57606f;
}

.toy-decor {
    position: relative;
    height: 90px;
    margin: 0 auto 10px;
    width: 100%;
    max-width: 620px;
    pointer-events: none;
}

.toy-item {
    position: absolute;
    font-size: 2.3rem;
    filter: drop-shadow(0 6px 8px rgba(0,0,0,0.08));
    animation: toyFloat 4s ease-in-out infinite;
}

.toy-1 { left: 8%; top: 25%; animation-delay: 0s; }
.toy-2 { left: 27%; top: 10%; animation-delay: 0.8s; }
.toy-3 { right: 28%; top: 18%; animation-delay: 1.2s; }
.toy-4 { right: 12%; top: 30%; animation-delay: 1.8s; }
.toy-5 { left: 48%; bottom: 0; animation-delay: 0.4s; }

@keyframes toyFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-12px) rotate(6deg); }
}

/* Buttons */
.btn {
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 14px 28px;
    font-size: 1.2rem;
    font-weight: bold;
    font-family: var(--font-family);
    cursor: pointer;
    box-shadow: 0 6px 15px rgba(255, 107, 107, 0.4);
    transition: all 0.2s ease;
}
.btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}
.btn:active {
    transform: translateY(1px);
}
.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}
.secondary-btn {
    background-color: var(--secondary);
    box-shadow: 0 6px 15px rgba(77, 171, 247, 0.4);
}
.secondary-btn:hover {
    background-color: var(--secondary-hover);
}
.small-btn {
    padding: 8px 16px;
    font-size: 0.95rem;
}

/* Start Screen Cards */
.animal-cards {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 22px;
    flex-wrap: wrap;
    margin-top: 10px;
    padding: 10px 0;
}
.animal-card {
    flex: 1 1 220px;
    max-width: 250px;
    background: linear-gradient(135deg, #fef3c7 0%, #f9a8d4 28%, #93c5fd 62%, #86efac 100%);
    border-radius: 20px;
    padding: 25px 18px;
    text-align: center;
    box-shadow: 0 8px 20px rgba(0,0,0,0.06);
    transition: transform 0.3s, box-shadow 0.3s, filter 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    border: 3px solid rgba(255,255,255,0.95);
    animation: floatCard 3.2s ease-in-out infinite;
}
.animal-card:nth-child(2) {
    animation-delay: 0.6s;
}
.animal-card:nth-child(3) {
    animation-delay: 1.2s;
}
.animal-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 25px rgba(0,0,0,0.12);
    border-color: #ff6b6b;
    filter: saturate(1.1);
}
.animal-card img {
    width: 110px;
    height: 110px;
    object-fit: contain;
    margin-bottom: 15px;
    animation: floatAnim 2.8s ease-in-out infinite;
}
@keyframes floatAnim {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50% { transform: translateY(-8px) rotate(2deg); }
}
@keyframes floatCard {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* Mode Selection */
.mode-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 30px 0;
    flex-wrap: wrap;
}
.mode-btn {
    font-size: 1.4rem;
    padding: 20px 40px;
    background: linear-gradient(135deg, #ff9a9e 0%, #fad0c4 99%, #fad0c4 100%);
    color: #2f3542;
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}
.mode-btn:hover {
    background: linear-gradient(135deg, #ff6b6b 0%, #ff8e53 100%);
    color: white;
}

/* Game Screen Layout */
.game-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}
#progress-container {
    text-align: center;
    flex: 1;
    max-width: 300px;
}
#progress-text {
    font-size: 0.9rem;
    font-weight: bold;
    color: #57606f;
}
.progress-bar-bg {
    background: #dfe4ea;
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    margin-top: 4px;
}
#progress-bar-fill {
    background: var(--success);
    height: 100%;
    width: 10%;
    transition: width 0.4s ease;
    border-radius: 6px;
}

.game-main-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    flex: 1;
}
@media(max-width: 768px) {
    .game-main-layout {
        grid-template-columns: 1fr;
    }
}

/* Target Section */
.target-section {
    background: linear-gradient(135deg, #fca5a5 0%, #f9a8d4 25%, #a5b4fc 50%, #67e8f9 75%, #fde68a 100%);
    border-radius: 18px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 3px dashed #ffffff;
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.7);
}
.target-section h3 {
    font-size: 1.3rem;
    color: #2f3542;
    margin-bottom: 5px;
}
.target-display {
    text-align: center;
    margin-bottom: 10px;
}
.instruction-label {
    font-size: 0.9rem;
    color: #747d8c;
    text-transform: uppercase;
    letter-spacing: 1px;
}
#target-number {
    font-size: 4rem;
    font-weight: bold;
    color: #ff4757;
    line-height: 1;
    text-shadow: 2px 2px 0px #ffeaa7;
}
#counter-status {
    font-size: 1.1rem;
    font-weight: bold;
    color: #2f3542;
    margin-top: 4px;
}

.counting-sequence {
    margin-top: 8px;
    font-size: 0.95rem;
    color: #ff6b6b;
    font-weight: 700;
    letter-spacing: 0.04em;
}

/* Drop Zone */
.drop-zone {
    flex: 1;
    width: 100%;
    min-height: 180px;
    background: linear-gradient(135deg, #7dd3fc 0%, #a7f3d0 25%, #f9a8d4 55%, #fcd34d 100%);
    border: 3px dashed #ffffff;
    border-radius: 14px;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    padding: 10px;
    gap: 8px;
    overflow-y: auto;
    position: relative;
    transition: background 0.2s, border-color 0.2s;
    box-shadow: inset 0 0 0 3px rgba(255,255,255,0.7), 0 8px 18px rgba(59,130,246,0.15);
}
.drop-zone.drag-over {
    background: #e1f5fe;
    border-color: #29b6f6;
}
.drop-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #a4b0be;
    font-weight: bold;
    font-size: 0.95rem;
    pointer-events: none;
    letter-spacing: 1px;
}
.drop-zone img.dropped-animal {
    width: 72px;
    height: 72px;
    object-fit: contain;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: grab;
}
@keyframes popIn {
    0% { transform: scale(0.3); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.action-buttons-row {
    margin-top: 10px;
}

/* Animal Pool */
.pool-section {
    background: linear-gradient(135deg, #bfdbfe 0%, #f9a8d4 30%, #fde68a 60%, #a7f3d0 100%);
    border-radius: 18px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 3px dashed #ffffff;
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.8);
}
.pool-section h4 {
    font-size: 1.1rem;
    color: #57606f;
    margin-bottom: 10px;
}
.animal-pool {
    flex: 1;
    width: 100%;
    background: linear-gradient(135deg, #fef9c3 0%, #bfdbfe 30%, #fbcfe8 60%, #bbf7d0 100%);
    border: 3px solid rgba(255,255,255,0.8);
    border-radius: 14px;
    padding: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-content: flex-start;
    justify-content: center;
    overflow-y: auto;
    min-height: 180px;
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.6);
}
.pool-animal {
    width: 72px;
    height: 72px;
    object-fit: contain;
    cursor: grab;
    transition: transform 0.2s;
    touch-action: none;
}
.pool-animal:active {
    cursor: grabbing;
}
.pool-animal:hover {
    transform: scale(1.1);
}

/* Completion Screen */
.completion-card {
    text-align: center;
    margin: auto;
    padding: 30px;
}
.champion-badge {
    font-size: 1.8rem;
    color: #ffa502;
    margin: 20px 0;
    text-shadow: 1px 1px 0px #ff4757;
    animation: bounce 1s infinite alternate;
}
@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-10px); }
}
.completion-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* Success Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s;
}
.modal-overlay.active {
    display: flex;
}
.modal-content {
    background: white;
    padding: 35px 50px;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.modal-content h2 {
    font-size: 2.5rem;
    color: #2ed573;
    margin-bottom: 10px;
}
.modal-content p {
    font-size: 1.3rem;
    color: #57606f;
    margin-bottom: 20px;
}