/* =============================================================================
   Mini Games Library — Global Styles
   -----------------------------------------------------------------------------
   - Game-agnostic foundations first (theme, layout, utilities)
   - Game-specific sections appended below (TTT, Connect Four, Snake, Dots & Boxes, Checkers)
   - Mobile-accurate viewport sizing via --vh/--header-h/--footer-h
   ============================================================================= */

/* -----------------------------------------------------------------------------
   Root: Theme tokens (dark default) + dynamic viewport vars
   ----------------------------------------------------------------------------- */
:root {
  /* Core palette */
  --bg: #0b1220;
  --panel: #121a2b;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --primary: #60a5fa;
  --accent: #7c3aed;
  --ok: #34d399;
  --warn: #f59e0b;
  --danger: #ef4444;
  --focus: #f472b6;

  /* Focus ring (rgba) */
  --ring: 0 0 0 3px rgba(244, 114, 182, 0.45);

  /* Player colors shared by games */
  --player-red:   #ef4444; /* Tailwind Red-500 */
  --player-yellow:#f59e0b; /* Tailwind Yellow-400 */

  /* Dynamic viewport sizing (JS will set these precisely) */
  --vh: 1vh;       /* 1% of *visual* viewport height */
  --header-h: 0px; /* measured in JS */
  --footer-h: 0px; /* measured in JS */

  /* Header/control sizing (logo-driven, no wobble) */
  --brand-img-h: 3em;       /* ← change this to scale logo without shifts */
  --hdr-vpad: 16px;         /* header vertical padding total (8px top + 8px bottom) */
  --hdr-h: calc(var(--brand-img-h) + var(--hdr-vpad));
  --ctrl-h: 36px;           /* control row height (buttons/selects/theme) */
}

/* Light theme override */
[data-theme="light"] {
  --bg: #f7fafc;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --primary: #2563eb;
  --accent: #6d28d9;
  --ok: #059669;
  --warn: #b45309;
  --danger: #b91c1c;
  --focus: #7c3aed;
  --ring: 0 0 0 3px rgba(124, 58, 237, 0.35);
}

/* Respect system preference (unless user forced dark) */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f7fafc;
    --panel: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --primary: #2563eb;
    --accent: #6d28d9;
    --ok: #059669;
    --warn: #b45309;
    --danger: #b91c1c;
    --focus: #7c3aed;
    --ring: 0 0 0 3px rgba(124, 58, 237, 0.35);
  }
}

/* -----------------------------------------------------------------------------
   Base / Reset-ish
   ----------------------------------------------------------------------------- */
* { box-sizing: border-box; }

html, body { height: 100%; min-height: 100vh; }

body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell,
        "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  background:
    radial-gradient(1200px 800px at 20% -10%, rgba(124,58,237,.15), transparent 60%),
    radial-gradient(800px 600px at 100% 10%, rgba(96,165,250,.15), transparent 60%),
    var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Accessibility helpers */
.skip-link {
  position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden;
}
.skip-link:focus {
  position: static; width: auto; height: auto;
  padding: .5rem .75rem; background: var(--panel); border-radius: .5rem;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* -----------------------------------------------------------------------------
   App Header (standardised)
   ----------------------------------------------------------------------------- */
.app-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 8px clamp(1rem, 2vw, 2rem);
  margin-bottom: 1rem;
  min-block-size: var(--hdr-h);      /* constant, logo-driven height across pages */
  background: none;
  gap: .75rem;
}

/* Brand strip: logo / library name / divider / game title */
.brand {
  display: inline-flex;
  align-items: center;               /* keep everything on the same line */
  gap: .6em;
  min-height: var(--ctrl-h);         /* matches control row height */
}
.brand-mark {
  block-size: var(--brand-img-h);
  inline-size: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  display: inline-block;
  vertical-align: baseline;    /* not middle */
}
.brand-title {
  font-size: 1.24rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: .03em;
  line-height: 1.1;
}
.divider {
  font-size: 1.2rem;
  color: var(--muted);
  opacity: .5;
  margin: 0 .55em;
  font-weight: 600;
  user-select: none;
  line-height: 1.1;
}
.game-title {
  font-size: 1.13rem;
  font-weight: 700;
  color: var(--muted);
  margin: 0;
  line-height: 1.1;
}

