/* ============================================================
 * ねだん マスター（Price Master）
 * iPad 横（1180×820・1024×700）が 基本。上に 帯、左に もんだい、右に そうさ（タイル・テンキー）。
 * 色の きまり：百の かたまり＝オレンジ／のこり（十・一）の かたまり＝あお／yen＝グレー。
 * くるくる レストラン（apps/kaiten）と 同じ 色あい・ボタンの 形。
 * ============================================================ */

:root {
    --ink: #4A2E1F;
    --ink-soft: #7A5A47;
    --red: #D9534A;
    --red-dark: #A93A32;
    --panel: #FFFFFF;
    --panel-bg: #FFF1DD;
    --line: #EBCFA9;
    --blue: #3B86D1;
    --blue-dark: #2A69A8;
    --ok: #2FA866;
    --ok-dark: #1F7D4A;
    --ng: #E2574C;
    --ng-dark: #A9372E;
    --sun: #FFD34D;
    --h-bg: #FFE1BF;
    --h-edge: #F08A24;
    --h-ink: #A4520A;
    --r-bg: #D9EBFB;
    --r-edge: #3B86D1;
    --r-ink: #1F5A96;
    --y-bg: #ECECEC;
    --y-edge: #9C9C9C;
    --font: 'M PLUS Rounded 1c', 'Gowun Dodum', 'Hiragino Maru Gothic ProN', 'Hiragino Sans', 'BIZ UDPGothic', 'Meiryo', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    background: var(--panel-bg);
    color: var(--ink);
    font-family: var(--font);
    font-weight: 700;
    overscroll-behavior: none;
}

button { font-family: var(--font); color: inherit; }

/* === UI要塞化（8つの 指定・rules md 2-9） === */
.hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
    z-index: -1 !important;
    position: absolute !important;
    max-width: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
}

#app {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

