* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ヘッダースタイル */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 0;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.header-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    font-weight: 600;
    color: white;
    text-decoration: none;
    font-size: 1.1rem;
    transition: color 0.3s ease;
}

.header-link:hover {
    color: #60a5fa;
}

.header-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: radial-gradient(ellipse at bottom, #0d1b2a 0%, #1b263b 50%, #0f172a 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: relative;
}

/* Background stars animation */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, rgba(255,255,255,0.3), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.2), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(255,255,255,0.5), transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255,255,255,0.3), transparent),
        radial-gradient(2px 2px at 160px 30px, rgba(255,255,255,0.4), transparent);
    background-repeat: repeat;
    background-size: 200px 100px;
    animation: twinkle 3s infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 0.4; }
}

.title-screen {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 1;
}

.title-container {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 24px;
    padding: 50px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    max-width: 700px;
    width: 100%;
    text-align: center;
}

.title-container h1 {
    font-size: 2.5em;
    color: #f1f5f9;
    margin-bottom: 20px;
    text-shadow: 0 0 20px rgba(96, 165, 250, 0.3), 0 4px 6px rgba(0, 0, 0, 0.5);
}

.game-description {
    font-size: 1.1em;
    color: rgba(241, 245, 249, 0.8);
    line-height: 1.8;
    margin-bottom: 40px;
}

.difficulty-selection h2 {
    font-size: 1.5em;
    color: #f1f5f9;
    margin-bottom: 25px;
}

.mode-tabs {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
}

.mode-tab {
    padding: 12px 30px;
    border: 2px solid rgba(59, 130, 246, 0.3);
    background: rgba(15, 23, 42, 0.6);
    border-radius: 10px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    color: rgba(241, 245, 249, 0.7);
    transition: all 0.3s ease;
}

.mode-tab:hover {
    border-color: #60a5fa;
    color: #60a5fa;
    background: rgba(15, 23, 42, 0.8);
}

.mode-tab.active {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border-color: #3b82f6;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.difficulty-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.btn-difficulty {
    background: rgba(15, 23, 42, 0.6);
    border: 3px solid rgba(59, 130, 246, 0.3);
    border-radius: 15px;
    padding: 25px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    position: relative;
}

.btn-difficulty:hover {
    transform: translateY(-5px);
    border-color: #60a5fa;
    background: rgba(15, 23, 42, 0.8);
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.4);
}

.difficulty-blind {
    border-color: rgba(239, 68, 68, 0.5);
}

.difficulty-blind:hover {
    border-color: #ef4444;
    box-shadow: 0 10px 25px rgba(239, 68, 68, 0.4);
}

.difficulty-title {
    font-size: 1.3em;
    font-weight: bold;
    color: #f1f5f9;
    margin-bottom: 8px;
}

.difficulty-desc {
    font-size: 0.9em;
    color: rgba(241, 245, 249, 0.7);
}

/* バッジスタイル */
.difficulty-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    border-radius: 8px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    animation: badgeAppear 0.5s ease-out;
    z-index: 10;
}

