:root {
    --bg-color: #0B0F19;
    --panel-bg: rgba(255, 255, 255, 0.03);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-main: #FFFFFF;
    --text-muted: #8B9BB4;
    --accent: #00E5FF;
    --tape-yellow: #FFD600;
    --tape-line: #000000;
    --indicator-red: #FF3B30;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    overflow-x: hidden;
    background-image:
        radial-gradient(circle at 15% 50%, rgba(0, 229, 255, 0.04), transparent 30%),
        radial-gradient(circle at 85% 30%, rgba(255, 214, 0, 0.03), transparent 30%);
}

.app-container {
    max-width: 1000px;
    width: 100%;
}

header {
    text-align: center;
    margin-bottom: 2rem;
    animation: fadeInDown 0.8s ease-out;
}

header h1 {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -1px;
}

.highlight {
    color: var(--accent);
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-top: 0.5rem;
}

.search-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 2rem;
    animation: fadeInDown 0.9s ease-out;
}

#segment-search {
    background: #000;
    border: 1px solid var(--panel-border);
    color: var(--text-main);
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    font-size: 1.1rem;
    width: 350px;
    outline: none;
    transition: border-color 0.3s;
}

#segment-search:focus {
    border-color: var(--accent);
}

#search-btn {
    background: var(--tape-yellow);
    color: #000;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.2s;
}

#search-btn:hover {
    transform: scale(1.05);
}

.display-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    margin-bottom: 3rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#current-measurement-text {
    font-size: 4.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--tape-yellow);
    text-shadow: 0 0 20px rgba(255, 214, 0, 0.3);
    font-variant-numeric: tabular-nums;
}

.fraction sup {
    font-size: 0.55em;
    vertical-align: top;
    position: relative;
    top: -0.2em;
}

.fraction sub {
    font-size: 0.55em;
    vertical-align: baseline;
    position: relative;
    top: 0.2em;
}

#measurement-detail {
    font-size: 1.2rem;
    color: var(--text-muted);
    font-weight: 400;
}

.tape-viewport-wrapper {
    position: relative;
    width: 100%;
    height: 200px;
    margin: 0 auto 2rem auto;
    background: #111;
    border-radius: 16px;
    box-shadow: inset 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 0 1px var(--panel-border);
    overflow: hidden;
}

.tape-viewport {
    width: 100%;
    height: 100%;
    position: relative;
    cursor: grab;
}

.tape-viewport:active {
    cursor: grabbing;
}

.measurement-indicator {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: var(--indicator-red);
    transform: translateX(-50%);
    z-index: 5;
    box-shadow: 0 0 15px rgba(255, 59, 48, 0.9);
    pointer-events: none;
}

.measurement-indicator::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 20px solid var(--indicator-red);
}

.measurement-indicator::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-bottom: 20px solid var(--indicator-red);
}

.tape-draggable {
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background: linear-gradient(to bottom, #FFE800 0%, #F2C800 100%);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    will-change: transform;
}

.tape-hook {
    position: absolute;
    left: -20px;
    top: 0;
    bottom: 0;
    width: 20px;
    background: #666;
    border-radius: 6px 0 0 6px;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.8);
    z-index: 10;
    background-image: repeating-linear-gradient(0deg,
            transparent,
            transparent 15px,
            rgba(0, 0, 0, 0.3) 15px,
            rgba(0, 0, 0, 0.3) 30px);
    border-right: 2px solid rgba(0, 0, 0, 0.8);
}

svg {
    height: 100%;
    display: block;
}

.tape-line {
    stroke: var(--tape-line);
}

.hint-text {
    text-align: center;
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-top: 2rem;
}

.fraction-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 1rem;
    padding: 0 1rem;
    margin-top: 1rem;
    margin-bottom: 2rem;
}

.fraction-btn {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    color: var(--text-main);
    padding: 1rem 0;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fraction-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    border-color: var(--tape-yellow);
    color: var(--tape-yellow);
}

/* Affiliate Marketing Section */
.affiliate-banner {
    background: linear-gradient(135deg, rgba(255, 214, 0, 0.1), rgba(0, 229, 255, 0.05));
    border: 1px solid var(--tape-yellow);
    border-radius: 15px;
    padding: 2rem;
    margin-top: 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    animation: fadeIn 1s ease-out;
}

.affiliate-info h3 {
    color: #FFF;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.affiliate-info p {
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1.4;
}

.affiliate-btn {
    background: var(--tape-yellow);
    color: #000;
    text-decoration: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 800;
    white-space: nowrap;
    transition: transform 0.2s, box-shadow 0.2s;
}

.affiliate-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(255, 214, 0, 0.3);
}

/* Display Ad Section */
.ad-container {
    margin-top: 3rem;
    text-align: center;
}

.ad-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.ad-placeholder {
    background: var(--panel-bg);
    border: 1px dashed var(--panel-border);
    border-radius: 10px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-style: italic;
}

/* Educational SEO Guide */
.educational-guide {
    margin-top: 4rem;
    padding: 3rem;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 15px;
    animation: fadeIn 1s ease-out;
}

.educational-guide h2 {
    color: var(--tape-yellow);
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

.educational-guide h3 {
    color: #FFF;
    font-size: 1.4rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.educational-guide p {
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.educational-guide ul {
    list-style-type: none;
    margin-left: 0;
    margin-bottom: 1rem;
}

.educational-guide li {
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 0.8rem;
    padding-left: 1.5rem;
    position: relative;
}

.educational-guide li::before {
    content: "•";
    color: var(--tape-yellow);
    font-weight: bold;
    font-size: 1.5rem;
    position: absolute;
    left: 0;
    top: -4px;
}

.educational-guide strong {
    color: #FFF;
}

footer {
    text-align: center;
    margin-top: 4rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2.5rem;
    }

    .display-panel {
        padding: 1.5rem;
        height: 160px;
    }

    #current-measurement-text {
        font-size: 3rem;
    }

    #segment-search {
        width: 100%;
    }

    .search-container {
        flex-direction: column;
    }

    .fraction-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.5rem;
    }

    .affiliate-banner {
        flex-direction: column;
        text-align: center;
        gap: 1.5rem;
    }
}