@font-face {
  font-family: "Bricolage";
  src: url("/assets/fonts/bricolage-latin.woff2") format("woff2");
  font-weight: 600 800;
  font-display: swap;
}
@font-face {
  font-family: "Bricolage";
  src: url("/assets/fonts/bricolage-latin-ext.woff2") format("woff2");
  font-weight: 600 800;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF;
}

:root {
  --felt: #0b7a3b;
  --felt-dark: #04431f;
  --cream: #fffaf0;
  --gold: #ffd54a;
  --gold-dark: #c99a14;
  --font-d: "Bricolage", "Segoe UI", system-ui, sans-serif;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  /* a JS állítja be a tábla méretéhez */
  --cw: 100px;
  --ch: 140px;
  --radius: calc(var(--cw) * 0.07);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--felt-dark);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }

.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; }

/* klasszikus zöld posztó: világosabb közép, sötétebb szélek, finom szövésminta */
.play-area {
  position: relative; width: 100%; height: 100%;
  background:
    radial-gradient(ellipse 75% 70% at 50% 40%, rgba(255, 255, 255, 0.10), transparent 70%),
    radial-gradient(ellipse at 50% 50%, var(--felt) 0%, #075a2c 65%, var(--felt-dark) 100%);
}
.play-area::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.35;
  background-image:
    repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.05) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.03) 0 1px, transparent 1px 3px);
}

/* ---------------- Screens ---------------- */
.screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; overflow-y: auto; }
.start-content { max-width: 560px; text-align: center; color: var(--cream); }
.start-cards { position: relative; height: 130px; margin-bottom: 8px; }
.sc {
  position: absolute; left: 50%; top: 10px; width: 78px; height: 109px; margin-left: -39px;
  border-radius: 6px; background-size: cover; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  transform-origin: 50% 120%;
}
.sc--1 { background-image: url(images/cards/hearts_A.png); transform: rotate(-16deg) translateX(-22px); }
.sc--2 { background-image: url(images/cards/back_classic.svg); transform: rotate(0deg); }
.sc--3 { background-image: url(images/cards/spades_K.png); transform: rotate(16deg) translateX(22px); }
.brand-title {
  font: 800 clamp(2.6rem, 9vw, 4.2rem)/1 var(--font-d); letter-spacing: -0.02em; margin: 0 0 14px;
  color: var(--cream); text-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}
