/* Declaring color-scheme explicitly (matching whichever theme is actually
   active) opts every page out of the browser's OWN automatic "force dark
   mode" content heuristics (Android Chrome/WebView's auto-dark-theme
   feature is the most common one) -- without it, a browser that force-
   darkens unrecognized content can invert/blacken real photos it doesn't
   know how to theme itself, which is exactly what a real uploaded board
   background image looked like once dark mode existed on the page at all
   (a real user report). Inline `style="background-image:url(...)"` on
   #board-wrap/.bg-preview always wins over any CSS rule here on
   specificity grounds, so this couldn't have been this stylesheet
   overriding the image directly -- it's the browser's own separate
   heuristic, and this is the standard, documented fix for it. */
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) { color-scheme: dark; }
}

:root {
  --bg: #f4ede1;
  --card-bg: #fffaf0;
  --card-border: #e0d3ba;
  --text: #3a2f22;
  --text-muted: #8a7860;
  --text-label: #6b5c46;
  --heading: #6b4226;
  --accent: #6b4226;
  --accent-hover: #54331d;
  --accent-contrast: #fff;
  --row-border: #eee2cc;
  --mine-bg: #eef6e8;
  --mine-border: #4c8a3f;
  --mine-row-border: #dcebd3;
  --badge-bg: #e0d3ba;
  --badge-text: #6b4226;
  --input-border: #ccc;
  --error-bg: #fbe9e7;
  --error-border: #e8b4ab;
  --error-text: #a0392b;
  --success-bg: #ecf3e6;
  --success-border: #bcd9a8;
  --success-text: #3d6b2f;
  --shadow: rgba(0,0,0,.05);
}
/* Applied by theme.js the instant it runs (before first paint) based on
   localStorage or, absent a saved choice, the OS preference -- this makes
   an explicit toggle always win over the media query in both directions. */
:root[data-theme="dark"] {
  --bg: #1c1812;
  --card-bg: #26201a;
  --card-border: #4a3d2c;
  --text: #f0e8dc;
  --text-muted: #b3a892;
  --text-label: #c9bda6;
  --heading: #d9a15a;
  --accent: #8a5a35;
  --accent-hover: #a9713f;
  --accent-contrast: #fff;
  --row-border: #3a2f22;
  --mine-bg: #22321c;
  --mine-border: #5fa04c;
  --mine-row-border: #2c3e26;
  --badge-bg: #3a2f22;
  --badge-text: #d9a15a;
  --input-border: #4a3d2c;
  --error-bg: #3a1f1a;
  --error-border: #7a3a30;
  --error-text: #e08a7a;
  --success-bg: #1f2e18;
  --success-border: #4a7a35;
  --success-text: #9fd989;
  --shadow: rgba(0,0,0,.3);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #1c1812;
    --card-bg: #26201a;
    --card-border: #4a3d2c;
    --text: #f0e8dc;
    --text-muted: #b3a892;
    --text-label: #c9bda6;
    --heading: #d9a15a;
    --accent: #8a5a35;
    --accent-hover: #a9713f;
    --accent-contrast: #fff;
    --row-border: #3a2f22;
    --mine-bg: #22321c;
    --mine-border: #5fa04c;
    --mine-row-border: #2c3e26;
    --badge-bg: #3a2f22;
    --badge-text: #d9a15a;
    --input-border: #4a3d2c;
    --error-bg: #3a1f1a;
    --error-border: #7a3a30;
    --error-text: #e08a7a;
    --success-bg: #1f2e18;
    --success-border: #4a7a35;
    --success-text: #9fd989;
    --shadow: rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
}
.wrap { max-width: 640px; margin: 0 auto; padding: 2rem 1.25rem; }
header.top { display: flex; flex-direction: column; align-items: flex-start; gap: .4rem; margin-bottom: 1.5rem; }
h1 { font-size: 1.3rem; margin: 0; color: var(--heading); white-space: nowrap; }
.who { font-size: .85rem; color: var(--text-muted); }
.who a { color: var(--text-muted); }
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px var(--shadow);
}
button, .btn {
  display: inline-block;
  padding: .6rem 1.2rem;
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  font-size: .9rem;
}
button:hover, .btn:hover { background: var(--accent-hover); }
label { display: block; margin-bottom: .3rem; font-size: .85rem; color: var(--text-label); }
input[type=email], input[type=text], input[type=number], input[type=password], textarea, select {
  padding: .6rem .8rem;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  font-size: 1rem;
  background: var(--card-bg);
  color: var(--text);
}
input[type=email], input[type=text], input[type=password] {
  width: 100%;
  margin-bottom: 1rem;
}
.error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
  border-radius: 6px;
  padding: .75rem 1rem;
  font-size: .85rem;
  margin-bottom: 1rem;
}
.success {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success-text);
  border-radius: 6px;
  padding: .85rem 1rem;
  font-size: .9rem;
}
.back { display: block; text-align: center; margin-top: 1.25rem; font-size: .82rem; color: var(--text-muted); text-decoration: none; }
.back:hover { color: var(--accent-hover); }
ul.game-list { list-style: none; margin: 0; padding: 0; }
ul.game-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .85rem 0;
  border-bottom: 1px solid var(--row-border);
}
ul.game-list li:last-child { border-bottom: none; }
ul.game-list li.mine {
  background: var(--mine-bg);
  border-left: 3px solid var(--mine-border);
  border-bottom-color: var(--mine-row-border);
  padding-left: .75rem;
  padding-right: .75rem;
  margin: 0 -.75rem;
  border-radius: 6px;
}
.game-meta { font-size: .8rem; color: var(--text-muted); }
.badge {
  font-size: .72rem;
  padding: .15rem .5rem;
  border-radius: 4px;
  background: var(--badge-bg);
  color: var(--badge-text);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.empty { color: var(--text-muted); font-size: .9rem; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* Theme toggle button, added to every page's header nav next to the other
   account links -- deliberately plain-text like its neighbors (settings,
   log out) rather than a styled button, so it doesn't visually compete. */
.theme-toggle {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0;
  display: inline;
}
.theme-toggle:hover { color: var(--accent-hover); background: none; }

/* "It's your turn" banners (render_turn_banners() in inc/svg_render.php) --
   deliberately full-bleed (outside .wrap's own max-width/centering) so
   they read as a site-level notice bar, not just another card, and stack
   directly under each other with no gap when a player has more than one
   game waiting on them. */
.turn-banner {
  display: block;
  width: 100%;
  text-align: center;
  padding: .7rem 1rem;
  font-weight: 700;
  text-decoration: none;
  box-sizing: border-box;
}
.turn-banner:hover { filter: brightness(1.08); }
