:root {
  --bg: #ffffff;
  --game-bg: #f4f8f3;
  --text: #363e52;
  --muted: #8a90a2;
  --border: #dee1e9;
  --tile-bg: #fbfcff;
  --tile-border: #c0c5d3;
  --tile-filled: #6d7385;
  --tile-text: #393e4c;
  --key: #dce1ed;
  --key-hover: #c4cbdd;
  --key-text: #414a5e;
  --btn: #e6e9f0;
  --correct: #79b851;
  --correct-dark: #5f9a3b;
  --present: #f3c237;
  --absent: #a4aec4;
  --modal: #ffffff;
  --shadow: 0 20px 60px rgba(54, 62, 82, .18);
  /* ჰედერი + ზედა რეკლამა + კლავიატურა და დაშორებები — ფილა რომ ეკრანის სიმაღლეში ჩაეტიოს */
  --ad-top-h: 62px;
  --chrome-h: 440px;
  --tile: max(34px, min(64px, calc((100vw - 48px) / 5), calc((100svh - var(--chrome-h)) / 6)));
}
@media (min-width: 768px) {
  :root { --ad-top-h: 106px; --chrome-h: 484px; }
}
:root[data-theme="dark"] {
  --bg: #13141c;
  --game-bg: #1a1b26;
  --text: #dfe1f3;
  --muted: #8f94ad;
  --border: #2e3042;
  --tile-bg: #191a24;
  --tile-border: #666a85;
  --tile-filled: #9a9eb6;
  --tile-text: #ffffff;
  --key: #656780;
  --key-hover: #73758f;
  --key-text: #ffffff;
  --btn: #40445c;
  --absent: #3d4054;
  --modal: #222433;
  --shadow: 0 20px 60px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans Georgian", "BPG Arial", "Sylfaen", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 12px; max-width: 640px; margin: 0 auto;
  background: var(--bg); position: relative; z-index: 5;
}
.topbar-right { display: flex; gap: 8px; }
.logo { margin: 0; font-size: 1.5rem; font-weight: 800; letter-spacing: .02em; }
.logo span { font-weight: 400; font-size: .9rem; color: var(--muted); }
.icon-btn {
  width: 38px; height: 38px; border: 0; border-radius: 8px;
  background: var(--btn); color: var(--text);
  font-weight: 700; font-size: 1.15rem; font-family: inherit; cursor: pointer;
  display: grid; place-items: center; transition: filter .15s;
}
.icon-btn:hover { filter: brightness(.94); }

/* სათამაშო ზონა — მთელ სიგანეზე მსუბუქი ფონი */
.game {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  gap: 16px;
  max-width: 500px; margin: 0 auto; padding: 16px 8px;
  min-height: calc(100svh - 56px - var(--ad-top-h));
  background: var(--game-bg);
  box-shadow: 0 0 0 100vmax var(--game-bg);
  clip-path: inset(0 -100vmax);
}

.board { display: grid; grid-template-rows: repeat(6, var(--tile)); gap: 6px; }
.row { display: grid; grid-template-columns: repeat(5, var(--tile)); gap: 6px; }
.row.shake { animation: shake .5s; }
.tile {
  display: grid; place-items: center;
  border: 2px solid var(--tile-border); background: var(--tile-bg); color: var(--tile-text);
  font-size: calc(var(--tile) * .45); font-weight: 700;
  user-select: none;
}
.tile.filled { border-color: var(--tile-filled); animation: pop .1s; }
.tile.reveal { animation: flip .5s ease forwards; }
.tile.correct, .tile.present, .tile.absent { color: #fff; }
.tile.correct { background: var(--correct); border-color: var(--correct); }
.tile.present { background: var(--present); border-color: var(--present); }
.tile.absent  { background: var(--absent); border-color: transparent; }
.tile.win { animation: bounce .4s ease; }

@keyframes pop { 50% { transform: scale(1.1); } }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes shake { 10%,90% { transform: translateX(-2px); } 20%,80% { transform: translateX(4px); } 30%,50%,70% { transform: translateX(-6px); } 40%,60% { transform: translateX(6px); } }
@keyframes bounce { 40% { transform: translateY(-20px); } 70% { transform: translateY(4px); } }

.keyboard { width: 100%; display: flex; flex-direction: column; gap: 6px; user-select: none; }
.kb-row { display: flex; justify-content: center; gap: 6px; }
.key {
  flex: 1; max-width: 54px; height: 54px; padding: 0;
  border: 0; border-radius: 4px;
  background: var(--key); color: var(--key-text);
  font-weight: 700; font-size: 1.1rem; font-family: inherit; cursor: pointer;
  touch-action: manipulation; transition: background .2s;
}
.key:hover { background: var(--key-hover); }
.key.wide { flex: 1.6; max-width: 86px; font-size: .78rem; }
.key.correct { background: var(--correct); color: #fff; }
.key.present { background: var(--present); color: #fff; }
.key.absent  { background: var(--absent);  color: #fff; }
.key:active { filter: brightness(.92); }
.key.ready {
  background: var(--correct); color: #fff;
  animation: ready-pulse 1.4s ease-in-out infinite;
}
@keyframes ready-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--correct) 60%, transparent); transform: scale(1); }
  50% { box-shadow: 0 0 0 6px transparent; transform: scale(1.06); }
}

