:root {
  --font: "Plus Jakarta Sans", Arial, sans-serif;
  --board: #1e293b;
  --board-edge: #334155;
  --orange: #f05023;
  --gold: #fbbf24;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
}
body {
  min-height: 100vh;
  background: linear-gradient(160deg, #4c2a9a 0%, #2a3bb0 45%, #0f6d74 100%);
  font-family: var(--font);
  color: #e2e8f0;
  display: grid;
  place-items: center;
  padding: 10px;
}

.shell {
  width: min(1180px, 100%);
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  padding: 6px 8px 6px 14px;
  border-radius: 12px;
  background: #ffffff14;
}
.title {
  font-weight: 800;
  font-size: 17px;
  color: #fff;
}
.top-actions {
  display: flex;
  gap: 8px;
}
.top-actions button,
.exit {
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: #0b1024;
  color: #fff;
  font: 700 13px var(--font);
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  cursor: pointer;
}

/* Khu chơi: bàn cờ bên trái, cột điểm bên phải */
.arena {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 215px;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(170deg, #3b2a6e, #23306f 50%, #0f5a66);
}
.board-area {
  padding: 3.2% 1.2% 3.2% 1.2%;
  display: grid;
  place-items: center;
}
#game {
  display: block;
  width: min(100%, calc((100vh - 150px) * 4 / 3));
  aspect-ratio: 4 / 3;
  border: 2px solid var(--board-edge);
  border-radius: 12px;
  background: var(--board);
  box-shadow: 0 16px 34px #00000055;
  touch-action: none;
  cursor: none;
}
.side {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-left: 3px solid #34d399;
  background: linear-gradient(180deg, #1d1140, #0e0a22);
  transition: border-color 0.3s;
}
.side.live {
  border-color: #f59e0b;
}
.side.over {
  border-color: #64748b;
}
.pill {
  padding: 3px 10px;
  border: 1px solid #34d39977;
  border-radius: 999px;
  background: #0f3a33;
  color: #6ee7b7;
  font: 800 10px var(--font);
  letter-spacing: 1.5px;
}
.side.live .pill {
  border-color: #f59e0b77;
  background: #3a2a10;
  color: #fcd34d;
}
.side.over .pill {
  border-color: #64748b77;
  background: #1e2533;
  color: #cbd5e1;
}
.side-label {
  color: #e2e8f0;
  font-weight: 700;
  font-size: 14px;
}
.side.live .side-label,
.side.over .side-label {
  color: #94a3b8;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
}
.side-score {
  font: 800 30px var(--font);
  color: var(--gold);
  text-shadow: 0 0 14px #fbbf2480;
}
.side-level {
  color: #94a3b8;
  font-weight: 700;
  font-size: 13px;
}
.side-level b {
  color: #e2e8f0;
}
[hidden] {
  display: none !important;
}

/* Lớp phủ thẻ thông báo */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #050a19d9;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 5;
  transition: opacity 0.25s;
}
.overlay.hide {
  opacity: 0;
  pointer-events: none;
}
.card-wrap {
  display: grid;
  justify-items: center;
  width: min(300px, 86%);
}
.card-pill {
  position: relative;
  z-index: 1;
  margin-bottom: -9px;
  padding: 3px 10px;
  border: 1px solid #3b5b8f;
  border-radius: 999px;
  background: #13284a;
  color: #cbd5e1;
  font: 800 10px var(--font);
  letter-spacing: 1.2px;
}
.card {
  width: 100%;
  padding: 18px 10px 10px;
  border: 1px solid #ffffff22;
  border-radius: 12px;
  background: #161a2b;
  text-align: center;
  box-shadow: 0 20px 40px #0008;
}
.emoji {
  font-size: 30px;
  line-height: 1;
}
.card h2 {
  margin: 6px 0 4px;
  font: 800 18px var(--font);
  color: #fff;
}
.card p {
  margin: 0 0 10px;
  font-size: 12px;
  color: #cbd5e1;
}
.final {
  display: grid;
  gap: 2px;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid #fbbf2455;
  border-radius: 10px;
  background: linear-gradient(135deg, #2a2a2a, #2b2118);
}
.final small {
  color: #94a3b8;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.2px;
}
.final b {
  font: 800 30px var(--font);
  color: var(--gold);
}
.final span {
  font-size: 11px;
  color: #94a3b8;
}
.cta {
  width: 100%;
  height: 46px;
  border: 0;
  border-bottom: 4px solid #b91c1c;
  border-radius: 9px;
  background: linear-gradient(180deg, #fb8a3c, #e8361f);
  color: #fff;
  font: 800 16px var(--font);
  cursor: pointer;
}
.cta:active {
  border-bottom-width: 1px;
  transform: translateY(3px);
}

/* Thông báo nhanh */
.toast {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 6;
  width: min(380px, 90%);
  padding: 18px 16px 22px;
  border: 1px solid #ffffff2a;
  border-radius: 18px;
  background: linear-gradient(180deg, #1c2334, #0b1020);
  text-align: center;
  transform: translate(-50%, -50%);
  box-shadow: 0 24px 50px #000a;
  animation: toastIn 0.3s ease-out;
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, -42%) scale(0.92);
  }
}
.toast h2 {
  margin: 6px 0;
  font: 800 30px var(--font);
  color: #fff;
  letter-spacing: -0.5px;
}
.toast p {
  margin: 0 0 10px;
  color: #cbd5e1;
  font-weight: 700;
}
.toast p b {
  color: var(--gold);
}
.toast u {
  display: block;
  margin-bottom: 12px;
  color: #cbd5e1;
  font-weight: 700;
  font-size: 13px;
}
.toast small {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
}

.help {
  margin: 10px 0 0;
  text-align: center;
  color: #dbe4ff;
  font-size: 13px;
}
kbd {
  display: inline-block;
  padding: 0 6px;
  border: 1px solid #ffffff55;
  border-radius: 5px;
  background: #ffffff1a;
  font: 700 12px var(--font);
}

@media (max-width: 700px) {
  .arena {
    grid-template-columns: 1fr;
  }
  .side {
    order: -1;
    flex-direction: row;
    justify-content: space-around;
    padding: 8px;
    border-left: 0;
    border-bottom: 3px solid #34d399;
  }
  .side.live {
    border-color: #f59e0b;
  }
  .side-score {
    font-size: 22px;
  }
  .board-area {
    padding: 8px;
  }
}
