/* Sảnh Đấu Trí của Orin — giao diện chung (tông lăng mộ ngầm: xanh đêm, bạc, lửa hồn lam, chút vàng). */
:root {
  --bg: #070d18;
  --bg2: #0c1526;
  --panel: rgba(12, 21, 38, 0.82);
  --panel-solid: #0e1930;
  --line: rgba(160, 190, 230, 0.18);
  --line-strong: rgba(170, 205, 245, 0.38);
  --ink: #e8eefb;
  --ink-dim: #9fb0cc;
  --ink-faint: #6c7d9a;
  --ice: #7dd3fc;
  --ice-deep: #38bdf8;
  --gold: #e8c36a;
  --gold-deep: #b98f2e;
  --bone: #f1ece0;
  --abyss: #1d3b6e;
  --win: #86efac;
  --lose: #fca5a5;
  --violet: #a78bfa;
  --danger: #f87171;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Cormorant Garamond', 'Times New Roman', serif;
  color-scheme: dark;
}
* { box-sizing: border-box; font-variant-numeric: lining-nums; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; }
body { overflow-x: hidden; }
button { font: inherit; color: inherit; }
img { max-width: 100%; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Nền sảnh ---------- */
.backdrop { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.backdrop-img {
  position: absolute; inset: -4%;
  background:
    radial-gradient(ellipse at 50% 38%, rgba(56, 120, 200, 0.16), transparent 62%),
    radial-gradient(ellipse at 50% 120%, rgba(232, 195, 106, 0.08), transparent 55%),
    linear-gradient(180deg, #08101f 0%, #070d18 60%, #05090f 100%);
  background-size: cover; background-position: center;
  transform: scale(1.04);
  animation: drift 40s ease-in-out infinite alternate;
}
.backdrop-img.has-art { opacity: 0.42; filter: saturate(0.9) blur(1.5px); }
.backdrop::after { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 30%, rgba(3, 6, 12, 0.85) 100%); }
#ambient { position: absolute; inset: 0; width: 100%; height: 100%; }
@keyframes drift { from { transform: scale(1.04) translate3d(-0.8%, -0.4%, 0); } to { transform: scale(1.07) translate3d(0.8%, 0.6%, 0); } }

/* ---------- Khung trang ---------- */
.app { position: relative; z-index: 1; min-height: 100dvh; display: flex; flex-direction: column; }
.loading, .notice { margin: auto; text-align: center; padding: 32px 20px; max-width: 520px; }
.loading p, .notice p { color: var(--ink-dim); line-height: 1.6; }
.notice h1 { font-family: var(--display); font-size: 34px; margin: 12px 0 6px; color: var(--gold); letter-spacing: 0.02em; }
.notice img.portrait { width: 160px; height: 160px; border-radius: 50%; object-fit: cover; border: 2px solid var(--line-strong); box-shadow: 0 0 40px rgba(125, 211, 252, 0.25); }
.sigil { width: 72px; height: 72px; margin: 0 auto; border-radius: 50%; border: 2px solid var(--ice); border-top-color: transparent; border-bottom-color: var(--gold); animation: spin 1.4s linear infinite; box-shadow: 0 0 24px rgba(125, 211, 252, 0.35); }
@keyframes spin { to { transform: rotate(360deg); } }

.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, rgba(7, 13, 24, 0.92), rgba(7, 13, 24, 0.6)); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 20; }
.topbar .crest { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line-strong); }
.topbar .title { min-width: 0; flex: 1; }
.topbar .title b { display: block; font-family: var(--display); font-size: 21px; line-height: 1.1; letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title span { font-size: 12px; color: var(--ink-dim); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); font-size: 12px; color: var(--ink-dim); white-space: nowrap; }
.chip.hard { color: #fecaca; border-color: rgba(248, 113, 113, 0.4); }
.chip.easy { color: #bbf7d0; border-color: rgba(134, 239, 172, 0.35); }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); display: grid; place-items: center; cursor: pointer; font-size: 17px; transition: background 0.15s, border-color 0.15s, transform 0.1s; }
.icon-btn:hover { background: rgba(125, 211, 252, 0.1); border-color: var(--line-strong); }
.icon-btn:active { transform: scale(0.95); }

.arena { width: 100%; max-width: 1500px; margin: 0 auto; padding: 14px 16px 28px; display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) 340px; grid-template-areas: 'stage orin' 'stage panel'; align-items: start; }
.stage-col { grid-area: stage; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.orin-col { grid-area: orin; }
.panel-col { grid-area: panel; display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 900px) {
  .arena { grid-template-columns: 1fr; grid-template-areas: 'orin' 'stage' 'panel'; padding: 10px 12px 24px; gap: 10px; }
  .topbar .title b { font-size: 18px; }
}

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); backdrop-filter: blur(4px); }
.card h3 { margin: 0 0 8px; font-family: var(--display); font-size: 19px; color: var(--gold); letter-spacing: 0.02em; }
.card .pad { padding: 14px; }

