:root {
    /* Theme: Ocean Night */
    --primary: #2B4C7E;
    --primary-dark: #1B325F;
    --background: #0A192F;
    --surface: #172A45;
    --text: #FFFFFF;
    --text-secondary: #CCD6F6;
    --accent: #46ab93;
    --nav-bg: rgba(11, 25, 47, 0.95);
    --radius: 1.25rem;
    --gradient-light: linear-gradient(135deg, #172A45 0%, #1B325F 100%);
    --shadow-soft: 0 20px 40px rgba(10, 25, 47, 0.3);
    --accent-soft: #64FFDA;
    --accent-muted: rgba(100, 255, 218, 0.1);
    
    /* Theme-specific Variables */
    --glow-effect: 0 0 15px rgba(100, 255, 218, 0.1);
    --card-border: 1px solid rgba(100, 255, 218, 0.2);
    --hover-transform: translateY(-5px);
    --gradient-accent: linear-gradient(135deg, #64FFDA 0%, #3CAEA3 100%);
    --text-gradient: linear-gradient(135deg, #E6F1FF 0%, #8892B0 100%);
    
    /* Additional Theme Colors */
    --highlight: #FF5E5B;
    --secondary-accent: #5D5DFF;
    --success: #3CAEA3;
    --warning: #FFB347;
    
    /* Background Patterns */
    --bg-noise: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%' height='100%' filter='url(%23noise)' opacity='0.05'/%3E%3C/svg%3E");
    --bg-grid: linear-gradient(rgba(100, 255, 218, 0.1) 1px, transparent 1px),
               linear-gradient(90deg, rgba(100, 255, 218, 0.1) 1px, transparent 1px);
}   

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--background);
    background-image: var(--bg-grid), var(--bg-noise);
    background-attachment: fixed;
    background-size: 50px 50px, 200px 200px;
    color: var(--text);
    font-family: 'Inter', sans-serif;
}
nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 2rem;
    background: var(--nav-bg);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(100, 255, 218, 0.1);
    box-shadow: 0 2px 20px rgba(10, 25, 47, 0.3);
    z-index: 1000;
}

.nav_logo {
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 2em;
    font-weight: 700;
    letter-spacing: -0.5px;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #80a9e6 0%, var(--secondary-accent) 90%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav_logo:hover {
    transform: scale(1.02);
    color: var(--accent);   
}

.nav_buttons {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    margin-left: auto;
    padding: 0.3rem;
    border-radius: 0.75rem;
}

.nav_items {
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s ease;
    padding: 0.5rem 1.2rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    background: transparent;
}

.nav_items a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s ease;
}

.nav_items:hover {
    background: var(--surface);
    transform: translateY(-1px);
    border: 1px solid var(--accent-muted);
}

.nav_items:hover a {
    color: var(--accent);
}

/* Hamburger button - hidden on desktop, visible on phone */
.nav_toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 1.6rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
}

/* Mobile: hamburger appears at phone level (<=768px) */
@media (max-width: 768px) {
    .nav_toggle {
        display: block;
        position: absolute;
        right: 1rem;
        top: 50%;
        transform: translateY(-50%);
        z-index: 1100;
    }

    /* hide nav buttons by default */
    .nav_buttons {
        display: none !important;
    }

    /* when menu is opened, show centered column */
    nav.nav-open .nav_buttons {
        display: flex !important;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        width: 100%;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        padding: 1rem 0;
        background: var(--nav-bg);
        border-bottom: 1px solid rgba(100, 255, 218, 0.1);
    }

    .nav_items {
        width: auto;
        text-align: center;
    }
}

.layout {
    display: flex;
    flex-direction: column;
    padding: 7rem 2rem 4rem;
    justify-content: flex-end;
    gap: 3rem;
    max-width: 1200px;
    margin: 0 auto;
}

.counter_screen {
    background: var(--surface);
    min-height: 150px;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(100, 255, 218, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    transition: all 0.3s ease;
    padding: 1rem;
    position: relative;
    overflow: hidden;
    background-size: 30px 30px;
}

.counter_screen:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(10, 25, 47, 0.3);
    border-color: var(--accent);
}

