@font-face {
   font-family: 'Wachafont';
   src: url('WachaFont.otf') format('opentype');
}

body {
   font-family: sans-serif;
   text-align: center;
   margin: 0;
   padding: 0;
   background-color: #121212;
   color: #e0e0e0;
   min-height: 100vh;
   display: flex;
   flex-direction: column;
   align-items: center;
}

h1 {
   font-size: 32px;
   margin-bottom: 30px;
   color: #64b5f6;
   margin-top: 50px;
}

.menu-container {
   display: flex;
   flex-direction: column;
   gap: 20px;
   width: 90%;
   max-width: 400px;
   margin: 0 auto 50px auto;
}

.mode-btn {
   display: block;
   padding: 20px;
   font-size: 20px;
   font-weight: bold;
   text-decoration: none;
   color: white;
   border-radius: 12px;
   transition: transform 0.2s, box-shadow 0.2s;
   box-shadow: 0 6px 15px rgba(0, 0, 0, 0.5);
}

.mode-btn:hover {
   transform: translateY(-3px);
   box-shadow: 0 8px 20px rgba(0, 0, 0, 0.7);
}

.btn-read {
   background-color: #1976d2;
}

.btn-write {
   background-color: #2e7d32;
}

.description {
   font-size: 14px;
   font-weight: normal;
   display: block;
   margin-top: 5px;
   color: #bbdefb;
   opacity: 0.9;
}

.btn-write .description {
   color: #c8e6c9;
}

.sub-menu {
   display: none;
   flex-direction: column;
   gap: 10px;
   margin-top: -10px;
   padding: 15px;
   background-color: #1e1e1e;
   border-radius: 0 0 12px 12px;
   box-shadow: inset 0 4px 6px rgba(0, 0, 0, 0.3);
}

.sub-btn {
   display: block;
   padding: 15px;
   font-size: 16px;
   font-weight: bold;
   text-decoration: none;
   color: #e0e0e0;
   background-color: #2c2c2c;
   border-radius: 8px;
   border: 1px solid #444;
   transition: 0.2s;
}

.sub-btn:hover {
   background-color: #424242;
}

.row-grid {
   display: grid;
   grid-template-columns: repeat(5, 1fr);
   gap: 5px;
   margin-top: 10px;
}

.row-btn {
   padding: 10px 5px;
   font-size: 14px;
   font-weight: bold;
   text-decoration: none;
   color: white;
   background-color: #0277bd;
   border-radius: 6px;
   transition: 0.2s;
}

.row-btn:hover {
   background-color: #01579b;
}

.row-btn-special {
   grid-column: span 2;
}

.header {
   display: flex;
   justify-content: space-between;
   align-items: center;
   width: 100%;
   max-width: 400px;
   margin: 20px auto 10px auto;
}

.back-btn {
   text-decoration: none;
   background-color: #424242;
   color: white;
   padding: 8px 15px;
   border-radius: 6px;
   font-size: 14px;
   font-weight: bold;
}

.back-btn:hover {
   background-color: #616161;
}

.game-container {
   display: flex;
   flex-direction: column;
   align-items: center;
   gap: 15px;
   background: #1e1e1e;
   padding: 20px;
   border-radius: 12px;
   box-shadow: 0 6px 15px rgba(0, 0, 0, 0.5);
   width: 90%;
   max-width: 400px;
   margin: 0 auto 50px auto;
   box-sizing: border-box;
}

.question-box {
   font-size: 18px;
   font-weight: bold;
   margin-bottom: 10px;
   color: #e0e0e0;
   width: 100%;
}

.next-btn {
   background-color: #2e7d32;
   color: white;
   border: none;
   padding: 15px;
   font-size: 18px;
   font-weight: bold;
   border-radius: 6px;
   cursor: pointer;
   width: 100%;
   display: none;
   margin-top: 10px;
   transition: 0.2s;
}

.next-btn:hover {
   background-color: #1b5e20;
}

#resultMessage {
   font-size: 24px;
   font-weight: bold;
   min-height: 60px;
   margin-top: 10px;
   width: 100%;
}

.success {
   color: #ef5350;
}

.fail {
   color: #42a5f5;
}

.original-text {
   font-family: 'Wachafont', sans-serif;
   font-size: 32px;
   vertical-align: middle;
}

/* 読み取りテストの文字サイズと幅を調整（単語が入るように） */
.question-char-read {
   font-family: 'Wachafont', sans-serif;
   font-size: 70px;
   color: #ffffff;
   background: #2c2c2c;
   padding: 15px 30px;
   border-radius: 12px;
   display: inline-block;
   line-height: 1.2;
   border: 1px solid #444;
   max-width: 100%;
   box-sizing: border-box;
   word-break: break-all;
}

