/* =====================================================================
   «Шлях твоїх змін» — базові стилі
   Палітра та типографіка підібрані під друковані картки:
   глибокий фіолетовий космос, золоті написи, рожево-золоті рамки.
   ===================================================================== */

:root {
  /* кольори */
  --bg-deep:    #150826;
  --bg:         #1f0d3a;
  --bg-soft:    #2c1550;
  --panel:      rgba(30, 14, 58, 0.78);
  --panel-edge: rgba(226, 176, 74, 0.35);

  --gold:       #e2b04a;
  --gold-light: #f3d27f;
  --gold-dim:   #b48a3c;
  --pink:       #e07ad0;
  --magenta:    #c94fb0;
  --violet:     #7a3fbf;

  --text:       #f4e9d0;
  --text-muted: #c9b8a2;

  /* шрифти */
  --font-display: "Playfair Display", "Georgia", "Times New Roman", serif;
  --font-body:    "Lora", "Georgia", "Times New Roman", serif;

  /* розміри */
  --topbar-h: 64px;
  --panel-w: 340px;
  --gap: clamp(12px, 2vw, 28px);
  --radius: 18px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--bg-deep); }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: clamp(15px, 1.05vw + 10px, 18px);
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(120% 90% at 85% 10%, rgba(201, 79, 176, 0.28), transparent 60%),
    radial-gradient(90% 80% at 10% 90%, rgba(122, 63, 191, 0.35), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* ледь помітні зорі на фоні */
.stars {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 12% 18%, rgba(255,255,255,.55) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 78% 32%, rgba(243,210,127,.6) 50%, transparent 51%),
    radial-gradient(1px 1px at 40% 70%, rgba(255,255,255,.45) 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 82%, rgba(255,255,255,.5) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 25% 92%, rgba(243,210,127,.5) 50%, transparent 51%),
    radial-gradient(1px 1px at 60% 8%, rgba(255,255,255,.5) 50%, transparent 51%),
    radial-gradient(1px 1px at 95% 55%, rgba(224,122,208,.6) 50%, transparent 51%),
    radial-gradient(1px 1px at 5% 45%, rgba(255,255,255,.4) 50%, transparent 51%);
  opacity: .9;
}

/* ---------- верхня панель ---------- */
.topbar {
  position: relative; z-index: 2;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--gap);
  padding-left: max(var(--gap), env(safe-area-inset-left));
  padding-right: max(var(--gap), env(safe-area-inset-right));
  border-bottom: 1px solid var(--panel-edge);
  background: linear-gradient(180deg, rgba(21, 8, 38, .85), rgba(21, 8, 38, .55));
  backdrop-filter: blur(8px);
}

.brand { display: flex; align-items: center; gap: 12px; color: var(--gold); }
.brand__lotus { display: inline-flex; filter: drop-shadow(0 0 6px rgba(243,210,127,.55)); }
.brand__text { display: flex; flex-direction: column; line-height: 1.05; }
.brand__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(16px, 1.4vw + 8px, 21px);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--gold-light);
  text-shadow: 0 0 12px rgba(243, 210, 127, .35);
}
.brand__sub {
  font-size: clamp(11px, .6vw + 7px, 13px);
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-top: 4px;
}

/* ---------- екрани ---------- */
.app { position: relative; z-index: 1; }
.screen { min-height: calc(100dvh - var(--topbar-h)); }
.screen[hidden] { display: none; }
.screen--center {
  display: flex; align-items: center; justify-content: center;
  padding: var(--gap);
  padding-bottom: max(var(--gap), env(safe-area-inset-bottom));
}
.screen__head { text-align: center; padding: clamp(18px, 3vh, 36px) var(--gap) 8px; max-width: 720px; margin: 0 auto; }
.screen__title {
  margin: 0 0 8px;
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(22px, 2.2vw + 12px, 34px);
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--gold-light);
  text-shadow: 0 0 18px rgba(243, 210, 127, .35);
}
.screen__lead { margin: 0; color: var(--text-muted); }

.card--wide { max-width: 640px; width: 100%; }
.card__title--big { font-size: clamp(24px, 2.6vw + 12px, 40px); letter-spacing: .12em; margin-bottom: 14px; }
.card__lead { margin: 0; color: var(--text); font-size: 1.02em; }
.card__lead em { color: var(--gold-light); font-style: italic; }
.card__text { margin: 0; color: var(--text-muted); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 18px; }
.actions--center { justify-content: center; padding: 0 var(--gap) var(--gap); }
.question {
  margin: 0;
  font-family: var(--font-display); font-weight: 600;
  font-size: 1.25em; color: var(--gold-light);
}

