/* Khung xanh lỗ tròn kiểu đồ chơi Connect 4: quân đỏ đi trước, quân vàng đi sau. */
:root {
  --bg: #e6eefa;
  --panel: #fff;
  --line: #cfdcef;
  --text: #1c2b44;
  --muted: #6a7c99;
  --accent: #2456c9;
  --frame: #2456c9;
  --hole: #eef3fb;
  --p1: #e0312f;
  --p2: #ffc62e;
  --good: #2e9e5b;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); overflow: hidden;
  font: 15px/1.4 "Be Vietnam Pro", "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.ic { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; }
button, input { font: inherit; color: inherit; }
button {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
  cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; justify-content: center;
}
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
input { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px;
  width: min(380px, calc(100vw - 32px)); display: grid; gap: 12px; text-align: center; box-shadow: 0 12px 40px #1c2b4426;
}
.card h1, .card h2 { margin: 0; display: flex; align-items: center; justify-content: center; gap: 8px; }
.card h1 .logo { width: 40px; height: 40px; }
.card h1 .back { color: var(--muted); display: inline-flex; }
.card label { display: grid; gap: 4px; text-align: left; color: var(--muted); }
.sub, .muted { margin: 0; color: var(--muted); }
.muted { font-size: 12px; }
.join { display: flex; gap: 8px; }
#code { text-transform: uppercase; letter-spacing: 3px; text-align: center; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
button.on { border-color: var(--accent); color: var(--accent); font-weight: 700; }
#home { height: 100%; display: grid; place-items: center; padding: 16px; }

#room { height: 100%; display: flex; flex-direction: column; }
header { display: flex; align-items: center; gap: 6px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
header .grow { flex: 1; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--p1); flex: none; }
.dot.on { background: var(--good); }
@media (max-width: 480px) { header .lbl { display: none; } }

#vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 0 12px; }
.side { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 6px 10px; border-radius: 12px; border: 2px solid transparent; background: #fff8; }
.side[data-seat="2"] { justify-content: flex-end; }
.side b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .sc { font-weight: 800; font-variant-numeric: tabular-nums; }
.side.turn { background: #fff; }
.side[data-seat="1"].turn { border-color: var(--p1); } .side[data-seat="2"].turn { border-color: #e0a800; }
.side.me b::after { content: ' (bạn)'; font-weight: 400; color: var(--muted); }
html[lang="en"] .side.me b::after { content: ' (you)'; }
.pc { width: 22px; height: 22px; border-radius: 50%; flex: none; box-shadow: inset 0 -3px #0003; }
.pc.p1 { background: var(--p1); } .pc.p2 { background: var(--p2); }
#clock { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 44px; text-align: center; }
#clock.low { color: var(--p1); animation: blink .5s infinite alternate; }
@keyframes blink { to { opacity: .4; } }

#wrap { position: relative; flex: 1; min-height: 0; margin: 8px; display: grid; place-items: center; }
/* Khung xanh, mỗi ô là một lỗ tròn; quân rơi từ trên cột xuống (clip trong khung). */
#board {
  display: grid; padding: 8px; gap: 0; background: var(--frame); border-radius: 18px; overflow: hidden;
  box-shadow: 0 10px 0 #183d93, 0 18px 30px #1c2b4440;
}
.c { position: relative; display: grid; place-items: center; cursor: pointer; }
.c::before { content: ''; position: absolute; inset: 9%; border-radius: 50%; background: var(--hole); box-shadow: inset 0 4px 6px #0003; }
.disc { position: relative; width: 82%; height: 82%; border-radius: 50%; box-shadow: inset 0 -5px #0003, inset 0 3px #fff5; }
.c.p1 .disc { background: var(--p1); } .c.p2 .disc { background: var(--p2); }
.disc.drop { animation: drop var(--t, .4s) cubic-bezier(.5, 0, 1, 1) both; }
@keyframes drop { from { transform: translateY(var(--from)); } }
.c.last .disc::after { content: ''; position: absolute; inset: 36%; border-radius: 50%; border: 3px solid #fffc; }
.c.win .disc { animation: pulse .6s ease-in-out infinite alternate; box-shadow: 0 0 0 4px #fff, inset 0 -5px #0003; }
@keyframes pulse { to { transform: scale(.86); } }
/* Tới lượt mình: rê chuột lên cột thì sáng cả cột. */
#board.mine .c.hl::before { background: #d7e4fb; }

#overlay { position: absolute; inset: 0; display: grid; place-items: center; background: #e6eefa66; z-index: 5; }
#btnResult { position: absolute; left: 50%; bottom: 8px; translate: -50% 0; z-index: 6; box-shadow: 0 6px 20px #1c2b4444; }

#emoBar { display: flex; justify-content: center; gap: 6px; padding: 6px 12px max(8px, env(safe-area-inset-bottom)); }
#emoBar button { padding: 4px 12px; font-size: 20px; }
.emo-fly { position: fixed; translate: -50% -100%; font-size: 34px; pointer-events: none; z-index: 20; animation: emo 1.6s ease-out forwards; }
.emo-fly .ic { filter: drop-shadow(0 2px 3px #0005); }
@keyframes emo { to { transform: translateY(-80px) scale(1.4); opacity: 0; } }
