:root {
    --bg-color: #ffffff;
    --text-color: #000000;
    --primary-yellow: #FFD700;
    --primary-yellow-hover: #e6c200;
    --dark-section: #000000;
    --gray-light: #ffffff;
    --gray-mid: #000000;
    --correct-color: #22c55e; /* Green for valid */
    --wrong-color: #ef4444;   /* Red for error */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --transition: all 0.2s ease-in-out;
}

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

html, body {
    height: 100vh;
    width: 100vw;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
}

/* Typography */
h1, h2, h3, h4 {
    font-weight: 800;
    letter-spacing: -0.025em;
}

.text-yellow { color: var(--primary-yellow); }

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background-color: var(--dark-section);
    color: white;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo h1 {
    font-size: 1.5rem;
    color: white;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.admin-link {
    color: var(--gray-mid);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    transition: var(--transition);
}

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

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
}

.hidden { display: none !important; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    gap: 0.5rem;
    font-size: 1rem;
}

.btn-primary {
    background-color: var(--primary-yellow);
    color: var(--dark-section);
}

.btn-primary:hover {
    background-color: var(--primary-yellow-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--dark-section);
    color: white;
}

.btn-secondary:hover {
    background-color: #1e293b;
    transform: translateY(-2px);
}

.btn-icon {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
}

.btn-icon:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Loader */
.loader {
    border: 4px solid var(--gray-light);
    border-top: 4px solid var(--primary-yellow);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 3rem auto;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Cards Grid */
.hero {
    text-align: center;
    margin-bottom: 3rem;
}

.hero h2 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.hero p {
    color: var(--gray-mid);
    font-size: 1.125rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.category-card {
    background-color: white;
    border: 2px solid var(--dark-section);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.category-card:hover {
    border-color: var(--primary-yellow);
    box-shadow: var(--shadow-lg);
    background-color: var(--dark-section);
    color: white;
    transform: translateY(-5px);
}

.category-card i {
    color: var(--primary-yellow);
    width: 48px;
    height: 48px;
}

.category-card h3 {
    font-size: 1.25rem;
}

/* Game View */
#game-view:not(.hidden) {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.zone-top {
    flex: 0 0 45vh; /* Fixed 45% top zone */
    display: flex;
    flex-direction: column;
    justify-content: center; /* keep contents centered */
    position: relative;
    padding-bottom: 0.5rem;
}

#quiz-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    align-items: center;
    position: relative;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--gray-light);
}

.score-display {
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
    background-color: var(--dark-section);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    border: 2px solid var(--primary-yellow);
}

/* Triangle Layout */
.triangle-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    height: 350px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: var(--transition);
    flex-shrink: 0;
    transform: scale(0.9); /* slight scale to fit 45vh better globally */
}

/* The SVG Triangle shape */
.triangle-svg {
    width: 340px;
    height: 294px;
    position: relative;
    z-index: 1; /* keep behind the text */
}

.triangle-polygon {
    fill: var(--dark-section);
    transition: fill 0.4s ease;
}

.triad-name {
    position: absolute;
    top: 55%; 
    left: 50%;
    transform: translate(-50%, -50%); /* Center over SVG */
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 60%; /* Strict user requirement */
    height: 30%; /* Strict user requirement */
    color: var(--primary-yellow);
    font-weight: 800;
    font-size: clamp(12px, 3vw, 16px); /* Normalized typography */
    text-transform: uppercase;
    z-index: 10;
    word-break: break-word;
    line-height: 1.2;
    margin: 0;
}

/* Triangle Status colors */
.triangle-container.success .triangle-polygon {
    fill: var(--correct-color);
}
.triangle-container.success .triad-name {
    color: white;
}
.triangle-container.error .triangle-polygon {
    fill: var(--wrong-color);
}
.triangle-container.error .triad-name {
    color: white;
}

.slot {
    position: absolute;
    width: 140px;
    padding: 0.5rem;
    background: white;
    border: 2px dashed var(--dark-section);
    border-radius: var(--radius-md);
    text-align: center;
    font-size: 14px; /* Normalized size */
    font-weight: 600;
    color: var(--dark-section);
    box-shadow: var(--shadow-sm);
    z-index: 20;
    transition: var(--transition);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 45px;
    word-break: break-word;
    line-height: 1.1;
}

.slot.filled {
    border: 2px solid var(--primary-yellow);
    background-color: var(--primary-yellow);
    color: var(--dark-section);
    cursor: pointer;
}

.slot.filled:hover {
    background-color: #fde047;
    transform: scale(1.05); /* allow quick removal if tapped */
}