.num {
    font-size: 8rem;
    font-weight: 700;
    color: var(--accent);
    transition: color 0.3s ease;
}
.control_panel {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    gap: 2rem;
    min-width: 50rem;
    min-height: 25rem;
}

.counter_action{
    display: flex;
    flex-direction: row;
}
.action_buttons {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2rem;
    background: var(--surface);
    padding: 2em;
    border-radius: var(--radius);
    border: 1px solid var(--accent);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.button {
    border: 1px solid rgba(100, 255, 218, 0.2);
    border-radius: var(--radius);
    font-size: 3rem;
    background: var(--surface);
    color: var(--accent);
    box-shadow: var(--shadow-soft);
    transition: all 0.3s ease;
    min-height: 120px;
    min-width: 100px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.button:hover {
    transform: translateY(-2px);
    background: var(--accent);
    color: var(--background);
       box-shadow: 0 6px 20px rgba(23, 59, 50, 0.2);    
    border-color: var(--accent);
}

.property_panel {
    background: var(--surface);
    border: 1px solid rgba(100, 255, 218, 0.2);
    display: flex;
    flex-direction: column;
    width: 40rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    transition: all 0.3s ease;
    background: linear-gradient(to bottom, var(--surface), rgba(23, 42, 69, 0.8));
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(8px);
}

.property_panel:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(44, 62, 80, 0.08);
    border-color: var(--accent-soft);
}
.panel {
    display: flex;
    flex-direction: row;
    padding: 1.5em 2em;
    justify-content: flex-start;
    gap: 30px;
    align-items: center;
    border-bottom: 1px solid var(--accent);
}

.panel:last-child {
    border-bottom: none;
}

.label {
    font-family: 'Inter', sans-serif;
    padding-right: 0.3rem;
    font-size: 1.2rem;
    color: var(--text);
    font-weight: 500;
}

#input {
    background: rgba(23, 42, 69, 0.8);
    border: 1px solid rgba(100, 255, 218, 0.2);
    border-radius: var(--radius);
    padding: 1em 1.2em;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    color: var(--text);
    transition: all 0.3s ease;
}

#input:hover {
    border-color: var(--accent-soft);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.1);
}

#input:focus {
    outline: none;
    border-color: var(--accent-soft);
    background: var(--surface);
    box-shadow: 0 6px 16px rgba(52, 152, 219, 0.15);
}

/* Remove spinner buttons from number inputs */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.auto_button,
.reset_button,
.series_button,
.start_button,
.infinity_button {
    border-radius: var(--radius);
    font-family: 'Inter', sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    padding: 0.8em 1.8em;
    background: var(--surface);
    color: var(--accent);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid var(--accent);
    box-shadow: var(--shadow-soft);
    position: relative;
    overflow: hidden;
}

.auto_button:hover,
.reset_button:hover,
.series_button:hover,
.start_button:hover,
.infinity_button:hover {
    background: var(--accent);
    color: var(--background);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(23, 59, 50, 0.2);
}

.func_box {
    width: 12rem;
    margin-top: 10px;
}

.x_display,.out_display{
    background: var(--gradient-light);
    min-width: 150px;
    min-height: 70px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--accent);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    font-family: 'Inter', sans-serif;
    font-size: 1.2rem;
    padding: 1.8em;
    white-space: pre;
    color: var(--text);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.x_display:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.08);
}

.graph_box {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding-bottom:  2rem;
    width: 90%;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1em;
    padding-right: 1em;
}


canvas {
    /* let the canvas fill its container but cap the width for very large screens */
    width: 100%;
    max-width: 1200px;
    /* Prefer a taller minimum so charts look balanced in desktop windows */
    aspect-ratio: 16 / 9;
    height: auto;
    min-height: 100px;
    max-height: 500px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--accent-muted);
    padding: 0.3rem;
    display: block;
    margin: 0 auto;
}

