/* Bộ Lạc Online - phong cách tiền sử: đất nâu, giấy da, gỗ, đá, lửa */
:root {
  --bg: #2a1a0e;
  --bg-2: #3b2614;
  --parchment: #ecdcae;
  --parchment-2: #dcc58a;
  --ink: #3a240f;
  --ink-soft: #6b4a26;
  --wood: #7a4b22;
  --wood-dark: #4e2e12;
  --stone: #8d8579;
  --stone-dark: #5e574d;
  --fire: #e8742a;
  --fire-2: #f4a83a;
  --leaf: #5c8f2a;
  --blood: #b8382a;
  --radius: 14px;
  --font: "Baloo 2", "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  color: var(--parchment);
  background-color: var(--bg);
  /* mặt đất có vân */
  background-image:
    radial-gradient(circle at 20% 10%, rgba(232, 116, 42, .10), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(92, 143, 42, .10), transparent 45%),
    repeating-linear-gradient(45deg, rgba(0, 0, 0, .06) 0 2px, transparent 2px 9px);
  min-height: 100vh;
}

a { color: var(--fire-2); }

/* ---------------------------------------------------------------- banner */
.banner { position: relative; line-height: 0; border-bottom: 6px solid var(--wood-dark); box-shadow: 0 6px 0 var(--wood), 0 12px 24px rgba(0, 0, 0, .5); }
.banner img { width: 100%; height: auto; display: block; }

/* ---------------------------------------------------------------- tabs: tấm gỗ */
.tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 18px 12px 4px;
  flex-wrap: wrap;
}
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px 8px;
  font-weight: 800;
  font-size: 1.08rem;
  color: #fbe9c1;
  text-decoration: none;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .55);
  border-radius: 10px 14px 9px 13px;
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .10) 0 3px, transparent 3px 14px),
    linear-gradient(180deg, #9a6230, var(--wood) 55%, var(--wood-dark));
  border: 2px solid #2d1a08;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .18), 0 4px 0 #2d1a08;
  transition: transform .1s ease, filter .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.tab:hover { filter: brightness(1.1); }
.tab:active { transform: translateY(3px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .18), 0 1px 0 #2d1a08; }
.tab.active {
  color: #2d1a08;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .4);
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .06) 0 3px, transparent 3px 14px),
    linear-gradient(180deg, var(--fire-2), var(--fire) 70%, #b9531a);
}
.badge {
  min-width: 26px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: .85rem;
  line-height: 1.6;
  text-align: center;
  color: var(--parchment);
  background: rgba(0, 0, 0, .45);
  text-shadow: none;
}
.tab.active .badge { background: var(--ink); }

.status-line { text-align: center; font-size: .9rem; color: var(--parchment-2); padding: 6px 0 0; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; background: var(--stone); vertical-align: 1px; }
.dot.live { background: #7ed957; box-shadow: 0 0 0 0 rgba(126, 217, 87, .6); animation: pulse 2s infinite; }
.dot.down { background: var(--blood); }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgba(126, 217, 87, 0); } 100% { box-shadow: 0 0 0 0 rgba(126, 217, 87, 0); } }

