/* styles.css — base reset + themed shell shared by every game.
   All colors/images come from CSS variables set by engine/theme.js.
   Layout reflows by orientation via the .is-portrait / .is-landscape classes
   set on <html> by engine/responsive.js. */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* sensible fallbacks until a theme is applied */
  --c-primary: #1f7a6f; --c-primary-dark: #0f4d46; --c-secondary: #f4a259;
  --c-accent: #ffd23f; --c-bg: #eef3f2; --c-surface: #fff; --c-playfield: #13635a;
  --c-text: #15302c; --c-text-muted: #5b746f; --c-text-on-primary: #fff;
  --c-success: #34c759; --c-danger: #e63946;
  --font-heading: system-ui, sans-serif; --font-body: system-ui, sans-serif;
  --img-bg-portrait: none; --img-bg-landscape: none; --img-logo: none;
  --img-card-back: none; --img-frame: none; --img-score: none; --img-timer: none;
  --vh: 100vh;
  --gap: clamp(6px, 1.6vmin, 16px);
  --radius: clamp(10px, 2.4vmin, 22px);
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-body);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* ---- stage: fills the viewport, hosts background + the game shell ---- */
.stage {
  position: fixed;
  inset: 0;
  height: var(--vh);
  display: grid;
  place-items: center;
  background-color: var(--c-bg);
  background-image: var(--img-bg-portrait);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
html.is-landscape .stage { background-image: var(--img-bg-landscape); }

/* The shell keeps a comfortable content width and safe-area padding */
.shell {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: min(560px, 100%);
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) clamp(10px, 3vw, 22px)
           max(12px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
html.is-landscape .shell {
  max-width: min(1100px, 100%);
}

/* ---- header / brand sign ---- */
.brand {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
}
.brand__logo {
  width: clamp(40px, 9vmin, 76px);
  aspect-ratio: 1;
  background: var(--img-logo) center/contain no-repeat;
}
.brand__logo:where([hidden]) { display: none; }
.brand__title {
  font-family: var(--font-heading);
  font-weight: 800;
  color: var(--c-primary-dark);
  font-size: clamp(20px, 5.5vmin, 40px);
  line-height: 1.05;
  letter-spacing: 0.5px;
}
.brand__subtitle { color: var(--c-text-muted); font-size: clamp(12px, 2.4vmin, 16px); }

/* ---- HUD (score / time / moves) ---- */
.hud {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  gap: clamp(8px, 2vw, 18px);
}
.hud__item {
  display: flex; align-items: center; gap: 8px;
  background: color-mix(in srgb, var(--c-surface) 88%, transparent);
  border-radius: 999px;
  padding: clamp(6px, 1.4vmin, 10px) clamp(12px, 2.4vmin, 18px);
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  min-width: clamp(78px, 22vw, 120px);
  justify-content: center;
}
.hud__icon { width: 20px; height: 20px; background-size: contain; background-repeat: no-repeat; background-position: center; }
.hud__icon--score { background-image: var(--img-score); }
.hud__icon--time { background-image: var(--img-timer); }
.hud__label { color: var(--c-text-muted); font-size: 11px; font-weight: 600; text-transform: uppercase; }
.hud__value { color: var(--c-text); font-variant-numeric: tabular-nums; }
.hud__item.is-low .hud__value { color: var(--c-danger); }

/* ---- playfield wrapper ---- */
.playfield {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  background: var(--c-playfield);
  border-radius: var(--radius);
  padding: clamp(8px, 2.2vmin, 20px);
  box-shadow: inset 0 2px 18px rgba(0, 0, 0, 0.18);
}
.playfield--framed { background: var(--img-frame) center/100% 100% no-repeat, var(--c-playfield); }

/* ---- buttons ---- */
.btn {
  font-family: var(--font-heading);
  font-weight: 700;
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  padding: clamp(10px, 2.2vmin, 16px) clamp(20px, 5vmin, 34px);
  font-size: clamp(14px, 3vmin, 20px);
  color: var(--c-text-on-primary);
  background: var(--c-primary);
  box-shadow: 0 6px 0 var(--c-primary-dark), 0 10px 20px rgba(0, 0, 0, 0.2);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  touch-action: manipulation;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--c-primary-dark), 0 6px 12px rgba(0, 0, 0, 0.2); }
.btn--ghost { background: var(--c-surface); color: var(--c-primary-dark); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12); }
.btn--accent { background: var(--c-secondary); box-shadow: 0 6px 0 color-mix(in srgb, var(--c-secondary) 70%, black), 0 10px 20px rgba(0, 0, 0, 0.2); }

.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  background: color-mix(in srgb, var(--c-surface) 90%, transparent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  font-size: 20px; display: grid; place-items: center;
}

/* ---- contact bar (themeable brand footer) ---- */
.contact {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: clamp(10px, 2.2vmin, 13px);
  color: var(--c-text-muted);
  padding: 6px 4px;
}
.contact__info { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.contact__info span { overflow-wrap: anywhere; word-break: break-word; max-width: 100%; }
.contact__socials { display: flex; gap: 8px; }
.contact__social {
  width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  background: var(--c-primary); color: var(--c-text-on-primary); font-size: 13px; font-weight: 700;
  text-decoration: none;
}
.contact[hidden] { display: none; }

/* ---- modal (start / win / lose) ---- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(8, 24, 22, 0.55);
  backdrop-filter: blur(3px);
  padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.modal.is-open { opacity: 1; pointer-events: auto; }
.modal__card {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: clamp(22px, 5vmin, 40px);
  width: min(440px, 92vw);
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  transform: translateY(12px) scale(0.96);
  transition: transform 0.2s ease;
  display: grid; gap: 16px; justify-items: center;
}
.modal.is-open .modal__card { transform: none; }
.modal__title { font-family: var(--font-heading); font-weight: 800; color: var(--c-primary-dark); font-size: clamp(22px, 6vmin, 34px); }
.modal__text { color: var(--c-text-muted); font-size: clamp(14px, 3vmin, 17px); line-height: 1.5; }
.modal__stats { display: flex; gap: 18px; font-weight: 700; }
.modal__stat { display: grid; gap: 2px; }
.modal__stat small { color: var(--c-text-muted); font-weight: 600; }
.modal__stat b { font-size: clamp(20px, 5vmin, 28px); color: var(--c-primary); }
.modal__actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
