/* Orðheimar game pages (shared by all the games): header image + intro (one screen together), the game
   section (at least one screen), live total, leaderboard, more games, footer.
   Each game adds its own stylesheet (ord-a-moti-ordi/game.css, ../daily.css + grind/grid.css, samhengi/samhengi.css). */
:root {
  --navy: #003449;
  --teal: #58d6dc;
  --yellow: #ffc452;
  --coral: #ff734d;
  --green: #00d984;
  --line: #e6e6e6;
  --wrap: min(1152px, calc(100vw - 48px));
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { overflow-x: clip; }
body {
  margin: 0;
  background: #fff;
  color: var(--navy);
  font-family: "Geograph", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Header image: top half of the first screen (wide image; square one on phones) ---------- */
.g-hero { position: relative; height: 50vh; height: 50svh; min-height: 260px; background: var(--navy); overflow: hidden; }
.g-hero picture, .g-hero img { position: absolute; inset: 0; width: 100%; height: 100%; }
.g-hero img { object-fit: cover; }
.g-hero::before { content: ""; position: absolute; inset: 0 0 auto; z-index: 1; height: 140px; background: linear-gradient(rgba(0,52,73,.55), rgba(0,52,73,0)); pointer-events: none; }
.g-nav { position: absolute; z-index: 2; top: 40px; left: 50%; transform: translateX(-50%); display: flex; gap: 40px; color: #fff; font-size: 15px; font-weight: 500; white-space: nowrap; }
.g-nav a:first-child { font-weight: 700; }
.g-nav a:hover { text-decoration: underline; text-underline-offset: 4px; }

/* ---------- Intro: bottom half of the first screen. Text centred on top, the three guide pictures centred below ---------- */
.g-intro { min-height: 50vh; min-height: 50svh; display: flex; align-items: center; padding: 56px 0; }
.g-intro-in { width: var(--wrap); margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 56px; }
.g-lead { flex: none; max-width: 468px; margin: 0; font-size: 18px; line-height: 1.6; text-align: center; text-wrap: pretty; }
.g-steps { flex: 0 0 auto; list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 175px); gap: 20px; }
.g-steps li { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.g-step-art { width: 96px; height: 96px; display: flex; align-items: center; justify-content: center; }
.g-step-art svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.g-step-label { font-size: 13px; font-weight: 700; line-height: 1.35; text-wrap: balance; }

/* ---------- Guide motion: while the steps are on screen, step 1, 2, 3 play in turn, hold, reset, repeat
   (page.js adds .is-anim to the list and .play to each step). Without JS or with reduced motion the
   drawings simply show their finished state. */
.g-steps.is-anim svg * { transform-box: fill-box; transform-origin: center; }
/* Orð á móti orði: cards flip from grey back to face; the pair pops; stars pop in a wave */
.g-steps.is-anim .b { transform: scaleX(1); }
.g-steps.is-anim .f { transform: scaleX(0); }
.g-steps.is-anim .play .b { animation: g-flip-out .2s ease-in var(--d) both; }
.g-steps.is-anim .play .f { animation: g-flip-in .2s ease-out calc(var(--d) + .2s) both; }
.g-steps.is-anim li:nth-child(2).play .f { animation: g-flip-in .2s ease-out calc(var(--d) + .2s) both, g-pop .4s ease 1s; }
.g-steps.is-anim .st { transform: scale(0); }
.g-steps.is-anim .play .st { animation: g-star .38s cubic-bezier(.3, 1.5, .5, 1) var(--d) both; }
@keyframes g-flip-out { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes g-flip-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes g-pop { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.14); } }
@keyframes g-star { from { transform: scale(0); } to { transform: scale(1); } }
/* Orðasúpa: the trace draws itself and the cells light up as it reaches them; finished letters empty out */
.g-steps.is-anim .ln { stroke-dasharray: 1; stroke-dashoffset: 1; }
.g-steps.is-anim .play .ln { animation: g-draw .84s linear both; }
.g-steps.is-anim li:nth-child(2).play .ln { animation-duration: 1.1s; }
.g-steps.is-anim .y, .g-steps.is-anim .g { fill: rgba(0, 0, 0, .1); stroke-opacity: 0; }
.g-steps.is-anim .play .y { animation: g-fill-y .16s ease-out var(--d) both; }
.g-steps.is-anim .play .g { animation: g-fill-g .16s ease-out var(--d) both; }
.g-steps.is-anim .v { fill: #e5e5e5; }
.g-steps.is-anim .play .v { animation: g-empty .3s ease-in var(--d) both; }
@keyframes g-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes g-fill-y { from { fill: rgba(0, 0, 0, .1); stroke-opacity: 0; } to { fill: #ffc452; stroke-opacity: 1; } }
@keyframes g-fill-g { from { fill: rgba(0, 0, 0, .1); stroke-opacity: 0; } to { fill: #00d984; stroke-opacity: 1; } }
@keyframes g-empty { from { fill: #e5e5e5; } to { fill: rgba(229, 229, 229, 0); } }
/* Orðspor: the guess types itself; the needle swings to green as the bar fills; #1 pops up */
.g-steps.is-anim .cv { transform-origin: 100% 50%; transform: scaleX(1); }
.g-steps.is-anim .cur { transform: translateX(-55px); }
.g-steps.is-anim .play .cv { animation: g-type .9s both; }
.g-steps.is-anim .play .cur { animation: g-caret .9s both, g-blink .9s step-end .9s 2; }
@keyframes g-type { 0% { transform: scaleX(1); } 22% { transform: scaleX(.63); } 44% { transform: scaleX(.514); } 66% { transform: scaleX(.265); } 88%, 100% { transform: scaleX(0); } }
@keyframes g-caret { 0% { transform: translateX(-55px); } 22% { transform: translateX(-35px); } 44% { transform: translateX(-28.8px); } 66% { transform: translateX(-15.8px); } 88%, 100% { transform: translateX(0); } }
.g-steps.is-anim .play .cv, .g-steps.is-anim .play .cur { animation-timing-function: step-end; }
@keyframes g-blink { 50% { opacity: 0; } }
.g-steps.is-anim .nd { transform-box: view-box; transform-origin: 48px 54px; transform: rotate(-95deg); }
.g-steps.is-anim .play .nd { animation: g-needle 1.1s cubic-bezier(.4, 0, .3, 1) both; }
@keyframes g-needle { 0% { transform: rotate(-95deg); } 72% { transform: rotate(9deg); } 88% { transform: rotate(-3deg); } 100% { transform: rotate(0); } }
.g-steps.is-anim .bar { transform-origin: 0 50%; transform: scaleX(0); }
.g-steps.is-anim .play .bar { animation: g-bar .8s cubic-bezier(.4, 0, .3, 1) both; }
.g-steps.is-anim li:nth-child(2).play .bar { animation: g-bar 1s cubic-bezier(.4, 0, .3, 1) both, g-heat 1s linear both; }
@keyframes g-bar { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes g-heat { 0% { fill: #ff734d; } 50% { fill: #ffc452; } 100% { fill: #00d984; } }
.g-steps.is-anim .pop { transform: scale(0); }
.g-steps.is-anim .play .pop { animation: g-star .45s cubic-bezier(.3, 1.5, .5, 1) .45s both; }

/* ---------- The game: navy, at least one full screen ---------- */
.g-play { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 96px 24px; background: var(--navy); color: #fff; }
.g-play > .leaders { width: 100%; }

/* ---------- More games ---------- */
.g-more { padding: 120px 24px; }
.g-tiles { width: min(760px, 100%); margin: 0 auto; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.g-tile { display: block; overflow: hidden; border-radius: 8px; transition: transform .25s ease, box-shadow .25s ease; }
.g-tile img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; }
a.g-tile:hover { transform: translateY(-4px); box-shadow: 0 14px 30px rgba(0,52,73,.18); }
a.g-tile:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; }
.g-tile.is-soon { aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; background: var(--yellow); text-align: center; font-size: clamp(16px, 2.2vw, 24px); font-weight: 500; line-height: 1.2; }

/* ---------- Footer ---------- */
.g-footer { width: var(--wrap); margin: 0 auto; padding: 56px 0; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: flex-end; /* logo only, on the right */ gap: 24px; flex-wrap: wrap; }
.g-footer .logo svg { display: block; width: 134px; height: auto; }
.g-footer nav { display: flex; flex-wrap: wrap; gap: 16px 40px; font-size: 14px; font-weight: 500; }
.g-footer nav a:hover { color: #2a8f95; }
.g-footer nav a[aria-current] { color: #2a8f95; }

@media (max-width: 900px) {
  .g-intro-in { gap: 40px; }
  .g-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
}
@media (max-width: 700px) {
  .g-hero { height: auto; aspect-ratio: 1; min-height: 0; max-height: 70svh; }
  .g-nav { top: 24px; left: 24px; transform: none; gap: 28px; font-size: 14px; }
  .g-intro { min-height: 0; padding: 48px 0 56px; }
  .g-lead { font-size: 16px; }
  .g-step-art { width: 72px; height: 72px; }
  .g-step-label { font-size: 12px; }
  .g-play { min-height: 0; padding: 56px 16px 72px; }
  .g-more { padding: 72px 24px; }
  .g-tiles { gap: 12px; }
  .g-footer { padding: 40px 0; }
  .g-footer nav { gap: 12px 24px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { .g-tile { transition: none; } }

/* ---------- Live total under the board ---------- */
.live { margin: 56px auto 0; display: flex; align-items: center; justify-content: center; gap: 12px; color: rgba(255,255,255,.75); font-size: 15px; text-align: center; text-wrap: balance; }
.live[hidden] { display: none; }
.live b { color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; }
.live b.bump { animation: live-bump .5s ease; }
.live-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(0,217,132,.6); animation: live-pulse 2s ease-out infinite; }
@keyframes live-pulse { 70% { box-shadow: 0 0 0 9px rgba(0,217,132,0); } 100% { box-shadow: 0 0 0 0 rgba(0,217,132,0); } }
@keyframes live-bump { 40% { color: var(--yellow); } }
@media (prefers-reduced-motion: reduce) { .live-dot, .live b.bump { animation: none; } }
@media (max-width: 640px) { .live { margin-top: 40px; font-size: 13px; align-items: flex-start; } .live-dot { margin-top: 5px; } }

/* ---------- Leaderboard (today's top 10) ---------- */
.leaders { margin: 96px auto 0; max-width: 440px; }
.leaders[hidden] { display: none; }
.leaders-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding-bottom: 12px; border-bottom: 1px solid rgba(255,255,255,.14); }
.leaders h3 { margin: 0; color: #fff; font-size: 18px; font-weight: 700; }
.leaders-col { color: rgba(255,255,255,.6); font-size: 12px; letter-spacing: .08em; }
.leaders-list { list-style: none; margin: 0; padding: 0; }
.leaders-list li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 9px 0; border-bottom: 1px solid rgba(255,255,255,.08); font-size: 15px; }
.lb-rank { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.1); font-size: 12px; font-weight: 700; }
.leaders-list li:nth-child(-n+3) .lb-rank { background: var(--yellow); color: var(--navy); }
.lb-name { overflow-wrap: anywhere; } /* long names wrap onto a second line instead of being cut */
.lb-moves { font-weight: 700; font-variant-numeric: tabular-nums; }
.leaders-list li.is-mine .lb-name { color: var(--teal); font-weight: 700; }
.leaders-empty { margin: 14px 0 0; color: rgba(255,255,255,.65); font-size: 14px; }
.leaders-empty[hidden], .leaders-list[hidden] { display: none; }

/* Name form in the win dialog (white background) */
.lb-form { margin: 18px 0 6px; padding: 16px; background: none; border-left: 4px solid #00d984; } /* green bar on the left (Figma) */
.lb-form .lb-form-title { margin: 0 0 10px; color: var(--navy); font-size: 15px; font-weight: 700; }
.lb-form-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } /* for screen readers; the field shows a placeholder */
.lb-form input::placeholder { color: #5a5a5a; opacity: 1; }
.lb-form-row { display: flex; gap: 8px; }
.lb-form input { flex: 1 1 0; width: 0; min-width: 0; height: 42px; padding: 0 12px; border: 1px solid rgba(0,52,73,.3); border-radius: 0; background: #fff; color: var(--navy); font: inherit; font-size: 16px; }
.lb-form input:focus { outline: 2px solid var(--teal); outline-offset: 0; border-color: var(--navy); }
.lb-form button { height: 42px; padding: 0 18px; border: 0; background: var(--navy); color: #fff; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.lb-form button:hover { background: #0a4a63; }
.lb-form button:disabled { opacity: .5; cursor: progress; }
.lb-form .lb-form-msg { margin: 8px 0 0; color: #bf563a; font-size: 13px; font-weight: 500; }
.lb-form .lb-form-msg:empty { display: none; }
.mg-dialog .lb-near, .og-dialog .lb-near { margin: 14px 0 0; font-size: 15px; font-weight: 500; color: var(--navy); } /* "Þú varst 12 sekúndum frá topplista dagsins." */
.mg-dialog .lb-form-done, .og-dialog .lb-form-done { margin: 16px 0 6px; padding: 12px 14px; background: #d1f8e9; color: var(--navy); font-size: 14px; font-weight: 700; }


/* ---------- Share card in the win dialogs: click it to get a link that unfurls into the card in chats ---------- */
.share-card { border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.share-card img { transition: transform .2s ease, box-shadow .2s ease; }
@media (hover: hover) { .share-card:hover img { transform: translateY(-4px) rotate(-1deg); box-shadow: 0 12px 28px rgba(0,0,0,.25); } }
.share-card:active img { transform: scale(.98); }
.share-card:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; }
.share-hint { margin: 0; color: var(--navy); font-size: 13px; font-weight: 700; text-align: center; }
.share-status { margin: -6px 0 0; min-height: 1.3em; color: #2a8f95; font-size: 13px; line-height: 1.4; text-align: center; overflow-wrap: anywhere; }
.share-status a { color: inherit; font-weight: 700; }
.share-again { margin-top: -6px; padding: 0; border: 0; background: none; color: var(--navy); font: inherit; font-size: 13px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
@media (prefers-reduced-motion: reduce) { .share-card img { transition: none; } }

/* ---------- Share card stack in the win dialogs (as in the Gluggar sketch): no frame, arrow + hint below ---------- */
.mg-preview-frame[data-format="stack"], .og-preview-frame[data-format="stack"],
.og-win .og-preview-frame[data-format="stack"] { width: 276px; max-width: 100%; height: auto; aspect-ratio: 1560 / 1760; background: none; }
.mg-preview-frame[data-format="stack"] img, .og-preview-frame[data-format="stack"] img,
.og-win .og-preview-frame[data-format="stack"] img { width: 100%; height: auto; max-width: none; max-height: none; box-shadow: none; }
@media (hover: hover) { .share-card[data-format="stack"]:hover img { transform: translateY(-4px) rotate(-1deg); box-shadow: none; filter: drop-shadow(0 8px 10px rgba(0,0,0,.12)); } }
.share-card[data-format="stack"] img { transition: transform .2s ease, filter .2s ease; }
.share-hint:has(.share-arrow), .mg-dialog .share-hint, .og-dialog .share-hint { position: relative; width: 116px; margin: -4px 0 0; color: var(--navy); font-size: 12.8px; font-weight: 700; line-height: 1.2; }
.share-arrow { position: absolute; left: calc(100% - 6px); bottom: 6px; width: 84px; height: 103px; transform: rotate(-25.4deg); transform-origin: 50% 50%; color: var(--navy); pointer-events: none; }

/* ---------- Win dialogs: one column, the card stack first and big, everything else below ---------- */
.mg-overlay, .og-overlay { align-items: flex-start; }
.mg-dialog, .og-dialog { margin: auto 0; }                       /* centred when it fits, scrolls when it doesn't */
.mg-overlay .mg-dialog, .og-overlay .og-dialog.og-win { width: min(520px, 100%); max-width: 520px; grid-template-columns: minmax(0, 1fr); gap: 0; padding: 28px 48px 40px; justify-items: center; text-align: center; }
.mg-overlay .mg-dialog .mg-preview, .og-overlay .og-win .og-preview { width: 100%; gap: 6px; }
.mg-overlay .mg-preview-frame[data-format="stack"], .og-overlay .og-preview-frame[data-format="stack"] { width: 400px; height: auto; }
/* arrow + hint scaled with the bigger stack (front card ≈ 246 px wide vs 192 in the sketch) */
.mg-overlay .share-hint, .og-overlay .share-hint { width: 150px; margin-top: -10px; font-size: 15px; }
.mg-overlay .share-arrow, .og-overlay .share-arrow { left: calc(100% - 8px); bottom: 8px; width: 108px; height: 132px; }
.mg-dialog .share-status, .og-dialog .share-status { margin: 2px 0 0; font-size: 13px; font-weight: 500; }
.mg-overlay .mg-dialog .mg-body, .og-overlay .og-win .og-body { width: 100%; margin-top: 18px; padding-top: 22px; border-top: 1px solid #e6e9ea; }
.mg-overlay .mg-dialog h2, .og-overlay .og-win h2 { margin: 0 0 8px; font-size: 2rem; }
.mg-dialog .lb-form, .og-dialog .lb-form { text-align: left; }
.mg-dialog .mg-again, .og-win .og-again { margin-top: 16px; }
@media (max-width: 760px) {
  .mg-overlay .mg-dialog, .og-overlay .og-dialog.og-win { padding: 22px 20px 28px; }
  .mg-overlay .mg-preview-frame[data-format="stack"], .og-overlay .og-preview-frame[data-format="stack"] { width: min(330px, 100%); }
  .mg-overlay .share-hint, .og-overlay .share-hint { width: 124px; margin-top: -6px; font-size: 13px; }
  .mg-overlay .share-arrow, .og-overlay .share-arrow { left: calc(100% - 7px); bottom: 7px; width: 89px; height: 109px; }
  .mg-overlay .mg-dialog h2, .og-overlay .og-win h2 { font-size: 1.75rem; }
}

/* "Spila næstu gátu" (daily games): navy button, with "Eldri gátur" beside it */
.og-win-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 24px; margin-top: 20px; }
.og-next { display: inline-flex; align-items: center; gap: 10px; height: 46px; padding: 0 22px; border: 0; background: var(--navy); color: #fff; font: inherit; font-size: 15px; font-weight: 700; cursor: pointer; }
.og-next:hover { background: #0a4a63; }
.og-next:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; }
.og-next svg { width: 14px; height: 14px; flex: none; transition: transform .2s ease; }
.og-next:hover svg { transform: translateX(3px); }
.og-overlay .og-win .og-win-actions .og-again { margin-top: 0; }
@media (prefers-reduced-motion: reduce) { .og-next svg { transition: none; } }

/* Top list heading: which board it is for (memory game: 9 pör / 6 pör on phones) */
.leaders-sub { font-weight: 400; opacity: .7; }

/* New arrow (Figma, Nov 2026): drawn as it sits, no rotation; tail ends just right of the hint text */
.mg-overlay .share-arrow, .og-overlay .share-arrow, .share-arrow { left: calc(100% + 2px); bottom: 17px; width: 104px; height: 130px; transform: none; }
.share-hint.is-done { color: #2a8f95; }
.mg-overlay .share-status:empty, .og-overlay .share-status:empty { display: none; }
@media (max-width: 760px) {
  .mg-overlay .share-arrow, .og-overlay .share-arrow { left: calc(100% + 2px); bottom: 14px; width: 86px; height: 107px; }
}
