* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background: linear-gradient(-45deg, #f3e7e9, #e3eeff, #e0c3fc, #8ec5fc);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 1rem 2rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-weight: 700;
    font-size: 1.25rem;
    color: #1a73e8;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    gap: 2rem;
    transition: all 0.6s cubic-bezier(0.25, 1, 0.5, 1);
    justify-content: center;
    animation: pageLoad 0.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes pageLoad {
    0% { opacity: 0; transform: translateY(20px) scale(0.98); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Ensure centering happens without overflowing on short screens */
main:not(.has-results) .calculator-container {
    margin-top: auto;
    margin-bottom: auto;
}

main.has-results {
    flex-direction: row;
    align-items: flex-start;
}

@media (max-width: 768px) {
    main.has-results {
        flex-direction: column;
        align-items: center;
    }
}

.calculator-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    width: 100%;
    max-width: 450px;
    max-height: 90vh;
    overflow-y: auto;
}

h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: #666;
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.input-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
}

input, select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
}

button {
    width: 100%;
    padding: 0.75rem;
    background-color: #1a73e8;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

button:hover {
    background-color: #1557b0;
}

.result-box {
    margin-top: 1.5rem;
    padding: 1rem;
    background-color: #e8f0fe;
    border-radius: 4px;
    text-align: center;
}

.hidden {
    display: none;
}

/* --- METAMORPHOSIS ANIMATIONS --- */
.calculator-container,
.calculator-container h1,
.calculator-container .subtitle,
.calculator-container label,
.calculator-container input,
.calculator-container select,
.calculator-container button {
    transition: all 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

main.has-results .calculator-container {
    max-width: 320px;
    padding: 1.5rem;
}

main.has-results .calculator-container h1 { font-size: 1.4rem; }
main.has-results .calculator-container .subtitle { font-size: 0.8rem; margin-bottom: 1.2rem; }
main.has-results .calculator-container label { font-size: 0.8rem; margin-bottom: 0.3rem; }

main.has-results .calculator-container input,
main.has-results .calculator-container select,
main.has-results .calculator-container button { 
    padding: 0.5rem; 
    font-size: 0.85rem; 
}

/* --- PREMIUM DASHBOARD LAYOUT --- */
.dashboard-container {
    display: none;
    flex-direction: column;
    gap: 1.25rem;
    width: 100%;
    max-width: 550px;
}

main.has-results .dashboard-container {
    display: flex;
    animation: revealDashboard 0.6s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes revealDashboard {
    0% { opacity: 0; transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1); }
}

.dashboard-main-chart {
    background: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.dashboard-stat-card {
    background: #fff;
    padding: 1.25rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.dashboard-stat-card .stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a73e8;
    margin-bottom: 0.25rem;
    word-break: break-all;
}

.dashboard-stat-card .stat-label {
    font-size: 0.8rem;
    color: #555;
}

/* Legacy chart containers (for older calculators not yet upgraded) */
.chart-container, .stats-grid-container {
    display: none;
    background: #fff;
    padding: 2.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 450px;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    max-height: 90vh;
    overflow-y: auto;
}

main.has-results .chart-container,
main.has-results .stats-grid-container {
    display: block;
    opacity: 1;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.stat-card {
    background: #e8f0fe;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}
.stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1a73e8;
}
.stat-label {
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.25rem;
}

.chart-explanation {
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: #555;
    text-align: center;
    line-height: 1.5;
}

footer {
    text-align: center;
    padding: 1.5rem;
    font-size: 0.85rem;
    color: #666;
    background-color: #fff;
    border-top: 1px solid #eee;
}

/* --- ANIMATED INFO PANELS --- */
.animated-panel {
    animation: fadeInRight 0.6s cubic-bezier(0.25, 1, 0.5, 1) forwards;
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1.5rem;
    border-left: 4px solid #1a73e8;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    text-align: left;
}

@keyframes fadeInRight {
    0% { opacity: 0; transform: translateX(20px); }
    100% { opacity: 1; transform: translateX(0); }
}

/* --- DASHBOARD GRID LAYOUT (True Honeycomb) --- */
.dashboard-tiles-container {
    width: 100%;
    max-width: 1600px;
    text-align: center;
    margin: auto;
}

.dashboard-tiles-container h1 {
    font-size: 2.25rem;
    margin-bottom: 0.5rem;
}

.dashboard-tiles-container .subtitle {
    font-size: 1.1rem;
    margin-bottom: 2.5rem;
}

.dashboard-grid {
    --hex-gap: 5px;
    --tile-w: 220px;
    --tile-h: calc(var(--tile-w) * 1.1547); /* perfect pointy-top hex ratio */

    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 0 4rem;
    
    display: grid;
    grid-template-columns: repeat(10, calc((var(--tile-w) + var(--hex-gap)) / 2));
    grid-auto-rows: calc((var(--tile-h) * 0.75) + (var(--hex-gap) * 0.866));
    justify-content: center;
    justify-items: center;
    gap: 0;
}

.dashboard-tile:nth-child(9n + 1) { grid-column: 1 / span 2; }
.dashboard-tile:nth-child(9n + 2) { grid-column: 3 / span 2; }
.dashboard-tile:nth-child(9n + 3) { grid-column: 5 / span 2; }
.dashboard-tile:nth-child(9n + 4) { grid-column: 7 / span 2; }
.dashboard-tile:nth-child(9n + 5) { grid-column: 9 / span 2; }
.dashboard-tile:nth-child(9n + 6) { grid-column: 2 / span 2; }
.dashboard-tile:nth-child(9n + 7) { grid-column: 4 / span 2; }
.dashboard-tile:nth-child(9n + 8) { grid-column: 6 / span 2; }
.dashboard-tile:nth-child(9n + 9) { grid-column: 8 / span 2; }

/* Center the 28th solo tile (28 % 9 = 1) */
.dashboard-tile:last-child:nth-child(9n + 1) {
    grid-column: 5 / span 2;
}

.dashboard-tile {
    width: var(--tile-w);
    height: var(--tile-h);
    filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.12));
    text-decoration: none;
    color: #333;
    transition: transform 0.25s ease, filter 0.25s ease;
    outline: none;
}

.dashboard-tile:hover {
    transform: translateY(-6px);
    filter: drop-shadow(0 10px 24px rgba(42, 102, 248, 0.18));
    z-index: 2;
}

.hex-content {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    /* Asymmetric padding keeps the text away from the pointy top/bottom
       edges where clip-path narrows the visible area. */
    padding: 2.5rem 1.5rem;
    transition: background 0.3s ease;
}

.tile-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
    transition: transform 0.3s ease;
}

.dashboard-tile:hover .tile-icon {
    transform: scale(1.15) rotate(5deg);
}

.dashboard-tile:hover .hex-content {
    background: rgba(232, 240, 254, 0.95);
}

.hex-content h2 {
    font-size: 1.35rem;
    color: #1a73e8;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.hex-content p {
    font-size: 0.85rem;
    color: #666;
}

@media (max-width: 1180px) {
    .dashboard-grid {
        --tile-w: 180px;
    }
}

@media (max-width: 980px) {
    .dashboard-grid {
        --tile-w: 150px;
    }
}

@media (max-width: 820px) {
    .dashboard-grid {
        --tile-w: 130px;
    }

    .hex-content h2 { font-size: 1rem; }
    .hex-content p  { font-size: 0.7rem; }
    .tile-icon      { font-size: 2rem; }
}

@media (max-width: 640px) {
    /* On phones, abandon the tessellation — the cells become too small
       to be usable. Fall back to a clean responsive single column. */
    .dashboard-grid {
        --tile-w: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
    }

    .dashboard-tile {
        width: 100%;
        max-width: 320px;
        height: auto;
        aspect-ratio: 240 / 278;
        filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.1));
    }
}