/* Controls */
.controls {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  flex-wrap: wrap;
  margin: 0;                          /* remove vertical creep */
}

/* Controls: lock to a shared height */
.btn,
.theme-btn,
.custom-select { height: var(--ctrl-h); }

/* Buttons */
.btn {
  appearance: none;
  cursor: pointer;
  user-select: none;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(0,0,0,.08)), var(--panel);
  border: 1px solid rgba(255,255,255,.08);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  line-height: 1;
  padding: 0 .82rem;
  border-radius: .65rem;
  font-weight: 600;
  font-size: 1em;
  margin: 0;
  transition: background .12s, border-color .14s, color .14s;
}
.btn.primary {
  background: linear-gradient(180deg, rgba(37,99,235,.20), rgba(124,58,237,.15));
  border-color: rgba(124,58,237,.35);
}
.btn:hover,
.btn:focus-visible {
  border-color: rgba(124,58,237,.21);
  color: var(--accent);
  outline: none;
}
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Theme toggle: square, same height as other controls */
.theme-btn {
  background: none;
  border: none;
  box-shadow: none;
  width: var(--ctrl-h);
  padding: 0;
  font-size: 1.15rem;                 /* icon sizing */
  color: var(--text);
  border-radius: .55rem;
  transition: background .14s, color .14s;
  cursor: pointer;
}
.theme-btn:hover,
.theme-btn:focus-visible {
  background: rgba(124,58,237,0.11);
  color: var(--accent);
  outline: none;
}
.theme-btn:active { background: rgba(124,58,237,0.17); color: var(--accent); }

/* Small screens: stack header cleanly without changing heights */
@media (max-width: 650px) {
  .app-header {
    grid-template-columns: 1fr;
    gap: .4rem;
    padding: .75rem .6rem;
    margin-bottom: .8rem;
  }
  .controls { justify-content: flex-start; }
}

/* Branding link reset */
.brand-title a,
.brand-link {
  color: inherit;
  text-decoration: none;
  font: inherit;
}
.brand-title a:focus-visible,
.brand-link:focus-visible {
  box-shadow: 0 0 0 3px var(--focus, #7c3aed);
  background: rgba(124,58,237,0.09);
}
.brand-title a:hover,
.brand-link:hover {
  text-decoration: none;
  color: var(--accent);
}
/* The link also needs baseline alignment for its children (img + title) */
.brand-link {
  display: inline-flex;
  align-items: baseline;       /* makes img + title share a baseline */
  gap: .6em;
  line-height: 1;              /* kill stray line-box slack */
}



/* Text pieces use the same line-height so their baselines match exactly */
.brand-title,
.game-title,
.divider {
  display: inline-block;
  line-height: 1;
}
/* --- Optical alignment for brand row -------------------------------------- */
:root{
  --brand-title-y: 0.04em;   /* lower the big title very slightly */
  --crumb-y:       0.02em;   /* lower divider + game title a touch */
}

/* center by boxes (not baselines) to ignore icon’s transparent padding */
.brand,
.brand-link{
  display:inline-flex;
  align-items:center;     /* was baseline in your file */
  gap:.6em;
  line-height:1;
}

.brand-mark{
  display:block;          /* no inline baseline box */
  block-size:var(--brand-img-h);
  inline-size:auto;
  aspect-ratio:1/1;
  object-fit:contain;
}

/* micro nudges: purely visual, don’t affect layout height or wrap */
.brand-title{ transform: translateY(var(--brand-title-y)); }
.divider,
.game-title{ transform: translateY(var(--crumb-y)); }


/* -----------------------------------------------------------------------------
   Native Select wrapper (kept for consistency with other pages)
   ----------------------------------------------------------------------------- */
.select-wrap {
  display: inline-flex; align-items: center;
  background: var(--panel); border: 1px solid rgba(255,255,255,.10);
  border-radius: .65rem; padding: .2em .85em .2em .5em;
  position: relative;
  min-width: 110px; font-size: 1em; margin-right: 0.2em;
}
.select-wrap select {
  appearance: none; background: transparent; color: var(--text);
  border: none; padding: .38em 1.7em .38em .2em;
  font-weight: 600; font-size: 1em; outline: none; min-width: 72px; cursor: pointer;
}
.select-wrap select:focus { outline: none; box-shadow: var(--ring); border-radius: .55rem; }
.select-wrap::after {
  content: '';
  pointer-events: none;
  position: absolute; right: .68em; top: 50%;
  width: 0.66em; height: 0.39em;
  border: solid var(--muted); border-width: 0 0 2.5px 2.5px; border-radius: .14em;
  transform: translateY(-45%) rotate(-45deg); opacity: 0.78;
}
.select-wrap select:disabled { opacity: 0.55; cursor: not-allowed; }

/* -----------------------------------------------------------------------------
   Hub layout (landing page)
   ----------------------------------------------------------------------------- */
   
.layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1rem;
  padding: 0 clamp(1rem, 2vw, 2rem) 2rem;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }
