body {
    font-family: 'Arial', sans-serif;
    margin: 0;
    padding: 20px;
    background-color: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
}

/* コントロールエリア全体のレイアウト */
.control-area {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 30px;
}

.control-left {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
}

.control-center-wrapper {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    text-align: center;
}

.control-right {
    flex: 1;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
}

.mode-selection {
    text-align: center;
}

.mode-selection label {
    margin: 0 15px 0 0;
    font-size: 16px;
    cursor: pointer;
}

.mode-selection input[type="radio"] {
    margin-right: 5px;
}

.problem-selection {
    text-align: center;
}

.problem-selection label {
    margin-right: 10px;
    font-size: 16px;
}

.problem-selection select {
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    margin-right: 10px;
    min-width: 200px;
}


#startButton {
    display: block;
    margin: 0;
    padding: 12px 24px;
    font-size: 16px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
    width: fit-content;
}

#loadTextButton {
    display: block;
    margin: 20px auto;
    padding: 12px 24px;
    font-size: 16px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#startButton:hover, #loadTextButton:hover {
    background-color: #45a049;
}

/* リアルタイム統計表示 */
.stats-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin: 0;
    padding: 15px;
    background-color: #f0f8ff;
    border-radius: 8px;
    border: 2px solid #2196F3;
    min-width: 380px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stat-label {
    font-size: 14px;
    color: #666;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 20px;
    font-weight: bold;
    color: #2196F3;
    min-width: 80px;
}

#timeDisplay {
    color: #4CAF50;
}

#correctDisplay {
    color: #2196F3;
}

#errorDisplay {
    color: #f44336;
}

#scoreDisplay {
    color: #FF9800;
    font-size: 24px;
    font-weight: bold;
}

.text-display {
    margin: 10px 0;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 5px;
    min-height: 100px;
    display: flex;
    align-items: end;
    justify-content: center;
}

#problemText {
    font-size: 24px;
    line-height: 1.6;
    letter-spacing: 1px;
}

.typed-correct {
    background-color: #c8e6c9;
    color: #2e7d32;
}

.typed-incorrect {
    background-color: #ffcdd2;
    color: #c62828;
}

.keyboard-layout {
    margin: 10px 0;
    padding: 10px;
    background-color: #f0f0f0;
    border-radius: 5px;
    transition: background-color 0.1s;
}

.keyboard-layout.error-background {
    background-color: rgba(255, 17, 0, 0.548);
}

.keyboard-row {
    display: flex;
    justify-content: center;
    margin: 5px 0;
}

.key {
    margin: 3px;
    padding: 6px 8px;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    min-width: 40px;
    min-height: 50px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    outline: 4px solid transparent;
}

/* 指の種類別の背景色 */
.key[data-finger="left-pinky"],
.key[data-finger="right-pinky"] {
    background-color: #ffebee; /* 薄いピンク - 小指 */
}

.key[data-finger="left-ring"],
.key[data-finger="right-ring"] {
    background-color: #e8f5e8; /* 薄い緑 - 薬指 */
}

.key[data-finger="left-middle"] {
    background-color: #f3e5f5; /* 薄い紫 - 中指 */
}

.key[data-finger="right-middle"] {
    background-color: #f2c7f8; /* 薄い紫 - 中指 */
}


.key[data-finger="left-index"] {
    background-color: #e3f2fd; /* 薄い青 - 人差指 */
}

.key[data-finger="right-index"] {
    background-color: #b4dcf9; /* 薄い青 - 人差指 */
}

.key[data-finger="left-thumb"],
.key[data-finger="right-thumb"] {
    background-color: #fff3e0; /* 薄いオレンジ - 親指 */
}

.key-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
    height: 50%;
}

.key-bottom {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    width: 100%;
    height: 50%;
}

.key-roman {
    font-size: 10px;
    color: #666;
    font-weight: normal;
}

.key-shift-kana {
    font-size: 12px;
    color: #333;
    font-weight: bold;
}

.key-kana {
    font-size: 16px;
    color: #333;
    font-weight: bold;
}

.current-char {
    background-color: #ffeb3b;
    padding: 2px 4px;
    border-radius: 2px;
    font-weight: bold;
}


.key.next-key {
    outline-color: #2196F3 !important;
    box-shadow: 0 0 8px rgba(33, 150, 243, 0.3);
    animation: pulse-outline 1s infinite;
}

.key.error-key {
    outline-color: #f44336 !important;
    box-shadow: 0 0 8px rgba(244, 67, 54, 0.4);
    transition: outline-color 0.1s, box-shadow 0.1s;
}

.key.correct-key {
    outline-color: #8BC34A !important;
    box-shadow: 0 0 8px rgba(139, 195, 74, 0.4);
    transition: outline-color 0.1s, box-shadow 0.1s;
}

.key.shift-pressed {
    outline-color: #8BC34A !important;
    box-shadow: 0 0 8px rgba(139, 195, 74, 0.4);
    transition: outline-color 0.1s, box-shadow 0.1s;
}

.key.key-pressed {
    outline-color: #8BC34A !important;
    box-shadow: 0 0 8px rgba(139, 195, 74, 0.4);
    transition: outline-color 0.1s, box-shadow 0.1s;
}

@keyframes pulse-outline {
    0% {
        outline-color: #2196F3;
        box-shadow: 0 0 8px rgba(33, 150, 243, 0.3);
    }
    50% {
        outline-color: #1976D2;
        box-shadow: 0 0 12px rgba(33, 150, 243, 0.6);
    }
    100% {
        outline-color: #2196F3;
        box-shadow: 0 0 8px rgba(33, 150, 243, 0.3);
    }
}

