:root {
    --primary: #c19a6b;
    /* Fallow wood */
    --secondary: #4a5d4e;
    /* Forest Green */
    --bg-dark: #121412;
    --card-bg: rgba(255, 255, 255, 0.05);
    --text-main: #f0f0f0;
    --text-dim: #a0a0a0;
    --accent: #ffd700;
    --glass-border: rgba(255, 255, 255, 0.1);
}

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

body {
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

.background-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 50% 50%, #1e251e 0%, #0d0f0d 100%);
    z-index: -1;
}

.container {
    width: 100%;
    max-width: 800px;
    padding: 2rem;
    animation: fadeIn 0.8s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-dim);
    font-weight: 300;
}

.author-credits {
    margin-top: 1.2rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    letter-spacing: 0.02em;
}

.text-small {
    font-size: 0.85rem;
    opacity: 0.8;
}

.lab-link {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 4px;
    font-weight: 600;
    transition: all 0.3s ease;
    padding: 2px 4px;
    border-radius: 4px;
}

.lab-link:hover {
    color: var(--accent);
    background: rgba(255, 215, 0, 0.05);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.calculator-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.input-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.full-width {
    grid-column: span 2;
}

label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.limit-hint {
    font-size: 0.7rem;
    color: var(--primary);
    opacity: 0.8;
    text-transform: none;
    font-weight: 400;
}

input,
select {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.8rem 1rem;
    color: var(--text-main);
    font-size: 1rem;
    transition: all 0.3s ease;
}

select option {
    background-color: #1a1e1a;
    /* Explicit dark background for options */
    color: #ffffff;
    /* Explicit white text for options */
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 0 4px rgba(193, 154, 107, 0.1);
}

/* Error States */
.input-group.error-state input {
    border-color: #ff4d4d;
    background: rgba(255, 77, 77, 0.05);
    box-shadow: 0 0 0 4px rgba(255, 77, 77, 0.1);
}

.input-group.error-state .limit-hint {
    color: #ff4d4d;
    font-weight: 700;
    opacity: 1;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-2px);
    }

    75% {
        transform: translateX(2px);
    }
}

.result-display {
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 2rem;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.visualizer-container {
    height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    overflow: hidden;
}

.log-visual {
    display: flex;
    align-items: center;
    transform: rotate(-5deg);
    transition: transform 0.5s ease;
}

.log-body {
    height: 60px;
    width: 200px;
    background: linear-gradient(to bottom, #8b5a2b, #4d2d18);
    transition: all 0.3s ease;
    clip-path: polygon(0% 20%, 100% 0%, 100% 100%, 0% 80%);
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

.log-end {
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.2);
}

.log-end.bottom {
    /* Right side: Tree rings */
    background: repeating-radial-gradient(circle at 50% 50%,
            #e4cfb1 0px,
            #d2b48c 2px,
            #c5a175 4px);
    border: none;
    box-shadow: -2px 0 0 #8b4513;
    /* Boundary line with the body */
    height: 60px;
    width: 30px;
    margin-left: -15px;
    z-index: 1;
    filter: brightness(0.9);
}

.result-item.main {
    text-align: center;
}

.result-item.main .label {
    display: block;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.value-container {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.5rem;
}

#weightVal {
    font-size: 4rem;
    font-weight: 700;
    color: var(--primary);
    text-shadow: 0 0 20px rgba(193, 154, 107, 0.3);
}

.unit {
    font-size: 1.5rem;
    color: var(--text-dim);
}

.result-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.detail-item {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
}

.detail-item .label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 0.25rem;
}

.detail-item .value {
    font-size: 1.25rem;
    font-weight: 600;
}

footer {
    margin-top: 2rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-dim);
}

@media (max-width: 600px) {
    .input-grid {
        grid-template-columns: 1fr;
    }

    .full-width {
        grid-column: span 1;
    }

    #weightVal {
        font-size: 3rem;
    }
}

.main-clear-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-dim);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.8rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.main-clear-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border-color: var(--primary);
}