.board-wrap { display: grid; gap: .75rem; align-content: start; }

.status { text-align: center; padding: .5rem; font-weight: 700; color: var(--muted); }
.hub-icon img { display: block; width: 100%; height: auto; border-radius: 0.9rem; }

.sidebar { display: grid; gap: 1rem; align-content: start; }
.card {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 1rem;
  padding: 1rem;
  margin-bottom: 1em;
}
.card h3 { margin: 0 0 .5rem; font-size: 1.05rem; }

.score { display: grid; gap: .4rem; }
.score dt { color: var(--muted); }
.score dd { margin: 0; font-weight: 800; }

/* Footer */
.app-footer {
  background: var(--panel);
  color: var(--muted);
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 1rem;
  text-align: center;
  margin-top: auto;
  padding: 1.1rem 0.8rem 1.2rem;
  box-shadow: 0 -2px 12px rgba(24,32,56,.06);
}
.footer-meta { font-size: 0.97em; color: var(--muted); letter-spacing: .01em; }
.footer-meta a { color: var(--accent); text-decoration: underline; font-weight: 500; }
.footer-meta a:hover,
.footer-meta a:focus { color: var(--primary); text-decoration: underline; outline: none; }

/* Keyboard hint */
.kbd, kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  border-bottom-width: 2px;
  border-radius: .4rem;
  padding: .1rem .35rem;
  font-size: .875em;
}
.about-card {
  display: flex;
  padding: 1.5rem;
  border-left: 4px solid var(--accent);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.05)), var(--panel);
  border-radius: 1rem;
  margin-bottom: 0rem;
}

.about-content {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
  align-items: center;
}

.about-text h3 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.75rem;
}

.features-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem 1.5rem;
  margin: 1rem 0;
  padding: 0;
  list-style: none;
}
.features-list li {
  font-weight: 600;
  color: var(--text);
}

.about-img {
  max-width: 160px;
  width: 100%;
  height: auto;
  opacity: 0.9;
}

/* -----------------------------------------------------------------------------
   Hub-specific blocks
   ----------------------------------------------------------------------------- */
