/* ============================================
   FLAVOURMAN BATTLE - Cartoon Style CSS
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Outfit:wght@400;600;700&display=swap');

:root {
    /* Warm Sunset Colors */
    --sky-top: #9d6b9e;
    --sky-mid: #f4a460;
    --sky-bottom: #ffcc66;

    /* Button Colors */
    --btn-green: linear-gradient(180deg, #7ed56f 0%, #55a649 100%);
    --btn-blue: linear-gradient(180deg, #6bb5e0 0%, #4a90b8 100%);
    --btn-purple: linear-gradient(180deg, #b088c0 0%, #8a6098 100%);
    --btn-red: linear-gradient(180deg, #e06b6b 0%, #c04848 100%);
    --btn-gray: linear-gradient(180deg, #a8a8a8 0%, #888888 100%);

    /* Text */
    --title-red: #cc3333;
    --title-yellow: #ffcc00;
    --title-outline: #5c3d1e;

    /* UI */
    --input-bg: #d0d0d0;
    --input-border: #999999;

    /* Character Colors */
    --color-spicy: #FF4D4D;
    --color-salty: #FFFFFF;
    --color-sour: #CCFF00;
    --color-sweet: #FF69B4;
    --color-umami: #9D00FF;

    --font-heading: 'Fredoka One', cursive;
    --font-body: 'Outfit', sans-serif;
}

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

body {
    font-family: var(--font-body);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ============================================
   BACKGROUND
   ============================================ */
.bg-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('img/bg.png') center center / 100% 100% no-repeat;
    z-index: -1;
}

/* Fallback gradient if image fails */
.bg-layer::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 50%, var(--sky-bottom) 100%);
    z-index: -1;
}

/* ============================================
   APP CONTAINER & CANVAS
   ============================================ */
.app-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 1920px;
    max-height: 1080px;
}

#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* ============================================
   SCREENS
   ============================================ */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.screen.active {
    opacity: 1;
    pointer-events: all;
}

.hidden {
    display: none !important;
}

/* ============================================
   GAME TITLE
   ============================================ */
.game-title {
    text-align: center;
    margin-bottom: 30px;
    animation: titleBounce 2s ease-in-out infinite;
}

@keyframes titleBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.title-main {
    font-family: var(--font-heading);
    font-size: 5rem;
    color: var(--title-yellow);
    text-shadow:
        -4px -4px 0 var(--title-outline),
        4px -4px 0 var(--title-outline),
        -4px 4px 0 var(--title-outline),
        4px 4px 0 var(--title-outline),
        0 6px 0 var(--title-red);
    letter-spacing: 4px;
    line-height: 0.9;
}

.title-sub {
    font-family: var(--font-heading);
    font-size: 3.5rem;
    color: var(--title-red);
    text-shadow:
        -3px -3px 0 var(--title-outline),
        3px -3px 0 var(--title-outline),
        -3px 3px 0 var(--title-outline),
        3px 3px 0 var(--title-outline),
        0 4px 0 #8B0000;
    margin-top: -15px;
}

.screen-subtitle {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--title-yellow);
    text-shadow: 2px 2px 0 var(--title-outline);
    margin-bottom: 20px;
}

/* ============================================
   CARTOON BUTTONS
   ============================================ */
.btn-cartoon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 280px;
    padding: 18px 30px;
    margin: 10px 0;
    border: none;
    border-radius: 50px;
    font-family: var(--font-heading);
    font-size: 1.4rem;
    color: white;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    position: relative;
    transition: transform 0.15s, box-shadow 0.15s;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.3);
}

.btn-cartoon::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50px;
    border: 4px solid rgba(0, 0, 0, 0.2);
    border-top-color: rgba(255, 255, 255, 0.3);
    pointer-events: none;
}