/* ---------- МАК: сітка сорочок ---------- */
.mak-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(8px, 1.6vw, 18px);
  /* три ряди по п'ять карт мають вміститися у висоту екрана */
  max-width: min(900px, calc((100dvh - 250px) * 0.97));
  margin: 0 auto;
  padding: 12px var(--gap) var(--gap);
}
.mak-grid[hidden] { display: none; }
.mak-card {
  position: relative;
  aspect-ratio: 720 / 1234;
  padding: 0; margin: 0;
  border: 0; background: transparent;
  cursor: pointer;
  perspective: 1200px;
  -webkit-tap-highlight-color: transparent;
  /* «роздача» карт; анімація на кнопці, щоб не заважати повороту .mak-card__inner */
  animation: dealIn .6s cubic-bezier(.2,.7,.3,1) both;
  animation-delay: calc(var(--i) * 45ms);
}
@keyframes dealIn { from { opacity: 0; transform: translateY(24px) scale(.92); } to { opacity: 1; transform: none; } }
.mak-card__inner {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transition: transform .8s cubic-bezier(.4,.1,.2,1);
  border-radius: 6%;
  box-shadow: 0 8px 22px rgba(0,0,0,.5), 0 0 0 1px rgba(243,210,127,.25);
}
.mak-card__back, .mak-card__face {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; border-radius: 6%;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.mak-card__face { transform: rotateY(180deg); }
.mak-card:hover .mak-card__inner, .mak-card:focus-visible .mak-card__inner {
  transform: translateY(-6px);
  box-shadow: 0 14px 30px rgba(0,0,0,.55), 0 0 0 1px rgba(243,210,127,.6), 0 0 22px rgba(243,210,127,.35);
}
.mak-card:focus-visible { outline: none; }
.mak-card.is-flipped .mak-card__inner { transform: rotateY(180deg) scale(1.06); }
.mak-card.is-dimmed { pointer-events: none; }
.mak-card.is-dimmed .mak-card__inner { opacity: .22; filter: grayscale(.4); transition: opacity .5s, transform .8s; }
.mak-card:disabled { cursor: default; }

/* ---------- МАК: відкрита карта + запит ---------- */
.mak-reveal {
  display: grid;
  grid-template-columns: minmax(220px, 340px) minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
  max-width: 900px; margin: 0 auto;
  padding: 8px var(--gap) var(--gap);
}
.mak-reveal[hidden] { display: none; }
.mak-reveal__card img {
  display: block; width: 100%; height: auto;
  border-radius: 14px;
  box-shadow: 0 18px 44px rgba(0,0,0,.55), 0 0 0 1px rgba(243,210,127,.35), 0 0 40px rgba(201,79,176,.25);
  animation: cardIn .7s cubic-bezier(.2,.7,.3,1) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(18px) scale(.96); } to { opacity: 1; transform: none; } }
.verdict { margin-top: 16px; }
.verdict[hidden] { display: none; }
.verdict__text { margin: 12px 0 0; }
.verdict__text.is-ok { color: var(--gold-light); }
.verdict__text.is-retry { color: #f0b7e6; }
.dice--big { width: 72px; height: 72px; margin: 0 auto; border-radius: 16px; }
.dice--big .dice__value { font-size: 36px; }

/* ---------- фігурки ---------- */
.figure-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(10px, 1.6vw, 18px);
  max-width: 620px; margin: 0 auto;
  padding: 12px var(--gap) 8px;
}
.figure {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 18px 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  color: var(--gold);
  cursor: pointer;
  transition: transform .15s, box-shadow .2s, border-color .2s, background-color .2s;
  -webkit-tap-highlight-color: transparent;
}
.figure:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(0,0,0,.4), 0 0 18px rgba(243,210,127,.2); border-color: rgba(243,210,127,.6); }
.figure:focus-visible { outline: none; border-color: var(--gold-light); }
.figure.is-selected {
  border-color: var(--gold-light);
  background: rgba(226, 176, 74, .12);
  box-shadow: 0 0 0 2px rgba(243,210,127,.35), 0 0 26px rgba(243,210,127,.4);
  color: var(--gold-light);
}
.figure__icon { width: 64px; height: 64px; filter: drop-shadow(0 0 8px rgba(243,210,127,.45)); }
.figure__icon svg { width: 100%; height: 100%; }
.figure__name { font-family: var(--font-display); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; font-size: 13px; }

