@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 {
  --red: #ff4561;
  --red-d: #c81e3a;
  --blue: #4f86ff;
  --blue-d: #1d4ed8;
  --ink: #eef1fa;
  --muted: #9aa4c0;
  --panel: rgba(15, 21, 39, 0.82);
  --line: rgba(255, 255, 255, 0.09);
  --turn: var(--red);
  --turn-d: var(--red-d);
  --font-d: "Bricolage", "Segoe UI", system-ui, sans-serif;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  /* a játéktér magassága (a felső sáv és az esetleges hirdetéssáv nélkül) */
  --frame-h: calc(100dvh - 48px - var(--mj-ad-h, 0px));
}
html.ksz-fullscreen { --frame-h: 100dvh; }
body.turn-blue { --turn: var(--blue); --turn-d: var(--blue-d); }

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

.game-frame {
  position: relative;
  width: 100vw;
  height: calc(100vh - 48px);
  height: calc(100dvh - 48px);
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 60% at 30% 20%, rgba(79, 134, 255, 0.16), transparent 70%),
    radial-gradient(ellipse 60% 60% at 80% 90%, rgba(255, 69, 97, 0.14), transparent 70%),
    radial-gradient(circle at 50% 50%, #121a33, #070a13 75%);
}
html.ksz-fullscreen .game-frame { height: 100vh; height: 100dvh; }

.fullscreen-btn {
  position: absolute; top: 10px; right: 10px; z-index: 20;
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 12px; border: 1px solid var(--line);
  background: rgba(15, 21, 39, 0.7); color: var(--ink);
}
.fullscreen-icon { width: 18px; height: 18px; }
.fullscreen-icon--exit { display: none; }
.fullscreen-btn.is-fullscreen .fullscreen-icon--enter { display: none; }
.fullscreen-btn.is-fullscreen .fullscreen-icon--exit { display: block; }

.screen { position: absolute; inset: 0; }