.btn-cartoon:hover {
    transform: scale(1.08) translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.btn-cartoon:active {
    transform: scale(0.98);
}

.btn-cartoon.green {
    background: var(--btn-green);
    box-shadow: 0 6px 0 #3d7a35, 0 8px 15px rgba(0, 0, 0, 0.2);
}

.btn-cartoon.blue {
    background: var(--btn-blue);
    box-shadow: 0 6px 0 #3a6f8a, 0 8px 15px rgba(0, 0, 0, 0.2);
}

.btn-cartoon.purple {
    background: var(--btn-purple);
    box-shadow: 0 6px 0 #6a4878, 0 8px 15px rgba(0, 0, 0, 0.2);
}

.btn-cartoon.red {
    background: var(--btn-red);
    box-shadow: 0 6px 0 #8a3030, 0 8px 15px rgba(0, 0, 0, 0.2);
}

.btn-cartoon.gray {
    background: var(--btn-gray);
    box-shadow: 0 6px 0 #666666, 0 8px 15px rgba(0, 0, 0, 0.2);
}

.btn-cartoon.green:active {
    box-shadow: 0 2px 0 #3d7a35;
    transform: translateY(4px);
}

.btn-cartoon.blue:active {
    box-shadow: 0 2px 0 #3a6f8a;
    transform: translateY(4px);
}

.btn-cartoon.purple:active {
    box-shadow: 0 2px 0 #6a4878;
    transform: translateY(4px);
}

.btn-cartoon.red:active {
    box-shadow: 0 2px 0 #8a3030;
    transform: translateY(4px);
}

.btn-icon {
    font-size: 1.6rem;
}

/* Locked Button */
.btn-cartoon.locked {
    background: var(--btn-gray);
    box-shadow: 0 6px 0 #555555, 0 8px 15px rgba(0, 0, 0, 0.2);
    cursor: not-allowed;
    opacity: 0.8;
}

.btn-cartoon.locked:hover {
    transform: none;
    box-shadow: 0 6px 0 #555555, 0 8px 15px rgba(0, 0, 0, 0.2);
}

.btn-cartoon.locked .lock-icon {
    position: absolute;
    right: 20px;
    font-size: 1.2rem;
}

/* Small buttons */
.btn-small {
    width: auto;
    padding: 12px 25px;
    font-size: 1rem;
}

/* ============================================
   CARTOON INPUTS
   ============================================ */
.input-cartoon {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 320px;
    padding: 15px 20px;
    margin: 10px 0;
    background: var(--input-bg);
    border: 3px solid var(--input-border);
    border-radius: 50px;
    font-family: var(--font-body);
    font-size: 1.1rem;
    color: #555;
    box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.1);
}

.input-cartoon .input-icon {
    font-size: 1.4rem;
    color: #777;
}

.input-cartoon input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: 1.1rem;
    color: #333;
    outline: none;
}

.input-cartoon input::placeholder {
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ============================================
   MENU CONTAINERS
   ============================================ */
.menu-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px;
    animation: fadeSlideUp 0.5s ease-out;
}

@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.button-row {
    display: flex;
    gap: 15px;
}

/* Forgot password link */
.forgot-link {
    margin-top: 15px;
    color: var(--title-yellow);
    font-family: var(--font-heading);
    font-size: 0.9rem;
    text-shadow: 1px 1px 0 var(--title-outline);
    cursor: pointer;
    transition: color 0.2s;
}

.forgot-link:hover {
    color: white;
}

/* ============================================
   CHARACTER SELECT
   ============================================ */
.char-select-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1000px;
}

.player-info-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 20px;
}

.player-banner {
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 30px;
    border-radius: 10px;
    font-family: var(--font-heading);
    font-size: 1.2rem;
    color: white;
}

.player-banner.p1 {
    border: 3px solid var(--color-spicy);
}

.player-banner.p2 {
    border: 3px solid #00CCFF;
}

