/* Cá ăn từ - canvas toàn màn hình + HUD nổi (tiền tố wf-). Màu/khối lấy từ theme.css.
   Lưu ý: mép dưới của .wf-prompt quyết định vùng bơi (số làn cá) - đừng đổi chiều cao thẻ đề bài tùy tiện. */
html:has(.wfpage) { height: 100%; overflow: hidden; }
.wfpage { margin: 0; height: 100%; overflow: hidden; background: var(--c-bg); overscroll-behavior: none; touch-action: none; -webkit-user-select: none; user-select: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; max-width: none; }

/* ---------- HUD ---------- */
.wf-hud { position: fixed; left: 0; right: 0; top: 0; padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left)); pointer-events: none; z-index: 10; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.wf-bar { width: min(760px, 100%); display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 52px; }
.wf-hearts { display: inline-flex; gap: 4px; padding: 6px 12px; background: var(--c-surface); border: 2.5px solid var(--c-ink); border-radius: var(--radius-pill); box-shadow: 0 3px 0 var(--c-ink); }
.wf-hearts .heart { width: 28px; height: 28px; }
.wf-hearts.is-hit { animation: hc-shake .45s; }
.wf-scorebox { position: relative; display: flex; flex-direction: column; align-items: center; line-height: 1.05; }
.wf-score { min-width: 96px; padding: 2px 18px 4px; text-align: center; font-size: clamp(24px, 5.5vmin, 32px); font-weight: 900; letter-spacing: .5px; font-variant-numeric: tabular-nums; background: var(--c-accent); color: var(--c-accent-ink); border: 2.5px solid var(--c-ink); border-radius: var(--radius-pill); box-shadow: 0 3px 0 var(--c-ink); }
.wf-score.pop { animation: wf-pop .3s; }
.wf-combo { position: absolute; top: 100%; margin-top: 3px; white-space: nowrap; font-size: 13px; font-weight: 900; color: #fff; text-shadow: -1px -1px 0 #1b2559, 1px -1px 0 #1b2559, -1px 1px 0 #1b2559, 1px 1px 0 #1b2559, 0 2px 0 #1b2559; z-index: 1; }
.wf-tools { display: flex; gap: 8px; pointer-events: auto; }
.wf-tools .btn--icon { color: var(--c-accent); }

/* thẻ đề bài / đáp án */
.wf-prompt { pointer-events: none; position: relative; width: min(760px, 100%); display: grid; background: var(--c-surface); color: var(--c-text); border: var(--bw) solid var(--c-ink); border-radius: 22px; padding: 8px 12px 16px; box-shadow: 0 5px 0 var(--c-ink), 0 12px 26px rgba(5, 10, 34, .3); transition: background .2s; }
.wf-prompt.ok { background: var(--c-good-soft); }
.wf-prompt.bad { background: var(--c-bad-soft); }
.wf-q, .wf-a { grid-area: 1 / 1; display: flex; align-items: center; gap: 12px; min-height: 84px; }
.wf-prompt.rev .wf-q { visibility: hidden; }
.wf-prompt:not(.rev) .wf-a { visibility: hidden; }
.wf-pe { font-family: var(--font-emoji); font-size: clamp(46px, 11vmin, 70px); line-height: 1; flex: none; filter: drop-shadow(0 3px 0 rgba(5, 10, 34, .25)); }
.wf-pt { flex: 1; min-width: 0; }
.wf-pvi { font-size: clamp(24px, 6vmin, 40px); font-weight: 900; line-height: 1.12; overflow-wrap: anywhere; }
.wf-phint { font-size: clamp(12px, 2.8vmin, 15px); color: var(--c-muted); font-weight: 700; margin-top: 2px; }
.wf-listen { pointer-events: auto; flex: none; }
.wf-prompt.ok .wf-aen { color: var(--c-good); }
.wf-prompt.bad .wf-aen { color: var(--c-bad); }
.wf-aen { font-size: clamp(26px, 7vmin, 46px); font-weight: 900; line-height: 1.05; overflow-wrap: anywhere; }
.wf-avi { font-size: clamp(16px, 3.8vmin, 22px); color: var(--c-muted); font-weight: 700; margin-top: 1px; }
.wf-abtn { display: flex; gap: 8px; flex: none; pointer-events: auto; }
.wf-abtn .btn--icon { min-width: 48px; min-height: 48px; }
.wf-timer { position: absolute; left: 14px; right: 14px; bottom: 5px; height: 9px; border-radius: 5px; background: var(--c-surface-3); border: 2px solid var(--c-ink); overflow: hidden; }
.wf-timer i { display: block; height: 100%; width: 100%; transform-origin: left center; background: linear-gradient(90deg, var(--c-good-fill), var(--c-accent)); }
.wf-timer.low i { background: linear-gradient(90deg, var(--c-warn-fill), var(--c-bad-fill)); }

/* ---------- Màn hình phủ trên biển ---------- */
.wf-stage { position: fixed; inset: 0; overflow-y: auto; touch-action: pan-y; z-index: 20; padding-top: max(16px, env(safe-area-inset-top)); background: linear-gradient(rgba(5, 14, 48, .1), rgba(5, 14, 48, .45)); }
.wf-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 30; background: var(--c-overlay); touch-action: pan-y; }
.wf-panel { width: min(400px, 100%); display: flex; flex-direction: column; align-items: stretch; gap: var(--sp-3); padding: var(--sp-5); border: var(--bw) solid var(--c-ink); border-radius: 28px; box-shadow: 0 8px 0 var(--c-ink), var(--shadow-soft); background: var(--c-surface); color: var(--c-text); text-align: center; animation: hc-pop .25s cubic-bezier(.2, 1.4, .4, 1) both; }
.wf-panel__mascot { width: 104px; margin: 0 auto; }
.wf-panel__title { font-size: 2.2rem; }
.wf-panel__lead { color: var(--c-muted); font-weight: 600; }

