/* =========================================================
   NRWales Games Hub — Shared Game Styles
   Use on:
   - memory-match.php
   - reaction-race.php
   - sorting-spree.php
   - word-flow.php

   Link with:
   <link rel="stylesheet" href="games-hub.css">
   ========================================================= */

:root {
  --nrw-black:#050505;
  --nrw-black-2:#090909;
  --nrw-black-3:#111111;
  --nrw-black-4:#181818;
  --nrw-white:#ffffff;
  --nrw-off-white:#f2f1ed;
  --nrw-text:#ffffff;
  --nrw-muted:#c8c8c8;
  --nrw-muted-2:#919191;
  --nrw-orange:#ff8c00;
  --nrw-orange-light:#ffad45;
  --nrw-orange-dark:#d87300;
  --nrw-green:#3bd889;
  --nrw-red:#ff6b6b;
  --nrw-blue:#65a6ff;
  --nrw-line:rgba(255,255,255,.11);
  --nrw-line-strong:rgba(255,255,255,.18);
  --nrw-shadow:0 24px 70px rgba(0,0,0,.46);
  --nrw-max:1240px;
  --nrw-ease:cubic-bezier(.2,.72,.2,1);
}

/* Reset */

*,
*::before,
*::after {
  box-sizing:border-box;
}

html {
  scroll-behavior:smooth;
}

