:root {
    --bg-color: #0F172A;
    --text-color: #E2E8F0;
    --accent-color: #0EA5E9;
    /* Sky 500 */
    --accent-glow: rgba(56, 189, 248, 0.5);
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    background-image:
        radial-gradient(circle at 50% 50%, #1E293B 1px, transparent 1px),
        linear-gradient(to right, rgba(30, 41, 59, 0.5) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(30, 41, 59, 0.5) 1px, transparent 1px);
    background-size: 20px 20px, 40px 40px, 40px 40px;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overflow-x: hidden;
    /* Prevent horizontal scroll on mobile */
    touch-action: manipulation;
}

/* ネオンテキスト */
.neon-text {
    text-shadow: 0 0 5px var(--accent-glow), 0 0 15px rgba(56, 189, 248, 0.3);
}

/* タブ切り替え */
.nav-btn {
    padding: 0.75rem 1rem;
    font-weight: 700;
    color: #94a3b8;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    flex-shrink: 0;
    white-space: nowrap;
    cursor: pointer;
}

.nav-btn:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 3px solid #38bdf8;
    outline-offset: 2px;
}

.nav-btn:hover {
    color: #38bdf8;
    background: rgba(30, 41, 59, 0.3);
}

.nav-btn.active {
    color: #38bdf8;
    border-color: #38bdf8;
    background: rgba(30, 41, 59, 0.5);
    text-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
}

/* パネル */
.glass-panel {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(148, 163, 184, 0.1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* 分数ピザ */
.pizza-container {
    width: 100%;
    height: 100%;
    max-width: 320px;
    max-height: 320px;
    position: relative;
    margin: 0 auto;
}

.pizza-slice {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    opacity: 0.9;
    transform-origin: center;
}

.pizza-slice:hover {
    opacity: 1;
    transform: scale(1.05);
}

.pizza-slice.active {
    fill: var(--accent-color);
    filter: drop-shadow(0 0 5px var(--accent-glow));
}

.pizza-slice.inactive {
    fill: #334155;
}

/* 数直線 (Number Line) */
.number-line-container {
    width: 100%;
    height: 60px;
    position: relative;
    margin-top: 10px;
}

.nl-track {
    height: 4px;
    width: 100%;
    background: #334155;
    border-radius: 2px;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

.nl-fill {
    height: 4px;
    background: var(--accent-color);
    border-radius: 2px;
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    transition: width 0.3s ease;
    box-shadow: 0 0 10px var(--accent-glow);
}

.nl-marker {
    position: absolute;
    top: 50%;
    width: 2px;
    height: 12px;
    background: #64748B;
    transform: translate(-50%, -50%);
}

.nl-label {
    position: absolute;
    top: 25px;
    transform: translateX(-50%);
    font-size: 10px;
    color: #94A3B8;
    font-family: monospace;
}

.nl-current {
    position: absolute;
    top: 50%;
    width: 16px;
    height: 16px;
    background: white;
    border: 3px solid var(--accent-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: left 0.3s ease;
    box-shadow: 0 0 10px var(--accent-glow);
    z-index: 10;
}

/* 長方形 (Bar Model) */
.bar-container {
    width: 100%;
    height: 40px;
    background: #1E293B;
    border: 2px solid #334155;
    border-radius: 8px;
    display: flex;
    overflow: hidden;
    margin-bottom: 5px;
}

.bar-segment {
    flex: 1;
    border-right: 1px solid #0F172A;
    transition: background 0.2s;
    cursor: pointer;
}

.bar-segment:last-child {
    border-right: none;
}

.bar-segment.active {
    background: #EC4899;
    box-shadow: inset 0 0 10px rgba(236, 72, 153, 0.5);
}

/* エジプトモード */
.egypt-panel {
    background: linear-gradient(160deg, #1e1b4b 0%, #312e81 100%);
    border: 2px solid #d97706;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(217, 119, 6, 0.2);
}

.egypt-bg-pattern {
    position: absolute;
    inset: 0;
    opacity: 0.05;
    background-image: repeating-linear-gradient(45deg, #fbbf24 0, #fbbf24 1px, transparent 0, transparent 50%);
    background-size: 20px 20px;
}

/* アニメーション */
.fade-in {
    animation: fadeIn 0.4s ease-out;
}

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

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

/* Inputs */
.input-num {
    background: transparent;
    text-align: center;
    font-weight: 900;
    border: none;
    transition: all 0.2s;
}

.input-num:focus {
    outline: none;
    color: white;
    text-shadow: 0 0 10px var(--accent-glow);
}

/* Scrollbar */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #0F172A;
}

::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* Toast Notification (Unified Design) */
#toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(5px);
    padding: 12px 24px;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    font-weight: bold;
    color: #E2E8F0;
    border: 2px solid #334155;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
    animation: fadeInUp 0.3s ease-out forwards;
    min-width: auto;
}

.toast-info {
    border-color: #3B82F6;
    color: #38BDF8;
}

.toast-success {
    border-color: #22C55E;
    color: #4ADE80;
}

.toast-warning {
    border-color: #F59E0B;
    color: #FBBF24;
}

.toast-error {
    border-color: #EF4444;
    color: #F87171;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