/* ---------- гравець на панелі ---------- */
.player { display: flex; align-items: center; gap: 14px; text-align: left; }
.player__figure {
  flex: none; width: 58px; height: 58px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--gold-light);
  background: radial-gradient(circle at 35% 30%, rgba(255,245,214,.25), rgba(122,63,191,.35) 70%);
  box-shadow: 0 0 0 1px rgba(243,210,127,.6), 0 0 18px rgba(243,210,127,.35);
}
.player__figure svg { width: 40px; height: 40px; }
.player__sector { font-family: var(--font-display); font-weight: 600; color: var(--gold-light); letter-spacing: .04em; line-height: 1.2; }
.player__cell { color: var(--text-muted); font-size: .92em; margin-top: 3px; }

.request-thumb {
  display: block; width: 110px; margin: 0 auto;
  padding: 0; border: 0; background: transparent; cursor: pointer;
  border-radius: 8px; overflow: hidden;
  box-shadow: 0 8px 20px rgba(0,0,0,.5), 0 0 0 1px rgba(243,210,127,.4);
  transition: transform .15s, box-shadow .2s;
}
.request-thumb:hover { transform: translateY(-3px); box-shadow: 0 12px 26px rgba(0,0,0,.55), 0 0 0 1px rgba(243,210,127,.8), 0 0 20px rgba(243,210,127,.35); }
.request-thumb img { display: block; width: 100%; height: auto; }

.history { list-style: none; margin: 0; padding: 0; text-align: left; font-size: .9em; max-height: 220px; overflow: auto; }
.history__item { padding: 5px 0; border-bottom: 1px dashed rgba(226,176,74,.2); color: var(--text-muted); }
.history__item:first-child { color: var(--text); }
.history__item--pause { color: #e7a6dc; }

.final-mak { width: min(220px, 55vw); margin: 18px auto 0; }
.final-mak img { display: block; width: 100%; height: auto; border-radius: 12px; box-shadow: 0 18px 44px rgba(0,0,0,.55), 0 0 0 1px rgba(243,210,127,.4); }

/* ---------- модальне вікно ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(10, 4, 20, .78); backdrop-filter: blur(6px); opacity: 0; transition: opacity .22s; }
.modal__box {
  position: relative;
  width: min(100%, 560px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 20px 20px 18px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(44,21,80,.96), rgba(31,13,58,.98));
  border: 1px solid rgba(243,210,127,.45);
  box-shadow: 0 30px 80px rgba(0,0,0,.6), 0 0 60px rgba(201,79,176,.2);
  text-align: center;
  opacity: 0; transform: translateY(18px) scale(.97);
  transition: opacity .22s, transform .22s;
}
.modal.is-open .modal__backdrop { opacity: 1; }
.modal.is-open .modal__box { opacity: 1; transform: none; }
.modal__title { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: .08em; text-transform: uppercase; color: var(--gold-light); }
.modal__sub { margin: 4px 0 0; color: var(--text-muted); font-size: .95em; }
.modal__sub[hidden] { display: none; }
.modal__card { margin: 14px auto 0; }
.modal__card[hidden] { display: none; }
.modal__card img {
  display: block; margin: 0 auto;
  width: auto; max-width: 100%;
  /* карта підлаштовується під висоту екрана: заголовок + кнопка ≈ 210px */
  max-height: calc(100dvh - 210px);
  height: auto;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,.55), 0 0 0 1px rgba(243,210,127,.35);
}
.modal__box--pause .modal__card img { box-shadow: 0 16px 40px rgba(0,0,0,.55), 0 0 0 1px rgba(224,122,208,.5), 0 0 30px rgba(224,122,208,.3); }
.modal__extra { margin-top: 12px; }
.modal__extra:empty { display: none; }
.timer { font-family: var(--font-display); font-weight: 700; font-size: 44px; color: var(--gold-light); line-height: 1.1; }
.timer[hidden] { display: none; }
.timer.is-done { color: var(--pink); }
.btn--small { padding: 9px 14px; font-size: 12px; }