/* ---------------- Menu ---------------- */
#screen-menu { display: grid; place-items: center; overflow-y: auto; padding: 20px 14px; }
.menu-card {
  width: min(460px, 100%);
  padding: 26px 22px 18px;
  border-radius: 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
}
.logo { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 18px; }
.logo h1 {
  margin: 0; text-align: center;
  font: 800 clamp(1.9rem, 7vw, 2.5rem)/0.95 var(--font-d); letter-spacing: -0.03em;
}
.logo h1 em {
  font-style: normal;
  background: linear-gradient(95deg, var(--red), #ff9f6b 45%, var(--blue));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.logo-pawn { width: 34px; height: 46px; flex: none; animation: hop 2.4s ease-in-out infinite; }
.logo-pawn--blue { animation-delay: -1.2s; }
.logo-pawn::before, .logo-pawn::after { content: ""; display: block; margin: 0 auto; border-radius: 50%; }
.logo-pawn::before { width: 20px; height: 20px; }
.logo-pawn::after { width: 32px; height: 26px; border-radius: 50% 50% 12px 12px; margin-top: -3px; }
.logo-pawn--red::before, .logo-pawn--red::after { background: radial-gradient(circle at 35% 30%, #ffb3be, var(--red) 45%, var(--red-d)); }
.logo-pawn--blue::before, .logo-pawn--blue::after { background: radial-gradient(circle at 35% 30%, #c4d7ff, var(--blue) 45%, var(--blue-d)); }
@keyframes hop { 0%, 70%, 100% { transform: translateY(0); } 80% { transform: translateY(-10px) rotate(-6deg); } 90% { transform: translateY(0) rotate(4deg); } }

.step-title { margin: 6px 0 12px; font-weight: 700; color: var(--muted); text-align: center; letter-spacing: 0.02em; }
.choice-list { display: grid; gap: 10px; }
.choice {
  display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 14px 16px; border-radius: 18px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.choice:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.07); }
.choice .ci { font-size: 1.6rem; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; background: rgba(255, 255, 255, 0.06); }
.choice b { display: block; font-size: 1.05rem; }
.choice small { color: var(--muted); }
.choice-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pill {
  padding: 14px 6px; border-radius: 16px; font-weight: 700;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line);
}
.pill:hover { border-color: var(--blue); }
.toggle-cards { display: grid; gap: 10px; }
.tcard {
  text-align: left; padding: 16px; border-radius: 18px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line);
}
.tcard b { display: block; font: 800 1.15rem var(--font-d); margin-bottom: 4px; }
.tcard small { color: var(--muted); line-height: 1.45; }
.tcard:hover { border-color: rgba(255, 255, 255, 0.3); }
.tcard--enemy { background: linear-gradient(135deg, rgba(255, 69, 97, 0.14), rgba(79, 134, 255, 0.14)); }
.link-back { display: block; margin: 14px auto 0; background: none; border: 0; color: var(--muted); }
.join-form { display: flex; gap: 8px; margin-top: 12px; }
.join-form input {
  flex: 1; min-width: 0; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25); color: var(--ink); font: 800 1.2rem var(--font-d); letter-spacing: 0.3em; text-transform: uppercase; text-align: center;
}
.btn {
  padding: 12px 18px; border-radius: 999px; border: 0; font-weight: 800;
  background: linear-gradient(135deg, var(--blue), var(--blue-d)); color: #fff;
  box-shadow: 0 8px 20px -8px var(--blue);
}
.btn--ghost { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); box-shadow: none; }
.form-msg { min-height: 1.2em; margin: 10px 0 0; text-align: center; color: var(--muted); font-size: 0.92rem; }
.room-code {
  margin: 6px auto 4px; text-align: center;
  font: 800 2.6rem var(--font-d); letter-spacing: 0.25em;
  background: linear-gradient(95deg, var(--red), var(--blue)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
#step-wait .btn { display: block; margin: 12px auto 0; }
.rules { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; color: var(--muted); font-size: 0.9rem; }
.rules summary { cursor: pointer; font-weight: 700; color: var(--ink); }
.rules ul { padding-left: 18px; margin: 10px 0 0; line-height: 1.5; }

/* ---------------- Game layout ---------------- */
.table {
  position: absolute; inset: 0;
  display: grid; grid-template-columns: auto 290px; align-items: center; justify-content: center;
  gap: 22px; padding: 14px 20px;
}
.board-wrap {
  position: relative;
  width: min(calc(var(--frame-h) - 28px), calc(100vw - 360px), 860px);
  aspect-ratio: 1;
}
html.ksz-fullscreen .board-wrap { width: min(calc(var(--frame-h) - 28px), calc(100vw - 360px), 980px); }
.board { width: 100%; height: 100%; display: block; overflow: visible; filter: drop-shadow(0 26px 50px rgba(0, 0, 0, 0.55)); }

.side { display: flex; flex-direction: column; gap: 14px; }
.players { display: grid; gap: 8px; }
.player {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--line);
  transition: box-shadow 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
}
.player .dot { width: 14px; height: 14px; border-radius: 50%; }
.player--red .dot { background: var(--red); box-shadow: 0 0 10px var(--red); }
.player--blue .dot { background: var(--blue); box-shadow: 0 0 10px var(--blue); }
.pname { font-weight: 800; flex: 1; }
.pstat { color: var(--muted); font-size: 0.85rem; }
.player.is-turn { transform: translateX(-4px); }
.player--red.is-turn { border-color: var(--red); box-shadow: 0 0 0 1px var(--red), 0 10px 30px -10px var(--red); }
.player--blue.is-turn { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue), 0 10px 30px -10px var(--blue); }

.status { min-height: 2.6em; text-align: center; font-weight: 700; color: var(--ink); display: grid; place-items: center; }

/* ---------------- Dice ---------------- */
.tray {
  position: relative; height: 150px; border-radius: 22px; overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 120%, rgba(255, 255, 255, 0.07), transparent 60%),
    linear-gradient(180deg, #0f3b2e, #0a2a21);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 6px 22px rgba(0, 0, 0, 0.55);
  perspective: 700px;
}
.tray::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 6px 6px;
}
.dice {
  --ds: 58px;
  position: absolute; left: calc(50% - var(--ds) / 2); top: calc(50% - var(--ds) / 2);
  width: var(--ds); height: var(--ds);
  transform-style: preserve-3d;
  transform: rotateX(-20deg) rotateY(25deg);
  z-index: 2;
}
.face {
  position: absolute; inset: 0; border-radius: 12px;
  background: radial-gradient(circle at 30% 25%, #fff, #f1f3f8 55%, #d9dde8);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06), inset 0 -4px 8px rgba(0, 0, 0, 0.12);
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 9px;
}
.face i {
  width: 11px; height: 11px; border-radius: 50%; place-self: center;
  background: radial-gradient(circle at 35% 30%, #ff8a9a, var(--turn) 50%, var(--turn-d));
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}
.f1 { transform: rotateY(0deg) translateZ(calc(var(--ds) / 2)); }
.f6 { transform: rotateY(180deg) translateZ(calc(var(--ds) / 2)); }
.f3 { transform: rotateY(90deg) translateZ(calc(var(--ds) / 2)); }
.f4 { transform: rotateY(-90deg) translateZ(calc(var(--ds) / 2)); }
.f2 { transform: rotateX(90deg) translateZ(calc(var(--ds) / 2)); }
.f5 { transform: rotateX(-90deg) translateZ(calc(var(--ds) / 2)); }
.f1 i { grid-area: 2 / 2; }
.f2 i:nth-child(1) { grid-area: 1 / 1; } .f2 i:nth-child(2) { grid-area: 3 / 3; }
.f3 i:nth-child(1) { grid-area: 1 / 1; } .f3 i:nth-child(2) { grid-area: 2 / 2; } .f3 i:nth-child(3) { grid-area: 3 / 3; }
.f4 i:nth-child(1) { grid-area: 1 / 1; } .f4 i:nth-child(2) { grid-area: 1 / 3; } .f4 i:nth-child(3) { grid-area: 3 / 1; } .f4 i:nth-child(4) { grid-area: 3 / 3; }
.f5 i:nth-child(1) { grid-area: 1 / 1; } .f5 i:nth-child(2) { grid-area: 1 / 3; } .f5 i:nth-child(3) { grid-area: 2 / 2; } .f5 i:nth-child(4) { grid-area: 3 / 1; } .f5 i:nth-child(5) { grid-area: 3 / 3; }
.f6 i:nth-child(1) { grid-area: 1 / 1; } .f6 i:nth-child(2) { grid-area: 2 / 1; } .f6 i:nth-child(3) { grid-area: 3 / 1; } .f6 i:nth-child(4) { grid-area: 1 / 3; } .f6 i:nth-child(5) { grid-area: 2 / 3; } .f6 i:nth-child(6) { grid-area: 3 / 3; }
.dice-shadow {
  position: absolute; left: calc(50% - 34px); top: calc(50% + 20px); width: 68px; height: 18px; border-radius: 50%;
  background: radial-gradient(rgba(0, 0, 0, 0.55), transparent 70%); z-index: 1;
}

/* ---------------- Roll control ---------------- */
.roll-ctl { display: grid; gap: 10px; }
.power {
  position: relative; height: 14px; border-radius: 999px; overflow: hidden;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line);
}
.power-fill {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  background: linear-gradient(90deg, #ffd54a, #ff9f43 45%, var(--turn));
  border-radius: inherit; box-shadow: 0 0 14px var(--turn);
}
.power-sweet { position: absolute; top: 0; bottom: 0; left: 72%; width: 14%; border-left: 1px dashed rgba(255, 255, 255, 0.35); border-right: 1px dashed rgba(255, 255, 255, 0.35); }
.roll-btn {
  position: relative; border: 0; border-radius: 22px; padding: 16px 10px 12px;
  background: linear-gradient(180deg, var(--turn), var(--turn-d)); color: #fff;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.35), 0 14px 30px -10px var(--turn);
  touch-action: none; transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.2s ease;
}
.roll-btn span { display: block; font: 800 1.45rem var(--font-d); letter-spacing: 0.08em; }
.roll-btn small { opacity: 0.85; font-size: 0.78rem; }
.roll-btn.is-down { transform: translateY(4px) scale(0.98); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35), 0 8px 18px -10px var(--turn); }
.roll-btn:disabled { filter: grayscale(0.8) brightness(0.6); cursor: default; }
.side-tools { display: flex; gap: 8px; }
.tool { flex: 1; padding: 10px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }

/* ---------------- Board pieces ---------------- */
.piece { cursor: default; transition: filter 0.2s ease; }
.piece.can-move { cursor: pointer; }
.piece .ring { opacity: 0; }
.piece.can-move .ring { opacity: 1; animation: ring 1s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes ring { 0%, 100% { transform: scale(0.9); opacity: 0.9; } 50% { transform: scale(1.15); opacity: 0.35; } }
.base-glow { opacity: 0; transition: opacity 0.3s ease; }
.base-glow.on { opacity: 1; animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { opacity: 0.45; } }

/* ---------------- Overlay / toast ---------------- */
.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(5, 7, 15, 0.6); backdrop-filter: blur(4px); z-index: 30; }
.win-card {
  width: min(380px, 90vw); text-align: center; padding: 28px 22px 22px; border-radius: 26px;
  background: var(--panel); border: 1px solid var(--line); animation: pop 0.4s cubic-bezier(.2, 1.4, .4, 1);
}
.win-card h2 { font: 800 1.8rem var(--font-d); margin: 10px 0 6px; }
.win-card p { color: var(--muted); margin: 0 0 18px; }
.win-actions { display: flex; gap: 10px; justify-content: center; }
.win-pawn { width: 64px; height: 84px; margin: 0 auto; animation: hop 1.2s ease-in-out infinite; }
.win-pawn::before, .win-pawn::after { content: ""; display: block; margin: 0 auto; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, var(--turn) 45%, var(--turn-d)); }
.win-pawn::before { width: 36px; height: 36px; }
.win-pawn::after { width: 60px; height: 48px; border-radius: 50% 50% 18px 18px; margin-top: -5px; }
@keyframes pop { from { transform: scale(0.7); opacity: 0; } }
.toast {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 25;
  padding: 10px 18px; border-radius: 999px; font-weight: 800;
  background: var(--panel); border: 1px solid var(--line); box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.6);
  animation: pop 0.25s ease;
}