body {
  margin:0;
  min-height:100vh;
  overflow-x:hidden;
  color:var(--nrw-text);
  background:
    radial-gradient(circle at 90% 0%,rgba(255,140,0,.13),transparent 28%),
    linear-gradient(180deg,#050505 0%,#000 50%,#050505 100%);
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  line-height:1.58;
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}

img,
svg {
  display:block;
  max-width:100%;
}

a {
  color:inherit;
  text-decoration:none;
}

button,
input,
select,
textarea {
  font:inherit;
}

button {
  cursor:pointer;
}

:focus-visible {
  outline:3px solid rgba(255,140,0,.92);
  outline-offset:4px;
}

::selection {
  background:rgba(255,140,0,.55);
  color:#000;
}

/* Shared layout */

.game-shell {
  width:min(calc(100% - 40px),var(--nrw-max));
  margin-inline:auto;
}

.game-page {
  min-height:100vh;
}

.game-skip-link {
  position:fixed;
  top:12px;
  left:12px;
  z-index:9999;
  transform:translateY(-160%);
  padding:10px 15px;
  background:var(--nrw-orange);
  color:#000;
  font-weight:950;
}

.game-skip-link:focus {
  transform:translateY(0);
}

/* Minimal ecosystem bar */

.game-ecosystem {
  border-bottom:1px solid var(--nrw-line);
  background:#050505;
}

.game-ecosystem-inner {
  min-height:39px;
  display:flex;
  align-items:center;
}

.game-ecosystem-brand {
  color:var(--nrw-orange-light);
  font-size:.66rem;
  font-weight:950;
  letter-spacing:.12em;
  text-transform:uppercase;
}

/* Game header */

.game-header {
  position:sticky;
  top:0;
  z-index:100;
  border-bottom:1px solid var(--nrw-line);
  background:#080808;
  box-shadow:0 16px 44px rgba(0,0,0,.38);
}

.game-header-inner {
  min-height:74px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:20px;
}

.game-brand {
  display:flex;
  align-items:center;
  gap:12px;
  min-width:0;
}

.game-brand-mark {
  width:52px;
  height:52px;
  flex:0 0 52px;
  display:grid;
  place-items:center;
  overflow:hidden;
  border:4px solid var(--nrw-orange);
  border-radius:50%;
  background:#fff;
}

.game-brand-mark img {
  width:78%;
  height:78%;
  object-fit:contain;
}

.game-brand-copy strong {
  display:block;
  font-size:.92rem;
  font-weight:980;
  line-height:1.05;
  letter-spacing:-.03em;
}

.game-brand-copy span {
  display:block;
  margin-top:4px;
  color:var(--nrw-muted-2);
  font-size:.66rem;
  font-weight:800;
}

.game-header-actions {
  display:flex;
  align-items:center;
  gap:9px;
}

/* Buttons */

.game-button,
.game-button-secondary,
.game-button-danger {
  min-height:48px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:9px;
  padding:12px 18px;
  border-radius:3px;
  font-weight:950;
  line-height:1;
  text-align:center;
  transition:
    transform 180ms var(--nrw-ease),
    background 180ms var(--nrw-ease),
    border-color 180ms var(--nrw-ease),
    color 180ms var(--nrw-ease);
}

.game-button {
  border:1px solid var(--nrw-orange);
  background:var(--nrw-orange);
  color:#000;
}

.game-button:hover {
  transform:translateY(-2px);
  border-color:var(--nrw-orange-light);
  background:var(--nrw-orange-light);
}

.game-button-secondary {
  border:1px solid rgba(255,255,255,.36);
  background:transparent;
  color:#fff;
}

.game-button-secondary:hover {
  transform:translateY(-2px);
  border-color:#fff;
  background:#fff;
  color:#000;
}

.game-button-danger {
  border:1px solid rgba(255,107,107,.55);
  background:rgba(255,107,107,.10);
  color:#ffd0d0;
}

.game-button-danger:hover {
  transform:translateY(-2px);
  border-color:var(--nrw-red);
  background:var(--nrw-red);
  color:#000;
}

/* Hero */

.game-hero {
  position:relative;
  isolation:isolate;
  overflow:hidden;
  border-bottom:7px solid var(--nrw-orange);
  background:
    linear-gradient(90deg,rgba(0,0,0,.98) 0%,rgba(0,0,0,.91) 52%,rgba(0,0,0,.35) 100%),
    linear-gradient(132deg,#050505 0 57%,#211006 57% 65%,var(--nrw-orange-dark) 65% 82%,var(--nrw-orange) 82% 88%,#080808 88% 100%);
}

.game-hero::before {
  content:attr(data-word);
  position:absolute;
  top:50%;
  right:clamp(-90px,-2vw,-15px);
  z-index:0;
  transform:translateY(-50%);
  color:rgba(0,0,0,.28);
  font-size:clamp(7rem,20vw,18rem);
  font-weight:1000;
  line-height:.72;
  letter-spacing:-.12em;
  text-transform:uppercase;
  pointer-events:none;
  user-select:none;
}

.game-hero-inner {
  position:relative;
  z-index:1;
  padding:clamp(70px,9vw,110px) 0 58px;
}

.game-kicker {
  display:inline-flex;
  align-items:center;
  gap:9px;
  padding:8px 12px;
  background:var(--nrw-orange);
  color:#000;
  font-size:.68rem;
  font-weight:950;
  letter-spacing:.10em;
  text-transform:uppercase;
}

.game-title {
  max-width:980px;
  margin:20px 0 0;
  font-size:clamp(3rem,7vw,6.4rem);
  font-weight:980;
  line-height:.87;
  letter-spacing:-.075em;
  text-transform:uppercase;
}

.game-title span {
  color:var(--nrw-orange);
}

.game-intro {
  max-width:760px;
  margin:21px 0 0;
  color:#dfdfdf;
  font-size:clamp(.98rem,1.5vw,1.12rem);
  line-height:1.66;
}

.game-hero-actions {
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top:26px;
}

/* Main game area */

.game-main {
  padding:clamp(42px,6vw,78px) 0;
}

.game-layout {
  display:grid;
  grid-template-columns:minmax(0,1fr) minmax(280px,.32fr);
  gap:1px;
  border:1px solid var(--nrw-line);
  background:var(--nrw-line);
  box-shadow:var(--nrw-shadow);
}

.game-board-panel {
  min-width:0;
  padding:clamp(24px,4vw,42px);
  background:#111;
}

.game-sidebar {
  display:flex;
  flex-direction:column;
  background:#0c0c0c;
}

.game-panel-title {
  margin:0;
  font-size:clamp(1.8rem,3.8vw,3.2rem);
  font-weight:980;
  line-height:.95;
  letter-spacing:-.055em;
  text-transform:uppercase;
}

.game-panel-copy {
  max-width:760px;
  margin:13px 0 0;
  color:var(--nrw-muted);
  font-size:.84rem;
}

/* Score and status cards */

.game-stats {
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:1px;
  margin:24px 0;
  border:1px solid var(--nrw-line);
  background:var(--nrw-line);
}

.game-stat {
  min-height:105px;
  display:flex;
  flex-direction:column;
  justify-content:flex-end;
  padding:18px;
  background:#0b0b0b;
}

.game-stat span {
  color:var(--nrw-orange);
  font-size:.62rem;
  font-weight:950;
  letter-spacing:.09em;
  text-transform:uppercase;
}

.game-stat strong {
  display:block;
  margin-top:9px;
  font-size:clamp(1.7rem,4vw,2.8rem);
  font-weight:1000;
  line-height:.82;
  letter-spacing:-.06em;
}

.game-status {
  margin:18px 0 0;
  padding:14px 16px;
  border-left:5px solid var(--nrw-orange);
  background:rgba(255,140,0,.09);
  color:#ffd6a1;
  font-size:.80rem;
  font-weight:800;
}

.game-status.success {
  border-color:var(--nrw-green);
  background:rgba(59,216,137,.09);
  color:#bdf6d6;
}

.game-status.error {
  border-color:var(--nrw-red);
  background:rgba(255,107,107,.09);
  color:#ffd1d1;
}

/* Sidebar blocks */

.game-side-block {
  padding:25px;
  border-bottom:1px solid var(--nrw-line);
}

.game-side-block:last-child {
  border-bottom:0;
}

.game-side-block.orange {
  background:var(--nrw-orange);
  color:#000;
}

.game-side-block strong {
  display:block;
  font-size:.69rem;
  font-weight:950;
  letter-spacing:.09em;
  text-transform:uppercase;
}

.game-side-block h2,
.game-side-block h3 {
  margin:12px 0 0;
  font-size:1.45rem;
  font-weight:980;
  line-height:.95;
  letter-spacing:-.045em;
  text-transform:uppercase;
}

.game-side-block p {
  margin:12px 0 0;
  color:var(--nrw-muted);
  font-size:.76rem;
}

.game-side-block.orange p {
  color:#452000;
}

.game-side-list {
  display:grid;
  gap:9px;
  margin:15px 0 0;
  padding:0;
  list-style:none;
}

.game-side-list li {
  position:relative;
  padding-left:18px;
  color:var(--nrw-muted);
  font-size:.74rem;
}

.game-side-list li::before {
  content:"";
  position:absolute;
  top:.58em;
  left:0;
  width:7px;
  height:7px;
  background:var(--nrw-orange);
}

/* Generic game controls */

.game-controls {
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top:22px;
}

.game-controls>* {
  flex:0 0 auto;
}

.game-input,
.game-select {
  width:100%;
  min-height:50px;
  padding:13px 14px;
  border:1px solid var(--nrw-line-strong);
  border-radius:0;
  background:#080808;
  color:#fff;
  outline:none;
}

.game-input:focus,
.game-select:focus {
  border-color:var(--nrw-orange);
  box-shadow:0 0 0 4px rgba(255,140,0,.10);
}

/* Memory Match */

.memory-grid {
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:10px;
  margin-top:24px;
}

.memory-card {
  position:relative;
  aspect-ratio:1 / 1;
  border:1px solid var(--nrw-line);
  background:#0a0a0a;
  perspective:900px;
}

.memory-card button {
  width:100%;
  height:100%;
  padding:0;
  border:0;
  background:transparent;
}

.memory-card-inner {
  position:relative;
  width:100%;
  height:100%;
  transform-style:preserve-3d;
  transition:transform 420ms var(--nrw-ease);
}

.memory-card.is-flipped .memory-card-inner,
.memory-card.is-matched .memory-card-inner {
  transform:rotateY(180deg);
}

.memory-card-face {
  position:absolute;
  inset:0;
  display:grid;
  place-items:center;
  backface-visibility:hidden;
  border:1px solid var(--nrw-line);
}

.memory-card-front {
  background:
    linear-gradient(145deg,rgba(255,140,0,.16),transparent 45%),
    #151515;
  color:var(--nrw-orange);
  font-size:clamp(1.7rem,5vw,3.2rem);
  font-weight:1000;
}

.memory-card-back {
  transform:rotateY(180deg);
  background:var(--nrw-orange);
  color:#000;
  font-size:clamp(1.7rem,5vw,3.2rem);
}

.memory-card.is-matched {
  box-shadow:0 0 0 3px rgba(59,216,137,.35);
}

/* Reaction Race */

.reaction-stage {
  min-height:380px;
  display:grid;
  place-items:center;
  margin-top:24px;
  border:1px solid var(--nrw-line);
  background:
    radial-gradient(circle at center,rgba(255,140,0,.08),transparent 38%),
    #080808;
}

.reaction-target {
  width:min(190px,44vw);
  aspect-ratio:1 / 1;
  display:grid;
  place-items:center;
  border:12px solid rgba(255,255,255,.08);
  border-radius:50%;
  background:#181818;
  color:#fff;
  font-size:1.05rem;
  font-weight:980;
  text-align:center;
  text-transform:uppercase;
  transition:
    transform 180ms var(--nrw-ease),
    background 180ms var(--nrw-ease),
    color 180ms var(--nrw-ease);
}

.reaction-target.ready {
  background:var(--nrw-orange);
  color:#000;
  transform:scale(1.08);
}

.reaction-target.success {
  background:var(--nrw-green);
  color:#000;
}

/* Sorting Spree */

.sorting-items {
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:10px;
  margin-top:24px;
}

.sort-item {
  min-height:92px;
  display:flex;
  align-items:center;
  gap:13px;
  padding:16px;
  border:1px solid var(--nrw-line);
  background:#0b0b0b;
  color:#fff;
  font-weight:900;
}

.sort-item[draggable="true"] {
  cursor:grab;
}

.sort-item[draggable="true"]:active {
  cursor:grabbing;
}

.sort-item.is-dragging {
  opacity:.48;
  transform:scale(.98);
}

.sort-zones {
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:10px;
  margin-top:18px;
}

.sort-zone {
  min-height:180px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  padding:18px;
  border:2px dashed rgba(255,140,0,.36);
  background:rgba(255,140,0,.05);
  color:var(--nrw-muted);
  text-align:center;
}

.sort-zone.is-over {
  border-color:var(--nrw-orange);
  background:rgba(255,140,0,.13);
  color:#fff;
}

.sort-zone.correct {
  border-color:var(--nrw-green);
  background:rgba(59,216,137,.09);
}

/* Word Flow */

.word-game {
  margin-top:24px;
  padding:clamp(22px,4vw,36px);
  border:1px solid var(--nrw-line);
  background:#0a0a0a;
}

.word-clue {
  color:var(--nrw-orange-light);
  font-size:.72rem;
  font-weight:950;
  letter-spacing:.10em;
  text-transform:uppercase;
}

.word-display {
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap:8px;
  margin:28px 0;
}

.word-letter {
  width:clamp(42px,8vw,62px);
  aspect-ratio:1 / 1;
  display:grid;
  place-items:center;
  border-bottom:5px solid var(--nrw-orange);
  background:#141414;
  color:#fff;
  font-size:clamp(1.5rem,5vw,2.7rem);
  font-weight:1000;
  text-transform:uppercase;
}

.word-keyboard {
  display:grid;
  grid-template-columns:repeat(9,minmax(0,1fr));
  gap:7px;
  margin-top:24px;
}

.word-key {
  min-height:46px;
  border:1px solid var(--nrw-line);
  background:#161616;
  color:#fff;
  font-weight:950;
  text-transform:uppercase;
}

.word-key:hover {
  border-color:var(--nrw-orange);
  color:var(--nrw-orange-light);
}

.word-key:disabled,
.word-key.used {
  opacity:.36;
  cursor:not-allowed;
}

/* Completion panel */

.game-complete {
  display:none;
  margin-top:24px;
  padding:clamp(25px,4vw,42px);
  border:1px solid rgba(59,216,137,.32);
  background:
    radial-gradient(circle at 100% 0%,rgba(59,216,137,.12),transparent 34%),
    #0d1511;
  text-align:center;
}

.game-complete.is-visible {
  display:block;
}

.game-complete h2 {
  margin:0;
  color:#bdf6d6;
  font-size:clamp(2rem,5vw,4rem);
  font-weight:1000;
  line-height:.9;
  letter-spacing:-.06em;
  text-transform:uppercase;
}

.game-complete p {
  max-width:650px;
  margin:15px auto 0;
  color:var(--nrw-muted);
}

.game-complete-actions {
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap:10px;
  margin-top:24px;
}

/* Footer */

.game-footer {
  border-top:1px solid var(--nrw-line);
  background:#050505;
}

.game-footer-inner {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
  padding:24px 0 30px;
  color:var(--nrw-muted-2);
  font-size:.70rem;
}

.game-footer-links {
  display:flex;
  flex-wrap:wrap;
  gap:14px;
}

.game-footer a:hover {
  color:var(--nrw-orange-light);
}

/* Responsive */

@media(max-width:980px) {
  .game-layout {
    grid-template-columns:1fr;
  }

  .game-sidebar {
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
  }

  .game-side-block {
    border-right:1px solid var(--nrw-line);
  }

  .memory-grid {
    grid-template-columns:repeat(3,minmax(0,1fr));
  }

  .sort-zones {
    grid-template-columns:1fr;
  }
}

@media(max-width:700px) {
  .game-shell {
    width:calc(100% - 24px);
  }

  .game-ecosystem-inner {
    min-height:43px;
  }

  .game-header-inner {
    min-height:72px;
  }

  .game-brand-mark {
    width:48px;
    height:48px;
    flex-basis:48px;
  }

  .game-brand-copy strong {
    max-width:220px;
    font-size:.80rem;
  }

  .game-brand-copy span {
    display:none;
  }

  .game-header-actions .game-button-secondary {
    display:none;
  }

  .game-title {
    font-size:clamp(2.8rem,15vw,4.7rem);
  }

  .game-hero-actions,
  .game-controls,
  .game-complete-actions {
    display:grid;
    grid-template-columns:1fr;
  }

  .game-hero-actions>*,
  .game-controls>*,
  .game-complete-actions>* {
    width:100%;
  }

  .game-stats {
    grid-template-columns:1fr;
  }

  .game-sidebar {
    grid-template-columns:1fr;
  }

  .game-side-block {
    border-right:0;
  }

  .memory-grid {
    grid-template-columns:repeat(2,minmax(0,1fr));
  }

  .sorting-items {
    grid-template-columns:1fr;
  }

  .word-keyboard {
    grid-template-columns:repeat(6,minmax(0,1fr));
  }

  .game-footer-inner {
    align-items:flex-start;
    flex-direction:column;
  }
}

@media(max-width:430px) {
  .word-keyboard {
    grid-template-columns:repeat(5,minmax(0,1fr));
  }

  .reaction-stage {
    min-height:300px;
  }
}

@media(prefers-reduced-motion:reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior:auto !important;
    transition:none !important;
    animation:none !important;
  }
}
