/* ==========================================================================
   🧩 Ghép chữ thành câu (gctc) — trochoilophoc.com
   Toàn bộ font/asset là nội bộ (không CDN) để hỗ trợ bản tải offline.
   ========================================================================== */

/* ---------- Fonts (local) ---------- */
@font-face { font-family: "Baloo 2"; src: url("../fonts/baloo2/wXKrE3kTposypRyd51fcANwr.woff2") format("woff2"); font-weight: 400 800; font-display: swap;
    unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: "Baloo 2"; src: url("../fonts/baloo2/wXKrE3kTposypRyd51bcANwr.woff2") format("woff2"); font-weight: 400 800; font-display: swap;
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Baloo 2"; src: url("../fonts/baloo2/wXKrE3kTposypRyd51jcAA.woff2") format("woff2"); font-weight: 400 800; font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Quicksand"; src: url("../fonts/quicksand/6xKtdSZaM9iE8KbpRA_hJFQNcOM.woff2") format("woff2"); font-weight: 400 700; font-display: swap;
    unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: "Quicksand"; src: url("../fonts/quicksand/6xKtdSZaM9iE8KbpRA_hJVQNcOM.woff2") format("woff2"); font-weight: 400 700; font-display: swap;
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Quicksand"; src: url("../fonts/quicksand/6xKtdSZaM9iE8KbpRA_hK1QN.woff2") format("woff2"); font-weight: 400 700; font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ---------- Tokens ---------- */
:root {
    --font-display: "Baloo 2", "Segoe UI", system-ui, sans-serif;
    --font-body: "Quicksand", "Segoe UI", system-ui, sans-serif;
    --page-bg: #141a33;
    --bar-bg: #eceef3;
    --field-bg: #ffd60a;
    --field-bg-2: #ffc300;
    --bg-1: #ffe45c;   /* tâm sáng */
    --bg-2: #ffd60a;   /* màu chính */
    --bg-3: #ffc300;   /* mép */
    --ink: #1f2547;
    --muted: #6b6f8a;
    --purple: #6a3df0;
    --primary: #3b8bf5;
    --primary-dark: #1f66d1;
    --success: #18b67a;
    --danger: #ef476f;
    --radius-lg: 18px;
    --chip-font: clamp(18px, 2.4vw, 34px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    font-family: var(--font-body);
    background: var(--page-bg);
    color: var(--ink);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}
button { font-family: inherit; cursor: pointer; border: 0; }
button:disabled { cursor: not-allowed; }
button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* ==========================================================================
   Welcome / Help — phong cách vũ trụ chuẩn EduGame
   ========================================================================== */
.cosmic-screen {
    position: fixed; inset: 0; z-index: 50;
    display: none; flex-direction: column;
    background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
    color: #fff; overflow: hidden;
}
.cosmic-screen.is-active { display: flex; animation: fadeIn .4s ease; }

.stars { position: absolute; inset: -50% 0 0 0; background-repeat: repeat; pointer-events: none; }
.stars1 { background-image: radial-gradient(1px 1px at 20px 30px, #fff, transparent), radial-gradient(1px 1px at 120px 80px, #fff, transparent), radial-gradient(1px 1px at 200px 150px, #fff, transparent); background-size: 250px 250px; animation: starFall 60s linear infinite; opacity: .7; }
.stars2 { background-image: radial-gradient(2px 2px at 50px 160px, #fff, transparent), radial-gradient(2px 2px at 180px 40px, #cfe8ff, transparent); background-size: 300px 300px; animation: starFall 40s linear infinite; opacity: .6; }
.stars3 { background-image: radial-gradient(3px 3px at 100px 100px, #ffe8a3, transparent); background-size: 420px 420px; animation: starFall 25s linear infinite; opacity: .5; }
@keyframes starFall { from { transform: translateY(0); } to { transform: translateY(50%); } }

.ws-header { position: relative; z-index: 2; padding: 20px 28px; }
.ws-logo { height: 40px; }
.ws-main {
    position: relative; z-index: 2; flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 20px;
}
.ws-chips-deco { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-bottom: 18px; }
.ws-chips-deco .chip { position: relative; font-size: clamp(18px, 3vw, 30px); animation: bob 3s ease-in-out infinite; }
.ws-chips-deco .chip:nth-child(2) { animation-delay: .3s; }
.ws-chips-deco .chip:nth-child(3) { animation-delay: .6s; }
.ws-chips-deco .chip:nth-child(4) { animation-delay: .9s; }
.ws-title {
    font-family: var(--font-display); font-weight: 800;
    font-size: clamp(36px, 6vw, 72px); line-height: 1.1; margin: 0 0 12px;
    background: linear-gradient(90deg, #ffe66d, #ffb703, #ff8fab);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    text-shadow: 0 6px 30px rgba(255, 200, 80, .25);
}
.ws-title-sm { font-size: clamp(30px, 4.5vw, 52px); }
.ws-subtitle { font-size: clamp(16px, 1.8vw, 21px); opacity: .85; margin: 0 0 32px; max-width: 620px; }
.ws-btn-primary-cosmic, .btn-play {
    font-family: var(--font-display); font-weight: 700; font-size: 22px; color: #fff;
    padding: 14px 44px; border-radius: 999px;
    background: linear-gradient(135deg, #ff9a3c, #ff5e7e);
    box-shadow: 0 8px 0 #c43c5c, 0 14px 30px rgba(255, 94, 126, .45);
    transition: transform .15s, box-shadow .15s;
}
.ws-btn-primary-cosmic:hover, .btn-play:hover { transform: translateY(-2px); }
.ws-btn-primary-cosmic:active, .btn-play:active { transform: translateY(5px); box-shadow: 0 3px 0 #c43c5c, 0 6px 14px rgba(255, 94, 126, .4); }
.ws-link { margin-top: 26px; color: #bfe3ff; text-decoration: none; font-size: 15px; opacity: .8; }
.ws-link:hover { opacity: 1; text-decoration: underline; }
.ws-credit { position: relative; z-index: 2; text-align: center; padding: 14px; font-size: 13px; opacity: .6; }
.ws-credit a { color: #fff; }

.help-list {
    text-align: left; max-width: 620px; margin: 8px 0 18px; padding: 22px 28px 22px 48px;
    background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .15);
    border-radius: var(--radius-lg); font-size: 18px; line-height: 1.6; backdrop-filter: blur(6px);
}
.help-list li + li { margin-top: 10px; }
.help-count { font-weight: 700; font-size: 18px; color: #ffe66d; margin: 0 0 22px; }
.help-actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.btn-fullscreen {
    font-weight: 700; font-size: 18px; color: #fff; padding: 14px 28px; border-radius: 999px;
    background: rgba(255, 255, 255, .12); border: 2px solid rgba(255, 255, 255, .35);
}
.btn-fullscreen:hover { background: rgba(255, 255, 255, .2); }

/* ==========================================================================
   Game screen
   ========================================================================== */
#gameScreen {
    position: fixed; inset: 0; display: none;
    flex-direction: column;
    background: radial-gradient(circle at 30% 25%, var(--bg-1) 0%, var(--bg-2) 45%, var(--bg-3) 100%);
    transition: background .4s;
}
#gameScreen.is-active { display: flex; }

.gs-topbar, .gs-bottombar {
    position: relative; z-index: 5;
    background: rgba(255, 255, 255, .7);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
    padding: 8px 16px;
}
.gs-topbar { box-shadow: 0 2px 12px rgba(160, 100, 0, .15); }
.gs-bottombar { box-shadow: 0 -2px 12px rgba(160, 100, 0, .15); }
.gs-meta { font-weight: 700; color: var(--purple); font-size: 15px; }
.gs-prompt {
    font-family: var(--font-display); font-weight: 700; color: var(--purple);
    font-size: clamp(15px, 1.6vw, 22px); text-align: center; max-width: 60vw;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gs-tools { display: flex; gap: 8px; justify-content: flex-end; }
.tool-btn {
    min-width: 38px; height: 34px; padding: 0 12px; border-radius: 999px;
    font-weight: 700; font-size: 15px; color: #fff; background: var(--primary);
    box-shadow: 0 3px 0 var(--primary-dark); transition: transform .1s;
}
.tool-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--primary-dark); }
#btnSound { background: var(--success); box-shadow: 0 3px 0 #0f8a5b; }
.tool-exit { background: var(--danger); box-shadow: 0 3px 0 #c22d52; }
.tool-settings { background: #8a5cf6; box-shadow: 0 3px 0 #6237d4; font-size: 19px; line-height: 1; }
.tool-settings:hover { animation: spin .8s ease; }
@keyframes spin { to { transform: rotate(180deg); } }
.tool-history { background: #0284c7; box-shadow: 0 3px 0 #0369a1; font-size: 17px; line-height: 1; }
.tool-history:hover { background: #0ea5e9; }

/* Sân chơi — Level 1 (trong suốt, dùng nền toàn trang) */
.gs-field { position: relative; flex: 1; overflow: hidden; }

/* Thanh dưới */
.gs-bottombar { grid-template-columns: auto 1fr auto; padding: 8px 16px; }
.gs-timer {
    width: 72px; height: 64px; border-radius: 14px; background: #fff;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    box-shadow: 0 4px 12px rgba(106, 61, 240, .25); color: var(--purple); line-height: 1;
}
.gs-timer b { font-family: var(--font-display); font-size: 30px; }
.gs-timer small { font-size: 11px; font-weight: 700; opacity: .8; }
.gs-timer.is-warning { color: var(--danger); animation: pulse 1s ease-in-out infinite; }

.gs-tray {
    display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center;
    min-height: 64px; padding: 4px;
}
.gs-tray.is-shake { animation: shake .5s; }
.gs-tray.is-correct .slot .chip { box-shadow: 0 0 0 3px #fff, 0 0 18px 4px rgba(24, 182, 122, .8); }
.slot {
    min-width: 54px; height: 44px; border-radius: 999px;
    border: 2px dashed #b9bdd0; background: #dde0ea;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s, border-color .2s, min-width .2s;
}
.slot.is-target { border-color: var(--primary); background: #d3e5ff; }
.slot.is-filled { border-color: transparent; background: transparent; min-width: 0; height: auto; }

.btn-next {
    font-family: var(--font-display); font-weight: 700; font-size: 17px; color: #fff;
    padding: 12px 24px; border-radius: 999px;
    background: linear-gradient(135deg, #4fa3ff, var(--primary));
    box-shadow: 0 4px 0 var(--primary-dark);
    transition: opacity .2s, transform .1s;
}
.btn-next:disabled { opacity: .35; box-shadow: none; }
.btn-next:not(:disabled) { animation: glowPulse 1.6s ease-in-out infinite; }
.btn-next:not(:disabled):active { transform: translateY(3px); box-shadow: 0 1px 0 var(--primary-dark); }

/* ---------- Thẻ từ Jelly 3D Glossy ---------- */
.chip {
    --c1: #ff9f43; --c2: #e17b1f; --glow: rgba(255, 159, 67, .6);
    position: absolute; display: inline-flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 700; font-size: var(--chip-font);
    color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .18);
    padding: .38em .9em; border-radius: 14px; white-space: nowrap;
    background: linear-gradient(180deg, var(--c1) 0%, var(--c2) 100%);
    border: 3px solid rgba(255, 255, 255, .9);
    box-shadow: 0 6px 0 rgba(0, 0, 0, .12), 10px 10px 22px var(--glow), inset 0 -6px 12px rgba(0, 0, 0, .12);
    cursor: grab; touch-action: none; z-index: 2;
}
.chip::before { /* điểm sáng bóng */
    content: ""; position: absolute; top: 7px; left: 10px; width: 24px; height: 13px;
    border-radius: 50%; background: rgba(255, 255, 255, .55); transform: rotate(-18deg);
}
.gs-field .chip { animation: popIn .45s cubic-bezier(.34, 1.56, .64, 1) both, bob 3.6s ease-in-out infinite; }
.gs-field .chip.settled { animation: bob 3.6s ease-in-out var(--bob-delay, 0s) infinite; }
.gs-field .chip:hover { filter: brightness(1.06); }
.slot .chip { position: relative; font-size: calc(var(--chip-font) * .72); padding: .3em .75em; border-radius: 12px; animation: none; box-shadow: 0 4px 0 rgba(0, 0, 0, .12), 4px 6px 12px var(--glow); }
.slot .chip::before { top: 5px; left: 8px; width: 16px; height: 9px; }
.chip.is-dragging { position: fixed; z-index: 1000; cursor: grabbing; animation: none !important; transform: scale(1.08) rotate(-3deg); }
.chip.is-flying { position: fixed; z-index: 999; animation: none !important; transition: left .32s cubic-bezier(.3, 1.3, .6, 1), top .32s cubic-bezier(.3, 1.3, .6, 1), font-size .32s; pointer-events: none; }

.chip.c1 { --c1: #f5a65b; --c2: #d9782b; --glow: rgba(245, 140, 60, .55); }  /* cam */
.chip.c2 { --c1: #5fd3e6; --c2: #23a9c4; --glow: rgba(35, 200, 220, .55); }  /* cyan */
.chip.c3 { --c1: #f47c7c; --c2: #d94848; --glow: rgba(240, 80, 80, .55); }   /* đỏ san hô */
.chip.c4 { --c1: #7b4fe0; --c2: #4a22b0; --glow: rgba(110, 60, 220, .55); }  /* tím */
.chip.c5 { --c1: #f2cc5c; --c2: #d4a42b; --glow: rgba(240, 190, 60, .55); }  /* vàng mật */
.chip.c6 { --c1: #f58fb0; --c2: #dc5585; --glow: rgba(240, 90, 140, .55); }  /* hồng sen */
.chip.c7 { --c1: #3ccf9f; --c2: #12a374; --glow: rgba(30, 190, 130, .55); }  /* xanh ngọc */
.chip.c8 { --c1: #5f9df0; --c2: #2f6fd0; --glow: rgba(60, 130, 230, .55); }  /* xanh coban */

/* Toast */
.gs-toast {
    position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.6);
    font-family: var(--font-display); font-weight: 800; font-size: clamp(28px, 4vw, 52px);
    padding: 14px 36px; border-radius: 22px; color: #fff; opacity: 0; pointer-events: none;
    transition: opacity .25s, transform .35s cubic-bezier(.34, 1.56, .64, 1); z-index: 900;
    box-shadow: 0 14px 40px rgba(0, 0, 0, .3); text-align: center; max-width: 90vw;
}
.gs-toast.is-show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.gs-toast.is-good { background: linear-gradient(135deg, #2bd38f, #12a374); }
.gs-toast.is-bad { background: linear-gradient(135deg, #ff7a8a, #e63a5c); }
.gs-toast small { display: block; font-size: .45em; font-weight: 600; opacity: .95; margin-top: 4px; }

/* End overlay */
.end-overlay {
    position: fixed; inset: 0; z-index: 950; display: none;
    align-items: center; justify-content: center; background: rgba(15, 20, 45, .72); backdrop-filter: blur(4px);
}
.end-overlay.is-active { display: flex; animation: fadeIn .3s; }
.end-card {
    background: #fff; border-radius: 26px; padding: 34px 44px; text-align: center; min-width: 320px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .4); animation: popIn .5s cubic-bezier(.34, 1.56, .64, 1);
}
.end-stars { font-size: 52px; letter-spacing: 6px; color: #ffc300; text-shadow: 0 4px 0 #d48f00; }
.end-stars .off { color: #dfe2ea; text-shadow: none; }
.end-card h2 { font-family: var(--font-display); font-size: 36px; margin: 6px 0; color: var(--purple); }
.end-score { font-size: 22px; margin: 0; }
.end-score b { font-family: var(--font-display); font-size: 44px; color: var(--ink); }
.end-detail { color: var(--muted); font-weight: 600; margin: 4px 0 24px; }

/* ==========================================================================
   Modal cài đặt
   ========================================================================== */
.settings-overlay {
    position: fixed; inset: 0; z-index: 960; display: none;
    align-items: center; justify-content: center; padding: 16px;
    background: rgba(15, 20, 45, .55); backdrop-filter: blur(3px);
}
.settings-overlay.is-active { display: flex; animation: fadeIn .2s; }
.settings-card {
    width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto;
    background: #fff; border-radius: 22px; padding: 22px 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .35); animation: popIn .35s cubic-bezier(.34, 1.56, .64, 1);
}
.settings-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.settings-head h2 { font-family: var(--font-display); font-size: 26px; margin: 0; color: var(--purple); }
.settings-close { width: 36px; height: 36px; border-radius: 50%; background: #f0f1f6; color: var(--muted); font-size: 16px; }
.settings-close:hover { background: #e4e6ef; }
.settings-group { margin-top: 16px; }
.settings-group h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; }

.style-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.style-opt {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 14px 6px 10px; border-radius: 14px; background: #f6f7fb;
    border: 2px solid transparent; color: var(--ink); transition: border-color .15s, background .15s;
}
.style-opt:hover { background: #eef0f8; }
.style-opt.is-selected { border-color: var(--primary); background: #eaf3ff; }
.style-opt small { font-size: 12px; font-weight: 700; }
.style-opt .chip { position: relative; font-size: 18px; animation: none; cursor: pointer; pointer-events: none; }

.bg-options { display: flex; flex-wrap: wrap; gap: 10px; }
.bg-opt {
    position: relative; width: 44px; height: 44px; border-radius: 50%;
    background: radial-gradient(circle at 30% 25%, var(--o1), var(--o2) 55%, var(--o3));
    box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .08); cursor: pointer; transition: transform .15s;
}
.bg-opt:hover { transform: scale(1.08); }
.bg-opt.is-selected { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--primary); }
.bg-opt[data-bg="sun"]      { --o1: #ffe45c; --o2: #ffd60a; --o3: #ffc300; }
.bg-opt[data-bg="orange"]   { --o1: #ffd2a1; --o2: #ffab5c; --o3: #ff8a3d; }
.bg-opt[data-bg="pink"]     { --o1: #ffd6e7; --o2: #ffa3c7; --o3: #f77aa8; }
.bg-opt[data-bg="lavender"] { --o1: #e7dcff; --o2: #bba5f6; --o3: #8f72ee; }
.bg-opt[data-bg="sky"]      { --o1: #c9ecff; --o2: #7cc8f5; --o3: #4aa3e8; }
.bg-opt[data-bg="mint"]     { --o1: #d2f8e4; --o2: #7ee0b0; --o3: #3cc48a; }
.bg-opt[data-bg="night"]    { --o1: #4a4f94; --o2: #2a2e66; --o3: #161a3d; }
.bg-custom {
    --o1: #fff; --o2: #fff; --o3: #fff;
    background: conic-gradient(#ff5e7e, #ffd60a, #3ccf9f, #4aa3e8, #8a5cf6, #ff5e7e);
    overflow: hidden;
}
.bg-custom::after { content: "+"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 22px; text-shadow: 0 1px 3px rgba(0, 0, 0, .4); pointer-events: none; }
.bg-custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }

.settings-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 22px; }
.settings-reset { background: none; color: var(--muted); font-weight: 700; font-size: 14px; text-decoration: underline; padding: 6px 0; }
.settings-reset:hover { color: var(--ink); }
.settings-done { animation: none !important; padding: 12px 36px; }

@media (max-width: 480px) {
    .style-options { grid-template-columns: repeat(2, 1fr); }
}

/* ==========================================================================
   Kiểu thẻ từ (class cs-* trên body hoặc ô xem trước trong cài đặt)
   ========================================================================== */
/* Bong bóng: tròn, gradient cầu */
body.cs-bubble .chip:not(.preview), .style-opt.cs-bubble .chip {
    border-radius: 999px; padding: .38em 1.05em;
    background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, .55) 0 12%, var(--c1) 30%, var(--c2) 100%);
    border: 2px solid rgba(255, 255, 255, .85);
}
body.cs-bubble .chip:not(.preview)::before, .style-opt.cs-bubble .chip::before { top: 6px; left: 16%; width: 30%; height: 10px; border-radius: 999px; transform: none; }

/* Phẳng hiện đại: màu đặc, không bóng sáng */
body.cs-flat .chip:not(.preview), .style-opt.cs-flat .chip {
    background: var(--c2); border: 0; border-radius: 12px; text-shadow: none;
    box-shadow: 0 5px 0 rgba(0, 0, 0, .18);
}
body.cs-flat .chip:not(.preview)::before, .style-opt.cs-flat .chip::before { display: none; }

/* Thẻ giấy: nền trắng, chữ màu */
body.cs-paper .chip:not(.preview), .style-opt.cs-paper .chip {
    background: #fffdf7; color: var(--c2); text-shadow: none;
    border: 2px solid var(--c1); border-radius: 10px;
    box-shadow: 0 5px 0 var(--c2), 6px 10px 18px rgba(0, 0, 0, .12);
}
body.cs-paper .chip:not(.preview)::before, .style-opt.cs-paper .chip::before { display: none; }

/* Ô xem trước luôn đúng kiểu của chính nó, không bị kiểu trên body ghi đè */
.style-opt.cs-jelly .chip {
    border-radius: 14px; padding: .38em .9em; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .18);
    background: linear-gradient(180deg, var(--c1) 0%, var(--c2) 100%);
    border: 3px solid rgba(255, 255, 255, .9);
    box-shadow: 0 6px 0 rgba(0, 0, 0, .12), 10px 10px 22px var(--glow), inset 0 -6px 12px rgba(0, 0, 0, .12);
}
.style-opt.cs-jelly .chip::before { display: block; top: 7px; left: 10px; width: 24px; height: 13px; border-radius: 50%; transform: rotate(-18deg); }

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -6px; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes glowPulse { 0%, 100% { box-shadow: 0 4px 0 var(--primary-dark), 0 0 0 0 rgba(59, 139, 245, .5); } 50% { box-shadow: 0 4px 0 var(--primary-dark), 0 0 0 10px rgba(59, 139, 245, 0); } }

/* ---------- Chế độ Tìm từ đúng ---------- */
.tray-word-fixed {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: calc(var(--chip-font) * .72);
    color: var(--ink);
    padding: .3em .65em;
    background: rgba(255, 255, 255, .85);
    border-radius: 12px;
    border: 2px solid rgba(26, 54, 93, 0.12);
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .05);
}
.slot.gc-blank {
    min-width: 64px;
    border: 2.5px dashed #4f46e5;
    background: rgba(99, 102, 241, 0.08);
    border-radius: 14px;
    transition: all .2s ease;
}
.slot.gc-blank.is-target {
    background: rgba(99, 102, 241, 0.22);
    border-color: #4338ca;
    transform: scale(1.05);
}
.slot.gc-blank.is-locked {
    border: 2.5px solid #10b981 !important;
    background: transparent !important;
}
.slot.gc-blank.is-locked .chip {
    pointer-events: none;
    cursor: default;
    filter: brightness(1.02);
    box-shadow: 0 0 0 3px #fff, 0 0 16px rgba(16, 185, 129, 0.85);
    animation: popIn .3s ease !important;
}

/* ---------- Pill Options trong Modal Cài đặt ---------- */
.pill-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.pill-opt {
    padding: 7px 15px;
    border-radius: 999px;
    background: #f6f7fb;
    border: 2px solid transparent;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
    cursor: pointer;
    transition: all .15s ease;
}
.pill-opt:hover {
    background: #eef0f8;
}
.pill-opt.is-selected {
    border-color: var(--primary);
    background: #eaf3ff;
    color: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(59, 139, 245, .25);
}

/* Responsive */
@media (max-width: 720px) {
    .gs-topbar { grid-template-columns: 1fr auto; }
    .gs-prompt { grid-column: 1 / -1; grid-row: 2; max-width: none; white-space: normal; }
    .gs-bottombar { grid-template-columns: auto 1fr; }
    .btn-next { grid-column: 1 / -1; }
    .gs-timer { width: 58px; height: 52px; }
    .gs-timer b { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ==========================================================================
   Vòng gọi tên học sinh (Vertical Slot Reel - 7 hàng, mờ dần từ giữa)
   ========================================================================== */
.call-name-overlay {
    position: fixed; inset: 0; z-index: 940; display: none;
    align-items: center; justify-content: center; padding: 16px;
    background: radial-gradient(circle at 50% 40%, rgba(26, 32, 70, 0.88), rgba(10, 14, 35, 0.96));
    backdrop-filter: blur(8px);
}
.call-name-overlay.is-active {
    display: flex;
    animation: fadeIn .25s ease-out;
}

.cn-card {
    position: relative;
    width: min(480px, 94vw);
    background: linear-gradient(180deg, #ffffff 0%, #f7f9fe 100%);
    border-radius: 26px;
    padding: 24px 28px 20px;
    text-align: center;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 255, 255, .15);
    animation: popIn .4s cubic-bezier(.34, 1.56, .64, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Head */
.cn-badge {
    display: inline-block;
    padding: 5px 14px;
    border-radius: 999px;
    background: linear-gradient(135deg, #7b4fe0, #5c27db);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    box-shadow: 0 4px 12px rgba(123, 79, 224, .35);
    margin-bottom: 8px;
}
.cn-title {
    font-family: var(--font-display);
    font-size: 26px;
    margin: 0;
    color: var(--purple);
    line-height: 1.25;
}
.cn-subtitle {
    margin: 4px 0 16px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
}
.cn-subtitle b {
    color: var(--primary);
}
.cn-turn-quota {
    display: inline-block;
    background: #eef2ff;
    color: #4f46e5;
    padding: 1px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
}

/* Reel Wrapper & Viewport */
.cn-reel-wrapper {
    position: relative;
    width: 100%;
    max-width: 380px;
    height: 364px; /* 7 hàng x 52px */
    margin: 0 auto 18px;
    background: #ffffff;
    border-radius: 18px;
    border: 2px solid #e5e9f4;
    box-shadow: inset 0 3px 12px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .05);
    overflow: hidden;
}

/* Khung Spotlight ở hàng 4 (chính giữa: top 156px, cao 52px) */
.cn-spotlight-frame {
    position: absolute;
    top: 156px;
    left: 8px;
    right: 8px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(90deg, rgba(255, 214, 10, 0.08) 0%, rgba(255, 171, 92, 0.14) 50%, rgba(255, 214, 10, 0.08) 100%);
    border: 2.5px solid #ffb703;
    box-shadow: 0 0 16px rgba(255, 183, 3, 0.45), inset 0 0 12px rgba(255, 183, 3, 0.2);
    pointer-events: none;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    transition: all .3s ease;
}
.cn-spotlight-frame.is-celebrate {
    border-color: #ffd60a;
    box-shadow: 0 0 25px rgba(255, 214, 10, 0.8), inset 0 0 18px rgba(255, 214, 10, 0.4);
    animation: spotlightPulse 0.8s ease-in-out infinite alternate;
}
@keyframes spotlightPulse {
    0% { transform: scale(1); filter: brightness(1); }
    100% { transform: scale(1.02); filter: brightness(1.2); }
}

.cn-pointer {
    font-size: 16px;
    color: #ffb703;
    text-shadow: 0 2px 4px rgba(0, 0, 0, .2);
    animation: pointerBounce 1.2s ease-in-out infinite;
}
.cn-pointer-left { animation-direction: alternate; }
.cn-pointer-right { animation-direction: alternate-reverse; }
@keyframes pointerBounce {
    0% { transform: translateX(0); }
    100% { transform: translateX(3px); }
}

/* Viewport 7 hàng cắt gradient mask mờ dần từ giữa */
.cn-reel-viewport {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom,
        transparent 0%,
        rgba(0, 0, 0, 0.15) 12%,
        rgba(0, 0, 0, 0.6) 28%,
        rgba(0, 0, 0, 1) 42%,
        rgba(0, 0, 0, 1) 58%,
        rgba(0, 0, 0, 0.6) 72%,
        rgba(0, 0, 0, 0.15) 88%,
        transparent 100%
    );
    mask-image: linear-gradient(to bottom,
        transparent 0%,
        rgba(0, 0, 0, 0.15) 12%,
        rgba(0, 0, 0, 0.6) 28%,
        rgba(0, 0, 0, 1) 42%,
        rgba(0, 0, 0, 1) 58%,
        rgba(0, 0, 0, 0.6) 72%,
        rgba(0, 0, 0, 0.15) 88%,
        transparent 100%
    );
}

.cn-reel-strip {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    will-change: transform;
}

.cn-reel-item {
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    color: #2b304c;
    letter-spacing: .02em;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: transform .25s ease, color .25s ease, filter .25s ease;
}

.cn-item-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 10px;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .14);
    flex-shrink: 0;
    transition: transform .25s ease;
}

.cn-item-mascot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-right: 10px;
    background: #eef2ff;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .1);
    flex-shrink: 0;
    line-height: 1;
    transition: transform .25s ease;
}

.cn-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cn-reel-item.is-winner {
    color: #b45309;
    font-size: 21px;
    font-weight: 800;
    text-shadow: 0 2px 10px rgba(217, 119, 6, .3);
    transform: scale(1.08);
}

.cn-reel-item.is-winner .cn-item-avatar,
.cn-reel-item.is-winner .cn-item-mascot {
    transform: scale(1.22);
    border-color: #ffd60a;
    box-shadow: 0 0 14px rgba(255, 214, 10, 0.85);
}

/* Actions */
.cn-actions {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 4px;
}
.cn-btn-spin {
    padding: 13px 40px;
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #ff9f43 0%, #ff5252 100%);
    border: none;
    border-radius: 999px;
    box-shadow: 0 6px 0 #d93838, 0 10px 24px rgba(255, 82, 82, .45);
    cursor: pointer;
    transition: all .15s ease;
}
.cn-btn-spin:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 0 #d93838, 0 14px 28px rgba(255, 82, 82, .55);
}
.cn-btn-spin:active:not(:disabled) {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #d93838, 0 4px 12px rgba(255, 82, 82, .4);
}
.cn-btn-spin:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none !important;
}

.cn-post-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    animation: fadeIn .3s ease;
}
.cn-btn-respin {
    padding: 12px 20px;
    border-radius: 999px;
    border: 2px solid #d2d7e5;
    background: #f6f7fb;
    color: #4b526d;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s ease;
}
.cn-btn-respin:hover {
    background: #eaeef8;
    color: #2b304c;
    border-color: #bbc2d4;
}
.cn-btn-start-q {
    padding: 12px 28px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    font-size: 15px;
    font-weight: 800;
    box-shadow: 0 5px 0 #047857, 0 8px 20px rgba(16, 185, 129, .4);
    cursor: pointer;
    transition: all .15s ease;
}
.cn-btn-start-q:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 0 #047857, 0 12px 24px rgba(16, 185, 129, .5);
}
.cn-btn-start-q:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 #047857, 0 4px 10px rgba(16, 185, 129, .3);
}

.cn-footer-info {
    margin-top: 14px;
    font-size: 13px;
    color: var(--muted);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}
.cn-btn-history-link {
    border: none;
    background: #edf2f7;
    color: #4b526d;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s ease;
}
.cn-btn-history-link:hover {
    background: #e2e8f0;
    color: #1e293b;
}

/* ==========================================================================
   Modal Lịch sử lượt gọi 📜
   ========================================================================== */
.call-history-overlay {
    position: fixed;
    inset: 0;
    z-index: 965;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 20, 45, .65);
    backdrop-filter: blur(4px);
}
.call-history-overlay.is-active {
    display: flex;
    animation: fadeIn .2s ease;
}
.ch-card {
    width: min(540px, 100%);
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 24px;
    padding: 22px 24px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .35);
    animation: popIn .35s cubic-bezier(.34, 1.56, .64, 1);
    overflow: hidden;
}
.ch-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 10px;
}
.ch-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 999px;
    background: #e0f2fe;
    color: #0284c7;
    letter-spacing: .05em;
}
.ch-title {
    font-family: var(--font-display);
    font-size: 24px;
    margin: 4px 0 2px;
    color: var(--purple);
}
.ch-subtitle {
    font-size: 13px;
    color: var(--muted);
    margin: 0;
    font-weight: 600;
}
.ch-subtitle b {
    color: var(--ink);
}
.ch-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f0f1f6;
    color: var(--muted);
    font-size: 16px;
    cursor: pointer;
    transition: all .15s ease;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ch-close:hover {
    background: #e4e6ef;
    color: var(--ink);
}

.ch-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 0 12px;
    border-bottom: 1px solid #edf0f7;
}
.ch-tabs {
    display: flex;
    gap: 6px;
    background: #f1f3f9;
    padding: 4px;
    border-radius: 999px;
}
.ch-tab {
    border: none;
    background: transparent;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    cursor: pointer;
    transition: all .15s ease;
}
.ch-tab.is-active {
    background: #fff;
    color: var(--purple);
    box-shadow: 0 2px 6px rgba(106, 61, 240, .15);
}
.ch-btn-reset {
    border: none;
    background: #fef2f2;
    color: #ef4444;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 12px;
    cursor: pointer;
    transition: all .15s ease;
}
.ch-btn-reset:hover {
    background: #fee2e2;
}

.ch-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 2px;
    min-height: 220px;
    max-height: 52vh;
}
.ch-body::-webkit-scrollbar {
    width: 6px;
}
.ch-body::-webkit-scrollbar-thumb {
    background: #dcdfe8;
    border-radius: 999px;
}

.ch-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 16px;
    background: #f8fafc;
    border: 1px solid #edf2f7;
    margin-bottom: 8px;
    transition: background .15s ease;
}
.ch-item:hover {
    background: #f1f5f9;
}
.ch-item-turn {
    font-size: 11px;
    font-weight: 800;
    color: #6366f1;
    background: #eef2ff;
    padding: 3px 8px;
    border-radius: 8px;
    flex-shrink: 0;
}
.ch-item-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
}
.ch-item-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}
.ch-item-info {
    flex: 1;
    min-width: 0;
}
.ch-item-name {
    font-weight: 800;
    font-size: 15px;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ch-item-meta {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}
.ch-item-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    background: #dcfce7;
    color: #15803d;
    white-space: nowrap;
    flex-shrink: 0;
}
.ch-item-badge.is-pending {
    background: #fef3c7;
    color: #b45309;
}

.ch-empty {
    text-align: center;
    padding: 40px 16px;
    color: var(--muted);
}
.ch-empty-icon {
    font-size: 44px;
    display: block;
    margin-bottom: 8px;
}
.ch-empty p {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--ink);
}
.ch-empty small {
    font-size: 13px;
}

.ch-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 12px;
    border-top: 1px solid #edf0f7;
}
.ch-done-btn {
    min-width: 110px;
    height: 40px;
    font-size: 14px;
    padding: 0 24px;
}