/* ---------- вибір МАК-карт після карти сектора ---------- */
.mak-pick {
  position: fixed; inset: 0; z-index: 55;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 20px 16px;
  overflow: auto;
  background: rgba(10, 4, 20, .86);
  backdrop-filter: blur(8px);
  opacity: 0; transition: opacity .25s;
}
.mak-pick[hidden] { display: none; }
.mak-pick.is-open { opacity: 1; }
.mak-pick__head { text-align: center; max-width: 640px; }
.mak-pick__title { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: clamp(18px, 1.6vw + 10px, 26px); letter-spacing: .1em; text-transform: uppercase; color: var(--gold-light); text-shadow: 0 0 18px rgba(243,210,127,.4); }
.mak-pick__sub { margin: 6px 0 0; color: var(--text-muted); }
.mak-pick__grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr));
  gap: clamp(8px, 1.4vw, 16px);
  width: min(100%, calc(var(--cols, 5) * 150px));
}
.mak-pick .mak-card { animation-delay: calc(var(--i) * 40ms); }
.mak-pick .mak-card.is-flipped .mak-card__inner { transform: rotateY(180deg) scale(1.08); box-shadow: 0 14px 30px rgba(0,0,0,.55), 0 0 0 1px rgba(243,210,127,.8), 0 0 26px rgba(243,210,127,.5); }
.mak-pick .actions { margin-top: 6px; }
.mak-pick__grid[hidden] { display: none; }
/* підсумок: карта клітинки + витягнуті МАК-карти поруч */
.mak-pick__review { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: clamp(10px, 2vw, 24px); width: 100%; max-width: 1100px; }
.mak-pick__review[hidden] { display: none; }
.mak-pick__review img {
  display: block; height: auto;
  width: min(300px, calc((100dvh - 230px) * 0.583), 42vw);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,.55), 0 0 0 1px rgba(243,210,127,.5);
  animation: cardIn .6s cubic-bezier(.2,.7,.3,1) both;
}
.mak-pick__review .is-sector img { box-shadow: 0 16px 40px rgba(0,0,0,.55), 0 0 0 1px rgba(224,122,208,.5); }
.mak-pick__review figure { margin: 0; text-align: center; }
.mak-pick__review figcaption { margin-top: 6px; font-size: .85em; letter-spacing: .1em; text-transform: uppercase; color: var(--gold-dim); }
.mak-pick__review--many img { width: min(230px, 42vw); }

/* ---------- анімація входу в сектор ---------- */
.sector-splash {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: 24px;
  background: radial-gradient(60% 60% at 50% 45%, rgba(201,79,176,.35), rgba(10,4,20,.9) 70%);
  cursor: pointer;
  opacity: 0; transition: opacity .4s;
}
.sector-splash[hidden] { display: none; }
.sector-splash.is-open { opacity: 1; }
.sector-splash__card { width: min(260px, 55vw); transform: scale(.5) rotateY(90deg); opacity: 0; transition: transform .9s cubic-bezier(.2,.8,.2,1), opacity .5s; }
.sector-splash.is-open .sector-splash__card { transform: none; opacity: 1; }
.sector-splash__card img { display: block; width: 100%; height: auto; border-radius: 14px; box-shadow: 0 30px 80px rgba(0,0,0,.7), 0 0 0 1px rgba(243,210,127,.6), 0 0 80px rgba(243,210,127,.45); }
.sector-splash__caption { text-align: center; opacity: 0; transform: translateY(12px); transition: opacity .6s .5s, transform .6s .5s; }
.sector-splash.is-open .sector-splash__caption { opacity: 1; transform: none; }
.sector-splash__kicker { font-family: var(--font-display); letter-spacing: .3em; text-transform: uppercase; font-size: 13px; color: var(--gold); }
.sector-splash__title { font-family: var(--font-display); font-weight: 700; font-size: clamp(20px, 2.4vw + 10px, 32px); letter-spacing: .08em; text-transform: uppercase; color: var(--gold-light); text-shadow: 0 0 22px rgba(243,210,127,.5); }

/* ---------- розкладка ---------- */
.layout {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  gap: var(--gap);
  padding: var(--gap);
  padding-left: max(var(--gap), env(safe-area-inset-left));
  padding-right: max(var(--gap), env(safe-area-inset-right));
  padding-bottom: max(var(--gap), env(safe-area-inset-bottom));
  align-items: start;
  max-width: 1600px;
  margin: 0 auto;
}