.selecting-indicator {
    background: rgba(0, 0, 0, 0.7);
    padding: 8px 20px;
    border-radius: 20px;
    font-family: var(--font-heading);
    color: var(--title-yellow);
    animation: pulse 1s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.char-grid {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 20px;
}

.char-card {
    width: 150px;
    background: rgba(0, 0, 0, 0.6);
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.char-card:hover {
    transform: translateY(-8px) scale(1.05);
    border-color: white;
}

.char-card.selected-p1 {
    border-color: var(--color-spicy);
    box-shadow: 0 0 20px var(--color-spicy);
}

.char-card.selected-p2 {
    border-color: #00CCFF;
    box-shadow: 0 0 20px #00CCFF;
}

.char-card .char-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin: 0 auto 10px;
    box-shadow: 0 0 15px currentColor;
}

.char-card h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: white;
    margin-bottom: 5px;
}

.char-card .role {
    font-size: 0.75rem;
    color: #aaa;
    margin-bottom: 8px;
}

.char-card .ability {
    font-size: 0.8rem;
    color: #88ccff;
}

/* Stats bars */
.stats {
    margin-top: 10px;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 4px;
    font-size: 0.7rem;
    color: #888;
}

.stat-row span {
    width: 28px;
}

.stat-bar-bg {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.bar {
    height: 100%;
    border-radius: 3px;
}

/* AI Difficulty Selector */
.difficulty-selector {
    display: flex;
    gap: 10px;
    margin: 15px 0;
}

.diff-btn {
    padding: 10px 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    font-family: var(--font-heading);
    cursor: pointer;
    transition: all 0.2s;
}

.diff-btn:hover {
    border-color: white;
}

.diff-btn.active {
    background: var(--btn-green);
    border-color: #55a649;
}

.diff-btn.active.medium {
    background: var(--btn-blue);
    border-color: #4a90b8;
}

.diff-btn.active.hard {
    background: var(--btn-red);
    border-color: #c04848;
}

/* ============================================
   GAME HUD
   ============================================ */
.game-ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    padding: 15px;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.player-hud {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 38%;
}

.player-hud.p2 {
    flex-direction: row-reverse;
    text-align: right;
}

.portrait {
    width: 55px;
    height: 55px;
    border: 3px solid white;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.bars {
    flex: 1;
}

.name {
    font-family: var(--font-heading);
    font-size: 1rem;
    color: white;
    text-shadow: 2px 2px 0 black;
    margin-bottom: 4px;
}

.health-container {
    height: 24px;
    background: rgba(0, 0, 0, 0.6);
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    overflow: hidden;
}

.health-bar-fill {
    height: 100%;
    background: linear-gradient(180deg, #ff6666 0%, #cc0000 100%);
    transition: width 0.2s;
    border-radius: 10px;
}

.p2 .health-bar-fill {
    background: linear-gradient(180deg, #66ccff 0%, #0099cc 100%);
}

/* Timer */
.timer-container {
    background: rgba(0, 0, 0, 0.7);
    padding: 8px 20px;
    border-radius: 15px;
    text-align: center;
}

.timer-display {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    color: white;
    text-shadow: 0 0 10px #00ccff;
}

.timer-label {
    font-size: 0.7rem;
    color: #aaa;
    letter-spacing: 2px;
}

/* Announcements */
.message-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-heading);
    font-size: 5rem;
    color: var(--title-yellow);
    text-shadow:
        -4px -4px 0 var(--title-outline),
        4px -4px 0 var(--title-outline),
        -4px 4px 0 var(--title-outline),
        4px 4px 0 var(--title-outline),
        0 8px 0 var(--title-red);
    display: none;
    animation: announceIn 0.3s ease-out;
    z-index: 200;
}

@keyframes announceIn {
    from {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }

    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* ============================================
   GAME OVER
   ============================================ */
.game-over-container {
    text-align: center;
    animation: fadeSlideUp 0.5s ease-out;
}

.winner-crown {
    font-size: 5rem;
    animation: crownBounce 0.8s ease infinite;
}

@keyframes crownBounce {

    0%,
    100% {
        transform: translateY(0) rotate(-5deg);
    }

    50% {
        transform: translateY(-15px) rotate(5deg);
    }
}

#winner-text {
    font-family: var(--font-heading);
    font-size: 3.5rem;
    color: var(--title-yellow);
    text-shadow:
        -3px -3px 0 var(--title-outline),
        3px -3px 0 var(--title-outline),
        -3px 3px 0 var(--title-outline),
        3px 3px 0 var(--title-outline);
    margin: 20px 0;
}

.game-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 30px;
}

.stat-item {
    text-align: center;
}

.stat-label {
    font-size: 0.9rem;
    color: #ccc;
    margin-bottom: 5px;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    color: #00ccff;
}

/* ============================================
   SETTINGS & LEADERBOARD
   ============================================ */
.panel-container {
    background: rgba(0, 0, 0, 0.7);
    padding: 30px 40px;
    border-radius: 20px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    min-width: 400px;
}

.panel-container h2 {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--title-yellow);
    text-shadow: 2px 2px 0 var(--title-outline);
    margin-bottom: 20px;
}

