/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Source Serif 4', serif;
}

/* Body and background */
body {
    background: #0a0a1a;
    color: #e0e0ff;
}

/* Star background canvas - more flexible targeting */
canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

/* Specific override for graph canvases */
.graph-container canvas {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    max-height: 300px !important;
    z-index: 15 !important;
}

/* Alternative: if you want to be more specific about starfield */
#starfield-canvas, canvas[id*="starfield"], canvas[class*="starfield"] {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

/* Container for calculator, blog, and other content */
.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: calc(100vh - 60px);
    padding: 20px;
    position: relative;
    z-index: 10;
}

/* Calculator styles */
.calculator {
    background: rgba(10, 10, 26, 0.5);
    border-radius: 10px;
    padding: 20px;
    width: 90vw;
    max-width: 450px;
    box-shadow: 0 0 20px rgba(100, 100, 255, 0.2);
    z-index: 15;
    margin-bottom: 20px;
}

/* Tip calculator styles */
.tip-calculator {
    background: rgba(10, 10, 26, 0.5);
    border-radius: 10px;
    padding: 20px;
    width: 90vw;
    max-width: 450px;
    box-shadow: 0 0 20px rgba(100, 100, 255, 0.2);
    z-index: 15;
}

/* Graph container */
.graph-container {
    width: 90vw;
    max-width: 450px;
    margin: 10px auto;
    padding: 10px;
    background: rgba(10, 10, 26, 0.5);
    border-radius: 5px;
    z-index: 15;
}

.graph-container canvas {
    width: 100%;
    height: auto;
    max-height: 300px;
}

/* Graph ad */
.graph-ad {
    display: none;
    width: 100%;
    max-width: 450px;
    min-height: 90px;
    margin: 10px auto;
    background: rgba(255, 255, 255, 0.1);
    text-align: center;
    z-index: 8;
}

.graph-ad.visible {
    display: block;
}

/* Secret notes teaser styles */
.secret-teaser {
    background: rgba(10, 10, 26, 0.5);
    border-radius: 10px;
    padding: 20px;
    width: 90vw;
    max-width: 450px;
    box-shadow: 0 0 20px rgba(100, 100, 255, 0.2);
    text-align: center;
    z-index: 15;
}

/* Display styles */
.display {
    background: transparent;
    border-radius: 5px;
    padding: 20px 20px;
    margin-bottom: 10px;
    position: relative;
}

#result, #lastNumbers, #bill-amount {
    width: 100%;
    background: transparent;
    border: none;
    color: #e0e0ff;
    font-size: 24px;
    text-align: right;
    outline: none;
    cursor: pointer;
}

#steps {
    width: 120%;
    margin-left: -10%;
    background: transparent;
    border: none;
    color: #e0e0ff;
    font-size: 16px;
    text-align: right; /* Changed to left-align steps */
    outline: none;
    margin-bottom: 10px;
}

/* Copied! notification */
.copy-message {
    position: absolute;
    top: -30px;
    right: 10px;
    background: rgba(50, 140, 110, 0.8);
    color: #e0e0ff;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    z-index: 20;
    pointer-events: none;
    text-transform: lowercase;
}

.copy-message.show {
    opacity: 1;
}

/* Button grid */
.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
}

button {
    background: rgba(100, 100, 255, 0.2);
    border: none;
    padding: 15px;
    font-size: 18px;
    color: #e0e0ff;
    border-radius: 5px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    box-shadow: 0 0 5px rgba(100, 100, 255, 0.3);
    position: relative;
    overflow: hidden;
    z-index: 20;
    pointer-events: auto;
    text-transform: lowercase;
}

button::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(50, 140, 110, 0.5);
    opacity: 0;
    transition: opacity 0.1s;
}

button.flash::after {
    opacity: 1;
    transition: opacity 0.1s;
}

button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(50, 140, 110, 0.5);
}

button:active {
    transform: scale(0.95);
    box-shadow: 0 0 15px rgba(50, 140, 110, 0.8);
}

button.flash {
    transform: scale(0.95);
    box-shadow: 0 0 15px rgba(50, 140, 110, 0.8);
}

/* Operator buttons */
.operator {
    background: rgba(50, 140, 110, 0.3);
    box-shadow: 0 0 8px rgba(50, 140, 110, 0.4);
}

.operator:hover {
    box-shadow: 0 0 12px rgba(50, 140, 110, 0.6);
}

.operator:active {
    box-shadow: 0 0 15px rgba(50, 140, 110, 1);
}

/* Memory buttons */
.memory {
    background: rgba(150, 100, 255, 0.2);
}

/* 𝕏 button */
.x-button {
    background: #000000 !important;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
}

.x-button:hover {
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.7);
}

.x-button:active {
    box-shadow: 0 0 15px rgba(0, 0, 0, 1);
}

/* Ad placeholders */
.ad-placeholder {
    background: rgba(255, 255, 255, 0.1);
    color: #b0c4ff;
    text-align: center;
    font-size: 14px;
    z-index: 8;
}

.banner-ad {
    width: 100%;
    max-width: 728px;
    min-height: 90px;
    margin: 20px auto;
    background: rgba(255, 255, 255, 0.1);
    text-align: center;
    z-index: 8;
}