/* ---------- Sân khấu (bàn cờ + lớp hiệu ứng) ---------- */
.stage { position: relative; border-radius: 18px; isolation: isolate; }
/* Lớp hiệu ứng chỉ vẽ ánh sáng cộng ('lighter'); tấm hoạt ảnh art/vfx/*.webp có nền đen đặc nên phải hòa "screen"
   vào bàn cờ, nếu không nền đen hiện thành ô vuông đen (sửa 2026-11-30). */
.stage .fx { position: absolute; inset: -40px; width: calc(100% + 80px); height: calc(100% + 80px); pointer-events: none; z-index: 30; mix-blend-mode: screen; }
.stage .floaters { position: absolute; inset: 0; pointer-events: none; z-index: 31; overflow: visible; }
.flash { position: fixed; inset: 0; pointer-events: none; z-index: 60; opacity: 0; }
.floater { position: absolute; transform: translate(-50%, -50%); font-weight: 800; font-size: 22px; white-space: nowrap; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.7), 0 0 12px rgba(0, 0, 0, 0.6); letter-spacing: 0.01em; }
.floater.crit { font-size: 30px; color: #fde68a; }
.floater.heal { color: var(--win); }
.floater.small { font-size: 15px; }
.banner { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 40; pointer-events: none; text-align: center; white-space: nowrap; }
.banner b { display: block; font-family: var(--display); font-size: clamp(26px, 5vw, 46px); letter-spacing: 0.04em; color: #fff; text-shadow: 0 0 18px var(--glow, rgba(125, 211, 252, 0.9)), 0 3px 0 rgba(0, 0, 0, 0.6); }
.banner span { display: block; font-size: 14px; color: var(--ink-dim); margin-top: 4px; text-shadow: 0 2px 4px #000; }
.banner .stripe { position: absolute; left: -60vw; right: -60vw; top: 50%; height: 70%; transform: translateY(-50%); background: linear-gradient(90deg, transparent, rgba(5, 10, 20, 0.85) 30%, rgba(5, 10, 20, 0.85) 70%, transparent); z-index: -1; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }

/* ---------- Bảng Orin ---------- */
.orin { position: relative; overflow: hidden; }
.orin .portrait { position: relative; aspect-ratio: 1 / 1; overflow: hidden; border-radius: var(--radius) var(--radius) 0 0; background: radial-gradient(circle at 50% 35%, #183456, #0a1426 70%); }
.orin .portrait img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 18%; transition: opacity 0.45s ease; will-change: opacity, transform; }
.orin .portrait img.sheet { object-fit: contain; object-position: 50% 0%; }
.orin .portrait .glow { position: absolute; inset: 0; background: radial-gradient(circle at 50% 30%, rgba(125, 211, 252, 0.0), transparent 60%); mix-blend-mode: screen; transition: background 0.4s; }
.orin.casting .portrait .glow { background: radial-gradient(circle at 50% 40%, rgba(125, 211, 252, 0.35), transparent 60%); }
.orin .portrait::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(8, 14, 26, 0.92)); }
.orin .nameplate { position: absolute; left: 14px; right: 14px; bottom: 10px; z-index: 2; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.orin .nameplate b { font-family: var(--display); font-size: 26px; letter-spacing: 0.04em; color: #fff; text-shadow: 0 0 14px rgba(125, 211, 252, 0.7); }
.orin .nameplate span { font-size: 12px; color: var(--ice); white-space: nowrap; }
.orin .thinking { display: none; gap: 4px; align-items: center; font-size: 12px; color: var(--ice); }
.orin.is-thinking .thinking { display: inline-flex; }
.orin.is-thinking .nameplate span.role { display: none; }
.thinking i { width: 6px; height: 6px; border-radius: 50%; background: var(--ice); animation: blink 1s infinite; }
.thinking i:nth-child(2) { animation-delay: 0.15s; } .thinking i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 100% { opacity: 0.2; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }
.bubble { position: relative; margin: 12px 14px 14px; padding: 12px 14px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); min-height: 48px; font-size: 14.5px; line-height: 1.55; color: var(--ink); font-style: italic; }
.bubble::before { content: ''; position: absolute; top: -7px; left: 26px; width: 12px; height: 12px; background: #142039; border-left: 1px solid var(--line); border-top: 1px solid var(--line); transform: rotate(45deg); }
.bubble.empty { color: var(--ink-faint); font-style: normal; }
@media (max-width: 900px) {
  .orin { display: flex; align-items: stretch; }
  .orin .portrait { width: 96px; min-width: 96px; aspect-ratio: auto; border-radius: var(--radius) 0 0 var(--radius); }
  .orin .portrait::after { background: linear-gradient(180deg, transparent 60%, rgba(8, 14, 26, 0.8)); }
  .orin .nameplate { left: 6px; right: 6px; bottom: 4px; }
  .orin .nameplate b { font-size: 17px; }
  .orin .nameplate span { display: none; }
  .orin .bubble { flex: 1; margin: 8px; font-size: 13.5px; min-height: 0; display: flex; align-items: center; }
  .orin .bubble::before { top: 50%; left: -7px; transform: translateY(-50%) rotate(-45deg); }
}

/* ---------- Người chơi + điều khiển ---------- */
.versus { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; padding: 10px 12px; }
.fighter { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 6px 8px; border-radius: 12px; border: 1px solid transparent; transition: border-color 0.3s, background 0.3s, box-shadow 0.3s; }
.fighter.right { flex-direction: row-reverse; text-align: right; }
.fighter.active { border-color: var(--line-strong); background: rgba(125, 211, 252, 0.07); box-shadow: 0 0 22px rgba(125, 211, 252, 0.12) inset; }
.fighter img, .fighter .ava { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line-strong); background: #13213b; flex: none; display: grid; place-items: center; font-weight: 700; }
.fighter b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fighter small { display: block; font-size: 12px; color: var(--ink-dim); }
.fighter .score { font-family: var(--display); font-size: 28px; font-weight: 700; color: var(--gold); margin-left: auto; padding: 0 4px; }
.fighter.right .score { margin-left: 0; margin-right: auto; }
.vs { font-family: var(--display); font-size: 18px; color: var(--ink-faint); }
.controls { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { appearance: none; border: 1px solid var(--line-strong); background: linear-gradient(180deg, rgba(56, 120, 200, 0.28), rgba(20, 40, 80, 0.5)); color: var(--ink); padding: 10px 14px; border-radius: 12px; font-weight: 600; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform 0.08s, box-shadow 0.2s, background 0.2s, opacity 0.2s; min-height: 42px; }
.btn:hover:not(:disabled) { box-shadow: 0 0 18px rgba(125, 211, 252, 0.25); border-color: var(--ice); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.gold { background: linear-gradient(180deg, #f3d58c, #b98f2e); color: #1b1305; border-color: #f7e2a8; }
.btn.ghost { background: rgba(255, 255, 255, 0.03); border-color: var(--line); }
.btn.danger { background: linear-gradient(180deg, rgba(248, 113, 113, 0.3), rgba(120, 20, 20, 0.45)); border-color: rgba(248, 113, 113, 0.5); }
.btn.wide { flex: 1; }
.hint { font-size: 13px; color: var(--ink-dim); line-height: 1.5; }
.log { max-height: 220px; overflow: auto; font-size: 13px; line-height: 1.5; color: var(--ink-dim); padding: 0 14px 12px; display: flex; flex-direction: column; gap: 4px; }
.log .row { padding: 5px 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.03); }
.log .row.me { border-left: 2px solid var(--bone); }
.log .row.foe { border-left: 2px solid var(--ice-deep); }
.log b { color: var(--ink); }

/* ---------- Thông báo, hộp thoại, màn kết ---------- */
.toasts { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(92vw, 480px); pointer-events: none; }
.toast { pointer-events: auto; padding: 11px 16px; border-radius: 12px; background: rgba(14, 25, 48, 0.96); border: 1px solid var(--line-strong); box-shadow: var(--shadow); font-size: 14px; line-height: 1.45; animation: toastIn 0.25s ease-out; }
.toast.err { border-color: rgba(248, 113, 113, 0.6); }
.toast.good { border-color: rgba(134, 239, 172, 0.55); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.overlay { position: fixed; inset: 0; z-index: 80; background: rgba(3, 6, 12, 0.72); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 16px; animation: fadeIn 0.25s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.dialog { width: min(560px, 100%); max-height: 86dvh; overflow: auto; background: var(--panel-solid); border: 1px solid var(--line-strong); border-radius: 18px; box-shadow: var(--shadow); padding: 20px; }
.dialog h2 { margin: 0 0 10px; font-family: var(--display); font-size: 28px; color: var(--gold); }
.dialog .md { font-size: 14.5px; line-height: 1.65; color: var(--ink); }
.dialog .md p { margin: 0 0 8px; }
.dialog .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.end { text-align: center; position: relative; overflow: hidden; }
.end .portrait { width: 132px; height: 132px; border-radius: 50%; object-fit: cover; margin: 4px auto 8px; display: block; border: 2px solid var(--line-strong); }
.end .verdict { font-family: var(--display); font-size: clamp(40px, 9vw, 64px); line-height: 1; letter-spacing: 0.05em; margin: 6px 0; }
.end.win .verdict { color: var(--gold); text-shadow: 0 0 28px rgba(232, 195, 106, 0.6); }
.end.loss .verdict { color: #9fb6da; text-shadow: 0 0 24px rgba(56, 120, 200, 0.5); }
.end.draw .verdict, .end.expired .verdict { color: var(--ink); }
.end .line { color: var(--ink-dim); font-style: italic; margin: 6px 0 12px; line-height: 1.55; }
.end .gain { display: inline-flex; flex-direction: column; gap: 6px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); margin: 6px 0; text-align: left; font-size: 14px; }
.end .bar { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden; width: 260px; max-width: 70vw; }
.end .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--ice-deep), var(--gold)); transition: width 1.2s cubic-bezier(.2, .8, .2, 1); }
.end ul { list-style: none; padding: 0; margin: 8px 0; font-size: 14px; color: var(--ink-dim); line-height: 1.6; }
.end .actions { justify-content: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ---------- Chơi thử (không cần Discord) ---------- */
.chip.guest { color: #fde68a; border-color: rgba(232, 195, 106, 0.5); }
.lobby { width: 100%; max-width: 1100px; margin: 0 auto; padding: 24px 16px 40px; display: flex; flex-direction: column; gap: 18px; }
.lobby-hero { display: flex; align-items: center; gap: 18px; }
.lobby-hero .portrait { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; object-position: 50% 15%; border: 2px solid var(--line-strong); box-shadow: 0 0 40px rgba(125, 211, 252, 0.25); background: radial-gradient(circle at 50% 35%, #183456, #0a1426 70%); flex: none; }
.lobby-hero h1 { margin: 0 0 6px; font-family: var(--display); font-size: clamp(32px, 6vw, 48px); color: var(--gold); letter-spacing: 0.03em; }
.lobby-hero p { margin: 0; color: var(--ink-dim); line-height: 1.6; }
.lobby-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.lobby-card { position: relative; appearance: none; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 16px; border: 1px solid var(--line); background: linear-gradient(180deg, rgba(30, 52, 92, 0.55), rgba(10, 18, 34, 0.85)); box-shadow: var(--shadow); transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s; animation: cardIn 0.5s both; animation-delay: calc(var(--i) * 50ms); }
.lobby-card:hover { transform: translateY(-3px); border-color: var(--ice); box-shadow: 0 0 28px rgba(125, 211, 252, 0.22), var(--shadow); }
.lobby-card.feature { grid-column: span 2; border-color: rgba(232, 195, 106, 0.5); }
.lobby-card.loading { opacity: 0.6; pointer-events: none; }
.lobby-art { height: 120px; border-radius: 12px; display: grid; place-items: center; background: radial-gradient(circle at 50% 60%, rgba(56, 120, 200, 0.3), transparent 70%); }
.lobby-card.feature .lobby-art { height: 170px; background: radial-gradient(circle at 50% 60%, rgba(251, 146, 60, 0.3), transparent 70%); }
.lobby-art { overflow: hidden; }
.lobby-art img { width: 100%; height: 100%; object-fit: contain; padding: 6px; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.6)); transition: transform 0.25s; }
.lobby-card:hover .lobby-art img { transform: scale(1.06) translateY(-3px); }
.lobby-art .emo { font-size: 56px; }
.lobby-txt b { display: block; font-size: 16px; }
.lobby-txt small { display: block; font-size: 13px; color: var(--ink-dim); line-height: 1.5; margin-top: 3px; }
.lobby-go { align-self: flex-end; font-size: 13px; font-weight: 700; color: var(--gold); }
.lobby-invite { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-color: rgba(232, 195, 106, 0.4); }
.lobby-invite > div { flex: 1; min-width: 240px; }
.end-invite { margin: 12px 0 6px; padding: 14px; border-radius: 14px; border: 1px solid rgba(232, 195, 106, 0.45); background: rgba(232, 195, 106, 0.07); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.end-invite b { color: var(--gold); font-size: 15px; }
.end-invite p { margin: 0; font-size: 13.5px; color: var(--ink-dim); line-height: 1.55; }
a.btn { text-decoration: none; }
@keyframes cardIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (max-width: 560px) { .lobby-card.feature { grid-column: auto; } .lobby-hero { flex-direction: column; text-align: center; } .lobby-hero .portrait { width: 100px; height: 100px; } }
.icon-btn.off { opacity: 0.45; text-decoration: line-through; }