.board-wrap {
  display: flex; justify-content: center; align-items: flex-start;
  min-width: 0;
  /* на широких екранах поле лишається в кадрі, коли прокручується панель */
  position: sticky;
  top: var(--gap);
}

/* ---------- поле ---------- */
.board {
  position: relative;
  width: min(100%, calc(100dvh - var(--topbar-h) - 2 * var(--gap)));
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(243, 210, 127, .35),
    0 0 0 4px rgba(21, 8, 38, .9),
    0 0 0 5px rgba(226, 176, 74, .35),
    0 24px 60px rgba(0, 0, 0, .55),
    0 0 80px rgba(201, 79, 176, .18);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.board__img {
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.board__cells, .board__tokens {
  position: absolute; inset: 0;
}
.board__tokens { pointer-events: none; }

/* клітинка — невидима кнопка поверх зображення */
.cell {
  position: absolute;
  left: calc(var(--x) * 1%);
  top:  calc(var(--y) * 1%);
  width:  calc(var(--size) * 1%);
  height: calc(var(--size) * 1%);
  transform: translate(-50%, -50%) rotate(calc(var(--rot) * 1deg));
  margin: 0; padding: 0;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 14%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
  color: transparent;
  font-size: 0;
}
.cell:hover, .cell:focus-visible {
  outline: none;
  border-color: rgba(243, 210, 127, .85);
  box-shadow: 0 0 0 3px rgba(243, 210, 127, .18), 0 0 18px rgba(243, 210, 127, .55);
  background: rgba(243, 210, 127, .08);
}
.cell.is-active {
  border-color: var(--gold-light);
  box-shadow: 0 0 0 3px rgba(243, 210, 127, .25), 0 0 26px rgba(243, 210, 127, .8);
  background: rgba(243, 210, 127, .12);
  animation: cellPulse 1.8s ease-in-out infinite;
}
.cell--pause.is-active {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(224, 122, 208, .25), 0 0 26px rgba(224, 122, 208, .85);
  background: rgba(224, 122, 208, .12);
}
@keyframes cellPulse {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.35); }
}

/* режим калібрування: показуємо всі зони */
.board.is-calibrating .cell {
  border-color: rgba(0, 255, 140, .8);
  background: rgba(0, 255, 140, .10);
  color: #b6ffde; font-size: 10px; font-family: monospace;
}
.board.is-calibrating .cell--pause {
  border-color: rgba(255, 120, 220, .9);
  background: rgba(255, 120, 220, .12);
}

/* ---------- фішка ---------- */
.token {
  position: absolute;
  left: calc(var(--x) * 1%);
  top:  calc(var(--y) * 1%);
  width: 6.4%; height: 6.4%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff8e6;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,245,214,.35), rgba(122,63,191,.75) 55%, rgba(60,25,100,.95) 100%);
  box-shadow:
    0 0 0 2px var(--gold-light),
    0 0 0 4px rgba(40, 15, 70, .9),
    0 6px 14px rgba(0, 0, 0, .55),
    0 0 22px rgba(243, 210, 127, .85);
  transition: left .42s cubic-bezier(.4, .1, .25, 1), top .42s cubic-bezier(.4, .1, .25, 1), opacity .3s;
  opacity: 0;
}
.token svg { width: 72%; height: 72%; filter: drop-shadow(0 0 4px rgba(243,210,127,.8)); }
.token.is-visible { opacity: 1; }
.token.is-hopping { animation: hop .55s ease-in-out; }
@keyframes hop {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50%      { transform: translate(-50%, -62%) scale(1.15); }
}

/* ---------- панель ---------- */
.panel { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }

.card {
  position: relative;
  padding: clamp(18px, 2vw, 26px);
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.25), 0 16px 40px rgba(0,0,0,.4);
  backdrop-filter: blur(10px);
  text-align: center;
}
.card::before {
  /* тонка внутрішня золота рамка, як на картках */
  content: "";
  position: absolute; inset: 7px;
  border-radius: calc(var(--radius) - 6px);
  border: 1px solid rgba(226, 176, 74, .28);
  pointer-events: none;
}
.card__ornament { color: var(--gold); margin-bottom: 4px; filter: drop-shadow(0 0 8px rgba(243,210,127,.5)); }