.hub-layout { grid-template-columns: 1fr 320px; }
.hub-section { display: grid; align-content: start; gap: 1rem; }
.hub-search input {
  appearance: none; background: var(--panel); border: 1px solid rgba(255,255,255,.08);
  border-radius: .65rem; padding: .55rem .8rem; color: var(--text); font-weight: 600; min-width: 14ch;
}
.hub-grid {
  --card-min: 260px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr));
  gap: 1rem; padding: 0; margin: 0; list-style: none;
}
.hub-card {
  display: grid; gap: .8rem;
  background: var(--panel); border: 1px solid rgba(255,255,255,.08);
  border-radius: 1rem; padding: 1rem;
}
.hub-card.coming { opacity: .7; }
.hub-card-body { display: grid; grid-template-columns: 72px 1fr; gap: .8rem; align-items: center; }
.hub-icon {
  display: grid; place-items: center; width: 72px; height: 72px;
  border-radius: .9rem; font-size: 1.25rem; font-weight: 900;
  background:
    radial-gradient(200px 160px at 20% -20%, rgba(124,58,237,.24), transparent 55%),
    radial-gradient(200px 160px at 120% 20%, rgba(96,165,250,.22), transparent 55%),
    var(--panel);
  border: 1px solid rgba(255,255,255,.08);
}
.hub-title { margin: 0 0 .35rem; font-size: 1.05rem; }
.hub-meta {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 1rem .8rem;
}
.hub-meta dt { color: var(--muted); font-weight: 600; }
.hub-meta dd { margin: 0; font-weight: 800; }
.hub-actions { display: flex; gap: .5rem; }
.hub-list { margin: .25rem 0 0; padding-left: 1.1rem; }

/* --- Hangman: custom stacked meta layout (hub card) --- */
.hub-meta.hangman-meta {
  display: grid;
  grid-template-columns: auto 1fr;   /* labels left, numbers right */
  grid-auto-rows: min-content;
  gap: .35rem .8rem;
  align-items: center;
}
.hub-meta.hangman-meta > div { display: contents; }
.hub-meta.hangman-meta dt {
  grid-column: 1;
  color: var(--muted);
  font-weight: 600;
}
.hub-meta.hangman-meta dd {
  grid-column: 2;
  margin: 0;
  font-weight: 800;
  text-align: right;
}
/* "Last" row spans both columns but aligns right */
.hub-meta.hangman-meta .last-row {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  margin-top: .2rem;
}
.hub-meta.hangman-meta .last-row dt {
  order: 0;
  font-weight: 600;
  color: var(--muted);
}
.hub-meta.hangman-meta .last-row dd {
  order: 1;
  font-weight: 800;
  text-align: right;
}

/* -----------------------------------------------------------------------------
   Privacy & Legal page
   ----------------------------------------------------------------------------- */
.legal-layout { max-width: 120ch; margin-inline: auto; padding-top: 2rem; }
.legal-layout h2 {
  font-size: 1.6rem; font-weight: 900; margin-bottom: 1rem;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.legal-layout .card {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.05)), var(--panel);
  border-left: 4px solid var(--accent);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  padding: 1.25rem; border-radius: 0.8rem; line-height: 1.65;
}
.legal-layout .card + .card { margin-top: 1.5rem; }
.legal-layout h3 { font-size: 1.1rem; color: var(--primary); margin-bottom: 0.5rem; }
.legal-layout ul { margin: 0.5rem 0 1rem 1.25rem; padding: 0; list-style: disc; }
.legal-layout li { margin-bottom: 0.3rem; }
body.legal-page {
  background:
    radial-gradient(1600px 800px at 50% 0%, rgba(124,58,237,.12), transparent 70%) no-repeat,
    radial-gradient(1000px 700px at 100% 10%, rgba(96,165,250,.1), transparent 60%) no-repeat,
    var(--bg);
  background-repeat: no-repeat; background-attachment: fixed; background-size: cover;
}

/* =============================================================================
   Shared Game Layout (applies to all games)
   - Accurate height via 100dvh + --vh fallback
   ============================================================================= */
.game-layout {
  display: grid;
  grid-template-columns: minmax(200px, 320px) 1fr;
  gap: 2.5rem;
  align-items: start;
  max-width: 1120px;
  margin: 0 auto 2rem;
  padding: 0 1.2rem;
  /* min-block-size: calc(100dvh - var(--header-h) - var(--footer-h)); */
}
@supports not (height: 1dvh) {
  .game-layout {
    min-block-size: calc((var(--vh) * 100) - var(--header-h) - var(--footer-h));
  }
}
.game-sidebar { position: sticky; top: 1.6rem; min-width: 200px; max-width: 320px; }
.game-main { max-width: 600px; width: 100%; margin: 0 auto; }

