@import url("./profile/profile-panel.css");

:root {
  color-scheme: light;
  --page: #f0f2ef;
  --surface: #fbfcfa;
  --ink: #111714;
  --muted: #6b7670;
  --forest: #052f29;
  --forest-soft: #0b4b40;
  --coral: #d9584b;
  --gold: #dfbb5a;
  --aqua: #24caae;
  --tile-radius: 6px;
  --tile-gap: 11px;
  --shell: min(1360px, calc(100vw - 48px));
  --desktop-tile: calc((var(--shell) - (13 * var(--tile-gap))) / 14);
  --control-tile-size: var(--desktop-tile);
  --shell-left: max(24px, calc((100vw - var(--shell)) / 2));
  --shadow-tile: 0 10px 28px rgba(5, 47, 41, 0.11);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
  scrollbar-color: var(--forest-soft) var(--page);
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--page);
}

::selection {
  color: var(--forest);
  background: rgba(36, 202, 174, 0.42);
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
}

.page-shell {
  width: var(--shell);
  margin: 0 auto;
  padding: 10px 0 68px;
}

.game-wall {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  grid-template-rows: repeat(3, var(--desktop-tile));
  gap: var(--tile-gap);
  align-items: stretch;
}

.control-tile,
.brand-tile,
.game-card {
  min-width: 0;
  min-height: 0;
  border: 1px solid rgba(5, 47, 41, 0.14);
  border-radius: var(--tile-radius);
  background: var(--surface);
  box-shadow: var(--shadow-tile);
}

.control-tile {
  position: sticky;
  top: max(10px, env(safe-area-inset-top));
  z-index: 20;
  grid-column: 1;
  grid-row: 1;
  align-self: start;
  aspect-ratio: 1;
}

.brand-control {
  display: grid;
  width: 100%;
  height: 100%;
  overflow: hidden;
  place-items: center;
  border-radius: calc(var(--tile-radius) - 1px);
  background: var(--forest);
}

.brand-control img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-trigger {
  position: absolute;
  right: -6px;
  bottom: -6px;
  display: grid;
  width: clamp(28px, 2.3vw, 34px);
  height: clamp(28px, 2.3vw, 34px);
  padding: 7px;
  cursor: pointer;
  place-items: center;
  border: 2px solid var(--surface);
  border-radius: 50%;
  color: var(--forest);
  background: var(--gold);
  box-shadow: 0 6px 14px rgba(5, 47, 41, 0.2);
}