.hand-display {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    margin: 10px 0;
    padding: 10px;
    background-color: #f0f0f0;
    border-radius: 5px;
    gap: 90px;
}

.hand {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 5px;
}

.finger {
    margin: 0;
    padding: 8px 4px;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
    transition: all 0.2s;
    min-width: 30px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

/* 指の種類別の背景色をキーと同じ色に */
.finger[data-finger="left-pinky"],
.finger[data-finger="right-pinky"] {
    background-color: #ffebee; /* 薄いピンク - 小指 */
}

.finger[data-finger="left-ring"],
.finger[data-finger="right-ring"] {
    background-color: #e8f5e8; /* 薄い緑 - 薬指 */
}

.finger[data-finger="left-middle"]{
    background-color: #f3e5f5; /* 薄い紫 - 中指 */
}

.finger[data-finger="right-middle"] {
    background-color: #f2c7f8; /* 薄い紫 - 中指 */
}

.finger[data-finger="left-index"]{
    background-color: #e3f2fd; /* 薄い青 - 人差指 */
}

.finger[data-finger="right-index"] {
    background-color: #b4dcf9cd; /* 薄い青 - 人差指 */
}

.finger[data-finger="left-thumb"],
.finger[data-finger="right-thumb"] {
    background-color: #fff3e0; /* 薄いオレンジ - 親指 */
}

.finger.active {
    background-color: #FF9800;
    color: white;
    transform: scale(1.1);
}

.left-hand .finger {
    order: 1;
}

.right-hand .finger {
    order: 1;
}

.space-key {
    width: 200px;
}

.enter-key {
    width: 60px;
}

.shift-key {
    width: 80px;
}

.tab-key {
    width: 60px;
}

.backspace-key {
    width: 80px;
}

/* 左手と右手の間のスペース調整 */
.keyboard-row .key:nth-child(6) {
    margin-right: 7px;
}

.keyboard-row .key:nth-child(7) {
    margin-left: 7px;
}

/* 結果表示エリア */
.result-display {
    margin: 20px 0;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 8px;
    border: 2px solid #4CAF50;
    text-align: center;
}

.result-display h3 {
    margin-top: 0;
    color: #4CAF50;
    font-size: 24px;
}

.current-result {
    margin: 20px 0;
    padding: 15px;
    background-color: white;
    border-radius: 5px;
    border: 1px solid #ddd;
    font-size: 18px;
    line-height: 1.5;
}

.current-result .score {
    font-size: 32px;
    font-weight: bold;
    color: #4CAF50;
    margin: 10px 0;
}

.current-result .details {
    display: flex;
    justify-content: space-around;
    margin: 15px 0;
    font-size: 16px;
}

.current-result .details > div {
    text-align: center;
}

.current-result .details .label {
    font-weight: bold;
    color: #666;
    margin-bottom: 5px;
}

.current-result .details .value {
    font-size: 18px;
    color: #333;
}

#showRankingButton, #retryButton, #closeRankingButton {
    margin: 10px;
    padding: 10px 20px;
    font-size: 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#showRankingButton {
    background-color: #2196F3;
    color: white;
}

#showRankingButton:hover {
    background-color: #1976D2;
}

#retryButton {
    background-color: #4CAF50;
    color: white;
}

#retryButton:hover {
    background-color: #45a049;
}

#closeRankingButton {
    background-color: #f44336;
    color: white;
}

#closeRankingButton:hover {
    background-color: #d32f2f;
}

/* ランキング表示エリア */
.ranking-display {
    margin: 20px 0;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 8px;
    border: 2px solid #2196F3;
    text-align: center;
}

.ranking-display h3 {
    margin-top: 0;
    color: #2196F3;
    font-size: 24px;
}

.ranking-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background-color: white;
    border-radius: 5px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.ranking-table th,
.ranking-table td {
    padding: 12px;
    text-align: center;
    border-bottom: 1px solid #ddd;
}

.ranking-table th {
    background-color: #2196F3;
    color: white;
    font-weight: bold;
}

.ranking-table tr:nth-child(even) {
    background-color: #f8f9fa;
}

.ranking-table tr:hover {
    background-color: #e3f2fd;
}

.ranking-table .rank {
    font-weight: bold;
    color: #2196F3;
}

.ranking-table .rank:first-child {
    color: #FFD700;
}

.ranking-table .rank:nth-child(2) {
    color: #C0C0C0;
}

.ranking-table .rank:nth-child(3) {
    color: #CD7F32;
}

.ranking-table .score {
    font-weight: bold;
    color: #4CAF50;
}

.ranking-table .mode {
    font-size: 12px;
    color: #666;
}

.ranking-table .time {
    color: #2196F3;
    font-weight: bold;
}

.ranking-table .correct-count {
    color: #4CAF50;
}

.ranking-table .error-count {
    color: #f44336;
}

.ranking-table .date {
    font-size: 14px;
    color: #666;
}

@media (max-width: 768px) {
    .container {
        padding: 20px;
    }
    
    .control-area {
        flex-direction: column;
        gap: 20px;
    }
    
    .control-left {
        justify-content: center;
    }
    
    .control-right {
        justify-content: center;
    }
    
    .stats-display {
        min-width: auto;
        width: 100%;
        gap: 15px;
    }
    
    .stat-item {
        min-width: auto;
    }
    
    .stat-value {
        min-width: auto;
        font-size: 18px;
    }
    
    .hand-display {
        flex-direction: column;
        align-items: center;
    }
    
    .hand {
        margin: 10px 0;
    }
    
    .keyboard-layout {
        overflow-x: auto;
    }
}