.toast {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 12px 18px; border-radius: 10px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 10;
  white-space: nowrap; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; }

.seo-content { max-width: 680px; margin: 0 auto; padding: 24px 16px 8px; line-height: 1.7; }
.seo-content h2 { font-size: 1.3rem; margin-top: 2rem; }
.seo-content details { border-bottom: 1px solid var(--border); padding: 10px 0; }
.seo-content summary { cursor: pointer; font-weight: 700; }
.legend { list-style: none; padding: 0; }
.legend li { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
kbd { border: 1px solid var(--tile-border); border-radius: 4px; padding: 1px 6px; font: inherit; font-size: .9em; }

.tile-mini {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 2px solid var(--tile-border); background: var(--tile-bg); color: var(--tile-text);
  font-weight: 700; flex: none;
}
.tile-mini.correct, .tile-mini.present, .tile-mini.absent { color: #fff; }
.tile-mini.correct { background: var(--correct); border-color: var(--correct); }
.tile-mini.present { background: var(--present); border-color: var(--present); }
.tile-mini.absent  { background: var(--absent); border-color: transparent; }

.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px 16px 40px; }

.modal {
  border: 0; border-radius: 24px; padding: 28px 24px 24px;
  width: min(440px, calc(100vw - 32px));
  background: var(--modal); color: var(--text); box-shadow: var(--shadow);
  position: fixed;
}
.modal::backdrop { background: rgba(30, 33, 45, .45); }
.modal h2 { margin-top: 0; font-size: 1.35rem; font-weight: 800; text-align: center; }
.modal h3 { font-size: 1rem; text-align: center; }
.modal .close {
  position: absolute; top: 14px; right: 14px; width: 34px; height: 34px;
  background: var(--btn); border: 0; border-radius: 8px; color: var(--text);
  font-size: 1.3rem; line-height: 1; cursor: pointer;
}
.example { display: flex; gap: 4px; margin-top: 12px; }
.muted { color: var(--muted); font-size: .9rem; }

.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; }
.stats-row strong { display: block; font-size: 1.8rem; }
.stats-row span { font-size: .72rem; color: var(--muted); }
.dist { display: flex; flex-direction: column; gap: 4px; }
.dist-row { display: flex; align-items: center; gap: 6px; font-size: .9rem; }
.dist-bar { background: var(--absent); color: #fff; text-align: right; padding: 2px 8px; font-weight: 700; min-width: 24px; border-radius: 4px; }
.dist-bar.hl { background: var(--correct); }
.endgame { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 20px; }
.next { display: flex; flex-direction: column; }
.next span { font-size: .85rem; color: var(--muted); }
.next strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
/* მთავარი ღილაკი — მწვანე, ქვედა „სისქით“ */
.share {
  background: var(--correct); color: #fff; border: 0; border-radius: 12px;
  padding: 13px 26px; font-weight: 800; font-size: 1.05rem; font-family: inherit; cursor: pointer;
  box-shadow: 0 4px 0 var(--correct-dark); transition: transform .1s, box-shadow .1s;
}
.share:hover { filter: brightness(1.04); }
.share:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--correct-dark); }
.noscript { text-align: center; }

