/* カスタムスタイル（Tailwindと併用） */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* 認証必要バナーアニメーション */
@keyframes slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.animate-slide-in {
    animation: slide-in 0.3s ease-out forwards;
}

/* スムーズスクロール */
html {
    scroll-behavior: smooth;
}

/* グラフとスコア表示 */
#chartWrapper {
    width: 100%;
    position: relative;
    min-height: 300px;
}

#scoreChart {
    width: 100% !important;
    height: auto !important;
    max-height: 400px;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: linear-gradient(to right, #f8fafc, #f1f5f9);
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.score-item:hover {
    background: linear-gradient(to right, #e0f2fe, #dbeafe);
    border-color: #10b981;
    transform: translateX(4px);
}

.score-label {
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 500;
}

.score-value {
    font-size: 1.125rem;
    font-weight: 700;
    color: #10b981;
    min-width: 50px;
    text-align: right;
}

/* キーボード */
#marksDisplay {
    display: flex;
    gap: 0.25rem;
}

.key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    width: 3rem;
    height: 3rem;
    border: 2px solid #e2e8f0;
    border-radius: 0.5rem;
    background: linear-gradient(to bottom, #ffffff, #f8fafc);
    font-weight: 600;
    font-size: 0.875rem;
    color: #334155;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.key:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.key.active {
    background: linear-gradient(to bottom, #fef08a, #fde047) !important;
    border-color: #facc15 !important;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px rgba(250, 204, 21, 0.4) !important;
}

.key.group1 {
    background: linear-gradient(to bottom, #fef2f2, #fee2e2);
    border-color: #fecaca;
}

.key.group2 {
    background: linear-gradient(to bottom, #f0fdf4, #dcfce7);
    border-color: #bbf7d0;
}

.key.group3 {
    background: linear-gradient(to bottom, #eff6ff, #dbeafe);
    border-color: #bfdbfe;
}

.grayed {
    color: #9ca3af;
    opacity: 0.6;
}

/* ユーザーメニュー */
#userMenuContent {
    position: absolute;
    right: 0;
    top: 100%;
    background-color: white;
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    padding: 1rem;
    width: 200px;
    margin-top: 0.5rem;
    border: 1px solid #e2e8f0;
}

/* ユーティリティ */
.hidden {
    display: none;
}

/* オンライン/オフラインインディケーター */
#offlineIndicator.offline {
    background: linear-gradient(135deg, #f59e0b, #f97316);
    color: white;
    animation: pulse 2s infinite;
}

#offlineIndicator.online {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

/* ユーザー選択ダイアログ */
.user-select-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
}

.user-select-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.user-select-content {
    background-color: white;
    border-radius: 1rem;
    padding: 1.5rem;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    border: 1px solid #e2e8f0;
}

.user-select-content h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #e2e8f0;
    color: #1e293b;
    font-size: 1.25rem;
    font-weight: 700;
}

.user-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.user-item {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.user-item:hover {
    background: linear-gradient(to right, #f0fdf4, #dcfce7);
    border-color: #10b981;
    transform: translateX(4px);
}

.user-item i {
    color: #10b981;
}

.user-item.new-user {
    border-top: 1px solid #e2e8f0;
    margin-top: 0.75rem;
    padding-top: 1rem;
}

.user-item.new-user i {
    color: #6366f1;
}

.dialog-buttons {
    display: flex;
    justify-content: flex-end;
}

/* ボーナスエフェクト */
.bonus-celebration {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 5rem;
    font-weight: 800;
    z-index: 9999;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.9);
    animation: bonusTextAnimation 2s ease-out forwards;
    pointer-events: none;
    background: linear-gradient(45deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: bonusTextAnimation 2s ease-out forwards, rainbowAnimation 1s linear infinite;
}

@keyframes bonusTextAnimation {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(-10deg);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.3) rotate(5deg);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
        opacity: 0;
    }
}

@keyframes rainbowAnimation {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.screen-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.3), transparent);
    z-index: 9998;
    pointer-events: none;
    animation: flashAnimation 0.6s ease-out;
}

@keyframes flashAnimation {
    0% { opacity: 0; }
    50% { opacity: 1; }
    100% { opacity: 0; }
}