.hint { font-size: 0.98rem; line-height: 1.6; color: rgba(255, 250, 240, 0.88); margin: 0 0 26px; }
.btnrow { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn-primary, .btn-secondary {
  font-weight: 700; font-size: 1rem; padding: 13px 28px; border-radius: 999px; border: none;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn-primary { background: var(--gold); color: #3a2a00; box-shadow: 0 4px 0 var(--gold-dark); }
.btn-secondary { background: rgba(0, 0, 0, 0.15); color: var(--cream); border: 2px solid rgba(255, 250, 240, 0.55); }
.btn-primary:active, .btn-secondary:active { transform: translateY(2px); }
.btn-primary:hover, .btn-secondary:hover { filter: brightness(1.07); }

/* ---------------- Panels ---------------- */
.panel {
  background: rgba(4, 50, 24, 0.94); border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 22px;
  padding: 28px 30px; max-width: 480px; width: 100%; text-align: center; color: var(--cream);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}
.panel-title { font: 800 1.9rem var(--font-d); color: var(--gold); margin: 0 0 14px; }
.win-crown { font-size: 2.6rem; animation: crown 1.4s ease-in-out infinite; }
@keyframes crown { 50% { transform: translateY(-6px) rotate(-6deg); } }
.win-time { font-size: 1.05rem; margin: 0 0 20px; }
.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 auto; gap: 10px; align-items: center;
  background: rgba(255, 255, 255, 0.07); border-radius: 10px; padding: 8px 12px; font-size: 0.92rem;
}
.lb-rank { color: var(--gold); font-weight: 700; text-align: left; }
.lb-name { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 600; }
.lb-time { color: rgba(255, 250, 240, 0.7); }
.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: inherit; 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(--gold); }

/* ---------------- Fullscreen ---------------- */
.fullscreen-btn {
  position: absolute; top: 9px; right: 10px; z-index: 50; width: 38px; height: 38px; border-radius: 12px; border: none;
  background: rgba(0, 0, 0, 0.28); color: var(--cream); display: flex; align-items: center; justify-content: center;
}
.fullscreen-btn svg { width: 19px; height: 19px; }
.fullscreen-icon--exit { display: none; }
.fullscreen-btn.is-fullscreen .fullscreen-icon--enter { display: none; }
.fullscreen-btn.is-fullscreen .fullscreen-icon--exit { display: block; }

/* ---------------- HUD ---------------- */
#screen-game { padding: 0; display: block; overflow: hidden; }
.hud {
  position: absolute; top: 8px; left: 10px; right: 58px; height: 40px; z-index: 40;
  display: flex; align-items: center; gap: 10px; color: var(--cream);
}
.hud-stats { display: flex; gap: 6px; }
.hud-stat {
  display: flex; align-items: baseline; gap: 6px; padding: 7px 12px; border-radius: 12px;
  background: rgba(0, 0, 0, 0.22); font-variant-numeric: tabular-nums;
}
.hud-stat small { font-size: 0.7rem; opacity: 0.75; text-transform: uppercase; letter-spacing: 0.06em; }
.hud-stat b { font: 800 1rem var(--font-d); }
.hud-controls { margin-left: auto; display: flex; gap: 6px; }
.hud-btn {
  display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px; border-radius: 12px; border: none;
  background: rgba(0, 0, 0, 0.22); color: var(--cream); font-weight: 700; font-size: 0.9rem;
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
}
.hud-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.hud-btn:hover:not(:disabled) { background: rgba(0, 0, 0, 0.35); }
.hud-btn:active:not(:disabled) { transform: translateY(1px); }
.hud-btn:disabled { opacity: 0.4; cursor: default; }
.hud-btn--icon { padding: 0 10px; }
.collect-all-btn {
  font-weight: 800; font-size: 0.85rem; padding: 8px 14px; border-radius: 999px; border: none;
  background: var(--gold); color: #3a2a00; box-shadow: 0 3px 0 var(--gold-dark); animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { filter: brightness(1.18); } }
.toast {
  position: absolute; left: 50%; top: 56px; transform: translateX(-50%); z-index: 45;
  padding: 7px 16px; border-radius: 999px; background: rgba(0, 0, 0, 0.55); color: var(--cream); font-weight: 700; font-size: 0.9rem;
}

/* ---------------- Board ---------------- */
.board { position: absolute; inset: 0; }
.pile {
  position: absolute; width: var(--cw); height: var(--ch); border-radius: var(--radius);
  border: 2px solid rgba(255, 255, 255, 0.16); background: rgba(0, 0, 0, 0.08);
}
.pile.tableau { border-color: rgba(255, 255, 255, 0.08); background: rgba(0, 0, 0, 0.05); }
.pile.foundation::before {
  content: attr(data-symbol); position: absolute; inset: 0; display: grid; place-items: center;
  font-size: calc(var(--cw) * 0.5); color: rgba(255, 255, 255, 0.16);
}
.pile.stock { cursor: pointer; }
.stock-empty-mark {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: rgba(255, 255, 255, 0.35); font-size: calc(var(--cw) * 0.42); font-weight: 700;
}
.pile.drop-ok { box-shadow: 0 0 0 3px var(--gold); }

.card {
  position: absolute; left: -2px; top: -2px; width: var(--cw); height: var(--ch); border-radius: var(--radius);
  background-color: #fff; background-size: 100% 100%; background-position: center;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.25), 0 2px 6px rgba(0, 0, 0, 0.22);
  transition: top 0.14s ease;
}
.card.face-down { background-color: transparent; }
.card.face-up { cursor: grab; }
.card.is-dragged { opacity: 0; }
.card.ghost {
  position: fixed; z-index: 500; pointer-events: none; transition: none;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.45); transform: rotate(-1.5deg);
}
.card.hint-flash { animation: flash 0.5s ease 2; }
@keyframes flash { 50% { box-shadow: 0 0 0 3px var(--gold), 0 2px 6px rgba(0, 0, 0, 0.22); } }
.card.fly { transition: left 0.22s ease, top 0.22s ease; z-index: 300; }

/* ---------------- Win FX ---------------- */
.win-fx { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 60; pointer-events: none; }
.skip-fx {
  position: absolute; right: 16px; bottom: 16px; z-index: 70; padding: 10px 18px; border-radius: 999px; border: none;
  background: rgba(0, 0, 0, 0.5); color: var(--cream); font-weight: 700;
}

@media (max-width: 640px) {
  .hud { left: 6px; right: 50px; gap: 6px; }
  .hud-stat { padding: 6px 8px; }
  .hud-stat small { display: none; }
  .hud-btn { padding: 0 9px; }
  .hud-btn span { display: none; }
  .collect-all-btn { font-size: 0.75rem; padding: 7px 10px; }
  .fullscreen-btn { right: 6px; }
}
@media (max-width: 380px) {
  .hud-stat:nth-child(3) { display: none; }
}
/* a győzelmi panel a pattogó lapok nyomai fölött */
#screen-win { z-index: 80; background: rgba(0, 20, 8, 0.35); }
