/* =====================================================================
   Thông báo đẹp cho toàn web (run 15):
   - .gn-alert  : thẻ thông báo trong trang (info / warn / danger / success)
   - .gn-over   : thẻ KẾT QUẢ ván (thắng / thua / hoà / xử thua) ở trang phòng
   - .gn-toasts : thông báo nổi (toast) tự ẩn — window.goToast(...) trong base.html
   Nạp SAU theme.css. Chỉ đổi giao diện, không đổi id / hàm JS.
   ===================================================================== */
:root {
  --gn-info: #2f7bf6;   --gn-info-bg: linear-gradient(135deg, #eef5ff 0%, #e6fbff 100%);
  --gn-warn: #f39c12;   --gn-warn-bg: linear-gradient(135deg, #fff8e6 0%, #ffefe0 100%);
  --gn-danger: #e8336f; --gn-danger-bg: linear-gradient(135deg, #fff0f4 0%, #ffe9e3 100%);
  --gn-ok: #17a673;     --gn-ok-bg: linear-gradient(135deg, #eafbf3 0%, #e7fbff 100%);
}

/* ---------- Thẻ thông báo trong trang ---------- */
.gn-alert {
  position: relative; display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px 12px 16px; margin: 0 0 12px; border-radius: 16px;
  border: 1px solid rgba(42, 31, 61, .08); border-left: 6px solid var(--gn-c, var(--gn-info));
  background: var(--gn-bg, var(--gn-info-bg)) !important; color: var(--ink, #2a1f3d);
  box-shadow: 0 1px 2px rgba(42, 31, 61, .06), 0 8px 22px -8px var(--gn-glow, rgba(47, 123, 246, .35));
  font-size: 14px; line-height: 1.45; animation: gnIn .35s cubic-bezier(.2, .9, .3, 1.2) both;
}
.gn-alert::before {                                   /* huy hiệu biểu tượng tròn nổi khối */
  content: var(--gn-icon, 'ℹ'); flex: 0 0 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-size: 15px; font-weight: 800; color: #fff;
  background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .55), transparent 42%), var(--gn-c, var(--gn-info));
  box-shadow: 0 3px 8px -2px var(--gn-glow, rgba(47, 123, 246, .45)), inset 0 -2px 0 rgba(0, 0, 0, .15);
}
.gn-alert > .gn-alert-body { flex: 1; min-width: 0; }
.gn-alert p { margin: 0 0 8px; } .gn-alert p:last-child { margin-bottom: 0; }
.gn-alert .row, .gn-alert > .gn-alert-body > button { margin-top: 4px; }
.gn-info    { --gn-c: var(--gn-info);   --gn-bg: var(--gn-info-bg);   --gn-glow: rgba(47, 123, 246, .35); --gn-icon: 'ℹ'; }
.gn-warn    { --gn-c: var(--gn-warn);   --gn-bg: var(--gn-warn-bg);   --gn-glow: rgba(243, 156, 18, .38); --gn-icon: '!'; }
.gn-danger  { --gn-c: var(--gn-danger); --gn-bg: var(--gn-danger-bg); --gn-glow: rgba(232, 51, 111, .36); --gn-icon: '⚠'; }
.gn-success { --gn-c: var(--gn-ok);     --gn-bg: var(--gn-ok-bg);     --gn-glow: rgba(23, 166, 115, .35); --gn-icon: '✓'; }
.gn-alert[hidden], .gn-alert:empty { display: none !important; }       /* ô lỗi trống thì không chiếm chỗ */
.err.gn-alert { color: #8a1538; font-weight: 600; min-height: 0; }

/* Nhãn cảnh báo nhỏ (vd đếm ngược "phải quay lại trong…") */
.gn-pill {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; padding: 4px 10px; border-radius: 999px;
  background: var(--gn-danger-bg); border: 1px solid rgba(232, 51, 111, .3); color: #a3164a; font-weight: 700;
  box-shadow: 0 4px 14px -5px rgba(232, 51, 111, .6);
}

/* ---------- Thẻ KẾT QUẢ ván ---------- */
#overCard.gn-over {
  position: relative; overflow: hidden; border: 0 !important; border-left: 0 !important; padding: 0 !important;
  border-radius: 22px !important; background: #fff !important; box-shadow: var(--shadow-3, 0 24px 60px rgba(74, 33, 119, .28));
  animation: gnPop .5s cubic-bezier(.2, .9, .3, 1.25) both;
}
.gn-over .gn-hero {
  position: relative; display: flex; gap: 16px; align-items: center; padding: 20px 20px 18px;
  background: var(--gn-hero, var(--grad-night)); color: #fff;
}
.gn-over .gn-hero::after {                            /* ánh sáng chéo bóng bẩy */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, .28) 0%, rgba(255, 255, 255, 0) 38%),
              radial-gradient(600px 160px at 85% -20%, rgba(255, 255, 255, .25), transparent 70%);
}
.gn-over .gn-medal {                                  /* huy chương tròn nổi khối */
  position: relative; z-index: 1; flex: 0 0 72px; height: 72px; border-radius: 50%;
  display: grid; place-items: center; font-size: 36px; line-height: 1;
  background: radial-gradient(circle at 34% 28%, #fff 0, rgba(255, 255, 255, .7) 18%, transparent 46%), var(--gn-medal, var(--grad-gold));
  box-shadow: 0 0 0 4px rgba(255, 255, 255, .55), 0 10px 22px -6px rgba(0, 0, 0, .45), inset 0 -4px 0 rgba(0, 0, 0, .18);
}
.gn-over .gn-head { position: relative; z-index: 1; min-width: 0; }
.gn-over .gn-kicker { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; opacity: .85; font-weight: 700; }
.gn-over .gn-title {
  margin: 2px 0 4px !important; font-size: 28px !important; line-height: 1.15; font-weight: 900;
  color: #fff !important; -webkit-text-fill-color: #fff !important; background: none !important;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .18), 0 6px 18px rgba(0, 0, 0, .25);
}
.gn-over .gn-title::after { display: none !important; }        /* bỏ gạch màu tiêu đề thẻ của theme */
.gn-over .gn-reason { margin: 0; font-size: 15px; font-weight: 600; opacity: .97; }
.gn-over .gn-code {
  display: inline-block; margin-left: 6px; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 800;
  background: rgba(255, 255, 255, .22); border: 1px solid rgba(255, 255, 255, .45); letter-spacing: .04em; vertical-align: 1px;
}
.gn-over .gn-detail {
  margin: 12px 18px 0; padding: 10px 12px; border-radius: 12px; font-size: 14px; font-weight: 600;
  background: var(--gn-detail-bg, #f6f2ff); color: var(--gn-detail-ink, #4a2177); border: 1px dashed var(--gn-detail-line, #d9c8f5);
}
.gn-over .gn-rest { padding: 14px 18px 18px; }
.gn-over .gn-rest > :first-child { margin-top: 0; }
.gn-over .gn-rest .btn, .gn-over .gn-rest button { margin: 4px 4px 0 0; }
/* biến thể theo kết quả */
/* nền đủ đậm để chữ trắng đạt tương phản (≥ 4.5:1) */
.gn-over.win     { --gn-hero: linear-gradient(135deg, #c2410c 0%, #be2a4f 55%, #a3164a 100%); --gn-medal: var(--grad-gold); }
.gn-over.lose    { --gn-hero: linear-gradient(135deg, #4c5a7a 0%, #33405e 55%, #2b1846 100%); --gn-medal: linear-gradient(135deg, #e3e8f2, #aab4c8);
                   --gn-detail-bg: #f2f4f9; --gn-detail-ink: #33405e; --gn-detail-line: #c9d1e2; }
.gn-over.draw    { --gn-hero: linear-gradient(135deg, #0f766e, #0e7490); --gn-medal: linear-gradient(135deg, #e7fff9, #9be9dc); }
.gn-over.neutral { --gn-hero: var(--grad-night); --gn-medal: var(--grad-gold); }
.gn-over.forfeit { --gn-detail-bg: #fff0f4; --gn-detail-ink: #a3164a; --gn-detail-line: #f4b3c8; }
.gn-over.forfeit.lose { --gn-hero: linear-gradient(135deg, #e8336f 0%, #a3164a 55%, #4a2177 100%); }
/* pháo giấy khi THẮNG (chỉ CSS, chạy 1 lần) */
.gn-confetti { position: absolute; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
.gn-confetti i {
  position: absolute; top: -14px; width: 8px; height: 13px; border-radius: 2px; opacity: 0;
  animation: gnFall 2.6s cubic-bezier(.25, .6, .4, 1) forwards;
}
.gn-confetti i:nth-child(6n+1) { background: #ffd23f; } .gn-confetti i:nth-child(6n+2) { background: #2ee6c5; }
.gn-confetti i:nth-child(6n+3) { background: #ff6a3d; } .gn-confetti i:nth-child(6n+4) { background: #4c6fff; }
.gn-confetti i:nth-child(6n+5) { background: #e8336f; } .gn-confetti i:nth-child(6n)   { background: #fff; }

/* ---------- Toast (thông báo nổi tự ẩn) ---------- */
.gn-toasts {
  position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 80;
  display: flex; flex-direction: column; gap: 10px; width: min(440px, calc(100vw - 32px)); pointer-events: none;
}
.gn-toast {
  pointer-events: auto; position: relative; overflow: hidden; display: flex; gap: 12px; align-items: center;
  padding: 12px 12px 14px 14px; border-radius: 16px; color: #fff; font-size: 14px; font-weight: 600; line-height: 1.4;
  background: var(--gn-t, var(--grad-night));
  box-shadow: 0 10px 30px -8px rgba(42, 31, 61, .55), inset 0 1px 0 rgba(255, 255, 255, .25);
  animation: gnToastIn .4s cubic-bezier(.2, .9, .3, 1.25) both;
}
.gn-toast.out { animation: gnToastOut .3s ease-in forwards; }
.gn-toast .gn-t-ico {
  flex: 0 0 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 18px;
  background: rgba(255, 255, 255, .22); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35);
}
.gn-toast .gn-t-msg { flex: 1; min-width: 0; text-shadow: 0 1px 1px rgba(0, 0, 0, .18); }
.gn-toast .gn-t-x {
  flex: 0 0 auto; background: rgba(255, 255, 255, .18) !important; color: #fff !important; border: 0 !important;
  box-shadow: none !important; width: 28px; height: 28px; padding: 0 !important; border-radius: 50%; cursor: pointer; font-size: 14px;
}
.gn-toast .gn-t-bar {                                   /* vạch thời gian còn lại */
  position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: rgba(255, 255, 255, .7);
  transform-origin: left; animation: gnBar linear forwards;
}
.gn-toast.info    { --gn-t: linear-gradient(135deg, #4c6fff, #12a8c9); }
.gn-toast.success { --gn-t: linear-gradient(135deg, #17a673, #12a8c9); }
.gn-toast.warn    { --gn-t: linear-gradient(135deg, #c2410c, #9a3412); }
.gn-toast.danger  { --gn-t: linear-gradient(135deg, #e8336f, #a3164a); }
.gn-toast.win     { --gn-t: linear-gradient(135deg, #c2410c, #be2a4f 60%, #a3164a); }
.gn-toast.lose    { --gn-t: linear-gradient(135deg, #4c5a7a, #2b1846); }

@keyframes gnIn { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes gnPop { 0% { opacity: 0; transform: translateY(10px) scale(.94); } 100% { opacity: 1; transform: none; } }
@keyframes gnPulse { 50% { box-shadow: 0 4px 16px -4px rgba(232, 51, 111, .75); } }
@keyframes gnFall {
  0% { opacity: 1; transform: translate3d(0, 0, 0) rotate(0); }
  100% { opacity: 0; transform: translate3d(var(--dx, 20px), 260px, 0) rotate(var(--rot, 540deg)); }
}
@keyframes gnToastIn { from { opacity: 0; transform: translateY(-14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes gnToastOut { to { opacity: 0; transform: translateY(-10px) scale(.96); } }
@keyframes gnBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }

@media (max-width: 600px) {
  .gn-toasts { top: auto; bottom: 18px; }
  .gn-over .gn-hero { padding: 16px; gap: 12px; }
  .gn-over .gn-medal { flex-basis: 56px; height: 56px; font-size: 28px; }
  .gn-over .gn-title { font-size: 22px !important; }
}
@media (prefers-reduced-motion: reduce) {
  .gn-alert, #overCard.gn-over, .gn-toast, .gn-toast.out, .gn-pill { animation: none !important; }
  .gn-confetti { display: none; }
  .gn-toast .gn-t-bar { animation: none !important; display: none; }
}
/* Chữ Lào: không giãn chữ / không viết hoa (vỡ dấu) */
:lang(lo) .gn-over .gn-kicker { letter-spacing: 0; text-transform: none; }
:lang(lo) .gn-over .gn-code { letter-spacing: 0; }

/* ---------- Hộp xác nhận đẹp thay cho confirm() của trình duyệt (vd "Xin thua?") — window.goConfirm ---------- */
.gn-modal-back {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(800px 500px at 50% 30%, rgba(74, 33, 119, .35), rgba(20, 12, 34, .62));
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: gnFade .2s ease-out both;
}
.gn-modal-back.out { animation: gnFadeOut .18s ease-in forwards; }
.gn-modal {
  position: relative; width: min(420px, 100%); border-radius: 22px; overflow: hidden; background: #fff; color: var(--ink, #2a1f3d);
  box-shadow: 0 30px 80px -20px rgba(20, 12, 34, .7), 0 0 0 1px rgba(255, 255, 255, .6) inset;
  animation: gnPop .32s cubic-bezier(.2, .9, .3, 1.25) both; text-align: center;
}
.gn-modal .gn-m-top { padding: 26px 22px 6px; background: var(--gn-m-top, linear-gradient(180deg, #f3ecff, #fff)); }
.gn-modal .gn-m-ico {
  width: 74px; height: 74px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center; font-size: 36px;
  background: radial-gradient(circle at 34% 28%, #fff 0, rgba(255, 255, 255, .6) 20%, transparent 48%), var(--gn-m-c, var(--grad-night));
  box-shadow: 0 0 0 6px rgba(255, 255, 255, .9), 0 12px 26px -8px var(--gn-m-glow, rgba(74, 33, 119, .6)), inset 0 -4px 0 rgba(0, 0, 0, .18);
}
.gn-modal h3 {
  margin: 0 0 6px !important; font-size: 21px !important; font-weight: 900; color: var(--ink, #2a1f3d) !important;
  -webkit-text-fill-color: currentColor !important; background: none !important;
}
.gn-modal h3::after { display: none !important; }
.gn-modal .gn-m-text { margin: 0 0 4px; color: var(--muted, #76688f); font-size: 15px; line-height: 1.5; }
.gn-modal .gn-m-acts { display: flex; gap: 10px; padding: 16px 22px 22px; }
.gn-modal .gn-m-acts button { flex: 1; min-height: 44px; font-size: 15px; font-weight: 800; }
.gn-modal.danger { --gn-m-top: linear-gradient(180deg, #ffe9ef, #fff); --gn-m-c: linear-gradient(135deg, #ff6a3d, #e8336f 60%, #a3164a);
                   --gn-m-glow: rgba(232, 51, 111, .6); }
.gn-modal.danger .gn-m-ok { background: linear-gradient(135deg, #ff6a3d, #e8336f 60%, #a3164a) !important; color: #fff !important; }
.gn-modal.warn { --gn-m-top: linear-gradient(180deg, #fff4dd, #fff); --gn-m-c: var(--grad-gold); --gn-m-glow: rgba(232, 138, 0, .55); }
@keyframes gnFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes gnFadeOut { to { opacity: 0; } }
@media (max-width: 420px) { .gn-modal .gn-m-acts { flex-direction: column-reverse; } }
@media (prefers-reduced-motion: reduce) { .gn-modal-back, .gn-modal-back.out, .gn-modal { animation: none !important; } }

/* ---------- Điện thoại / màn hình cảm ứng (run 17) ---------- */
@media (pointer: coarse) {
  /* vùng chạm tối thiểu ~40px (trừ các nút biểu tượng nhỏ đã có vùng riêng) */
  button:not(.x):not(.snd):not(.gn-t-x), .btn, select, input:not([type=checkbox]):not([type=radio]) { min-height: 40px; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
  #btnSound { min-width: 44px; }
}
@media (max-width: 600px) {
  main { padding-bottom: 84px; }                       /* nút 🏠 nổi không che nội dung cuối trang */
  .gn-toasts { bottom: 84px; }                         /* thông báo nổi nằm TRÊN nút 🏠, không bị che */
}
