/* ===========================================================
   Shared theme + common elements for the Game Arcade
   Light is the default; [data-theme="dark"] opts into dark.
   =========================================================== */

:root {
  /* page chrome — flips with theme */
  --bg:          #eef1f7;
  --surface:     #ffffff;   /* boards, cards, score boxes      */
  --surface-2:   #e3e8f2;   /* empty cells / inset wells       */
  --surface-3:   #d4dcec;   /* hover / raised chrome           */
  --text:        #1a1f3a;
  --muted:       #64708a;
  --accent:      #f3b007;   /* gold highlight                  */
  --accent-text: #1a1f3a;   /* text drawn on top of --accent   */
  --btn-bg:      #1a1f3a;
  --btn-text:    #ffffff;
  --border:      rgba(20, 30, 70, 0.10);
  --shadow:      rgba(30, 40, 80, 0.16);
  --overlay:     rgba(238, 241, 247, 0.90);

  /* game piece palette — mostly constant across themes */
  --red:              #e94560;
  --green:            #1fae84;
  --yellow:           #f5b301;
  --blue-board:       #2756c4;
  --blue-board-dark:  #1e44a0;
  --hole:             #11173a;  /* connect-four empty hole */
  --hole-hover:       #1b2552;

  /* theme-aware tints */
  --cell-blue:        #e7edf9;  /* noughts & crosses cell  */
  --cell-blue-hover:  #d6e0f4;
}

:root[data-theme="dark"] {
  --bg:          #1a1a2e;
  --surface:     #16213e;
  --surface-2:   #1f2a4d;
  --surface-3:   #243160;
  --text:        #eaeaea;
  --muted:       #9aa3c0;
  --accent:      #ffd460;
  --accent-text: #1a1a2e;
  --btn-bg:      #eaeaea;
  --btn-text:    #1a1a2e;
  --border:      rgba(255, 255, 255, 0.06);
  --shadow:      rgba(0, 0, 0, 0.40);
  --overlay:     rgba(22, 33, 62, 0.88);

  --cell-blue:       #0f3460;
  --cell-blue-hover: #1a4d8f;
}

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

/* ---------- base layout (games centre a single column) ---------- */
body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 20px;
  transition: background 0.25s ease, color 0.25s ease;
}

h1 { font-weight: 600; letter-spacing: 1px; }

/* ---------- buttons ---------- */
button {
  padding: 12px 28px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--btn-text);
  background: var(--btn-bg);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}
button:hover { opacity: 0.85; }

/* ---------- shared status / hint text ---------- */
#status {
  font-size: 1.3rem;
  min-height: 1.6rem;
  font-weight: 500;
  transition: color 0.2s;
}
.hint { font-size: 0.85rem; opacity: 0.6; text-align: center; }

/* ---------- score / stat boxes ---------- */
.score-box, .stat {
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 16px;
  text-align: center;
  min-width: 72px;
  box-shadow: 0 2px 8px var(--shadow);
}
.score-box .label, .stat .label {
  font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 1px; opacity: 0.7;
}
.score-box .val, .stat .val { font-size: 1.3rem; font-weight: 700; }

/* ---------- theme toggle (injected by theme.js) ---------- */
.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 4px 14px var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.theme-toggle:hover { opacity: 1; background: var(--surface-3); }

/* ---------- back-to-homepage link (injected by theme.js on game pages) ---------- */
.home-link {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 44px;
  height: 44px;
  font-size: 1.35rem;
  line-height: 1;
  text-decoration: none;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 4px 14px var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.home-link:hover { background: var(--surface-3); }

/* ---------- help button + dialog (injected by theme.js when a page ships
   a <template id="gameHelp">) ---------- */
.help-toggle {
  position: fixed;
  top: 16px;
  right: 70px;            /* sits just left of the theme toggle */
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 4px 14px var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.help-toggle:hover { opacity: 1; background: var(--surface-3); }

.help-dialog {
  margin: auto;            /* centre the modal */
  padding: 0;
  width: min(440px, 92vw);
  max-height: 88vh;
  overflow: auto;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}
.help-dialog::backdrop {
  background: rgba(10, 12, 24, 0.55);
  backdrop-filter: blur(2px);
}
/* gentle pop-in */
.help-dialog[open] { animation: helpPop 0.18s ease; }
@keyframes helpPop {
  from { transform: translateY(8px) scale(0.98); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
.help-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 1.4rem;
  line-height: 1;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  border: none;
  cursor: pointer;
}
.help-close:hover { opacity: 1; background: var(--surface-3); }
.help-body { padding: 26px 26px 24px; }
.help-body h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 34px 12px 0;   /* keep clear of the close button */
}
.help-body p { margin: 0 0 10px; line-height: 1.5; }
.help-body ul,
.help-body ol { margin: 0 0 12px; padding-left: 22px; line-height: 1.5; }
.help-body li { margin-bottom: 6px; }
.help-body strong { color: var(--accent); }
.help-body kbd {
  display: inline-block;
  min-width: 1.1em;
  padding: 2px 7px;
  font: inherit;
  font-size: 0.85em;
  text-align: center;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
}
.help-body .help-tip {
  margin: 14px 0 0;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}
.help-body .help-fact {
  margin: 10px 0 0;
  padding: 10px 12px;
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}