/* ---------------------------------------------------------------- khung giấy da */
.wrap { max-width: 1100px; margin: 0 auto; padding: 14px 14px 30px; }
.panel {
  color: var(--ink);
  background:
    radial-gradient(ellipse at top left, rgba(255, 255, 255, .35), transparent 55%),
    radial-gradient(ellipse at bottom right, rgba(120, 80, 30, .25), transparent 60%),
    var(--parchment);
  border: 3px solid #5a3a1a;
  border-radius: 18px 26px 16px 24px;
  box-shadow: inset 0 0 40px rgba(122, 75, 34, .35), 0 8px 0 #1c1007, 0 14px 30px rgba(0, 0, 0, .45);
  padding: 20px 22px 24px;
  margin-bottom: 22px;
}
.js .panel { display: none; }
.js .panel.active { display: block; animation: show .25s ease; }
@keyframes show { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.panel h2 {
  margin: 0 0 4px;
  font-size: 1.6rem;
  line-height: 1.2;
  color: var(--wood-dark);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
}
.hint { margin: 0 0 14px; color: var(--ink-soft); font-size: .95rem; }
.empty { text-align: center; padding: 22px 10px 6px; color: var(--ink-soft); }
.empty p:first-child { font-size: 1.15rem; font-weight: 700; color: var(--ink); margin: 0 0 6px; }

/* ---------------------------------------------------------------- phòng trống */
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.room {
  position: relative;
  padding: 14px 16px 12px;
  color: #f4ead4;
  border-radius: 16px 12px 18px 10px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, .18), transparent 40%),
    linear-gradient(160deg, var(--stone), var(--stone-dark));
  border: 2px solid #3f3a33;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .25), 0 4px 0 #2b2721;
}
.room .label { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; opacity: .85; }
.room .code {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: .12em;
  color: #fff3cf;
  text-shadow: 0 2px 0 #2b2721;
  font-variant-numeric: tabular-nums;
}
.copy {
  font: inherit;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: 0;
  padding: 4px 10px;
  color: var(--ink);
  background: var(--parchment);
  border: 2px solid #3f3a33;
  border-radius: 8px;
  cursor: pointer;
}
.copy.done { background: #b9e08f; }
.room .meta { font-size: .95rem; margin-top: 4px; }
.room .meta b { color: #fff3cf; }

/* ---------------------------------------------------------------- trận đấu */
.match-list { display: flex; flex-direction: column; gap: 10px; }
.match {
  display: grid;
  grid-template-columns: 110px 1fr 150px 130px 200px;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .35);
  border: 2px solid rgba(90, 58, 26, .45);
}
.match.head {
  background: none;
  border: none;
  padding-top: 0;
  padding-bottom: 0;
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-soft);
}
.match .code { font-weight: 800; font-size: 1.15rem; letter-spacing: .08em; font-variant-numeric: tabular-nums; }
.match .code.private { font-size: .95rem; letter-spacing: 0; color: var(--ink-soft); font-style: italic; }
.vs { font-weight: 700; }
.vs .x { margin: 0 6px; color: var(--fire); font-weight: 800; }
.vs .win { color: var(--leaf); }
.vs .win::after { content: " ★"; color: var(--fire); }
.vs .lose { color: var(--ink-soft); text-decoration: line-through; text-decoration-thickness: 1px; }
.time { font-variant-numeric: tabular-nums; font-size: .95rem; }
.time small { display: block; color: var(--ink-soft); font-size: .8rem; }
.result {
  justify-self: start;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 800;
  border: 2px solid currentColor;
}
.result.live { color: #b9531a; background: rgba(244, 168, 58, .25); }
.result.live::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--fire); margin-right: 6px; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.result.done { color: var(--leaf); background: rgba(92, 143, 42, .15); }
.result.bad { color: var(--blood); background: rgba(184, 56, 42, .12); }
.res { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.watch {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 11px; border-radius: 999px;
  font-size: .85rem; font-weight: 800; text-decoration: none;
  color: #2d1a08; background: linear-gradient(180deg, var(--fire-2), var(--fire));
  box-shadow: 0 2px 0 #2d1a08;
}
.watch::before { content: "▶"; font-size: .7rem; }
.watch:hover { filter: brightness(1.08); }
.watch:active { transform: translateY(2px); box-shadow: none; }

/* ---------------------------------------------------------------- tải game */
.download {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .35);
  border: 2px solid rgba(90, 58, 26, .45);
}
.dl-info { display: flex; align-items: center; gap: 14px; }
.dl-icon { image-rendering: pixelated; border-radius: 14px; border: 3px solid var(--wood-dark); background: #fff; }
.dl-title { font-size: 1.5rem; font-weight: 800; color: var(--wood-dark); }
.dl-buttons { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 190px;
  padding: 12px 22px 10px;
  font-weight: 800;
  font-size: 1.1rem;
  line-height: 1.15;
  text-decoration: none;
  border-radius: 14px 10px 16px 12px;
  border: 2px solid #2d1a08;
  box-shadow: 0 5px 0 #2d1a08;
  transition: transform .1s ease, filter .15s ease;
}
.btn small { font-weight: 600; font-size: .8rem; opacity: .9; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #2d1a08; }
.btn-fire { color: #2d1a08; background: linear-gradient(180deg, var(--fire-2), var(--fire)); }
.btn-stone { color: #fff3cf; background: linear-gradient(180deg, var(--stone), var(--stone-dark)); text-shadow: 0 1px 0 #2b2721; }

.guide { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 18px; }
.guide-card { padding: 12px 16px; border-left: 6px solid var(--wood); background: rgba(255, 255, 255, .25); border-radius: 6px 14px 14px 6px; }
.guide-card h3 { margin: 0 0 4px; color: var(--wood-dark); font-size: 1.15rem; }
.guide-card p { margin: 0; }

/* ---------------------------------------------------------------- footer */
.footer {
  text-align: center;
  padding: 20px 14px 26px;
  color: var(--parchment-2);
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .35));
  border-top: 4px solid var(--wood-dark);
}
.footer p { margin: 2px 0; }
.footer a { font-weight: 800; text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.footer .small { font-size: .85rem; opacity: .75; }

/* ---------------------------------------------------------------- điện thoại */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .tabs { gap: 6px; padding-top: 14px; }
  .tab { padding: 8px 12px 6px; font-size: .98rem; }
  .panel { padding: 16px 14px 18px; }
  .panel h2 { font-size: 1.35rem; }
  .match.head { display: none; }
  .match {
    grid-template-columns: 1fr auto;
    grid-template-areas: "vs vs" "code result" "time map";
    row-gap: 4px;
  }
  .match .vs { grid-area: vs; font-size: 1.05rem; }
  .match .code { grid-area: code; }
  .match .res { grid-area: result; justify-self: end; }
  .match .time { grid-area: time; }
  .match .map { grid-area: map; justify-self: end; font-size: .9rem; color: var(--ink-soft); }
  .btn { width: 100%; }
  .dl-buttons { width: 100%; }
}
@media (max-width: 440px) {
  .tabs { gap: 5px; padding-left: 6px; padding-right: 6px; flex-wrap: nowrap; }
  .tab { padding: 7px 9px 5px; font-size: .88rem; gap: 5px; }
  .badge { min-width: 20px; padding: 0 5px; font-size: .72rem; }
}
@media (max-width: 340px) {
  .tab .badge { display: none; }
}
.dl-plain { word-break: break-all; color: var(--fire); }