/* === 上の 帯 === */
.topbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 68px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) calc(12px + env(safe-area-inset-right, 0px)) 8px calc(140px + env(safe-area-inset-left, 0px));
    border-bottom: 4px solid var(--red);
    background: #fff;
}
.top-mode {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.top-pill {
    flex: 0 0 auto;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    padding: 2px 12px;
    border-radius: 999px;
    border: 3px solid var(--line);
    font-size: 18px;
    white-space: nowrap;
}
.top-first { border-color: var(--sun); }
.quit-btn {
    flex: 0 0 auto;
    min-height: 46px;
    min-width: 88px;
    padding: 2px 12px;
    border-radius: 12px;
    border: 3px solid var(--line);
    background: #fff;
    color: var(--ink-soft);
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
}
.quit-btn.is-confirm { background: var(--ng); border-color: var(--ng-dark); color: #fff; font-size: 13px; }

/* === あそぶ ところ（左 もんだい・右 そうさ） === */
.play {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 40%);
    gap: 14px;
    padding: 14px calc(14px + env(safe-area-inset-right, 0px)) calc(14px + env(safe-area-inset-bottom, 0px)) calc(14px + env(safe-area-inset-left, 0px));
}
.q-area, .ctrl-area {
    position: relative;
    min-height: 0;
    overflow-y: auto;
    border-radius: 22px;
    background: #fff;
    border: 3px solid var(--line);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.q-area > *, .ctrl-area > * { flex-shrink: 0; }   /* 入りきらない ときに 重ならない（スクロールに する） */
.q-area > :first-child { margin-top: auto; }
.q-area > :last-child { margin-bottom: auto; }
.ctrl-area { justify-content: flex-start; background: #FFF8EE; }
/* 入りきらない ときに 上が 切れない まんなかよせ（見えている 1つを margin: auto で。rules md 2-9） */
.ctrl-area > * { margin-top: auto; margin-bottom: auto; }

.q-lead {
    margin: 0;
    text-align: center;
    font-size: 19px;
    line-height: 1.45;
    color: var(--ink-soft);
    white-space: pre-line;
    word-break: keep-all;
    overflow-wrap: anywhere;
}

/* おきゃくさんの ふきだし（おかいけい） */
.bubble {
    position: relative;
    max-width: 92%;
    padding: 10px 16px;
    border-radius: 18px;
    background: #EAF4FD;
    border: 3px solid var(--blue);
}
.bubble-text {
    margin: 0;
    font-size: 22px;
    line-height: 1.35;
    color: var(--ink);
    text-align: center;
}

/* たべものの おぼん */
.tray {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}
.tray-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 120px;
}
.tray-item img {
    width: 104px;
    height: 104px;
    object-fit: contain;
}
.tray-name {
    font-size: 15px;
    color: var(--ink);
    text-align: center;
    line-height: 1.2;
}
.tray-tag {
    padding: 0 10px;
    border-radius: 999px;
    background: var(--red);
    color: #fff;
    font-size: 16px;
    white-space: nowrap;
}
.tray.is-one .tray-item { width: 150px; }
.tray.is-one .tray-item img { width: 136px; height: 136px; }
.tray-tagonly {
    min-width: 150px;
    padding: 18px 22px;
    border-radius: 18px;
    background: #FFF7E8;
    border: 4px dashed var(--line);
    font-size: 54px;
}

/* ねだん（かたまりの 色） */
.price-box {
    display: flex;
    align-items: baseline;
    gap: 10px;
}
.price-num {
    font-size: 72px;
    line-height: 1;
    letter-spacing: 0.04em;
}
.price-yen { font-size: 30px; color: var(--ink-soft); }
/* ねだんの よこの 🔊 きく（くみたて・おかいけいの えいご・ペアの いう人） */
.hear-btn {
    align-self: center;
    margin-left: 6px;
    min-height: 54px;
    padding: 4px 18px;
    border-radius: 999px;
    border: 3px solid var(--blue-dark);
    background: var(--blue);
    box-shadow: 0 4px 0 var(--blue-dark);
    color: #fff;
    font-size: 20px;
    font-weight: 800;
    white-space: nowrap;
    cursor: pointer;
}
.hear-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--blue-dark); }
.dg-h { color: var(--h-edge); }
.dg-r { color: var(--r-edge); }
.dg-z { color: #B9B9B9; }

/* レジの まど */
.lcd {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 8px;
    min-width: 260px;
    padding: 8px 18px;
    border-radius: 14px;
    background: #23372B;
    border: 5px solid #5B6B60;
    color: #9CF2B4;
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.5);
}
.lcd-num {
    font-size: 58px;
    line-height: 1.05;
    letter-spacing: 0.08em;
    font-variant-numeric: tabular-nums;
}
.lcd-yen { font-size: 24px; }
.lcd.is-ok { border-color: var(--ok); }
.lcd.is-ng { border-color: var(--ng); animation: shake 0.35s; }

