:root {
  --bg-1: #3a4a5c;
  --bg-2: #212d3a;
  --ink: #16241c;
  --cream: #f2f5f8;
  --accent: #ffb300;
  --accent-dark: #c98600;
  --red: #c62828;
  --panel: rgba(24, 34, 46, 0.92);

  --font-display: "Baloo 2", "Segoe UI", sans-serif;
  --font-body: "Poppins", "Segoe UI", sans-serif;

  --tile-ivory: #f4efe4;
  --tile-ink: #21201c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font-body);
  background: var(--bg-2);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.game-frame {
  position: relative;
  width: 100vw;
  height: calc(100vh - 48px);
  height: calc(100dvh - 48px);
  overflow: hidden;
}

html.ksz-fullscreen .game-frame {
  height: 100vh;
  height: 100dvh;
}

.play-area {
  position: relative;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at 50% 0%, var(--bg-1), var(--bg-2) 75%);
}

.hidden { display: none !important; }

/* ---------------- Screens ---------------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

.start-content {
  max-width: 580px;
  text-align: center;
  color: var(--cream);
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.2rem, 8vw, 3.6rem);
  letter-spacing: 2px;
  color: var(--accent);
  text-shadow: 0 3px 0 rgba(0,0,0,0.35);
  margin: 0 0 18px;
}

.hint {
  font-size: 0.96rem;
  line-height: 1.6;
  color: rgba(242,245,248,0.88);
  margin: 0 0 26px;
}

.size-select {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.size-btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 10px 20px;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.06);
  color: var(--cream);
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease, border-color 0.12s ease;
}

.size-btn:hover { filter: brightness(1.12); }
.size-btn:active { transform: translateY(2px); }

.size-btn.is-selected {
  border-color: var(--accent);
  background: rgba(255,179,0,0.18);
  color: var(--accent);
}

.btnrow {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-primary, .btn-secondary, .btn-action {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  padding: 14px 28px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn-primary {
  background: var(--accent);
  color: #2b1a00;
  box-shadow: 0 4px 0 var(--accent-dark);
}

.btn-secondary {
  background: transparent;
  color: var(--cream);
  border: 2px solid rgba(242,245,248,0.6);
}

.btn-action {
  background: var(--accent);
  color: #2b1a00;
  font-size: 0.85rem;
  padding: 8px 18px;
  box-shadow: 0 3px 0 var(--accent-dark);
}

.btn-primary:active, .btn-secondary:active, .btn-action:active {
  transform: translateY(2px);
}

.btn-primary:hover, .btn-secondary:hover, .btn-action:hover {
  filter: brightness(1.08);
}

/* ---------------- Panels (leaderboard / gameover) ---------------- */
.panel {
  background: var(--panel);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 28px 32px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  color: var(--cream);
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
}

.panel-title {
  font-family: var(--font-display);
  color: var(--accent);
  font-size: 1.7rem;
  margin: 0 0 18px;
}

.win-time {
  font-size: 1.05rem;
  margin: 0 0 20px;
}

.size-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.size-tab {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 8px 14px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.2);
  background: transparent;
  color: var(--cream);
  cursor: pointer;
}

.size-tab.is-selected {
  border-color: var(--accent);
  background: rgba(255,179,0,0.18);
  color: var(--accent);
}

.leaderboard-list {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 40vh;
  overflow-y: auto;
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: 2em 1fr auto;
  gap: 10px;
  align-items: center;
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.92rem;
}

.leaderboard-list li.is-me { background: rgba(255,179,0,0.16); }

.lb-rank { color: var(--accent); font-weight: 700; text-align: left; }
.lb-name { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 600; text-align: right; }

.lb-empty {
  font-size: 0.9rem;
  color: rgba(242,245,248,0.7);
  margin: 0 0 20px;
}

.highscore-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0 0 20px;
}

.highscore-form label { font-size: 0.9rem; text-align: left; }

.highscore-form input {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: var(--cream);
}

.highscore-form input:focus { outline: none; border-color: var(--accent); }