/* --- SCROLL PLANT LADDER --- */
#plant-ladder {
    position: fixed;
    top: 100px;
    right: 30px;
    bottom: 40px;
    width: 50px;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

@media (max-width: 1024px) {
    #plant-ladder {
        display: none; /* Hide on smaller screens to avoid overlap */
    }
}

.plant-stem {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    background: linear-gradient(to bottom, #81c784, #2e7d32);
    height: 0%;
    border-radius: 2px;
    transition: height 0.15s ease-out;
}

.plant-stem::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(50%);
    width: 10px;
    height: 10px;
    background: #a5d6a7;
    border-radius: 50%;
    box-shadow: 0 0 10px #a5d6a7;
}

.plant-leaf {
    position: absolute;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #a5d6a7, #2e7d32);
    border-radius: 0 50% 0 50%;
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.plant-leaf::before {
    content: '';
    position: absolute;
    width: 1.5px;
    height: 140%;
    background: rgba(255,255,255,0.4);
    top: -20%;
    left: 50%;
    transform: rotate(-45deg);
}

.plant-leaf.left {
    right: calc(50% - 2px);
    margin-top: -24px;
    transform-origin: bottom right;
    transform: scale(0) rotate(-45deg);
    box-shadow: -2px 2px 4px rgba(0,0,0,0.1);
}

.plant-leaf.right {
    left: calc(50% - 2px);
    margin-top: -24px;
    transform-origin: bottom left;
    transform: scale(0) rotate(45deg) scaleX(-1);
    box-shadow: -2px 2px 4px rgba(0,0,0,0.1);
}

.plant-leaf.left.grown {
    opacity: 1;
    transform: scale(1) rotate(-10deg);
}

.plant-leaf.right.grown {
    opacity: 1;
    transform: scale(1) rotate(10deg) scaleX(-1);
}

/* --- MARIO CLIMBER --- */
.mario-climber {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 26px;
    margin-top: -13px; /* Centers Mario right on the growing tip */
    transition: top 0.15s ease-out, transform 0.2s ease;
    z-index: 10;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    user-select: none;
}
