﻿
  :root {
    --bg: #f5f0e8;
    --card: #fffef9;
    --text: #3d3226;
    --muted: #8b7e6a;
    --red: #d35d47;
    --green: #4a9c6c;
    --blue: #5b8cb8;
    --gold: #e8b44b;
    --shadow: 0 2px 8px rgba(0,0,0,0.07);
    --shadow-lg: 0 6px 20px rgba(0,0,0,0.12);
    --radius: 14px;
  }
  * { margin: 0; padding: 0; box-sizing: border-box; }
  body {
    font-family: 'Segoe UI', 'Microsoft YaHei', 'PingFang SC', 'Noto Sans CJK SC', 'Hiragino Sans', 'Yu Gothic', sans-serif;
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .app {
    width: 100%;
    max-width: 760px;
    min-height: 500px;
    position: relative;
  }

  /* Views */
  .view { display: none; }
  .view.active { display: block; }

  /* Home */
  .home-card {
    background: #fffef9;
    border-radius: 24px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.08);
    padding: 48px 32px;
    text-align: center;
  }
  .home-icon { font-size: 4rem; margin-bottom: 8px; }
  .home-card h1 { font-size: 1.8rem; color: #3d3226; margin-bottom: 4px; }
  .home-card .subtitle { color: #8b7e6a; font-size: 0.95rem; margin-bottom: 8px; }
  .home-progress { color: #8b7e6a; font-size: 0.85rem; margin-bottom: 28px; }
  .home-btns { display: flex; flex-direction: column; gap: 14px; align-items: center; }
  .btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 14px 36px; border-radius: 12px; border: none;
    font-size: 1.05rem; font-weight: 700; cursor: pointer;
    transition: all 0.2s; letter-spacing: 0.03em;
    font-family: inherit;
  }
  .btn-primary {
    background: linear-gradient(135deg, #d35d47, #c0392b);
    color: #fff; box-shadow: 0 4px 14px rgba(211,93,71,0.35);
  }
  .btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(211,93,71,0.45); }
  .btn-secondary {
    background: #f5f0e8; color: #5b4e3e;
    border: 2px solid #e0d5c5;
  }
  .btn-secondary:hover { background: #ede4d6; }
  .btn-small { padding: 8px 18px; font-size: 0.85rem; border-radius: 8px; }

  /* Level Select */
  .level-list { display: flex; flex-direction: column; gap: 12px; }
  .level-card {
    background: #fffef9; border: 2px solid #e0d5c5; border-radius: 16px;
    padding: 16px; display: flex; align-items: center; gap: 14px;
    cursor: pointer; transition: all 0.2s;
  }
  .level-card:hover { border-color: #c0b59a; box-shadow: var(--shadow-lg); transform: translateY(-1px); }
  .level-emoji { font-size: 1.9rem; }
  .level-info { flex: 1; min-width: 0; }
  .level-title { font-weight: 700; color: #3d3226; margin-bottom: 2px; font-size: 0.98rem; }
  .level-desc { font-size: 0.78rem; color: #8b7e6a; line-height: 1.4; }
  .level-stars { font-size: 0.95rem; color: #e8b44b; letter-spacing: 1px; white-space: nowrap; }
  .level-stars .empty { color: #e0d5c5; }

  /* Game View */
  .game-header {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin-bottom: 12px;
  }
  .btn-back {
    background: #fff; border: 2px solid #e0d5c5; border-radius: 10px;
    padding: 8px 14px; font-size: 0.85rem; cursor: pointer;
    font-weight: 600; color: #5b4e3e; transition: all 0.2s;
    font-family: inherit;
  }
  .btn-back:hover { background: #f0ebe0; }
  .round-badge {
    background: #fff; border: 2px solid #e0d5c5; border-radius: 10px;
    padding: 6px 14px; font-weight: 700; font-size: 0.85rem; color: #3d3226;
  }
  .error-badge {
    margin-left: auto;
    background: #fff; border: 2px solid #f0d0c8; border-radius: 10px;
    padding: 6px 14px; font-weight: 700; font-size: 0.85rem; color: #d35d47;
  }
  .game-panel {
    background: #fffef9; border-radius: 20px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.08);
    padding: 24px 20px 20px;
    position: relative;
  }
  .section-label {
    text-align: center; font-size: 0.78rem; color: #8b7e6a;
    font-weight: 600; letter-spacing: 0.05em; margin-bottom: 8px;
  }
  .kana-pool {
    display: flex; justify-content: center; gap: 12px;
    flex-wrap: wrap; min-height: 82px; padding: 6px 0;
    align-items: center;
  }
  .romaji-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(56px, 110px));
    justify-content: center;
    gap: 14px;
    min-height: 96px; padding: 6px 0;
    align-items: center;
  }
  .romaji-grid.cols-7 {
    grid-template-columns: repeat(7, minmax(52px, 110px));
  }

  /* Kana card */
  .kana-card {
    width: 72px; height: 72px;
    background: #fffef9;
    border: 2.5px solid #ddd6c8;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; font-weight: 700; color: #3d3226;
    cursor: grab; transition: box-shadow 0.2s, border-color 0.2s;
    box-shadow: var(--shadow);
    position: relative;
    touch-action: none;
  }
  .kana-card:active { cursor: grabbing; }
  .kana-card:hover { border-color: #c0b59a; box-shadow: var(--shadow-lg); }
  .kana-card.dragging {
    position: fixed; z-index: 999;
    box-shadow: 0 12px 32px rgba(0,0,0,0.2);
    border-color: #5b8cb8; transform: scale(1.08);
    cursor: grabbing; pointer-events: none;
    transition: none;
  }
  .kana-card.returning {
    position: fixed;
    transition: left 0.35s cubic-bezier(0.22, 0.61, 0.36, 1),
                top 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
    z-index: 998;
    pointer-events: none;
  }
  .kana-card.in-zone {
    width: 56px; height: 56px; font-size: 1.6rem;
    cursor: grab; margin: 0;
    border-color: #c0b59a;
    transition: none;
  }
  .kana-card.placed {
    opacity: 0.3; pointer-events: none; transform: scale(0.9);
  }

  /* Romaji zone */
  .romaji-zone {
    width: 100%; min-height: 84px;
    border: 2.5px dashed #d5ccbb;
    border-radius: var(--radius);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 4px; padding: 6px;
    transition: all 0.2s;
    position: relative;
    background: #fdfaf5;
  }
  .romaji-zone .zone-label {
    font-size: 0.95rem; font-weight: 700; color: #b0a590;
    transition: all 0.2s; letter-spacing: 0.03em;
  }
  .romaji-zone.highlight {
    border-color: #5b8cb8; border-style: solid;
    background: #ecf3fa; box-shadow: 0 0 0 6px rgba(91,140,184,0.12);
    transform: scale(1.04);
  }
  .romaji-zone.filled { border-style: solid; border-color: #c0b59a; }
  .romaji-zone.correct {
    border-color: #4a9c6c; border-style: solid;
    background: #e8f4eb; box-shadow: 0 0 0 5px rgba(74,156,108,0.10);
  }
  .romaji-zone.correct .zone-label { color: #4a9c6c; }
  .romaji-zone.wrong {
    border-color: #d35d47; border-style: solid;
    background: #fdf0ed; box-shadow: 0 0 0 5px rgba(211,93,71,0.10);
    animation: shake 0.4s ease;
  }
  .romaji-zone.wrong .zone-label { color: #d35d47; }

  @keyframes shake {
    0%,100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    50% { transform: translateX(4px); }
    75% { transform: translateX(-3px); }
  }

  .divider {
    border: none; border-top: 1px dashed #e0d5c5;
    margin: 16px 0;
  }

  /* Check button area */
  .check-area {
    display: flex; justify-content: flex-end; align-items: center;
    gap: 10px; margin-top: 12px;
  }
  .btn-check {
    background: #5b8cb8; color: #fff;
    padding: 10px 24px; font-size: 0.95rem;
    box-shadow: 0 3px 10px rgba(91,140,184,0.3);
  }
  .btn-check:hover { background: #4a7da8; }
  .btn-check:disabled {
    background: #c5c0b5; cursor: not-allowed; box-shadow: none;
  }
  .btn-round-next {
    background: #4a9c6c; color: #fff;
    padding: 10px 24px; font-size: 0.95rem;
    box-shadow: 0 3px 10px rgba(74,156,108,0.3);
  }
  .btn-round-next:hover { background: #3d8a5c; }
  .hint-text {
    font-size: 0.8rem; color: #8b7e6a; text-align: right;
  }

  /* Star overlay */
  .star-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55); z-index: 1000;
    justify-content: center; align-items: center;
  }
  .star-overlay.show { display: flex; }
  .star-dialog {
    background: #fffef9; border-radius: 24px;
    padding: 36px 28px; text-align: center;
    max-width: 380px; width: 90%;
    box-shadow: 0 16px 48px rgba(0,0,0,0.25);
  }
  .star-dialog h2 { font-size: 1.4rem; margin-bottom: 4px; color: #3d3226; }
  .star-dialog .level-label { color: #8b7e6a; font-size: 0.85rem; margin-bottom: 16px; }
  .stars-row {
    display: flex; justify-content: center; gap: 8px;
    margin-bottom: 12px; font-size: 3.2rem;
  }
  .star { color: #e0d5c5; transition: all 0.4s ease; }
  .star.earned { color: #e8b44b; animation: starPop 0.5s ease; }
  @keyframes starPop {
    0% { transform: scale(0); }
    60% { transform: scale(1.3); }
    100% { transform: scale(1); }
  }
  .star-dialog .err-summary { font-size: 0.9rem; color: #5b4e3e; margin-bottom: 18px; line-height: 1.5; }
  .star-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
  .star-dialog .btn { font-size: 0.95rem; }

  /* Round complete mini-banner */
  .round-ok {
    text-align: center; padding: 8px;
    color: #4a9c6c; font-weight: 700; font-size: 0.95rem;
  }

  /* Wrong Answers View */
  .wa-card {
    background: #fffef9; border-radius: 24px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.08); padding: 28px 24px;
  }
  .wa-header {
    display: flex; align-items: center; gap: 12px; margin-bottom: 20px;
  }
  .wa-header h2 { font-size: 1.2rem; color: #3d3226; }
  .level-item {
    border: 2px solid #e0d5c5; border-radius: 12px;
    overflow: hidden; transition: all 0.2s;
  }
  .level-item.open { border-color: #c0b59a; }
  .level-summary {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; cursor: pointer; background: #fdfaf5;
    transition: background 0.2s;
  }
  .level-summary:hover { background: #f5f0e8; }
  .level-summary .level-name { font-weight: 700; color: #3d3226; }
  .level-summary .level-count { font-size: 0.85rem; color: #d35d47; font-weight: 600; }
  .level-summary .arrow { color: #8b7e6a; font-size: 1.2rem; transition: transform 0.2s; }
  .level-item.open .arrow { transform: rotate(180deg); }
  .level-detail { display: none; padding: 0 18px 16px; }
  .level-item.open .level-detail { display: block; }
  .wa-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
  .wa-table th {
    text-align: left; padding: 8px 6px; border-bottom: 2px solid #e0d5c5;
    color: #8b7e6a; font-weight: 600; font-size: 0.8rem;
  }
  .wa-table td { padding: 8px 6px; border-bottom: 1px solid #f0ebe0; color: #3d3226; }
  .wa-table .wrong-count { color: #d35d47; font-weight: 700; text-align: center; }
  .wa-empty { text-align: center; color: #8b7e6a; padding: 24px; }
  .btn-clear {
    background: transparent; border: 1px solid #d35d47; color: #d35d47;
    padding: 6px 14px; font-size: 0.78rem; border-radius: 6px;
    cursor: pointer; font-weight: 600; margin-top: 16px;
    transition: all 0.2s; font-family: inherit;
  }
  .btn-clear:hover { background: #fdf0ed; }

  /* Chart View */
  .chart-title { margin: 20px 0 10px; color: #3d3226; font-size: 1rem; }
  .chart-title:first-child { margin-top: 0; }
  .table-wrap { overflow-x: auto; }
  .kana-table {
    width: 100%; border-collapse: separate; border-spacing: 4px;
  }
  .kana-table th { font-size: 0.78rem; color: #8b7e6a; font-weight: 600; padding: 4px 2px; }
  .kana-table td {
    background: #fdfaf5; border: 1px solid #eee5d8; border-radius: 10px;
    padding: 6px 2px; text-align: center; min-width: 52px;
  }
  .kana-table td.cell-empty { background: transparent; border: none; }
  .kana-table .row-name {
    background: #f5f0e8; color: #8b7e6a; font-size: 0.72rem;
    font-weight: 600; white-space: nowrap; min-width: 44px;
  }
  .cell-kana { display: flex; justify-content: center; gap: 4px; font-size: 1.15rem; line-height: 1.2; }
  .cell-kana .kata { color: #8b7e6a; }
  .cell-roma { font-size: 0.72rem; color: #5b8cb8; font-weight: 700; }
  .tips {
    background: #fdfaf5; border: 2px solid #e0d5c5; border-radius: 14px;
    padding: 14px 16px; margin-top: 20px;
  }
  .tips h3 { font-size: 0.95rem; margin-bottom: 8px; color: #3d3226; }
  .tips ul { padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
  .tips li { font-size: 0.85rem; color: #5b4e3e; line-height: 1.55; }

  /* ═══════════════ Memory Mode ═══════════════ */
  .memory-panel {
    background: #fffef9; border-radius: 20px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.08);
    padding: 20px 18px 18px;
  }
  .memory-phase {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    margin-bottom: 10px; flex-wrap: wrap;
  }
  .phase-item {
    font-size: 0.8rem; font-weight: 700; color: #b0a590;
    padding: 6px 12px; border-radius: 999px; border: 2px solid #e0d5c5;
    background: #fdfaf5; transition: all 0.25s;
  }
  .phase-item.active { color: #fff; background: #5b8cb8; border-color: #5b8cb8; }
  .phase-item.done { color: #4a9c6c; border-color: #4a9c6c; background: #e8f4eb; }
  .phase-arrow { color: #c5bfae; font-weight: 700; }
  .memory-progress-track {
    height: 8px; background: #f0ebe0; border-radius: 999px;
    overflow: hidden; margin-bottom: 14px;
  }
  .memory-progress-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, #5b8cb8, #4a9c6c);
    border-radius: 999px; transition: width 0.5s ease;
  }
  .memory-card { min-height: 280px; display: flex; align-items: center; justify-content: center; }
  .memory-actions { display: flex; justify-content: center; margin-top: 12px; }
  .memory-actions .btn { min-width: 160px; justify-content: center; }
  .memory-actions .btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

  .mem-discover { text-align: center; width: 100%; }
  .mem-kana-row {
    display: flex; justify-content: center; gap: 18px; margin-bottom: 10px;
  }
  .kana-big {
    width: 110px; height: 110px; border-radius: 20px;
    background: #fffef9; border: 3px solid #e0d5c5;
    display: flex; align-items: center; justify-content: center;
    font-size: 3.6rem; font-weight: 700; color: #3d3226;
    box-shadow: var(--shadow); position: relative;
    opacity: 0; transform: scale(0.7);
  }
  .kana-big.kata { color: #5b4e3e; }
  .kana-big.anim-pop { animation: kanaPop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
  @keyframes kanaPop {
    0% { opacity: 0; transform: scale(0.6) rotate(-6deg); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); }
  }
  .daku-mark {
    position: absolute; top: 8px; right: 8px;
    font-size: 1.2rem; line-height: 1; color: #d35d47;
    opacity: 0; transform: translateY(-18px);
    transition: all 0.35s ease;
  }
  .daku-mark.dropped { opacity: 1; transform: translateY(0); }
  .youon-small {
    display: inline-block; font-size: 1.6rem; vertical-align: bottom;
    opacity: 0; transform: translateX(-10px);
    transition: all 0.35s ease;
  }
  .youon-small.join { opacity: 1; transform: translateX(0); }
  .mem-roma {
    font-size: 1.5rem; font-weight: 800; color: #5b8cb8;
    letter-spacing: 0.05em; margin-bottom: 10px;
  }
  .speaker-btn {
    background: #f5f0e8; border: 2px solid #e0d5c5; border-radius: 10px;
    font-size: 1rem; padding: 4px 10px; cursor: pointer;
    transition: all 0.2s; vertical-align: middle; font-family: inherit;
  }
  .speaker-btn:hover { background: #ede4d6; }
  .mem-origin {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    font-size: 1.05rem; color: #8b7e6a; margin-bottom: 10px;
    opacity: 0; transform: translateY(6px); flex-wrap: wrap;
    transition: all 0.4s ease;
  }
  .mem-origin.show { opacity: 1; transform: translateY(0); }
  .mem-origin .origin-kanji { font-weight: 700; color: #3d3226; }
  .mem-origin .origin-kana { font-weight: 700; color: #5b8cb8; }
  .mem-origin .origin-arrow { color: #c5bfae; }
  .mem-origin .origin-divider { color: #e0d5c5; }
  .mem-hint {
    font-size: 0.92rem; color: #5b4e3e; line-height: 1.6;
    background: #fdfaf5; border-radius: 12px;
    border: 2px dashed #e0d5c5; padding: 10px 14px; display: inline-block;
    max-width: 92%;
  }
  .mem-play, .mem-recall { text-align: center; width: 100%; }
  .mem-prompt { font-size: 1.05rem; font-weight: 700; color: #3d3226; margin-bottom: 16px; }
  .opt-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
    max-width: 360px; margin: 0 auto 14px;
  }
  .opt-card {
    border: 3px solid #e0d5c5; border-radius: 16px; background: #fffef9;
    padding: 18px 8px; font-size: 1.9rem; font-weight: 700; color: #3d3226;
    cursor: pointer; transition: all 0.2s; font-family: inherit;
    box-shadow: var(--shadow);
  }
  .opt-card.roma { font-size: 1.15rem; letter-spacing: 0.04em; color: #5b8cb8; }
  .opt-card:hover { border-color: #5b8cb8; transform: translateY(-2px); box-shadow: var(--shadow-lg); }
  .opt-card.correct { border-color: #4a9c6c; background: #e8f4eb; color: #4a9c6c; animation: correctPop 0.4s ease; }
  .opt-card.wrong { border-color: #d35d47; background: #fdf0ed; color: #d35d47; animation: shake 0.4s ease; }
  @keyframes correctPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
  }
  .mem-feedback {
    font-size: 0.95rem; font-weight: 700; min-height: 1.4em; margin-bottom: 4px;
  }
  .mem-feedback.ok { color: #4a9c6c; }
  .mem-feedback.bad { color: #d35d47; }
  .recall-flash {
    font-size: 5rem; font-weight: 700; color: #3d3226;
    width: 150px; height: 150px; margin: 10px auto 8px;
    border: 3px solid #5b8cb8; border-radius: 24px;
    display: flex; align-items: center; justify-content: center;
    background: #fffef9; box-shadow: var(--shadow-lg);
  }
  .recall-flash.flash { animation: recallFlash 1.5s ease; }
  @keyframes recallFlash {
    0% { opacity: 0; transform: scale(0.5); }
    25% { opacity: 1; transform: scale(1.08); }
    45% { opacity: 1; transform: scale(1); }
    70% { opacity: 1; }
    100% { opacity: 0; transform: scale(0.92); }
  }
  .mem-recall-roma { font-size: 1.2rem; font-weight: 800; color: #5b8cb8; letter-spacing: 0.08em; }
  .mem-seen { margin-top: 2px; }

  /* 主页按钮统一宽度 */
  .home-btns .btn { width: 100%; max-width: 280px; justify-content: center; }

  /* 关卡分组与锁定 */
  .level-group-title {
    font-size: 0.9rem; font-weight: 800; color: #8b7e6a;
    margin: 16px 0 8px; letter-spacing: 0.04em;
  }
  .level-group-title:first-child { margin-top: 0; }
  .level-card.locked { opacity: 0.55; }
  .level-card.locked:hover { transform: none; box-shadow: var(--shadow); }
  .lock-star { font-size: 1.05rem; }

  /* 四选一与翻牌配对 */
  .quiz-box { text-align: center; padding: 6px 0 2px; }
  .quiz-progress { font-size: 0.85rem; color: #8b7e6a; font-weight: 600; margin-bottom: 10px; }
  .quiz-prompt { font-size: 1.05rem; font-weight: 700; color: #3d3226; margin-bottom: 14px; }
  .quiz-glyph { font-size: 4.2rem; font-weight: 700; color: #3d3226; margin: 4px 0 8px; line-height: 1.15; }
  #quizArea .opt-grid { max-width: 420px; }
  .match-grid {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px;
    max-width: 540px; margin: 4px auto 14px;
  }
  .match-card {
    position: relative; height: 74px; border: 2.5px solid #ddd6c8; border-radius: 14px;
    background: #f5f0e8; cursor: pointer; font-family: inherit;
    transition: all 0.2s; box-shadow: var(--shadow);
  }
  .match-card:hover { border-color: #5b8cb8; transform: translateY(-1px); }
  .match-card .match-back {
    display: flex; align-items: center; justify-content: center; height: 100%;
    font-size: 1.5rem; color: #b0a590;
  }
  .match-card .match-front {
    display: none; align-items: center; justify-content: center; height: 100%;
    font-size: 1.7rem; font-weight: 700; color: #3d3226;
  }
  .match-card .match-front.roma { font-size: 1rem; color: #5b8cb8; letter-spacing: 0.03em; }
  .match-card.flipped { background: #fffef9; border-color: #5b8cb8; }
  .match-card.flipped .match-back { display: none; }
  .match-card.flipped .match-front { display: flex; animation: correctPop 0.3s ease; }
  .match-card.matched { border-color: #4a9c6c; background: #e8f4eb; cursor: default; opacity: 0.85; }
  .match-card.matched .match-front { color: #4a9c6c; }
  .match-card.wrong-flash { border-color: #d35d47; background: #fdf0ed; animation: shake 0.4s ease; }

  @media (max-width: 480px) {
    .match-grid { grid-template-columns: repeat(5, 1fr); gap: 6px; }
    .match-card { height: 58px; }
    .match-card .match-front { font-size: 1.25rem; }
    .match-card .match-front.roma { font-size: 0.75rem; }
    .quiz-glyph { font-size: 3.2rem; }
  }

  @media (max-width: 480px) {
    .kana-card { width: 56px; height: 56px; font-size: 1.5rem; }
    .kana-card.in-zone { width: 40px; height: 40px; font-size: 1.15rem; }
    .romaji-zone { min-height: 66px; }
    .romaji-zone .zone-label { font-size: 0.78rem; }
    .kana-pool { gap: 8px; }
    .romaji-grid { gap: 8px; grid-template-columns: repeat(auto-fit, minmax(52px, 110px)); }
    .game-panel { padding: 16px 10px 14px; }
    .kana-table td { min-width: 44px; }
  }
  /* 关卡模块：展开/折叠 */
  .level-module { border: 2px solid #e0d5c5; border-radius: 16px; overflow: hidden; background: #fffef9; }
  .level-module + .level-module { margin-top: 12px; }
  .level-module-head {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px; cursor: pointer; background: #fdfaf5;
    transition: background 0.2s;
  }
  .level-module-head:hover { background: #f5f0e8; }
  .level-module-title { font-weight: 800; color: #3d3226; flex: 1; font-size: 0.98rem; }
  .level-module-progress { font-size: 0.78rem; color: #8b7e6a; font-weight: 600; white-space: nowrap; }
  .level-module-body { display: none; padding: 0 12px 12px; }
  .level-module.open .level-module-body { display: block; }
  .level-module .arrow { color: #8b7e6a; font-size: 1.1rem; transition: transform 0.2s; }
  .level-module.open .arrow { transform: rotate(180deg); }
  .level-module-body .level-list { gap: 8px; }

  /* 记忆模式：例词与片假名强化 */
  .mem-word {
    font-size: 1rem; color: #3d3226; font-weight: 600;
    background: #fffef9; border: 2px solid #e0d5c5; border-radius: 12px;
    padding: 8px 14px; display: inline-block; margin-bottom: 10px;
  }
  .mem-word .word-mark { background: #fde9b8; color: #d35d47; border-radius: 4px; padding: 0 2px; font-weight: 800; }
  .mem-word .mem-word-mean { color: #8b7e6a; font-weight: 500; margin-left: 6px; }
  .kana-big-tag {
    position: absolute; top: -10px; right: -8px;
    background: #d35d47; color: #fff; font-size: 0.65rem; font-weight: 700;
    padding: 2px 8px; border-radius: 999px;
  }
  .mem-phrase {
    font-size: 2.2rem; font-weight: 800; color: #3d3226;
    background: #fffef9; border: 3px solid #5b8cb8; border-radius: 20px;
    padding: 18px 24px; display: inline-block; margin: 6px 0 12px;
    box-shadow: var(--shadow-lg);
  }
  .mem-phrase.anim-pop { animation: kanaPop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }

  /* 移动端细节适配 */
  @media (max-width: 480px) {
    body { padding: 12px; }
    .home-card { padding: 36px 20px; }
    .home-btns .btn { max-width: 100%; }
    .wa-card { padding: 20px 14px; }
    .level-card { padding: 12px; gap: 10px; }
    .level-module-head { padding: 12px 12px; }
    .memory-panel { padding: 16px 12px 14px; }
    .kana-big { width: 84px; height: 84px; font-size: 2.8rem; }
    .mem-phrase { font-size: 1.8rem; padding: 14px 18px; }
    .recall-flash { width: 120px; height: 120px; font-size: 4rem; }
    .opt-card { padding: 14px 6px; }
    .memory-actions .btn { min-width: 140px; }
    .star-dialog { padding: 28px 18px; }
    .level-summary .level-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .level-summary .level-count { white-space: nowrap; }
  }



/* 防止拖动时页面回弹/滚动 */
body { overscroll-behavior: none; }

/* 图表假名点击朗读 */
.kana-table td.cell-speak { cursor: pointer; transition: background 0.2s, border-color 0.2s; }
.kana-table td.cell-speak:hover { border-color: #5b8cb8; background: #ecf3fa; }
.kana-table td.cell-speak.speaking { animation: cellSpeak 0.45s ease; }
@keyframes cellSpeak {
  0% { transform: scale(1); background: #fffef9; }
  40% { transform: scale(1.12); background: #fde9b8; }
  100% { transform: scale(1); background: #fffef9; }
}


/* 寒暄语闪卡：横向、宽度随内容自适应 */
.recall-flash.phrase {
  display: inline-flex;
  width: auto;
  min-width: 120px;
  max-width: 92%;
  height: auto;
  padding: 18px 28px;
  font-size: clamp(1.3rem, 6vw, 2.2rem);
  white-space: nowrap;
  border-radius: 20px;
}


/* 冒泡提示（测试模式） */
.toast {
  position: fixed; top: 18px; left: 50%;
  transform: translateX(-50%) translateY(-16px);
  background: rgba(61, 50, 38, 0.92); color: #fff;
  padding: 12px 22px; border-radius: 999px;
  font-size: 0.9rem; font-weight: 700; letter-spacing: 0.02em;
  opacity: 0; pointer-events: none; z-index: 2000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  transition: opacity 0.3s ease, transform 0.3s ease;
  max-width: 92%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 拗音回忆闪卡：横向、宽度稍宽，避免两个假名溢出 */
.recall-flash.compound {
  width: auto;
  min-width: 180px;
  height: 150px;
  padding: 0 28px;
  white-space: nowrap;
  display: inline-flex;
  font-size: 4.2rem;
}

/* 拗音认识大卡：稍宽，避免两个假名超出边界 */
.kana-big.compound { width: 134px; font-size: 3rem; }
.kana-big.compound .youon-small { font-size: 1.4rem; }

@media (max-width: 480px) {
  .kana-big.compound { width: 104px; font-size: 2.3rem; }
  .recall-flash.compound { min-width: 140px; font-size: 3rem; padding: 0 18px; }
}

/* 手机端：7 个选项（第3/4/5轮）改为每排两个、从上往下排 */
@media (max-width: 560px) {
  .romaji-grid.cols-7 {
    grid-template-columns: repeat(2, minmax(0, 150px));
    gap: 8px;
  }
}