.slot.correct-reveal {
    border: 2px solid var(--correct-color);
    background-color: var(--correct-color);
    color: white;
}

/* Position the slots around the css triangle */
.slot-top {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

.slot-left {
    bottom: 20px;
    left: 10%;
}

.slot-right {
    bottom: 20px;
    right: 10%;
}

/* Feedback Overlay */
.feedback-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: 800;
    text-shadow: 0 4px 6px rgba(0,0,0,0.3);
    z-index: 30;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.feedback-overlay.success-text { color: var(--correct-color); }
.feedback-overlay.error-text { color: var(--wrong-color); }

@keyframes popIn {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* Proposals Container */
.zone-bottom {
    flex: 1; /* Take up remaining 55% */
    display: flex; /* Helps filling inner content */
    flex-direction: column;
    overflow: hidden; /* Prevent this wrap container from scrolling */
}

.proposals-container {
    height: 100%;
    overflow-y: auto; /* Only proposals scroll */
    -webkit-overflow-scrolling: touch;
    padding: 1rem;
    padding-bottom: 3rem;
    background-color: white;
    border-top: 2px solid var(--dark-section);
}

.proposals-container h4 {
    margin-bottom: 1rem;
    text-align: center;
    font-size: 18px; /* Normalized header */
}

.proposals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.proposal-btn {
    background-color: white;
    border: 2px solid var(--dark-section);
    color: var(--dark-section);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    font-size: 14px; /* Normalized */
    transition: var(--transition);
    text-align: center;
    min-height: 44px; /* Slightly reduced to prevent huge grids */
    display: flex;
    align-items: center;
    justify-content: center;
    word-break: break-word;
    line-height: 1.2;
    overflow: hidden;
}

.proposal-btn:hover:not(:disabled) {
    background-color: var(--dark-section);
    color: white;
    border-color: var(--dark-section);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.proposal-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background-color: white;
}

/* Confirmation Section */
.confirmation-section {
    width: 100%;
    text-align: center;
    flex-shrink: 0;
    position: absolute;
    bottom: -15px;
    left: 0;
    z-index: 50;
}

/* End Screen replacement in Bottom Zone */
.end-screen {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center horizontally in bottom zone */
    align-items: center;
    background-color: white;
    position: relative;
    z-index: 100;
    padding: 2rem 1rem;
}

.end-screen h2 {
    font-size: 24px;
    margin-bottom: 1.5rem;
}

.final-score-circle {
    width: 120px; /* Reduced to fit mobile bottom zone easily */
    height: 120px;
    border-radius: 50%;
    background-color: var(--dark-section);
    color: var(--primary-yellow);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 0 auto 2rem auto;
    border: 6px solid var(--primary-yellow);
    box-shadow: var(--shadow-md);
}

#final-score-value {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
}

.out-of {
    font-size: 1.5rem;
    color: white;
}

.actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    header { padding: 1rem; }
    main.container { padding: 1rem; }
    
    .game-header { margin-bottom: 1rem; padding-bottom: 0.5rem; }
    
    /* Responsive Proposals Grid (2 columns on mobile) */
    .proposals-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    
    .proposal-btn {
        padding: 0.5rem;
        font-size: 0.85rem;
        min-height: 50px;
    }

    .proposals-container {
        padding: 0.5rem;
        height: 100%;
        border-top: 3px solid var(--dark-section);
        border-radius: 1rem 1rem 0 0;
    }

    .zone-top {
        flex: 0 0 45vh; /* Keep exact proportion */
    }

    /* Scaling the triangle down for mobile */
    .triangle-container {
        height: 180px;
        max-width: 100%;
        margin-bottom: 0;
        transform: scale(0.85); /* Keep original bounding box but scale visually */
    }
    
    .triangle-svg {
        width: 180px;
        height: 155px;
    }

    .triad-name {
        /* Already handled by top:55% / left:50% absolute centering! */
        /* Just keeping clamp from above */
        width: 100%;
        max-width: 80%;
    }

    .slot {
        width: 100px;
        font-size: 0.75rem;
        padding: 0.3rem;
        min-height: 35px;
    }
    
    .slot-top { top: -20px; }
    .slot-left { left: -10%; bottom: -10px; }
    .slot-right { right: -10%; bottom: -10px; }
    
    .confirmation-section {
        bottom: 0px;
    }

    .confirmation-section .btn {
        font-size: 1rem;
        padding: 0.5rem;
    }
    
    .logo h1 { font-size: 1.25rem; }
}