.profile-trigger img {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-tile {
  grid-column: 2 / 4;
  grid-row: 1 / 4;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
  padding: clamp(14px, 1.45vw, 22px);
  overflow: hidden;
}

.brand-tile small,
.home-editorial small {
  color: var(--coral);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
}

.brand-tile h1 {
  margin: 0;
  color: var(--forest);
  font-size: clamp(24px, 2.35vw, 34px);
  font-weight: 900;
  line-height: 0.98;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  white-space: nowrap;
}

.brand-tile p {
  margin: 10px 0 0;
  color: var(--forest-soft);
  font-size: clamp(12px, 1.12vw, 15px);
  font-weight: 720;
  line-height: 1.35;
}

.game-card {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
  color: var(--forest);
  isolation: isolate;
}

.game-card img {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  background: var(--forest-soft);
  object-fit: cover;
  transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.game-card h2 {
  position: relative;
  z-index: 1;
  min-width: 0;
  margin: 0;
  padding: 10px 12px 11px;
  color: var(--forest);
  background: var(--surface);
  font-size: clamp(12px, 1.15vw, 16px);
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.game-card[data-game-id="horse-racing"] {
  grid-column: 4 / 7;
  grid-row: 1 / 4;
}

.game-card[data-game-id="archery"] {
  grid-column: 1;
  grid-row: 2;
}

.game-card[data-game-id="penalty-kick"] {
  grid-column: 1;
  grid-row: 3;
}

.game-card[data-game-id="archery"],
.game-card[data-game-id="penalty-kick"] {
  grid-template-rows: minmax(18px, 1fr) auto;
}

.game-card[data-game-id="archery"] h2,
.game-card[data-game-id="penalty-kick"] h2 {
  padding: clamp(4px, 0.55vw, 7px) clamp(5px, 0.6vw, 8px) clamp(5px, 0.62vw, 8px);
  font-size: clamp(8px, 0.82vw, 11px);
  line-height: 1.12;
  text-wrap: balance;
}

.game-card[data-game-id="temple-treasure"] {
  grid-column: 7 / 9;
  grid-row: 1 / 4;
}

.game-card[data-game-id="bar-darts"] {
  grid-column: 9 / 11;
  grid-row: 1 / 4;
}

.game-card[data-game-id="cock-fighting"] {
  grid-column: 11 / 13;
  grid-row: 1 / 4;
}

.game-card[data-game-id="world-cup-slots"] {
  grid-column: 13 / 15;
  grid-row: 1 / 4;
}

.brand-control:focus-visible,
.profile-trigger:focus-visible,
.game-card:focus-visible {
  outline: 3px solid var(--aqua);
  outline-offset: 3px;
}

.profile-panel[hidden] {
  display: none;
}

.profile-panel {
  position: fixed;
  top: calc(max(10px, env(safe-area-inset-top)) + var(--control-tile-size) + 12px);
  left: var(--shell-left);
  z-index: 30;
  width: min(284px, calc(100vw - 48px));
  padding: 16px 18px;
  border: 1px solid rgba(5, 47, 41, 0.16);
  border-radius: var(--tile-radius);
  color: var(--forest);
  background: var(--surface);
  box-shadow: var(--shadow-tile);
}

.profile-panel strong {
  display: block;
  font-size: 14px;
  font-weight: 850;
  line-height: 1.3;
}

.profile-panel p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.home-editorial {
  max-width: 72ch;
  margin: 92px 0 0;
  padding-top: 28px;
  border-top: 1px solid rgba(5, 47, 41, 0.18);
}

.home-editorial h2 {
  max-width: 19ch;
  margin: 12px 0 0;
  color: var(--forest);
  font-size: clamp(32px, 4.5vw, 58px);
  font-weight: 880;
  line-height: 1.02;
  letter-spacing: 0;
  text-wrap: balance;
}

.home-editorial p {
  max-width: 68ch;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.site-footer {
  width: var(--shell);
  min-height: 84px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 32px;
  border-top: 1px solid rgba(5, 47, 41, 0.12);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.site-footer strong {
  color: var(--forest);
}

@media (hover: hover) and (pointer: fine) {
  .brand-control:hover {
    background: var(--forest-soft);
  }

  .profile-trigger:hover {
    background: var(--aqua);
  }

  .game-card:hover img {
    transform: scale(1.02);
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  :root {
    --shell: calc(100vw - 32px);
    --tablet-tile: calc((var(--shell) - (6 * var(--tile-gap))) / 7);
    --control-tile-size: var(--tablet-tile);
    --shell-left: 16px;
  }

  .game-wall {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-template-rows: repeat(6, var(--tablet-tile));
  }

  .brand-tile {
    grid-column: 2 / 4;
    grid-row: 1 / 3;
  }

  .game-card[data-game-id="horse-racing"] {
    grid-column: 4 / 7;
    grid-row: 1 / 4;
  }

  .game-card[data-game-id="temple-treasure"] {
    grid-column: 2 / 4;
    grid-row: 3 / 5;
  }

  .game-card[data-game-id="bar-darts"] {
    grid-column: 4 / 6;
    grid-row: 4 / 6;
  }

  .game-card[data-game-id="cock-fighting"] {
    grid-column: 6 / 8;
    grid-row: 4 / 6;
  }

  .game-card[data-game-id="world-cup-slots"] {
    grid-column: 2 / 4;
    grid-row: 5 / 7;
  }
}

@media (max-width: 767px) {
  :root {
    --tile-gap: 10px;
    --shell: calc(100vw - 20px);
    --mobile-tile: calc((var(--shell) - (2 * var(--tile-gap))) / 3);
    --control-tile-size: var(--mobile-tile);
    --shell-left: 10px;
  }

  .page-shell {
    padding-bottom: 54px;
  }

  .game-wall {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(5, var(--mobile-tile));
  }

  .control-tile {
    grid-column: 1;
    grid-row: 1;
  }

  .profile-trigger {
    right: -5px;
    bottom: -5px;
    width: 32px;
    height: 32px;
  }

  .profile-panel {
    width: min(280px, calc(100vw - 20px));
    padding: 14px 15px;
  }

  .brand-tile {
    grid-column: 2 / 4;
    grid-row: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 6px 12px;
    padding: 12px 13px;
  }

  .brand-tile small {
    grid-column: 1 / -1;
    font-size: 9px;
  }

  .brand-tile h1 {
    font-size: clamp(25px, 7.5vw, 32px);
  }

  .brand-tile p {
    max-width: 14ch;
    margin-top: 5px;
    font-size: 10px;
    line-height: 1.25;
  }

  .game-card h2 {
    padding: 7px 8px 8px;
    font-size: 11px;
    line-height: 1.18;
  }

  .game-card[data-game-id="horse-racing"] {
    grid-column: 1 / 3;
    grid-row: 2 / 4;
  }

  .game-card[data-game-id="archery"] {
    grid-column: 3;
    grid-row: 2;
  }

  .game-card[data-game-id="penalty-kick"] {
    grid-column: 3;
    grid-row: 3;
  }

  .game-card[data-game-id="archery"],
  .game-card[data-game-id="penalty-kick"] {
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .game-card[data-game-id="archery"] h2,
  .game-card[data-game-id="penalty-kick"] h2 {
    position: relative;
    right: auto;
    bottom: auto;
    width: auto;
    height: auto;
    padding: 7px 8px 8px;
    overflow: visible;
    clip: auto;
    white-space: normal;
  }

  .game-card[data-game-id="temple-treasure"] {
    grid-column: 1;
    grid-row: 4;
  }

  .game-card[data-game-id="bar-darts"] {
    grid-column: 2;
    grid-row: 4;
  }

  .game-card[data-game-id="cock-fighting"] {
    grid-column: 3;
    grid-row: 4;
  }

  .game-card[data-game-id="world-cup-slots"] {
    grid-column: 1;
    grid-row: 5;
  }

  .game-wall::after {
    grid-column: 2 / 4;
    grid-row: 5;
    align-self: end;
    max-width: 22ch;
    padding: 0 4px 5px;
    color: var(--forest-soft);
    content: "Bảy trò chơi, chọn kỹ cho những phút giải lao.";
    font-size: clamp(14px, 4vw, 17px);
    font-weight: 760;
    line-height: 1.3;
  }

  .home-editorial {
    margin-top: 64px;
    padding-top: 22px;
  }

  .home-editorial h2 {
    margin-top: 10px;
    font-size: clamp(30px, 10vw, 44px);
  }

  .home-editorial p {
    margin-top: 18px;
    font-size: 15px;
  }

  .site-footer {
    min-height: 104px;
    padding: 18px 0 max(18px, env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .game-card img {
    transition: none;
  }
}