.bottom-ad {
    display: none;
    width: 100%;
    max-width: 728px;
    min-height: 90px;
    margin: 20px auto;
    background: rgba(255, 255, 255, 0.1);
    text-align: center;
    z-index: 8;
}

.bottom-ad.visible {
    display: block;
    position: static;
}

/* Random blog post */
.random-blog-post {
    width: 100%;
    max-width: 600px;
    margin: 20px auto;
    padding: 10px;
    background: rgba(10, 10, 26, 0.5);
    border-radius: 5px;
    text-align: left;
}

.read-more {
    color: #b0c4ff;
    text-decoration: none;
    font-size: 16px;
    text-transform: lowercase;
    transition: color 0.3s;
}

.read-more:hover {
    color: #a0d0ff;
}

/* Tip calculator table */
.tip-table {
    margin-top: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
    color: #e0e0ff;
    font-family: 'Source Serif 4', serif;
}

th, td {
    padding: 8px;
    text-align: right;
    border-bottom: 1px solid rgba(100, 100, 255, 0.2);
}

th {
    background: rgba(50, 140, 110, 0.3);
    font-weight: 700;
    text-transform: lowercase;
}

td {
    background: rgba(10, 10, 26, 0.5);
}

/* Emoji toggle */
.emoji-toggle {
    font-size: 24px;
    cursor: pointer;
    position: fixed;
    right: 20px;
    top: 70%;
    z-index: 25;
    animation: float 4s ease-in-out infinite;
    pointer-events: auto;
}

.emoji-toggle:hover {
    transform: scale(1.2);
}

@keyframes float {
    0% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0); }
}

/* Privacy policy and blog styles */
h1 {
    color: #e0e0ff;
    margin-bottom: 20px;
    font-family: 'Source Serif 4', serif;
    font-weight: 700;
}

h2 {
    color: #e0e0ff;
    font-family: 'Source Serif 4', serif;
    font-weight: 700;
    font-size: 20px;
    text-transform: lowercase;
    margin-bottom: 10px;
}

p {
    color: #b0c4ff;
    margin-bottom: 10px;
    font-family: 'Source Serif 4', serif;
}

article {
    display: block;
    width: 100%;
    max-width: 600px;
    margin-bottom: 30px;
    padding: 10px;
    background: rgba(10, 10, 26, 0.5);
    border-radius: 5px;
}

/* Navbar styles */
.navbar {
    background-color: #1a1a1a;
    padding: 10px;
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.menu-toggle {
    display: block;
    color: #e0e0ff;
    font-size: 1.5em;
    cursor: pointer;
    padding: 10px;
    background-color: #2a2a2a;
    border-radius: 5px;
    width: fit-content;
    margin: 0;
    transition: background-color 0.3s;
}

.menu-toggle:hover {
    background-color: #3a3a3a;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 50px;
    left: 10px;
    right: auto;
    background-color: rgba(40, 40, 104, 0.8);
    border: 1px solid #444;
    border-radius: 5px;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 1000;
    padding: 10px;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    width: 100%;
    max-width: 200px;
}

.dropdown-menu::-webkit-scrollbar {
    width: 8px;
}

.dropdown-menu::-webkit-scrollbar-track {
    background: rgba(10, 10, 26, 0.5);
    border-radius: 5px;
}

.dropdown-menu::-webkit-scrollbar-thumb {
    background: #b0c4ff;
    border-radius: 5px;
}

.dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: #e0e0ff;
}

/* Firefox scrollbar fallback */
.dropdown-menu {
    scrollbar-color: #b0c4ff rgba(10, 10, 26, 0.5);
    scrollbar-width: thin;
}

.dropdown-menu.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.dropdown-section {
    margin-bottom: 10px;
}

.dropdown-section h3 {
    color: #e0e0ff;
    font-size: 1.2em;
    margin: 10px 0 5px;
}

.dropdown-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.dropdown-section li {
    margin: 0;
}

.dropdown-section a {
    color: #b0c4ff;
    text-decoration: none;
    font-size: 1em;
    display: block;
    padding: 4px;
    border-radius: 3px;
    transition: background-color 0.2s;
}

.dropdown-section a:hover, .dropdown-section a.active {
    background-color: #e0e0ff;
    color: #1a1a1a;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
        align-items: center;
    }
    .calculator, .tip-calculator, .secret-teaser, .graph-container {
        margin: 10px;
    }
    .dropdown-menu {
        width: 100%;
        max-width: 200px;
        left: 10px;
        right: auto;
    }
    .dropdown-section {
        text-align: left;
    }
    .navbar {
        text-align: left;
    }
    .menu-toggle {
        margin: 0;
    }
}

@media (min-width: 769px) {
    .menu-toggle:hover + .dropdown-menu, .dropdown-menu:hover {
        display: block;
        opacity: 1;
        transform: translateY(0);
    }
    .dropdown-menu {
        width: 100%;
        max-width: 200px;
        left: 10px;
        right: auto;
        display: grid;
        grid-template-columns: 1fr;
        gap: 0;
    }
    .dropdown-section {
        border-right: none;
        padding-right: 0;
    }
    .emoji-toggle {
        right: calc(50% + 220px);
        top: 50%;
    }
}