/* --- レイアウト構造 --- */
.tool-island { background: #fff; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.05); border: 1px solid #e2e8f0; overflow: hidden; max-width: 1080px; margin: -60px auto 40px; }
.island-grid { display: grid; grid-template-columns: 1.2fr 0.8fr; background: #fff; }
@media (max-width: 1080px) { .island-grid { grid-template-columns: 1fr; } }

.input-panel { padding: 30px; border-right: 1px solid #f1f5f9; position: relative; }
.diagnostic-panel { padding: 30px; background: #f8fafc; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; }

/* --- 学習エリア（文字位置・ボタン位置を固定） --- */
.karuta-card-display { 
    background: #f8fafc; border-radius: 12px; border: 1px solid #e2e8f0; 
    height: 470px; position: relative; overflow: hidden;
    touch-action: none;
}

.reading-area {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 15px; /* 上の句の余白を少し詰める */
    gap: 10px;
}

/* 文字が表示されるキャンバスのサイズを固定し、ボタンの押し上げを防ぐ */
.text-canvas {
    height: 340px; width: 210px; display: flex; align-items: center; justify-content: flex-end; overflow: hidden;
}

.typing-text { 
    writing-mode: vertical-rl; text-orientation: upright; font-family: "Sawarabi Mincho", serif; 
    font-size: 1.8rem; font-weight: 800; color: #1e293b; letter-spacing: 0.4rem; 
    line-height: 2.4; height: 90%; text-align: start;
}

/* ボタンはabsoluteを外す */
.center-reveal-controls {
    position: static;
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

/* 進行表示はボタンの下に */
.progress-text {
    /*text-align: center;
    font-weight: 800;*/
    color: #94a3b8;
    font-size: 12px;
    letter-spacing: 0.05rem;
    margin-top: 6px;
    /*margin-bottom: 6px;*/
}
.progress-text #current-pos { color:#2563eb; }
.progress-text #card-number { color:#64748b; }

/* 語呂合わせ表示（回答スライダー内） */
.goro-display { font-size: 18px; font-weight: 800; color: #1e293b; padding: 12px; background: #fff; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.05); margin-bottom: 35px; width: 85%; text-align: center; }

/* --- スライダー・スタート画面 --- */
.card-slider-hidden { position: absolute; top: 0; right: -100%; width: 100%; height: 100%; background: #fff; transition: right 0.35s cubic-bezier(0.2, 1, 0.3, 1); z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.card-slider-visible { right: 0 !important; }

/* スタートオーバーレイ（統合版） */
.start-overlay { 
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 100;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 40px;
    background: #fff;
    background-image: radial-gradient(#f1f5f9 1px, transparent 1px);
    background-size: 20px 20px;
}

/* --- 右パネル：統計情報 --- */
.score-section { text-align: center;margin-top: 10px;margin-bottom: 25px; }
.timer-section { text-align: center;  margin-bottom: -25px; }
.score-circle { position: relative; width: 110px; height: 110px; margin: 0 auto; }
.score-circle svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.circle-bg { fill: none; stroke: #e2e8f0; stroke-width: 3; }
.circle-progress { fill: none; stroke: #22c55e; stroke-width: 3; stroke-linecap: round; transition: stroke-dasharray 0.5s ease; }
.score-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 22px; font-weight: 800; color: #1e293b; }
.timer-display { font-size: 28px; font-weight: 800; color: #1e293b; font-family: monospace; }
.score-label { font-weight: 800; color: #94a3b8; margin-top: 5px; font-size: 11px; text-transform: uppercase; }
.panel-sep { width: 100%; border: none; border-top: 1px solid #e2e8f0; margin: 20px 0; }

.reset-link { background:none; border:none; color:#cbd5e1; font-size:10px; cursor:pointer; margin-top:5px; text-decoration: underline; transition: 0.2s; }
.reset-link:hover { color: #ef4444; }

/* --- UI部品 --- */
.filter-chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chip { cursor: pointer; text-align: center; padding: 8px 0; background: #fff; border-radius: 6px; font-size: 13px; font-weight: 700; color: #64748b; border: 1px solid #e2e8f0; transition: 0.2s; }
.chip:has(input:checked) { background: #2563eb; color: #fff; border-color: #1d4ed8; }
.chip input { display: none; }
.arrow-btn { background: #2563eb; color: #fff; border: none; padding: 8px 24px; border-radius: 50px; cursor: pointer; font-weight: bold; box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2); }
.primary-btn { background: #22c55e; color: #fff; border: none; border-radius: 50px; cursor: pointer; font-weight: bold; }
.sub-btn { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.close-btn { margin-top: 35px; background: #64748b; color: #fff; border: none; padding: 8px 44px; border-radius: 33px; cursor: pointer; }
#card-image { width: 140px; height: auto; border-radius: 4px; box-shadow: 0 8px 25px rgba(0,0,0,0.15); }

/* --- 下部アクションエリア --- */
.action-grid { margin-top: 20px; text-align: center; }

/* アニメーション */
.joka-display { animation: fadeIn 1.5s ease-out; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 序歌全体 */
.joka-container {
    display: flex; flex-direction: column; align-items: center; gap: 20px;
}
.joka-title {
    font-size: 1rem; color: #94a3b8; letter-spacing: 0.2rem;
}

/* 縦書きのメインテキスト（最終値を採用） */
.joka-text {
    writing-mode: vertical-rl; text-orientation: upright;
    font-family: "Sawarabi Mincho", serif;
    font-size: 1.6rem; font-weight: 800;
    line-height: 2.5;
    letter-spacing: 0.5rem;
    height: 280px;
    text-align: start;
    margin: 0 8px 0 0;
}

/* スタートボタン */
#start-btn {
    width: 240px; height: 55px; font-size: 20px;
    letter-spacing: 0.3rem; border-radius: 50px; transition: transform 0.2s;
}

/* ルビ（ひらがな） */
rt {
    font-size: 0.6rem; letter-spacing: 0.1rem; color: #64748b; font-weight: 400;
}

/* SP対応（後勝ちの最終値に統一） */
@media (max-width: 768px) {

.karuta-card-display { height: 410px;}

    .reading-area {
        height: 95%;
        padding-bottom: 0;
        justify-content: flex-start;
        padding-top: 20px;
    }
    .center-reveal-controls {
        bottom: 0;
        margin-top: 0;
    }
    .progress-text {
        bottom: 70px;
        font-size: 13px;
    }

    .text-canvas {
        height: 290px; /* SPは少し低くする */
    }
    .typing-text {
        font-size: 1.6rem; /* 少し詰めて中央に寄せる */
        line-height: 2.2;
    height: 95%;
padding-right: 20px;
    }

    .diagnostic-panel {
        align-items: stretch;
        display: flex;
        flex-wrap: wrap;
    }

    .diagnostic-panel .panel-header {
        text-align: center;
        width: 100%;
    }
    .input-panel {
    padding: 30px 30px 10px;
    }

    .joka-text {
        font-size: 1.5rem;
        height: 250px;
        line-height: 2.2;
    }
    #start-btn {
        width: 200px;
        height: 56px;
    }
    rt {
        font-size: 0.5rem;
    }
.stats-row {
        display: flex;
        align-items: center; 
        margin-left: 50px;
        margin-top: 15px;
    }
.score-section, .timer-section {
        flex: 1; /* 1:1で均等に幅を持たせる */
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        margin: 0 !important;
    }
.timer-display {
        font-size: 24px;
        margin-top: 8px;
        height: 72px;
        display: flex;
        align-items: center;
    }

    .score-circle {
        width: 80px;
        height: 80px;
    }
    
    .score-text { font-size: 18px; }
}
.finish-box{ width:100%; display:none; }
.finish-card{
  padding: 22px;
  background:#fff;
  border:4px double #64748b;
  border-radius:12px;
  width:min(280px, 86vw);
  box-shadow:0 10px 25px rgba(0,0,0,0.1);
  text-align:center;
}
.finish-title{ font-size:1.2rem; font-weight:900; margin:0 0 10px; }
.finish-time{ font-size:1.1rem; font-weight:700; margin:0; }