@media (max-width: 820px) {
  .game-layout { display: block; max-width: none; gap: 0; padding: 0 .5rem; }
  .game-sidebar { position: static; min-width: 0; max-width: none; margin: 1.5em 0 0 0; }
  .game-main { max-width: 98vw; }
}

.game-header { background: none; display: flex; flex-direction: column; align-items: center; padding: 1.1rem 0 .5rem; gap: .35rem; }
.brand-row { display: flex; align-items: center; gap: .8rem; margin-bottom: .3em; }
.game-title { font-size: 1.4rem; font-weight: 700; letter-spacing: .015em; }

.settings-row { display: flex; gap: .5em; flex-wrap: wrap; justify-content: center; margin-bottom: .4em; }
@media (max-width: 520px) { .settings-row { flex-direction: column; gap: .4em; width: 100%; } }

.status-bar {
  font-size: 1.15rem;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  color: #fff;
  border-radius: .7rem;
  padding: .7em 1.2em;
  margin: 0 0 1.2rem 0;
  box-shadow: 0 2px 8px rgba(124,58,237,0.14);
  text-align: center; letter-spacing: .02em;
}
.actions-bar { display: flex; gap: .55em; flex-wrap: wrap; justify-content: center; margin-bottom: 1.2em; }
@media (max-width:520px) { .actions-bar { flex-direction: column; align-items: stretch; gap: .5em; margin-bottom: .8em; } }

/* =============================================================================
   Custom Select (shared)
   - Rotating chevron only on the trigger
   - No styling on option items beyond your palette
   ============================================================================= */
.custom-select {
  position: relative;
  display: inline-block;
  font-size: 1rem;
  font-weight: 600;
  min-width: 140px;
  max-width: 100%;
  user-select: none;
  cursor: pointer;
  z-index: 10;
  color: var(--text);
}
.custom-select-selected {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  height: var(--ctrl-h);
  width: 100%;
  padding: 0 1em;
  border-radius: .4em;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: background .2s ease, border .2s ease;
  position: relative; /* for arrow */
}
.custom-select-selected:hover,
.custom-select-selected:focus { background: rgba(255, 255, 255, 0.05); outline: none; }

/* Rotate-only arrow on the trigger */
.custom-select-selected::after {
  content: "⯆";
  position: absolute; right: .75em; top: 50%;
  transform: translateY(-50%) rotate(0deg);
  transition: transform .25s ease;
  pointer-events: none;
  font-size: .85em; color: var(--muted);
}
.custom-select-selected[aria-expanded="true"]::after {
  transform: translateY(-50%) rotate(180deg);
}

.custom-select-options {
  position: absolute; top: calc(100% + .25em); left: 0; width: 100%;
  margin-top: 0; padding: .25em 0;
  border-radius: .4em; background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 6px 12px rgba(0,0,0,.25);
  z-index: 100; font-size: 1rem;
}
.custom-select-options[hidden] { display: none; }
.custom-select-options li {
  padding: .45em 1em;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
  list-style: none; /* scoped reset */
}
.custom-select-options li:hover,
.custom-select-options li:focus {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  outline: none;
}
.custom-select-options li[aria-selected="true"] {
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
}




/* ============================================================================
   Responsive hardening (320px → desktop)
   - Prevent overflows
   - Compact controls on small screens
   - Stack "About" card cleanly
   - Make hub grid adapt without gaps
   ============================================================================ */

/* 1) Generic guards: prevent mystery overflows */
html, body { overflow-x: hidden; }

img, svg, video, canvas {
  max-inline-size: 100%;
  block-size: auto;
  display: block;
}