.wf-modebox__title { font-size: var(--fs-xs); font-weight: 900; text-transform: uppercase; letter-spacing: .08em; color: var(--c-muted); margin-bottom: var(--sp-2); }
.wf-modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--sp-3); }
.wf-mode { justify-content: flex-start; gap: var(--sp-3); text-align: left; min-height: 64px; height: auto; padding: 8px 14px; border-radius: var(--radius-m); border-width: var(--bw); }
.wf-mode[aria-pressed="true"]::before { content: none; }
.wf-mode[aria-pressed="true"]::after { content: "✓"; margin-left: auto; width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--c-ink); color: #fff; font-weight: 900; font-size: 14px; }
.wf-mode__icon { font-family: var(--font-emoji); font-size: 30px; line-height: 1; flex: none; }
.wf-mode__text { display: flex; flex-direction: column; min-width: 0; }
.wf-mode__text strong { font-size: 1.05rem; font-weight: 900; }
.wf-mode__desc { font-size: var(--fs-xs); font-weight: 600; line-height: 1.25; opacity: .85; }
.wf-note { color: var(--c-warn); font-size: var(--fs-s); font-weight: 700; margin-top: var(--sp-2); }

/* cảnh báo "không lưu được": nằm ở đáy; màn hình menu/kết thúc chừa chỗ cho nó; khi đang chơi thu gọn còn một dòng và không chặn thao tác */
.wfpage .banner--warn { position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; border-bottom: 0; border-top: var(--bw) solid var(--c-ink); pointer-events: none; text-align: center; }
.wfpage:has(.banner--warn) .wf-stage { bottom: var(--banner-h, 0px); }
.wfpage:has(#stage[hidden]) .banner--warn { font-size: 0; padding: 3px 12px; opacity: .92; }
.wfpage:has(#stage[hidden]) .banner--warn strong { font-size: 12px; }
@keyframes wf-pop { 0% { transform: scale(1); } 40% { transform: scale(1.22); } 100% { transform: scale(1); } }
@media (max-height: 520px) { .wf-q, .wf-a { min-height: 64px; } .wf-pe { font-size: 44px; } }
@media (max-width: 420px) { .wf-hearts .heart { width: 24px; height: 24px; } .wf-score { min-width: 80px; padding: 2px 12px 4px; } }
@media (max-width: 480px) { .wf-abtn { flex-direction: column; gap: 6px; } .wf-abtn .btn--icon { min-height: 44px; } }
/* điện thoại: nút "Nghe lại" chỉ còn biểu tượng để thẻ đề bài không cao thêm (giữ nguyên vùng bơi) */
@media (max-width: 480px) {
  .wf-listen { font-size: 0; gap: 0; min-width: 52px; padding: 0; }
  .wf-listen .ico { width: 28px; height: 28px; }
  .wf-pvi { font-size: clamp(21px, 5.6vmin, 40px); }
  .wf-q, .wf-a { gap: 10px; }
}