.choices {
   display: grid;
   grid-template-columns: 1fr 1fr;
   gap: 15px;
   width: 100%;
   margin-top: 10px;
}

.choice-btn {
   background-color: #1976d2;
   color: white;
   border: none;
   padding: 20px;
   font-size: 20px;
   font-weight: bold;
   border-radius: 8px;
   cursor: pointer;
   transition: 0.2s;
   box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
   word-break: break-all;
}

.choice-btn:hover {
   background-color: #1565c0;
}

.choice-btn:disabled {
   opacity: 0.5;
   cursor: not-allowed;
}

.question-char-write {
   font-size: 48px;
   color: #64b5f6;
   background: #2c2c2c;
   padding: 10px 30px;
   border-radius: 8px;
   display: inline-block;
   margin-top: 10px;
   border: 1px solid #444;
}

canvas {
   border: 2px solid #555;
   background-color: #2d2d2d;
   cursor: crosshair;
   touch-action: none;
   border-radius: 4px;
   box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.controls {
   display: flex;
   gap: 10px;
   width: 100%;
   justify-content: center;
}

.controls button {
   padding: 12px 20px;
   font-size: 16px;
   font-weight: bold;
   cursor: pointer;
   border: none;
   border-radius: 6px;
   color: white;
   transition: 0.2s;
}

.controls button.clear {
   background-color: #555;
}

.controls button.clear:hover {
   background-color: #777;
}

.controls button.judge {
   background-color: #2e7d32;
   flex-grow: 1;
}

.controls button.judge:hover {
   background-color: #1b5e20;
}

button.hint {
   background-color: #f57c00;
}

button.hint:hover {
   background-color: #c62828;
}

button.hint:disabled {
   background-color: #555;
   color: #888;
   cursor: not-allowed;
}

.candidate-btn {
   background-color: #0277bd;
   color: white;
   width: 90%;
   padding: 10px;
   font-size: 16px;
   display: flex;
   align-items: center;
   justify-content: center;
   gap: 10px;
   cursor: pointer;
   border: none;
   border-radius: 8px;
   transition: 0.2s;
}

.candidate-btn:hover {
   background-color: #01579b;
}

.candidate-btn-1 {
   background-color: #ffb300;
   color: #121212;
   font-size: 18px;
   font-weight: bold;
}

.candidate-btn-1:hover {
   background-color: #ff8f00;
}

#wordDisplay {
   font-size: 32px;
   font-weight: bold;
   color: #888;
   display: none;
   margin-top: 10px;
   background: #2c2c2c;
   padding: 10px 20px;
   border-radius: 8px;
   border: 1px solid #444;
}

.word-char {
   margin: 0 4px;
}

.word-active {
   color: #64b5f6;
   font-size: 40px;
   text-decoration: underline;
}

.word-done {
   color: #4caf50;
}

.stats-container {
   width: 95%;
   max-width: 600px;
   background: #1e1e1e;
   padding: 20px;
   border-radius: 12px;
   box-shadow: 0 6px 15px rgba(0, 0, 0, 0.5);
   margin: 0 auto 30px auto;
   box-sizing: border-box;
}

.stats-grid {
   display: grid;
   grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
   gap: 10px;
   margin-top: 20px;
}

.stat-card {
   background-color: #2c2c2c;
   padding: 10px;
   border-radius: 8px;
   border: 1px solid #444;
   display: flex;
   flex-direction: column;
   align-items: center;
}

.stat-char {
   font-size: 24px;
   font-weight: bold;
   color: #64b5f6;
}

.stat-percent {
   font-size: 18px;
   font-weight: bold;
   margin-top: 5px;
}

.stat-detail {
   font-size: 12px;
   color: #aaa;
   margin-top: 2px;
}

.stat-perfect {
   border-color: #4caf50;
   box-shadow: inset 0 0 5px rgba(76, 175, 80, 0.3);
}

.stat-perfect .stat-percent {
   color: #4caf50;
}

.stat-good {
   color: #fff;
}

.stat-bad {
   border-color: #ef5350;
   background-color: rgba(239, 83, 80, 0.1);
}

.stat-bad .stat-percent {
   color: #ef5350;
}

.stat-none {
   opacity: 0.5;
}

.reset-btn {
   background-color: #c62828;
   color: white;
   border: none;
   padding: 12px 20px;
   font-size: 16px;
   font-weight: bold;
   border-radius: 6px;
   cursor: pointer;
   margin-top: 20px;
   transition: 0.2s;
}

.reset-btn:hover {
   background-color: #b71c1c;
}