.card__title {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(17px, 1.1vw + 10px, 22px);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--gold-light);
}
.card__subtitle {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(15px, .9vw + 9px, 18px);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gold);
}

.cell-info__num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(38px, 4vw + 10px, 56px);
  line-height: 1;
  color: var(--gold-light);
  text-shadow: 0 0 18px rgba(243, 210, 127, .45);
}
.cell-info__kind {
  margin-top: 6px;
  color: var(--text-muted);
  font-style: italic;
}

.divider {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0;
  color: var(--gold);
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
}

.controls { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }

.btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 12px 20px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid var(--gold);
  color: var(--gold-light);
  background: transparent;
  transition: background-color .18s, box-shadow .18s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: rgba(226, 176, 74, .12); box-shadow: 0 0 18px rgba(243, 210, 127, .3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; box-shadow: none; }
.btn--primary {
  background: linear-gradient(180deg, #f0c96b, #c8953a);
  color: #2a1245;
  border-color: #f3d27f;
  box-shadow: 0 6px 18px rgba(226, 176, 74, .35);
}
.btn--primary:hover { background: linear-gradient(180deg, #f7d78a, #d5a247); }
.btn--ghost { border-color: rgba(226, 176, 74, .5); }

.dice {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border-radius: 12px;
  border: 1px solid var(--gold);
  background: rgba(21, 8, 38, .6);
  box-shadow: inset 0 0 12px rgba(243, 210, 127, .15);
}
.dice__value {
  font-family: var(--font-display);
  font-weight: 700; font-size: 26px;
  color: var(--gold-light);
}
.dice.is-rolling .dice__value { animation: shake .5s ease-in-out; }
@keyframes shake {
  0%,100% { transform: rotate(0); }
  25%     { transform: rotate(-18deg) scale(1.15); }
  75%     { transform: rotate(18deg) scale(1.15); }
}

.hint { margin: 16px 0 0; font-size: .9em; color: var(--text-muted); }

.legend { list-style: none; margin: 0; padding: 0; text-align: left; font-size: .92em; }
.legend li { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
.legend__swatch {
  flex: none; width: 18px; height: 18px; border-radius: 5px;
  border: 2px solid var(--gold-light); box-shadow: 0 0 8px rgba(243,210,127,.5);
}
.legend__swatch--pause { border-color: var(--pink); box-shadow: 0 0 8px rgba(224,122,208,.6); }
.legend__swatch--token {
  border-radius: 50%; border: 2px solid rgba(255,245,214,.8);
  background: radial-gradient(circle at 35% 30%, #fff5d6, var(--gold) 60%, #8b6420);
}

.panel__footer {
  text-align: center;
  font-size: .8em;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gold-dim);
}

/* ---------- адаптив ---------- */
@media (max-width: 1100px) {
  :root { --panel-w: 300px; }
}

/* планшет портрет і телефон: панель під полем */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .board-wrap { position: static; }
  .board { width: min(100%, calc(100dvh - var(--topbar-h) - 2 * var(--gap) - 120px)); margin: 0 auto; }
  .panel { max-width: 560px; width: 100%; margin: 0 auto; }
}

@media (max-width: 700px) {
  .mak-reveal { grid-template-columns: 1fr; }
  .mak-reveal__card { width: min(260px, 70vw); margin: 0 auto; }
}

@media (max-width: 560px) {
  :root { --topbar-h: 56px; --radius: 14px; }
  .board { width: 100%; }
  .brand__sub { display: none; }
  .btn { padding: 11px 16px; font-size: 13px; }
  .card { padding: 18px 16px; }
  .mak-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .mak-pick__grid { grid-template-columns: repeat(min(var(--cols, 5), 4), minmax(0, 1fr)); width: 100%; }
  .figure-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal__box { padding: 16px 14px 14px; }
}

/* ландшафт на низьких екранах: тримаємо поле в кадрі */
@media (max-height: 520px) and (orientation: landscape) {
  .layout { grid-template-columns: minmax(0, 1fr) 260px; }
  .board { width: min(100%, calc(100dvh - var(--topbar-h) - 2 * var(--gap))); }
}

@media (prefers-reduced-motion: reduce) {
  .token, .cell { transition: none; }
  .cell.is-active, .token.is-hopping, .dice.is-rolling .dice__value { animation: none; }
}