@keyframes badgeAppear {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    70% {
        transform: scale(1.1) rotate(5deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.badge-emoji {
    font-size: 1em;
    line-height: 1;
}

.badge-text {
    font-size: 0.55em;
    letter-spacing: 0.3px;
    line-height: 1;
}

.badge-perfect {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
    border: 2px solid #fbbf24;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.badge-gold {
    background: linear-gradient(135deg, #fbbf24, #d97706);
    color: white;
    border: 2px solid #fbbf24;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.badge-silver {
    background: linear-gradient(135deg, #e5e7eb, #9ca3af);
    color: #1f2937;
    border: 2px solid #d1d5db;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5);
}

.badge-bronze {
    background: linear-gradient(135deg, #d97706, #92400e);
    color: white;
    border: 2px solid #b45309;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.highscore-display {
    padding: 25px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 15px;
    margin-top: 20px;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.3);
}

.highscore-title {
    font-size: 1.4em;
    color: #f1f5f9;
    font-weight: bold;
    margin-bottom: 20px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.highscore-section {
    margin-bottom: 20px;
}

.highscore-section:last-child {
    margin-bottom: 0;
}

.mode-title {
    font-size: 1.2em;
    color: rgba(241, 245, 249, 0.9);
    font-weight: bold;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.highscore-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.highscore-item {
    background: rgba(15, 23, 42, 0.4);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    border: 2px solid transparent;
}

.highscore-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* ハイスコアアイテムのバッジカラー */
.highscore-item.badge-perfect {
    border-color: #fbbf24;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(245, 158, 11, 0.1));
}

.highscore-item.badge-gold {
    border-color: #fbbf24;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.12), rgba(217, 119, 6, 0.08));
}

.highscore-item.badge-silver {
    border-color: #d1d5db;
    background: linear-gradient(135deg, rgba(229, 231, 235, 0.15), rgba(156, 163, 175, 0.1));
}

.highscore-item.badge-bronze {
    border-color: #b45309;
    background: linear-gradient(135deg, rgba(217, 119, 6, 0.15), rgba(146, 64, 14, 0.1));
}

.highscore-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 1.5em;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.highscore-item.easy {
    border-left: 4px solid #10b981;
}

.highscore-item.normal {
    border-left: 4px solid #3b82f6;
}

.highscore-item.hard {
    border-left: 4px solid #f59e0b;
}

.highscore-item.expert {
    border-left: 4px solid #ef4444;
}

.highscore-difficulty {
    font-size: 0.9em;
    color: rgba(241, 245, 249, 0.7);
    font-weight: 600;
}

.highscore-score {
    font-size: 1.3em;
    font-weight: bold;
    color: #60a5fa;
}

.no-score {
    text-align: center;
    color: rgba(241, 245, 249, 0.5);
    font-size: 1.1em;
    padding: 30px;
    font-style: italic;
}

.container {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    max-width: 800px;
    width: 100%;
    position: relative;
    z-index: 1;
}

.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    gap: 20px;
}

.header-bar h1 {
    margin: 0;
    flex: 1;
}

.btn-back-top {
    padding: 10px 20px;
    font-size: 0.9em;
    border: 2px solid rgba(59, 130, 246, 0.3);
    background: rgba(15, 23, 42, 0.6);
    color: rgba(241, 245, 249, 0.9);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    font-weight: bold;
}

.btn-back-top:hover {
    border-color: #60a5fa;
    color: #60a5fa;
    background: rgba(15, 23, 42, 0.8);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

h1 {
    text-align: center;
    color: #f1f5f9;
    margin-bottom: 30px;
    font-size: 2em;
    text-shadow: 0 0 20px rgba(96, 165, 250, 0.3), 0 4px 6px rgba(0, 0, 0, 0.5);
}

.game-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    gap: 20px;
    flex-wrap: wrap;
}

.info-box {
    flex: 1;
    min-width: 150px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.info-label {
    font-size: 0.9em;
    opacity: 0.9;
    margin-bottom: 5px;
}

.info-value {
    font-size: 2em;
    font-weight: bold;
}

.scale-display {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    text-align: center;
    border: 3px solid rgba(59, 130, 246, 0.5);
}

.scale-label {
    font-size: 1.1em;
    color: rgba(241, 245, 249, 0.7);
    margin-bottom: 10px;
}

.scale-label span {
    font-weight: bold;
    color: #60a5fa;
    font-size: 1.3em;
}

.current-weight {
    font-size: 3em;
    font-weight: bold;
    color: #f1f5f9;
    margin: 10px 0;
}

.current-weight.hidden {
    color: transparent;
    text-shadow: 0 0 15px rgba(0,0,0,0.3);
    user-select: none;
}

.current-weight.hidden::before {
    content: '???';
    color: #999;
    text-shadow: none;
}

.weight-difference {
    font-size: 1.2em;
    margin-top: 10px;
    font-weight: 600;
    color: rgba(241, 245, 249, 0.7);
}

.weight-difference.over {
    color: #ef4444;
}

.weight-difference.under {
    color: #fbbf24;
}

.weight-difference.perfect {
    color: #10b981;
}

.items-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.item {
    background: rgba(15, 23, 42, 0.6);
    border: 3px solid rgba(59, 130, 246, 0.3);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    color: #f1f5f9;
}

.item:hover {
    transform: translateY(-5px);
    background: rgba(15, 23, 42, 0.8);
    border-color: #60a5fa;
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.3);
}

.item.selected {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border-color: #3b82f6;
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.item.optimal {
    background: rgba(15, 23, 42, 0.6);
    color: #f1f5f9;
    border: 4px solid #fbbf24;
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.5);
}

.item.selected.optimal {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border: 4px solid #fbbf24;
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.5);
}

.item-icon {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.item-weight {
    font-size: 1.3em;
    font-weight: bold;
}

.btn-back-bottom {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.btn-back-bottom:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

.result-display {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    text-align: center;
    border: 3px solid rgba(59, 130, 246, 0.5);
}

.result-display h2 {
    font-size: 2em;
    margin-bottom: 20px;
    color: #f1f5f9;
}

.result-display.success h2 {
    color: #10b981;
}

.result-display.failure h2 {
    color: #ef4444;
}

.result-display.set-complete {
    background: rgba(15, 23, 42, 0.8);
    border: 4px solid #fbbf24;
    box-shadow: 0 0 30px rgba(251, 191, 36, 0.4);
}

.result-display.set-complete h2 {
    color: #fbbf24;
    font-size: 2.3em;
    text-shadow: 0 0 20px rgba(251, 191, 36, 0.5);
}

.result-details {
    font-size: 1.1em;
    color: rgba(241, 245, 249, 0.8);
    white-space: pre-line;
    line-height: 1.8;
}

.buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

button {
    padding: 15px 40px;
    font-size: 1.1em;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.btn-confirm {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-confirm:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.btn-confirm:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-next {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.btn-next:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.shake {
    animation: shake 0.5s ease;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.bounce {
    animation: bounce 0.5s ease;
}

/* トースト通知 */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    border: 2px solid rgba(59, 130, 246, 0.5);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    font-size: 1.1em;
    font-weight: 600;
    z-index: 10000;
    animation: toastSlideIn 0.3s ease-out;
    min-width: 250px;
    text-align: center;
}

.toast.toast-hide {
    animation: toastSlideOut 0.3s ease-in forwards;
}

@keyframes toastSlideIn {
    0% {
        transform: translateX(-50%) translateY(100px);
        opacity: 0;
    }
    100% {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@keyframes toastSlideOut {
    0% {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateX(-50%) translateY(100px);
        opacity: 0;
    }
}
