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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

h1 {
    text-align: center;
    color: white;
    font-size: 2.5rem;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.section {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.hidden {
    display: none;
}

/* 登録フォーム */
#registration {
    text-align: center;
    max-width: 500px;
    margin: 0 auto;
}

#registration h2 {
    margin-bottom: 20px;
    color: #333;
}
.ad{
    margin-left:auto;
    margin-right:auto;
}
.input-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

#username {
    flex: 1;
    max-width: 300px;
    padding: 12px 20px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 25px;
    outline: none;
    transition: border-color 0.3s;
}

#username:focus {
    border-color: #667eea;
}

#register-btn {
    padding: 12px 25px;
    font-size: 16px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: transform 0.2s;
}

#register-btn:hover {
    transform: translateY(-2px);
}

/* ゲーム画面 */
.game-area {
    text-align: center;
    margin-bottom: 30px;
}

.word-display {
    margin-bottom: 30px;
}

.word-display h3 {
    margin-bottom: 15px;
    color: #555;
}

/* 単語表示エリア - 縦配置 */
.word-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-bottom: 30px;
    padding: 30px;
    background: #f8f9fa;
    border-radius: 15px;
    border: 3px solid #e9ecef;
}

.current-hiragana {
    font-size: 1.5rem;
    color: #6c757d;
    font-family: 'Courier New', monospace;
    font-weight: normal;
    text-align: center;
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.current-kanji {
    font-size: 4rem;
    color: #333;
    font-weight: bold;
    text-align: center;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 10px 0;
}

.current-romaji {
    font-size: 1.8rem;
    letter-spacing: 3px;
    font-family: 'Courier New', monospace;
    text-align: center;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ローマ字の色分け */
.current-romaji .completed {
    color: #6c757d; /* 灰色 - 入力済み */
}

.current-romaji .next {
    color: #dc3545; /* 赤色 - 次の入力文字 */
    background: #fff3cd;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: bold;
}

.current-romaji .remaining {
    color: #000000; /* 黒色 - 未入力 */
}

/* 入力フィールドは削除されました - 画面全体で直接入力を受け付けます */

/* ゲーム画面をフォーカス可能にする */
#game {
    outline: none;
    cursor: text;
    transition: opacity 0.3s ease, box-shadow 0.3s ease;
}

#game:focus {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
    opacity: 1;
}

/* フォーカスが外れている時の視覚的な変化 */
#game:not(:focus) {
    opacity: 0.8;
}

.score-display {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.score-display h3 {
    font-size: 1.5rem;
    color: #333;
    margin: 0;
}

#user-score {
    color: #28a745;
    font-weight: bold;
}

.change-name-btn {
    padding: 8px 16px;
    font-size: 14px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.change-name-btn:hover {
    background: #5a6268;
}

.status-message {
    padding: 10px;
    border-radius: 5px;
    font-weight: bold;
    margin-bottom: 20px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-message.correct {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-message.mistake {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* 情報パネル */
.info-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.panel {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    border: 1px solid #e9ecef;
}

.panel h3 {
    margin-bottom: 15px;
    color: #333;
    border-bottom: 2px solid #667eea;
    padding-bottom: 5px;
}

.list {
    max-height: 300px;
    overflow-y: auto;
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 5px;
    background: white;
    border-radius: 5px;
    border: 1px solid #e9ecef;
    overflow: hidden;
}

.list-item.current-user {
    background: #e3f2fd;
    border-color: #2196f3;
}

.list-item.current-user .score-progress {
    background: linear-gradient(90deg, #2196f3 0%, #21cbf3 100%);
    opacity: 0.3;
}

.participant-name-container {
    position: relative;
    flex: 1;
    min-width: 0;
}

.score-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 3px;
    opacity: 0.2;
    transition: width 0.3s ease;
    z-index: 1;
}

.participant-name {
    position: relative;
    font-weight: 500;
    z-index: 2;
    padding: 2px 4px;
}

.participant-score {
    font-weight: bold;
    color: #28a745;
}

.ranking-position {
    background: #667eea;
    color: white;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.ranking-position.first {
    background: #ffd700;
    color: #333;
}

.ranking-position.second {
    background: #c0c0c0;
    color: #333;
}

.ranking-position.third {
    background: #cd7f32;
    color: white;
}

/* レスポンシブ */
@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }
    
    .word-stack {
        padding: 20px;
        gap: 10px;
    }
    
    .current-hiragana {
        font-size: 1.2rem;
    }
    
    .current-kanji {
        font-size: 3rem;
    }
    
    .current-romaji {
        font-size: 1.4rem;
        letter-spacing: 2px;
    }
    
    .info-panels {
        grid-template-columns: 1fr;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    #username {
        max-width: 100%;
        margin-bottom: 10px;
    }
}

/* アニメーション */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.section {
    animation: fadeIn 0.5s ease-out;
}

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

.current-kanji {
    animation: pulse 2s infinite;
}