.setting-group {
    margin-bottom: 20px;
    text-align: left;
}

.setting-group label {
    display: block;
    font-family: var(--font-heading);
    color: white;
    margin-bottom: 8px;
}

.setting-group input[type="range"] {
    width: 100%;
    height: 10px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.2);
    appearance: none;
}

.setting-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 24px;
    height: 24px;
    background: var(--btn-green);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.setting-group select {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    font-family: var(--font-body);
    font-size: 1rem;
}

/* Leaderboard Table */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard-table th {
    font-family: var(--font-heading);
    color: #00ccff;
}

.leaderboard-table .rank-gold {
    color: #ffd700;
}

.leaderboard-table .rank-silver {
    color: #c0c0c0;
}

.leaderboard-table .rank-bronze {
    color: #cd7f32;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
    .title-main {
        font-size: 3rem;
    }

    .title-sub {
        font-size: 2rem;
    }

    .btn-cartoon {
        width: 240px;
        font-size: 1.1rem;
    }

    .char-card {
        width: 120px;
    }
}

@media (max-width: 600px) {
    .title-main {
        font-size: 2rem;
    }

    .title-sub {
        font-size: 1.4rem;
    }

    .btn-cartoon {
        width: 200px;
        font-size: 1rem;
        padding: 14px 20px;
    }

    .char-grid {
        gap: 8px;
    }

    .char-card {
        width: 100px;
        padding: 10px;
    }
}

/* ============================================
   PAUSE MENU
   ============================================ */
.pause-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.pause-panel {
    background: linear-gradient(180deg, #4a3c6e 0%, #2d1b4e 100%);
    border-radius: 25px;
    padding: 40px 60px;
    text-align: center;
    border: 4px solid #ffcc00;
    box-shadow: 0 0 40px rgba(255, 204, 0, 0.3);
}

.pause-panel h2 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    color: #ffcc00;
    margin-bottom: 30px;
    text-shadow: 3px 3px 0 #5c3d1e;
}

.pause-panel .btn-cartoon {
    display: block;
    margin: 15px auto;
    width: 250px;
}

/* ============================================
   CONTROL SETTINGS
   ============================================ */
.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 20px 0;
}

.control-section {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 15px;
}

.control-section h4 {
    color: #ffcc00;
    margin-bottom: 10px;
}

.control-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 8px 0;
    color: #ccc;
}

.control-row input {
    width: 60px;
    padding: 8px;
    text-align: center;
    border: 2px solid #666;
    border-radius: 8px;
    background: #333;
    color: #fff;
    font-family: var(--font-body);
    font-size: 14px;
    cursor: pointer;
}

.control-row input:focus {
    border-color: #ffcc00;
    outline: none;
}

.key-display {
    background: #444;
    padding: 5px 12px;
    border-radius: 5px;
    font-weight: bold;
    min-width: 50px;
    text-align: center;
}