/* ---------------- Portrait / phones ---------------- */
@media (max-aspect-ratio: 1/1), (max-width: 760px) {
  .table { grid-template-columns: 1fr; grid-template-rows: auto auto; align-content: center; gap: 10px; padding: 8px 10px 10px; }
  .board-wrap { width: min(calc(100vw - 20px), calc(var(--frame-h) - 250px), 720px); justify-self: center; }
  .side { display: grid; grid-template-columns: 1fr 120px; grid-template-areas: "players tray" "status tray" "ctl ctl" "tools tools"; gap: 8px; width: min(100%, 520px); justify-self: center; }
  .players { grid-area: players; grid-template-columns: 1fr 1fr; }
  .player { padding: 8px 10px; }
  .player.is-turn { transform: none; }
  .pstat { display: none; }
  .status { grid-area: status; min-height: 0; font-size: 0.92rem; }
  .tray { grid-area: tray; height: 100%; min-height: 96px; }
  .dice { --ds: 46px; }
  .face { padding: 7px; border-radius: 10px; }
  .face i { width: 9px; height: 9px; }
  .roll-ctl { grid-area: ctl; grid-template-columns: 1fr; }
  .roll-btn { padding: 12px 10px 9px; }
  .roll-btn span { font-size: 1.2rem; }
  .side-tools { grid-area: tools; }
  .tool { padding: 7px; }
  .fullscreen-btn { top: 6px; right: 6px; width: 34px; height: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  .logo-pawn, .win-pawn { animation: none; }
}