/* ならべた ことば */
.answer {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    min-height: 66px;
    width: 100%;
    padding: 8px 10px;
    border-radius: 16px;
    background: #FFFBF4;
    border: 3px dashed var(--line);
}
.answer-pre, .answer-dot { font-size: 26px; }
.answer-tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    min-height: 48px;
    align-items: center;
}
.answer.is-ok { border-style: solid; border-color: var(--ok); background: #EAF8EF; }
.answer.is-ng { border-style: solid; border-color: var(--ng); animation: shake 0.35s; }

/* タイル（ことば） */
.tile {
    min-height: 52px;
    min-width: 64px;
    padding: 4px 14px;
    border-radius: 14px;
    border: 3px solid var(--line);
    background: #fff;
    box-shadow: 0 4px 0 var(--line);
    color: var(--ink);
    font-size: 24px;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
}
.tile:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.tile.is-used { opacity: 0.25; pointer-events: none; }
.tile.tok-h { background: var(--h-bg); border-color: var(--h-edge); box-shadow: 0 4px 0 var(--h-edge); color: var(--h-ink); }
.tile.tok-r { background: var(--r-bg); border-color: var(--r-edge); box-shadow: 0 4px 0 var(--r-edge); color: var(--r-ink); }
.tile.tok-y { background: var(--y-bg); border-color: var(--y-edge); box-shadow: 0 4px 0 var(--y-edge); }
.answer-tiles .tile { min-height: 46px; font-size: 22px; padding: 2px 10px; }

/* えらぶ タイル＝左の 🔊（よむ）＋ ことば（ならべる）。🔊 は 指が 入る 44px */
.chip {
    display: inline-flex;
    align-items: stretch;
    border-radius: 14px;
    border: 3px solid var(--line);
    background: #fff;
    box-shadow: 0 4px 0 var(--line);
    overflow: hidden;
}
.chip-snd {
    flex: 0 0 auto;
    width: 44px;
    min-height: 52px;
    padding: 0;
    border: 0;
    border-right: 2px solid var(--line);
    background: #EAF4FD;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.chip-snd:active { background: #C9E0F7; }
/* よんでいる 🔊 は 光る（おわるまで もう一度 おしても やりなおさない） */
.chip-snd.is-speaking { background: var(--sun); animation: speakPulse 0.8s ease-in-out infinite; }
.hear-btn.is-speaking, .say-btn.is-speaking { animation: speakPulse 0.8s ease-in-out infinite; filter: brightness(1.12); }
.weak-item.is-speaking { border-color: var(--blue); background: #EAF4FD; }
@keyframes speakPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
.chip-word {
    min-height: 52px;
    min-width: 60px;
    padding: 4px 14px;
    border: 0;
    background: transparent;
    color: var(--ink);
    font-size: 24px;
    font-weight: 800;
    white-space: nowrap;
    cursor: pointer;
}
.chip-word:active { background: #FFF1DD; }
.chip.is-used { opacity: 0.3; box-shadow: none; }
.chip.is-used .chip-word { pointer-events: none; }

.feedback {
    margin: 0;
    min-height: 1.4em;
    text-align: center;
    font-size: 19px;
    line-height: 1.4;
    white-space: pre-line;
    word-break: keep-all;
    overflow-wrap: anywhere;
}
.feedback.is-ok { color: var(--ok-dark); }
.feedback.is-ng { color: var(--ng-dark); }
.fb-phrase { font-size: 1.2em; color: var(--ink); }

.q-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}
.say-btn, .read-btn {
    min-height: 50px;
    padding: 4px 18px;
    border-radius: 999px;
    border: 3px solid var(--blue);
    background: #fff;
    color: var(--blue-dark);
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
}
.read-btn { border-color: var(--sun); color: #8A6A00; }
.say-btn.is-big {
    min-height: 62px;
    padding: 6px 26px;
    font-size: 22px;
    background: var(--blue);
    color: #fff;
    border-color: var(--blue-dark);
    box-shadow: 0 5px 0 var(--blue-dark);
}
.next-btn {
    min-height: 58px;
    padding: 4px 30px;
    border-radius: 16px;
    border: 4px solid var(--red-dark);
    background: var(--red);
    box-shadow: 0 5px 0 var(--red-dark);
    color: #fff;
    font-size: 22px;
    font-weight: 900;
    cursor: pointer;
}
.say-btn:active, .read-btn:active, .next-btn:active { transform: translateY(3px); }

/* そうさ（右） */
.ctrl-title {
    margin: 0 0 6px;
    text-align: center;
    font-size: 17px;
    color: var(--ink-soft);
    word-break: keep-all;
    overflow-wrap: anywhere;
}
.tiles-box, .tenkey-box, .pass-box {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.tiles {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    padding: 6px 0 10px;
}
.tile-tools {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}
.tool-btn {
    min-height: 48px;
    padding: 4px 14px;
    border-radius: 12px;
    border: 3px solid var(--line);
    background: #fff;
    color: var(--ink-soft);
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
}
.tenkey {
    display: grid;
    grid-template-columns: repeat(3, 84px);
    grid-auto-rows: 70px;
    gap: 10px;
}
.key {
    border-radius: 16px;
    border: 3px solid var(--line);
    background: #fff;
    box-shadow: 0 5px 0 var(--line);
    font-size: 32px;
    font-weight: 900;
    color: var(--ink);
    cursor: pointer;
}
.key:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--line); }
.key-del { color: var(--ink-soft); font-size: 26px; }
.key-ok { background: var(--ok); border-color: var(--ok-dark); box-shadow: 0 5px 0 var(--ok-dark); color: #fff; font-size: 28px; }
.tenkey.is-off { opacity: 0.4; pointer-events: none; }
.pass-text {
    margin: 0 0 12px;
    text-align: center;
    font-size: 20px;
    line-height: 1.5;
    white-space: pre-line;
    word-break: keep-all;
    overflow-wrap: anywhere;
}
.pass-btn {
    min-height: 74px;
    padding: 6px 28px;
    border-radius: 20px;
    border: 4px solid var(--blue-dark);
    background: var(--blue);
    box-shadow: 0 6px 0 var(--blue-dark);
    color: #fff;
    font-size: 24px;
    font-weight: 900;
    cursor: pointer;
}
.pass-btn:active { transform: translateY(4px); }

/* === 重ねる 画面（はじめ・おわり） === */
.overlay {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(14px + env(safe-area-inset-top, 0px)) 14px calc(14px + env(safe-area-inset-bottom, 0px)) calc(140px + env(safe-area-inset-left, 0px));
    background: rgba(74, 46, 31, 0.45);
    overflow-y: auto;
}
.start-box, .result-box {
    width: 100%;
    max-width: 820px;
    max-height: 100%;
    overflow-y: auto;
    border-radius: 26px;
    background: #fff;
    border: 5px solid var(--red);
    padding: 16px 22px 18px;
    box-shadow: 0 14px 0 rgba(74, 46, 31, 0.25);
}
.start-head, .result-head {
    display: flex;
    align-items: center;
    gap: 14px;
}
.start-img, .result-img {
    width: 72px;
    height: 72px;
    object-fit: contain;
    flex: 0 0 auto;
}
.start-title-box { flex: 1 1 auto; min-width: 0; }
.start-title {
    margin: 0;
    font-size: 32px;
    line-height: 1.15;
    word-break: keep-all;
    overflow-wrap: anywhere;
}
.start-sub { margin: 2px 0 0; font-size: 16px; color: var(--red); letter-spacing: 0.04em; }
.start-lead {
    margin: 8px 0 6px;
    font-size: 18px;
    line-height: 1.5;
    color: var(--ink-soft);
    word-break: keep-all;
    overflow-wrap: anywhere;
}
.lang-slot { flex: 0 0 auto; align-self: flex-start; max-width: 100%; }
.opt-row {
    margin: 8px 0 0;
    padding: 8px 14px 10px;
    border-radius: 18px;
    background: var(--panel-bg);
}
.opt-pair {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
}
.opt-title { margin: 0 0 6px; font-size: 17px; }
.opt-trio { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1.2fr); }
.opt-trio .seg-btn { font-size: 14px; padding: 4px 3px; white-space: nowrap; }
.mode-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}
.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-height: 104px;
    padding: 6px 6px 8px;
    border-radius: 16px;
    border: 3px solid var(--line);
    background: #fff;
    box-shadow: 0 4px 0 var(--line);
    cursor: pointer;
    text-align: center;
}
.mode-ico { font-size: 30px; line-height: 1.1; }
.mode-name { font-size: 19px; font-weight: 900; }
.mode-sub {
    font-size: 12px;
    line-height: 1.3;
    color: var(--ink-soft);
    word-break: keep-all;
    overflow-wrap: anywhere;
}
.mode-btn.on { background: var(--red); border-color: var(--red-dark); box-shadow: 0 4px 0 var(--red-dark); color: #fff; }
.mode-btn.on .mode-sub { color: #FFE9E6; }
.seg { display: flex; gap: 8px; }
/* むずかしさ・こえの はやさ は 2×2（上の だんが やさしい・ゆっくり） */
.seg.seg-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 8px; }
/* こえの はやさ：ゆっくりを 上に 大きく、ふつう・はやいを 下に（3つ） */
.seg.seg-speed { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 8px; }
.seg.seg-speed .seg-btn:first-child { grid-column: 1 / -1; }
.seg-btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: 50px;
    padding: 4px 8px;
    border-radius: 14px;
    border: 3px solid var(--line);
    background: #fff;
    box-shadow: 0 4px 0 var(--line);
    font-size: 17px;
    font-weight: 800;
    cursor: pointer;
    word-break: keep-all;
    overflow-wrap: anywhere;
}
.seg-btn.on { background: var(--red); border-color: var(--red-dark); box-shadow: 0 4px 0 var(--red-dark); color: #fff; }
.opt-row.is-off { opacity: 0.45; pointer-events: none; }
.opt-note {
    margin: 6px 6px 0;
    min-height: 1.4em;
    font-size: 15px;
    color: var(--ink-soft);
    word-break: keep-all;
    overflow-wrap: anywhere;
}
.medal-note {
    margin: 8px 4px 0;
    padding: 8px 12px;
    border-radius: 14px;
    background: #FFF8DB;
    border: 2px dashed #E8C55A;
    font-size: 15px;
    line-height: 1.5;
    color: #6B5200;
    white-space: pre-line;
    word-break: keep-all;
    overflow-wrap: anywhere;
}
.start-foot {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    flex-wrap: wrap;
}
.voice-btn {
    min-height: 50px;
    padding: 4px 16px;
    border-radius: 14px;
    border: 3px solid var(--line);
    background: #fff;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
}
.voice-btn.is-off { color: var(--ink-soft); background: #F4F4F4; }
.sound-note { flex: 1 1 auto; margin: 0; font-size: 14px; color: var(--ink-soft); }
.start-btn {
    min-height: 64px;
    padding: 6px 34px;
    border-radius: 18px;
    border: 4px solid var(--red-dark);
    background: var(--red);
    box-shadow: 0 6px 0 var(--red-dark);
    color: #fff;
    font-size: 26px;
    font-weight: 900;
    cursor: pointer;
}
.start-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--red-dark); }
.novoice-note { margin: 8px 0 0; font-size: 14px; color: var(--ng-dark); }

.result-title { margin: 0; font-size: 30px; }
.result-score { margin: 4px 0 0; font-size: 18px; color: var(--ink-soft); white-space: pre-line; }
.result-medal {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 10px 0 0;
    padding: 8px 12px;
    border-radius: 16px;
    background: #FFF8DB;
}
.result-medal-img { width: 64px; height: 64px; object-fit: contain; }
.result-medal-name { margin: 0; font-size: 22px; }
.result-medal-why { margin: 2px 0 0; font-size: 15px; color: var(--ink-soft); word-break: keep-all; overflow-wrap: anywhere; }
.result-nomedal { margin: 10px 0 0; font-size: 16px; color: var(--ink-soft); word-break: keep-all; overflow-wrap: anywhere; }
.weak-title { margin: 12px 0 6px; font-size: 18px; }
.weak-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 8px;
}
.weak-item {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 58px;
    padding: 4px 12px;
    border-radius: 14px;
    border: 3px solid var(--line);
    background: #fff;
    cursor: pointer;
    text-align: left;
}
.weak-num { flex: 0 0 auto; font-size: 22px; min-width: 3.2em; }
.weak-en { flex: 1 1 auto; min-width: 0; font-size: 15px; color: var(--ink-soft); overflow-wrap: anywhere; }
.weak-say { font-size: 20px; }
.weak-none { margin: 4px 0 0; font-size: 16px; color: var(--ok-dark); }
.result-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.res-btn {
    flex: 1 1 180px;
    min-height: 56px;
    padding: 4px 12px;
    border-radius: 14px;
    border: 3px solid var(--line);
    background: #fff;
    box-shadow: 0 4px 0 var(--line);
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
}
.res-retry { background: var(--red); border-color: var(--red-dark); box-shadow: 0 4px 0 var(--red-dark); color: #fff; }
.res-cert { background: var(--sun); border-color: #D9A900; box-shadow: 0 4px 0 #D9A900; }

@keyframes shake {
    0%, 100% { translate: 0 0; }
    25% { translate: -6px 0; }
    75% { translate: 6px 0; }
}
@media (prefers-reduced-motion: reduce) {
    .lcd.is-ng, .answer.is-ng { animation: none; }
    .chip-snd.is-speaking, .hear-btn.is-speaking, .say-btn.is-speaking { animation: none; }
}

/* === iPad 横で ブラウザの 帯が ある（高さ 700 前後） === */
@media (max-height: 800px) {
    .start-box, .result-box { padding: 12px 18px 14px; }
    .start-img { width: 58px; height: 58px; }
    .start-title { font-size: 28px; }
    .start-lead { margin: 4px 0 4px; font-size: 16px; }
    .opt-row { margin-top: 5px; padding: 5px 12px 6px; }
    .opt-title { margin-bottom: 4px; font-size: 15px; }
    .mode-btn { min-height: 92px; }
    .seg-btn { min-height: 44px; font-size: 16px; }
    .opt-note { margin-top: 3px; font-size: 13px; min-height: 0; }
    .medal-note { margin-top: 5px; padding: 5px 10px; font-size: 14px; }
    .start-foot { margin-top: 8px; }
    .start-btn { min-height: 58px; font-size: 24px; }
    .tray-item img { width: 88px; height: 88px; }
    .tray.is-one .tray-item img { width: 112px; height: 112px; }
    .price-num { font-size: 60px; }
    .lcd-num { font-size: 50px; }
    .tenkey { grid-auto-rows: 62px; }
    .seg.seg-grid .seg-btn, .seg.seg-speed .seg-btn { min-height: 40px; }
    .hear-btn { min-height: 48px; font-size: 18px; padding: 2px 14px; }
}

/* === せまい はば === */
@media (max-width: 900px) {
    .play { grid-template-columns: minmax(0, 1fr) minmax(290px, 44%); gap: 10px; }
    .tenkey { grid-template-columns: repeat(3, 76px); }
    .mode-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mode-btn { min-height: 80px; }
}

/* === スマホの たて：上に もんだい・下に そうさ（ページを スクロール） === */
@media (max-width: 600px) and (orientation: portrait) {
    .topbar { padding-left: calc(132px + env(safe-area-inset-left, 0px)); gap: 6px; flex-wrap: wrap; min-height: 64px; }
    .top-mode { flex: 1 1 100%; order: 5; font-size: 16px; }
    .top-pill { font-size: 15px; min-height: 34px; padding: 1px 8px; }
    .quit-btn { min-height: 40px; min-width: 0; margin-left: auto; }
    .play {
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        gap: 8px;
        padding: 8px 8px calc(10px + env(safe-area-inset-bottom, 0px));
    }
    .q-area, .ctrl-area { flex: 0 0 auto; overflow: visible; padding: 10px; }
    .q-area > :first-child { margin-top: 0; }
    .q-area > :last-child { margin-bottom: 0; }
    .tray-item { width: 96px; }
    .tray-item img { width: 76px; height: 76px; }
    .tray.is-one .tray-item img { width: 100px; height: 100px; }
    .tray-tagonly { font-size: 40px; padding: 10px 16px; }
    .bubble-text { font-size: 18px; }
    .price-num { font-size: 52px; }
    .lcd { min-width: 0; width: 100%; }
    .lcd-num { font-size: 44px; }
    .tile { font-size: 20px; min-height: 48px; min-width: 52px; padding: 2px 10px; }
    .chip-snd { width: 40px; min-height: 48px; font-size: 16px; }
    .chip-word { font-size: 20px; min-height: 48px; min-width: 48px; padding: 2px 10px; }
    .price-box { flex-wrap: wrap; justify-content: center; }
    .hear-btn { min-height: 46px; font-size: 17px; padding: 2px 14px; }
    .tiles { gap: 8px; }
    .tenkey { grid-template-columns: repeat(3, minmax(0, 92px)); grid-auto-rows: 58px; }
    .overlay { padding: calc(64px + env(safe-area-inset-top, 0px)) 8px calc(8px + env(safe-area-inset-bottom, 0px)) 8px; align-items: flex-start; }
    .start-box, .result-box { padding: 10px 12px 12px; border-width: 4px; }
    .start-head { flex-wrap: wrap; }
    .lang-slot { flex: 1 1 100%; }
    .start-img { width: 50px; height: 50px; }
    .start-title { font-size: 24px; }
    .opt-pair, .opt-trio { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .mode-btn { min-height: 76px; }
    .mode-sub { font-size: 11px; }
    .start-btn { flex: 1 1 100%; }
    .weak-list { grid-template-columns: minmax(0, 1fr); }
}

/* === スマホの よこ・高さの ひくい 画面（いちばん さいごに 書く。rules md 2-9） === */
@media (max-height: 560px) and (orientation: landscape) {
    .topbar { min-height: 52px; padding-top: calc(4px + env(safe-area-inset-top, 0px)); padding-bottom: 4px; }
    .top-mode { font-size: 16px; }
    .top-pill { min-height: 32px; font-size: 15px; }
    .quit-btn { min-height: 40px; }
    .play { gap: 8px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)) calc(8px + env(safe-area-inset-left, 0px)); grid-template-columns: minmax(0, 1fr) minmax(260px, 46%); }
    .q-area, .ctrl-area { padding: 6px 8px; gap: 6px; border-radius: 16px; }
    .q-lead { font-size: 15px; }
    .bubble { padding: 4px 10px; }
    .bubble-text { font-size: 15px; }
    .tray { gap: 4px; }
    .tray-item { width: 76px; }
    .tray-item img, .tray.is-one .tray-item img { width: 54px; height: 54px; }
    .tray-name { font-size: 12px; }
    .tray-tag { font-size: 13px; }
    .tray-tagonly { font-size: 30px; padding: 6px 12px; min-width: 0; }
    .price-num { font-size: 40px; }
    .price-yen { font-size: 20px; }
    .lcd { min-width: 0; padding: 2px 12px; border-width: 4px; }
    .lcd-num { font-size: 34px; }
    .answer { min-height: 48px; padding: 4px 6px; }
    .answer-tiles .tile { min-height: 38px; font-size: 17px; }
    .feedback { font-size: 15px; }
    .say-btn, .read-btn { min-height: 42px; font-size: 15px; padding: 2px 12px; }
    .say-btn.is-big { min-height: 46px; font-size: 17px; }
    .next-btn { min-height: 46px; font-size: 18px; }
    .ctrl-title { font-size: 14px; margin-bottom: 2px; }
    .tiles { gap: 6px; padding: 2px 0 4px; }
    .tile { min-height: 42px; min-width: 48px; font-size: 18px; padding: 2px 8px; }
    .chip-snd { width: 38px; min-height: 42px; font-size: 15px; }
    .chip-word { min-height: 42px; min-width: 44px; font-size: 18px; padding: 2px 8px; }
    .hear-btn { min-height: 40px; font-size: 15px; padding: 2px 10px; margin-left: 2px; }
    .seg.seg-grid, .seg.seg-speed { gap: 4px 6px; }
    .seg.seg-grid .seg-btn, .seg.seg-speed .seg-btn { min-height: 38px; }
    .tool-btn { min-height: 40px; font-size: 14px; }
    .tenkey { grid-template-columns: repeat(3, 64px); grid-auto-rows: 44px; gap: 6px; }
    .key { font-size: 24px; }
    .pass-text { font-size: 16px; margin-bottom: 6px; }
    .pass-btn { min-height: 54px; font-size: 18px; }
    .overlay { padding: calc(6px + env(safe-area-inset-top, 0px)) 8px calc(6px + env(safe-area-inset-bottom, 0px)) calc(140px + env(safe-area-inset-left, 0px)); align-items: flex-start; }
    .start-box, .result-box { padding: 8px 14px 10px; border-width: 4px; }
    .start-img, .result-img { width: 44px; height: 44px; }
    .start-title { font-size: 22px; }
    .start-lead { font-size: 14px; margin: 2px 0; }
    .opt-row { margin-top: 4px; padding: 4px 10px 6px; }
    .mode-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .mode-btn { min-height: 64px; padding: 4px; }
    .mode-ico { font-size: 22px; }
    .mode-name { font-size: 15px; }
    .mode-sub { display: none; }
    .seg-btn { min-height: 40px; font-size: 14px; }
    .medal-note { font-size: 13px; padding: 4px 8px; }
    .start-btn { min-height: 50px; font-size: 20px; padding: 4px 22px; }
    .voice-btn { min-height: 44px; font-size: 14px; }
    .result-title { font-size: 22px; }
    .res-btn { min-height: 46px; font-size: 15px; flex-basis: 150px; }
}