/* ---------------- Fullscreen button ---------------- */
.fullscreen-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 50;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.35);
  color: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.fullscreen-btn svg { width: 20px; height: 20px; }
.fullscreen-icon--exit { display: none; }
.fullscreen-btn.is-fullscreen .fullscreen-icon--enter { display: none; }
.fullscreen-btn.is-fullscreen .fullscreen-icon--exit { display: block; }

/* ---------------- HUD ---------------- */
.hud {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 60px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 40;
  flex-wrap: wrap;
}

.hud-pill {
  background: rgba(0,0,0,0.3);
  border-radius: 999px;
  padding: 6px 14px;
  display: flex;
  gap: 6px;
  align-items: baseline;
  color: var(--cream);
}

.hud-label { font-size: 0.7rem; opacity: 0.75; }
.hud-value { font-family: var(--font-display); font-weight: 700; font-size: 1rem; }

.hud-controls { margin-left: auto; display: flex; gap: 8px; }

.hud-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.3);
  color: var(--cream);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hud-icon-btn:active { transform: translateY(1px); }

/* ---------------- Board ---------------- */
#screen-game { align-items: stretch; padding: 0; }

.domino-board {
  position: absolute;
  inset: 0;
  padding: 60px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-row {
  display: flex;
  gap: 6px;
  justify-content: center;
  min-height: 44px;
  flex-wrap: wrap;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 34px;
  color: var(--cream);
  font-size: 0.92rem;
  text-align: center;
}

.chain-viewport {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.15);
  border-radius: 14px;
}

.chain-row {
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 4px;
  padding: 12px;
}

.player-row {
  display: flex;
  gap: 6px;
  justify-content: center;
  min-height: 78px;
  flex-wrap: wrap;
  padding-bottom: 4px;
}

/* ---------------- Domino tiles ---------------- */
.tile {
  display: flex;
  background: var(--tile-ivory);
  border: 2px solid #cfc6ae;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.35);
  flex-shrink: 0;
}

.tile-half {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 2px;
  padding: 5px;
}

.pip {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--tile-ink);
  place-self: center;
  aspect-ratio: 1;
  max-width: 8px;
  max-height: 8px;
}

/* vizszintes tile (lanc): egymas mellett ket fel, elvalasztova */
.tile--h {
  flex-direction: row;
  width: 64px;
  height: 32px;
}
.tile--h .tile-half { width: 32px; height: 32px; }
.tile--h .tile-half:first-child { border-right: 2px solid #cfc6ae; }

/* fuggoleges tile (kez): egymas alatt ket fel */
.tile--v {
  flex-direction: column;
  width: 44px;
  height: 84px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.tile--v .tile-half { width: 44px; height: 42px; }
.tile--v .tile-half:first-child { border-bottom: 2px solid #cfc6ae; }

.tile--v.is-playable:hover {
  transform: translateY(-6px);
  box-shadow: 0 10px 18px rgba(0,0,0,0.4);
}

.tile--v.is-disabled {
  filter: grayscale(0.6) brightness(0.65);
  cursor: not-allowed;
}

.tile--back {
  background: linear-gradient(135deg, #8f4e15, #b5651d);
  border-color: rgba(255,255,255,0.25);
}

.tile--back.tile--v { width: 30px; height: 60px; }

.status-text.is-warn { color: var(--accent); font-weight: 600; }

@media (max-width: 640px) {
  .hint { font-size: 0.88rem; }
  .size-btn { padding: 8px 14px; font-size: 0.88rem; }
  .tile--h { width: 52px; height: 26px; }
  .tile--h .tile-half { width: 26px; height: 26px; }
  .tile--v { width: 36px; height: 68px; }
  .tile--v .tile-half { width: 36px; height: 34px; }
  /* Keskeny képernyőn a HUD (pontok + gombok) gyakran két sorba törik -
     ilyenkor több helyet kell neki hagyni felül, különben átfedésbe kerül
     a gép lapjaival. */
  .domino-board { padding-top: 96px; }
}