/* Specific layout for the landing page graph section so the chart doesn't look squeezed */
.graph_section {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto 3rem;
    padding: 0 1rem;
}

.graph_section canvas {
    /* occupy most of the available width but leave room for the info column */
    width: 65%;
    min-height: 420px; /* slightly taller on landing */
    max-height: 800px;
    margin: 0;
}

.graph_section .graph_info {
    width: 35%;
    max-width: 420px;
}

@media (max-width: 1024px) {
    .layout {
        padding: 6rem 1.5rem 3rem;
        gap: 2rem;
    }

    .control_panel {
        flex-direction: column;
        min-width: auto;
        gap: 1.5rem;
    }

    .property_panel {
        width: 100%;
    }

    .graph_box {
        grid-template-columns: 1fr;
        width: 100%;
        padding: 0;
    }
    canvas { 
        min-height: 320px;
        width: 100%;
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .layout {
        padding: 5rem 1rem 4rem 1rem;
    }

    .graph_box {
        width: 100%;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        max-width: 100%;
    }

    nav {
        padding: 0.5rem 1rem;
        /* stack nav on smaller screens */
        flex-direction: column;
        align-items: flex-start;
        gap: 0.4rem;
    }

    .nav_logo {
        font-size: 1.5em;
        padding: 0.4rem 0.8rem;
    }

    .nav_buttons {
        gap: 1rem;
    }

    .nav_items {
        font-size: 0.9rem;
        padding: 0.4rem 0.8rem;
    }

    /* make nav buttons full-width and stacked for easy tapping */
    .nav_buttons {
        flex-direction: column;
        width: 100%;
        margin-left: 0;
        padding: 0.25rem 0;
    }

    .nav_items {
        width: 100%;
        padding-left: 0.6rem;
        border-radius: 0.5rem;
    }

    .counter_action {
        flex-direction: column;
        gap: 1.5rem;
    }

    .action_buttons {
        flex-direction: row;
        padding: 1.5em;
        justify-content: center;
        width: 100%;
    }

    .button {
        font-size: 2rem;
        min-width: 80px;
        max-height: 80px;
    }

    .counter_screen {
        min-height: 200px;
        padding: 1.5rem;
    }

    .num {
        font-size: 5rem;
    }

    .panel {
        flex-wrap: wrap;
        padding: 1.2em 1.5em;
        gap: 20px;
    }

    #input {
        padding: 0.8em 1em;
    }

    .auto_button,
    .reset_button,
    .series_button {
        font-size: 1rem;
        padding: 0.6em 1.4em;
    }

    .x_display,
    .out_display {
        min-height: 60px;
        font-size: 1rem;
        padding: 1.4em;
    }

    canvas {
        /* smaller minimum for narrow screens but keep aspect ratio */
        min-height: 220px;
        max-height: 420px;
        width: 100%;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .layout {
        padding: 5rem 1rem 2rem;
    }

    .action_buttons {
        padding: 1em;
        gap: 1rem;
    }

    .button {
        font-size: 1.5rem;
        min-width: 60px;
        max-height: 60px;
    }

    .counter_screen {
        min-height: 150px;
    }

    .num {
        font-size:3rem;
    }

    .panel {
        padding: 1em;
        gap: 15px;
    }

    .label {
        font-size: 1rem;
    }

    #input {
        font-size: 0.9rem;
        padding: 0.7em 0.9em;
    }

    .func_box {
        width: 100%;
    }

    .x_display,
    .out_display {
        min-height: 50px;
        font-size: 0.9rem;
        padding: 1.2em;
        min-width: 120px;
    }

    canvas {
        min-height: 160px;
        max-height: 300px;
    }
}

/* Large screens / TV sizes: keep graphs readable and not overly stretched */
@media (min-width: 1600px) {
    .graph_box {
        max-width: 1600px;
        gap: 3rem;
        align-items: center;
        justify-content: center;
    }

    canvas {
        min-height: 520px;
        max-height: 1100px;
        aspect-ratio: 16 / 9;
    }
}