/* テーマ：ミッドナイトブルー＆ゴールド */
:root {
  --bg: #020617;
  --panel: #0f172a;
  --line: #1e293b;
  --text: #f8fafc;
  --muted: #64748b;
  --shadow: 0 20px 50px rgba(0,0,0,0.7);
  --accent: #fbbf24; /* Gold */
  --accent2: #d97706;
  --pass: #10b981;
  --pass-bg: rgba(16, 185, 129, 0.1);
  --fail: #ef4444;
  --fail-bg: rgba(239, 68, 68, 0.1);
  --fingerTargetFill: #1e293b;
  --fingerTargetStroke: #fbbf24;
  --fingerActiveFill: #451a03;
  --fingerActiveStroke: #f59e0b;
  --key: #1e293b;
  --keyBorder: #334155;
  --keyText: #94a3b8;
  --boxBg: #000000;
  --char-typed: #475569;
  --char-current: #fbbf24;
  --char-future: #64748b;
}

html, body { height: 100%; margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); overflow-y: scroll; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 20px; }

.topbar{display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:16px;}
.title{font-size:20px; font-weight:900; color:var(--accent); letter-spacing:1px; display:flex; align-items:center; gap:8px; text-transform:uppercase;}
.badge{background:linear-gradient(135deg, #fbbf24, #b45309); color:#000; font-weight:800; font-size:11px; padding:3px 8px; border-radius:4px;}
.pill{display:flex; gap:10px; align-items:center;}
button{font-family:inherit;}
.btn-sm{border:1px solid var(--line); background:#1e293b; padding:6px 14px; border-radius:6px; cursor:pointer; font-weight:700; color:#cbd5e1; font-size:12px; transition:all .2s;}
.btn-sm:hover{background:#334155; border-color:#64748b; color:#fff;}
.btn-sm:active{transform:translateY(1px);}
.panel{background:var(--panel); border:1px solid var(--line); border-radius:20px; box-shadow: var(--shadow); padding:24px; position: relative;}
.displayBox{height:380px; border:2px solid var(--line); border-radius:16px; background:var(--boxBg); position:relative; margin-bottom:20px; overflow:hidden; display:flex; flex-direction:column; transition: border-color 0.2s, background-color 0.2s;}

/* ★修正箇所：リザルト画面のレイアウト調整（余白を詰める） */
.resultOverlay{position: absolute; top:0; left:0; width:100%; height:100%; background: rgba(2, 6, 23, 0.95); backdrop-filter: blur(10px); z-index: 50; display:none; flex-direction: column; align-items: center; justify-content: center; padding: 20px;}
.resultOverlay.show { display:flex; animation: fadeIn .3s ease; }
@keyframes fadeIn { from{opacity:0;} to{opacity:1;} }
.res-header { font-size:12px; color:var(--muted); letter-spacing:2px; margin-bottom:5px; font-weight:700; text-transform:uppercase; }
.res-main { font-size: 64px; font-weight: 900; line-height:1; margin-bottom: 15px; letter-spacing: -2px; background: linear-gradient(to bottom, #fff, #94a3b8); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.res-main.pass { background: linear-gradient(to bottom, #fbbf24, #d97706); -webkit-background-clip: text; -webkit-text-fill-color: transparent; text-shadow: 0 4px 20px rgba(251, 191, 36, 0.3); }
.res-main.fail { background: linear-gradient(to bottom, #94a3b8, #475569); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.res-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap:10px; width: 100%; max-width: 800px; }
.res-card { background: #1e293b; border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center; }
.res-card-title { font-size: 11px; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: 1px; }
.res-card-score { font-size: 24px; font-weight: 900; color: #fff; font-variant-numeric: tabular-nums; }
.res-card-meta { font-size: 10px; color: var(--muted); font-weight: 600; }
.res-status { margin-top: 4px; font-size: 11px; font-weight: 900; padding: 2px 8px; border-radius: 4px; text-transform: uppercase; letter-spacing: 1px; }
.res-status.pass { background: var(--pass-bg); color: var(--pass); border: 1px solid var(--pass); }
.res-status.fail { background: var(--fail-bg); color: var(--fail); border: 1px solid var(--fail); }
.res-footer { margin-top: 20px; display:flex; gap:12px; }
.btn-restart { background: var(--accent); color: #000; border:none; padding: 10px 24px; border-radius: 8px; font-weight: 800; font-size: 14px; cursor: pointer; transition: transform .1s; }
.btn-restart:hover { transform: scale(1.05); }

/* メインコンテンツエリア */
.contentFitArea{flex:1; padding:20px 30px; display:flex; flex-direction:column; justify-content:center; align-items:flex-start; gap:15px; overflow:hidden;}
.kanjiText{color:#f8fafc; font-weight:950; line-height:1.4; width:100%; white-space: pre-wrap; text-shadow: 0 2px 4px rgba(0,0,0,0.5); border-left: 4px solid var(--accent); padding-left: 16px; transition: font-size 0.2s ease;}
.kanaOneLine{width:100%; height:40px; display:flex; align-items:center; overflow:hidden; position:relative; background: rgba(15,23,42, 0.5); border-radius: 6px; padding:0 10px; margin-top:auto; border: 1px solid var(--line);}
.kanaScrollInner{display:flex; white-space:nowrap; font-family: ui-monospace, SFMono-Regular, monospace; font-size:18px; font-weight:700; transition: transform 0.15s ease-out; align-items: center; height: 100%;}
.char-typed { color: var(--char-typed); }
.char-current { color: var(--char-current); background: rgba(251, 191, 36, 0.15); border-radius: 4px; padding: 2px 4px; border-bottom: 2px solid var(--accent); }
.char-future { color: var(--char-future); }
.underArea{height:36px; background:rgba(15,23,42, 0.95); border-top:1px solid var(--line); padding:0 20px; display:flex; gap:10px; align-items:center; flex-shrink: 0;}
.typedUnder{flex:1; font-family: ui-monospace, SFMono-Regular, monospace; font-size:13px; color:#94a3b8; white-space:pre; overflow:hidden; display:flex; align-items:center;}
.continueMsg{position:absolute; top:50%; left:50%; transform:translate(-50%, -50%); background:rgba(0,0,0,0.9); color:var(--accent); padding:16px 32px; border-radius:8px; font-weight:bold; font-size:18px; border:2px solid var(--accent); display:none; z-index:20;}
.continueMsg.show{display:block;}
.shake { animation: shake 0.3s cubic-bezier(.36,.07,.19,.97) both; border-color:var(--fail); }
@keyframes shake { 10%, 90% { transform: translate3d(-1px, 0, 0); } 20%, 80% { transform: translate3d(2px, 0, 0); } 30%, 50%, 70% { transform: translate3d(-4px, 0, 0); } 40%, 60% { transform: translate3d(4px, 0, 0); } }
.error-flash { animation: flashRed 0.2s ease-out; }
@keyframes flashRed { 0% { background-color: var(--fail-bg); border-color: var(--fail); } 100% { background-color: var(--boxBg); border-color: var(--line); } }
.solved-flash { animation: flashGreen 0.2s ease-out forwards; }
@keyframes flashGreen { 0% { background-color: rgba(16, 185, 129, 0.2); } 100% { background-color: var(--boxBg); } }
.hud{display:grid; grid-template-columns: 1.5fr 1fr 1fr; gap:10px; margin-bottom:16px;}
.card{background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:8px 14px; display:flex; flex-direction:column; justify-content:center;}
.card .l{font-size:11px; color:var(--muted); font-weight:800; margin-bottom:2px;}
.card .v{font-size:18px; font-weight:950; color:#fff;}
.kbdWrap{display:flex; justify-content:center; margin:10px 0 16px;}
.kbd{user-select:none; display:flex; flex-direction:column; gap:6px;}
.row{display:flex; gap:6px; justify-content:center;}
.key{width:46px; height:42px; border-radius:6px; border:1px solid var(--keyBorder); border-bottom-width:3px; background:var(--key); color:var(--keyText); display:flex; align-items:center; justify-content:center; font-weight:bold; font-size:14px; transition: transform .05s, border-bottom-width .05s, background .1s;}
.key.wide{width:80px;} .key.xwide{width:260px;}
.key.pressed{transform:translateY(2px); border-bottom-width:1px; background:#475569; border-color:var(--accent); color:var(--accent);}
.key.target{background:var(--fingerTargetFill); border-color:var(--fingerTargetStroke); color:#fbbf24;}
.handCard{border:1px solid var(--line); border-radius:12px; background:var(--panel); padding:10px 14px;}
.handTitle{font-size:12px; color:var(--muted); font-weight:bold; margin-bottom:8px; display:flex; justify-content:space-between;}
svg{width:100%; height:140px; display:block;}
.fLabel{font-size:11px; fill:#94a3b8; font-weight:900;}
.pad{fill:#334155; stroke:#475569; stroke-width:2; transition: fill .1s, stroke .1s;}
.pad.target{fill:var(--fingerTargetFill); stroke:var(--fingerTargetStroke); stroke-width:3;}
.pad.active{fill:var(--fingerActiveFill); stroke:var(--fingerActiveStroke); stroke-width:3;}
.footer{margin-top:12px; display:flex; justify-content:space-between; color:var(--muted); font-size:12px; font-weight:700;}