*,
*::before,
*::after { min-inline-size: 0; } /* allow flex/grid children to shrink */

/* Long words / URLs don’t push layouts off-screen */
.hub-card, .card, .about-card, .brand, .controls {
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

/* 2) Header: shrink & wrap sanely on small screens */
.app-header {
  grid-template-columns: 1fr auto;
  gap: .75rem 1rem;
}

.brand { flex-wrap: wrap; }
.brand .brand-title,
.brand .game-title {
  /* Allow wrapping on tiny viewports */
  white-space: normal;
}

/* Controls can wrap to multiple lines without pushing width */
.controls {
  flex-wrap: wrap;
  gap: .45rem .55rem;
  justify-content: flex-end;
}
.controls > * {
  flex: 0 1 auto;        /* allow shrinking */
  min-inline-size: 0;    /* no min-content overflow */
}

/* Buttons & theme toggle compress gracefully at 320–360px */
.btn {
  padding-inline: .7rem;
  font-size: clamp(.9rem, 2.6vw, 1rem);
  height: var(--ctrl-h);
}
.theme-btn { width: var(--ctrl-h); }

/* 3) Selects: allow shrinking + scrolling menu on phones */
.select-wrap { min-width: 0; }
.custom-select { min-width: 0; max-width: 100%; }
.custom-select-selected { padding-inline: .75em 2.25em; }
.custom-select-options {
  max-height: 240px;
  overflow: auto;
  overscroll-behavior: contain;
}

/* 4) About card: two columns on desktop → stack on mobile */
.about-card { padding: clamp(1rem, 3vw, 1.5rem); }

.about-content {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: clamp(1rem, 3vw, 2rem);
  align-items: center;
}

.about-text { min-width: 0; }
.about-side { min-width: 0; justify-self: end; }

@media (max-width: 900px) {
  .about-content {
    grid-template-columns: 1fr; /* stack */
  }
  .about-side { justify-self: start; }
  .about-img { max-width: 200px; }
}

@media (max-width: 480px) {
  .features-list {
    grid-template-columns: 1fr; /* one-per-line on very small screens */
  }
  .about-img { max-width: 160px; }
}

/* 5) Hub layout: keep same outer width, make grid adaptive inside */
.layout {
  /* Existing structure kept; just safe padding on tiny screens */
  padding-inline: clamp(.75rem, 3vw, 2rem);
}

.hub-grid {
  /* Make cards adapt to narrow phones without overflow gaps */
  --card-min: clamp(200px, 46vw, 280px);
  grid-auto-rows: 1fr;
}

/* Ensure hub cards don't get squished by long text */
.hub-card { min-width: 0; }

/* 6) Sidebar: no overflow on small viewports */
.sidebar { min-width: 0; }

/* 7) Game layout: avoid horizontal scroll at small widths */
.game-layout {
  gap: clamp(1rem, 3vw, 2.5rem);
  padding-inline: clamp(.5rem, 2vw, 1.2rem);
}

@media (max-width: 820px) {
  .game-layout { display: block; }
  .game-sidebar, .game-main { max-width: 100%; }
}

/* 8) Tiny baseline tweaks to keep brand row visually level */
:root{
  --brand-title-y: 0.03em;
  --crumb-y:       0.02em;
}
.brand-title{ transform: translateY(var(--brand-title-y)); }
.divider, .game-title{ transform: translateY(var(--crumb-y)); }

/* 9) Motion-respectful UI (optional but nice) */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
/* Orientation overlay base */
.orientation-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* respect [hidden] attribute */
.orientation-overlay[hidden] { display: none !important; }

.orientation-box {
  background: var(--panel);
  color: var(--text);
  padding: 1.25rem 1.5rem;
  border-radius: 1rem;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 6px 16px rgba(0,0,0,.4);
}

/* Restrict to mobile/tablet only */
@media (min-width: 1025px) {
  #orientationOverlay { display: none !important; }
}

/* =============================================================================
   End of file
   ============================================================================= */