/* スコア行のハイライト */
.score-row-passed {
    background: linear-gradient(to right, #d1fae5, #a7f3d0) !important;
    animation: highlightPulsePassed 0.6s ease-out;
}

.score-row-failed {
    background: linear-gradient(to right, #fee2e2, #fecaca) !important;
    animation: highlightPulseFailed 0.6s ease-out;
}

@keyframes highlightPulsePassed {
    0% {
        background: linear-gradient(to right, #d1fae5, #a7f3d0);
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes highlightPulseFailed {
    0% {
        background: linear-gradient(to right, #fee2e2, #fecaca);
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
    100% {
        transform: scale(1);
    }
}

.confetti {
    position: fixed;
    width: 12px;
    height: 12px;
    z-index: 9999;
    pointer-events: none;
    animation: confettiFall 3s ease-out forwards;
    border-radius: 2px;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.firework {
    position: fixed;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    z-index: 9999;
    pointer-events: none;
    animation: fireworkAnimation 1s ease-out forwards;
}

@keyframes fireworkAnimation {
    0% {
        transform: translate(0, 0);
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

/* モード選択ラベル */
.mode-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background: linear-gradient(to right, #ffffff, #f8fafc);
    position: relative;
}

.mode-label:hover {
    border-color: #10b981;
    background: linear-gradient(to right, #f0fdf4, #dcfce7);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

.mode-label:has(input:checked) {
    border-color: #10b981;
    background: linear-gradient(to right, #d1fae5, #a7f3d0);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.mode-radio {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: #10b981;
    cursor: pointer;
}

.mode-text {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 500;
    color: #334155;
}

.completion-mark {
    font-size: 1.25rem;
}

/* キーボードガイドメッセージ */
#keyboardGuideMessage {
    animation: pulseWarning 2s ease-in-out infinite;
}

@keyframes pulseWarning {
    0%, 100% {
        border-color: #fbbf24;
        box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.4);
    }
    50% {
        border-color: #f59e0b;
        box-shadow: 0 0 0 8px rgba(251, 191, 36, 0);
    }
}

/* 手の指グラフィック */
.finger-base {
    fill: #e2e8f0;
    stroke: #94a3b8;
    stroke-width: 2;
    transition: all 0.3s ease;
}

.palm-base {
    fill: #f1f5f9;
    stroke: #94a3b8;
    stroke-width: 2;
}

.finger-base.highlight-pinky {
    fill: #f87171;
    stroke: #dc2626;
    filter: drop-shadow(0 0 8px rgba(220, 38, 38, 0.6));
    animation: fingerGlow 0.5s ease-in-out;
}

.finger-base.highlight-ring {
    fill: #4ade80;
    stroke: #16a34a;
    filter: drop-shadow(0 0 8px rgba(22, 163, 74, 0.6));
    animation: fingerGlow 0.5s ease-in-out;
}

.finger-base.highlight-middle {
    fill: #60a5fa;
    stroke: #2563eb;
    filter: drop-shadow(0 0 8px rgba(37, 99, 235, 0.6));
    animation: fingerGlow 0.5s ease-in-out;
}

.finger-base.highlight-index {
    fill: #fde047;
    stroke: #facc15;
    filter: drop-shadow(0 0 8px rgba(250, 204, 21, 0.6));
    animation: fingerGlow 0.5s ease-in-out;
}

@keyframes fingerGlow {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* キーの指別ハイライト強化 */
.key.group1.active {
    background: linear-gradient(to bottom, #fca5a5, #f87171) !important;
    border-color: #dc2626 !important;
    box-shadow: 0 4px 16px rgba(220, 38, 38, 0.6) !important;
    animation: fingerPulse 0.5s ease-in-out;
}

.key.group2.active {
    background: linear-gradient(to bottom, #86efac, #4ade80) !important;
    border-color: #16a34a !important;
    box-shadow: 0 4px 16px rgba(22, 163, 74, 0.6) !important;
    animation: fingerPulse 0.5s ease-in-out;
}

.key.group3.active {
    background: linear-gradient(to bottom, #93c5fd, #60a5fa) !important;
    border-color: #2563eb !important;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.6) !important;
    animation: fingerPulse 0.5s ease-in-out;
}

.key:not(.group1):not(.group2):not(.group3).active {
    background: linear-gradient(to bottom, #fef08a, #fde047) !important;
    border-color: #facc15 !important;
    box-shadow: 0 4px 16px rgba(250, 204, 21, 0.6) !important;
    animation: fingerPulse 0.5s ease-in-out;
}

@keyframes fingerPulse {
    0%, 100% {
        transform: translateY(-2px) scale(1.05);
    }
    50% {
        transform: translateY(-4px) scale(1.1);
    }
}

/* カウントダウン表示の制限 */
#countdown {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* レスポンシブ調整 */
@media (max-width: 768px) {
    .key {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 0.75rem;
        padding: 0.5rem;
    }
    
    .mode-label {
        padding: 0.75rem;
    }
    
    .mode-text {
        font-size: 0.8125rem;
    }
    
    #countdown {
        font-size: 1.5rem;
    }
}
