/* ===========================================
   C'est Quoi Ce Niveau - Clash Royale Theme
   =========================================== */

/* Font Face - Clash Royale Style */
@font-face {
    font-family: 'Clash';
    src: url('/assets/fonts/Clash_Regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* CSS Variables */
:root {
    --tip-bg: #9ACDFF;
    --tip-stroke: #67B3E6;
    --panel-bg: #f5ebe0;
    --panel-border: #3d5a80;
    --panel-header-bg: #457b9d;
    --text-dark: #1d3557;
    --text-light: #f1faee;
    --accent-gold: #f4a261;
    --accent-red: #e63946;
    
    /* Tier Colors */
    --tier-top1k: #e63946;
    --tier-top10k: #f4a261;
    --tier-top50k: #e9c46a;
    --tier-ranked: #9d4edd;
    --tier-supreme: #7b2cbf;
    --tier-15k: #2a9d8f;
    --tier-10k-15k: #219ebc;
    --tier-casual: #57cc99;
    --tier-beginner: #6c757d;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Clash', 'Supercell Magic', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(180deg, #5ba3d9 0%, #3d8bc4 50%, #2a6a9a 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
}

/* App Container - uses most of horizontal space */
.app {
    display: flex;
    flex-direction: column;
    width: clamp(400px, 80vw, 700px);
    height: calc(100vh - 3rem);
    max-height: 920px;
    min-height: 600px;
    border-radius: 28px;
    padding: 2rem 2.5rem;
    background: url('/assets/images/bg-tile.png') no-repeat center center;
    background-size: cover;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

/* Header */
.header {
    text-align: center;
    padding: 0.5rem 0 1.5rem;
    flex-shrink: 0;
}

.header-banner {
    position: relative;
    display: inline-block;
    width: 100%;
    max-width: 420px;
}

.header-image {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.4));
}

.header-text {
    position: absolute;
    top: 42%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 75%;
    text-align: center;
}

.header-title {
    font-family: 'Clash', sans-serif;
    font-size: 1.8rem;
    color: #FFFFFF;
    text-shadow: 
        2px 2px 0 #1a5276,
        -1px -1px 0 #1a5276,
        1px -1px 0 #1a5276,
        -1px 1px 0 #1a5276,
        0 3px 6px rgba(0, 0, 0, 0.5);
    line-height: 1.1;
    margin: 0;
    letter-spacing: 0.01em;
}

.header-subtitle {
    font-family: 'Clash', sans-serif;
    font-size: 0.9rem;
    color: #FFE066;
    text-shadow: 
        1px 1px 0 #8B4513,
        -1px -1px 0 #5a3010,
        0 2px 4px rgba(0, 0, 0, 0.6);
    margin-top: 0.2rem;
    letter-spacing: 0.02em;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 1rem 0 0;
}

/* Search Section */
.search-container {
    width: 100%;
    max-width: 420px;
    padding: 0 1rem;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

/* CR-style input field */
.search-input {
    flex: 1;
    min-width: 0; /* Prevent flex overflow */
    font-family: inherit;
    font-size: 1.1rem;
    padding: 0.9rem 1rem;
    border: 1px solid #000000;
    border-radius: 8px;
    background: #FFFFFF;
    color: var(--text-dark);
    outline: none;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.search-input::placeholder {
    color: #B7B7B7;
    text-transform: none;
    letter-spacing: normal;
}

.search-input:focus {
    border-color: #000000;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.search-input:disabled {
    opacity: 0.6;
}

/* CR-style search button with depth effect */
.search-button {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    padding: 3px;
    border: 1px solid #D9FFFF;
    border-radius: 6px;
    background: #ADB4C2;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s;
}

.search-button-inner {
    width: 100%;
    height: 100%;
    background: #BFCEDB;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-button:hover:not(:disabled) {
    transform: scale(1.05);
}

.search-button:active:not(:disabled) {
    transform: scale(0.95);
}

.search-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.search-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.search-hint {
    text-align: center;
    margin-top: 0.75rem;
    font-size: 0.95rem;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    min-height: 1.5em;
}

.search-hint.error {
    color: #ffc9c9;
}

.search-hint.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Results Section */
.results-section {
    width: 100%;
    animation: slideUp 0.4s ease-out;
}

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

/* Tournament Info */
.tournament-info {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    text-align: center;
}

.tournament-name {
    font-size: 1.3rem;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 0.5rem;
}

.tournament-meta {
    display: flex;
    justify-content: center;
    gap: 1rem;
    font-size: 0.9rem;
}

.tournament-status {
    color: #a5d6a7;
    padding: 0.25rem 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
}

.tournament-status.ended {
    color: #ef9a9a;
}

.tournament-status.live {
    color: #81c784;
    animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px rgba(129, 199, 132, 0.5); }
    50% { box-shadow: 0 0 15px rgba(129, 199, 132, 0.8); }
}

.tournament-players {
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Results Panel - CR Style */
.results-panel {
    background: var(--panel-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 
        0 4px 0 rgba(0, 0, 0, 0.2),
        0 8px 20px rgba(0, 0, 0, 0.3);
    border: 3px solid var(--panel-border);
}

.panel-header {
    background: linear-gradient(180deg, #5c9ece 0%, var(--panel-header-bg) 100%);
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--panel-border);
}

.panel-title {
    font-size: 1rem;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.02em;
}

.panel-time {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
}

/* Tier List */
.tier-list {
    padding: 0.5rem;
}

.tier-row {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.tier-row:last-child {
    border-bottom: none;
}

.tier-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.tier-label {
    font-size: 0.9rem;
    color: var(--text-dark);
    min-width: 100px;
    flex-shrink: 0;
}

.tier-bar-container {
    flex: 1;
    height: 16px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

.tier-bar {
    height: 100%;
    border-radius: 8px;
    transition: width 0.6s ease-out;
    min-width: 4px;
}

.tier-stats {
    display: flex;
    gap: 0.5rem;
    min-width: 70px;
    justify-content: flex-end;
    flex-shrink: 0;
}

.tier-count {
    font-weight: bold;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.tier-percent {
    font-size: 0.8rem;
    color: #6c757d;
    min-width: 40px;
    text-align: right;
}

/* Panel Footer */
.panel-footer {
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.05);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #6c757d;
}

.footer-errors {
    color: var(--accent-red);
}

/* Reset Button */
.reset-button {
    display: block;
    width: 100%;
    margin-top: 1.5rem;
    padding: 1rem;
    font-family: inherit;
    font-size: 1rem;
    color: white;
    background: linear-gradient(180deg, #74c0fc 0%, #4dabf7 50%, #339af0 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 
        0 4px 0 #1971c2,
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transition: transform 0.1s, box-shadow 0.1s;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.reset-button:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 6px 0 #1971c2,
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.reset-button:active {
    transform: translateY(2px);
    box-shadow: 
        0 2px 0 #1971c2,
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* Tip Footer */
.tip-footer {
    flex-shrink: 0;
    padding: 0 0 0.5rem;
    margin-top: auto;
    width: 100%;
    display: flex;
    justify-content: center;
}

.tip-panel {
    position: relative;
    background: var(--tip-bg);
    border: 4px solid var(--tip-stroke);
    border-radius: 8px;
    padding: 1.5rem 1.25rem 1.25rem;
    width: 100%;
    max-width: 420px;
}

.tip-label {
    position: absolute;
    top: -0.7em;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Clash', sans-serif;
    font-size: 1.1rem;
    font-weight: bold;
    color: #FFFFFF;
    text-shadow: 
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000,
        0 2px 4px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

.tip-text {
    text-align: center;
    font-size: 1rem;
    color: #000000;
    font-weight: 600;
    line-height: 1.4;
    min-height: 3em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.tip-text.fade {
    opacity: 0;
}

/* Loading State */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
    margin-right: 0.5rem;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Mobile - full screen, no border */
@media (max-width: 600px) {
    body {
        padding: 0;
        background: none;
    }
    
    .app {
        width: 100vw;
        height: 100vh;
        max-height: none;
        min-height: 100vh;
        border-radius: 0;
        padding: 1.5rem 1.25rem;
        box-shadow: none;
    }
    
    .header {
        padding: 1rem 0 1.5rem;
    }
    
    .header-banner {
        max-width: 320px;
    }
    
    .header-title {
        font-size: 1.8rem;
    }
    
    .header-subtitle {
        font-size: 0.95rem;
    }
    
    .search-container {
        max-width: 100%;
        padding: 0;
    }
    
    .search-input {
        font-size: 1rem;
        padding: 0.85rem 0.75rem;
    }
    
    .search-button {
        width: 48px;
        height: 48px;
    }
    
    .search-icon {
        width: 28px;
        height: 28px;
    }
    
    .tip-panel {
        max-width: 100%;
    }
    
    .tier-label {
        min-width: 85px;
        font-size: 0.9rem;
    }
    
    .tier-stats {
        min-width: 65px;
    }
}

/* Large screens */
@media (min-width: 1400px) {
    .app {
        width: 680px;
    }
}