/* --- სარეკლამო ადგილი ჰედერის ქვეშ: 728×90 კომპიუტერზე, 320×50 მობილურზე --- */
.ad-top { width: min(320px, calc(100% - 32px)); height: 50px; margin: 6px auto; }
.ad-top .ad-free { flex-direction: row; gap: 8px; padding: 6px 12px; border-radius: 8px; }
.ad-top .ad-free strong { white-space: nowrap; }
.ad-top .ad-free span { display: none; }
@media (min-width: 768px) {
  .ad-top { width: min(728px, calc(100% - 32px)); height: 90px; margin: 8px auto; }
  .ad-top .ad-free { flex-direction: column; gap: 4px; }
  .ad-top .ad-free span { display: inline; font-size: .78rem; }
}
.ad-top img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }

@media (max-height: 700px) {
  .key { height: 46px; }
  :root { --chrome-h: 410px; }
}
@media (prefers-reduced-motion: reduce) {
  .tile, .row, .key.ready { animation: none !important; }
}
@media (max-width: 380px) {
  .logo { font-size: 1.25rem; }
  .logo span { display: none; }
  .key.wide { font-size: .65rem; }
}

/* --- უკუკავშირი --- */
a.logo { color: inherit; text-decoration: none; }
a.icon-btn { text-decoration: none; }
.page { max-width: 680px; margin: 0 auto; padding: 16px 16px 8px; line-height: 1.7; }
.page h1 { font-size: 1.8rem; margin: .4rem 0; }
.crumbs { font-size: .85rem; color: var(--muted); }
.crumbs a, .footer a { color: inherit; }
.footer-nav { margin-bottom: 6px; }
.card { border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-top: 20px; background: var(--modal); }
.form { display: grid; gap: 16px; }
.grid2 { display: grid; gap: 16px; align-items: start; }
@media (min-width: 600px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.field { display: grid; gap: 6px; }
.field > span { font-weight: 700; font-size: .92rem; }
.field small { color: var(--muted); font-size: .78rem; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--tile-border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 1rem;
}
.field textarea { resize: vertical; }
.field :focus { outline: 2px solid var(--correct); outline-offset: 1px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.notice { margin: 0; padding: 10px 12px; border-radius: 8px; background: #fdecea; color: #8a1c13; font-size: .9rem; }
.form .share { justify-self: start; }
.form .share:disabled { opacity: .6; cursor: wait; }
.sent { text-align: center; }
.sent .check { width: 48px; height: 48px; margin: 0 auto 8px; border-radius: 50%; display: grid; place-items: center; background: var(--correct); color: #fff; font-size: 1.5rem; }
.sent h2 { margin: 0; font-size: 1.15rem; }
.btn-ghost { background: none; border: 1px solid var(--tile-border); color: var(--text); border-radius: 8px; padding: 10px 16px; font: inherit; cursor: pointer; margin-top: 8px; }
.small { font-size: .8rem; margin-top: 16px; }

/* --- სარეკლამო ადგილები გვერდებზე (მხოლოდ ფართო ეკრანზე) --- */
.ad-rail { display: none; }
@media (min-width: 1000px) {
  .ad-rail {
    display: block; position: absolute; top: 180px; z-index: 1;
    width: 160px; height: min(600px, calc(100svh - 110px));
  }
  .ad-left  { left:  max(16px, calc(50% - 250px - 160px - 56px)); }
  .ad-right { right: max(16px, calc(50% - 250px - 160px - 56px)); }
}
.ad-free {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 16px; text-align: center; text-decoration: none;
  border: 2px dashed var(--border); border-radius: 12px; color: var(--muted);
  transition: border-color .2s, color .2s, background .2s;
}
.ad-free strong { color: var(--text); font-size: .95rem; }
.ad-free span { font-size: .78rem; line-height: 1.5; }
.ad-free:hover { border-color: var(--correct); color: var(--text); background: color-mix(in srgb, var(--correct) 8%, transparent); }
.ad-rail img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }
.field select {
  appearance: none; -webkit-appearance: none;
  padding-right: 44px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23878a8c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center; background-size: 12px 8px;
}

/* --- სარეკლამო ადგილები მობილურზე: შედეგების ფანჯარაში და თამაშის ქვემოთ --- */
.ad-inline { display: block; width: 100%; max-width: 320px; height: 100px; margin: 20px auto 0; }
.ad-inline .ad-free { padding: 10px 14px; gap: 2px; }
.ad-inline img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }
.ad-below { margin: 8px auto 0; padding: 0 16px; max-width: 352px; }
@media (min-width: 1000px) { .ad-inline { display: none; } }
.modal { max-height: calc(100svh - 32px); overflow-y: auto; }
