:root {
  --red: #8B1220;
  --red-dark: #6c0e19;
  --dark: #26262a;
  --gray: #6b6b70;
  --line: #e2e2e6;
  --bg: #f7f6f5;
  --good: #1f9d55;
  --warn: #d9822b;
}

* { box-sizing: border-box; }

/* Prevent any residual element from forcing horizontal scroll on the page,
   regardless of viewport size — a safety net on top of the specific fixes
   below, not a replacement for them. */
html, body { max-width: 100%; overflow-x: hidden; }
img, svg, canvas { max-width: 100%; height: auto; }

/* Hidden by default (desktop) — the media query further down switches this
   to a fixed bottom bar on phone-width viewports. Declared here, before the
   media query, so source order lets the mobile override win when it matches. */
.bottom-tabbar { display: none; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--dark);
}
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: #fff;
  border-bottom: 3px solid var(--red);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar .brand { font-weight: 800; font-size: 18px; color: var(--red); letter-spacing: 0.3px; }
.topbar .brand small { display: block; font-weight: 500; color: var(--gray); font-size: 11px; letter-spacing: 1px; }
.topbar nav a {
  color: var(--dark);
  margin-left: 18px;
  font-weight: 600;
  font-size: 14px;
}
.topbar nav a.active { color: var(--red); }
.topbar .user-pill {
  margin-left: 18px;
  font-size: 13px;
  color: var(--gray);
}
.topbar form { display: inline; margin-left: 18px; }
.topbar button.link-btn {
  background: none; border: none; color: var(--gray); font-weight: 600; cursor: pointer; font-size: 13px;
}

.container { max-width: 1080px; margin: 0 auto; padding: 28px; }
.container.narrow { max-width: 620px; }

/* ==========================================================================
   Responsive breakpoints
   - 1024px and below: tablets (also catches large-phone/tablet landscape)
   - 768px and below:  large phones / small tablets — nav becomes a scroll
                        strip, bottom tab bar appears, tables scroll
   - 480px and below:  small phones — tighter spacing, smaller type scale
   Desktop (1025px+) styles above/outside these blocks are unchanged.
   ========================================================================== */


h1 { font-size: 24px; margin: 0 0 6px; }
h2 { font-size: 18px; color: var(--red); margin: 28px 0 12px; }
p.subtitle { color: var(--gray); margin-top: 0; }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 18px;
}
.card-header {
  background: var(--red);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.4px;
  padding: 10px 16px;
  border-radius: 8px 8px 0 0;
  margin: -20px -20px 16px -20px;
}

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-box { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px; text-align: center; }
.stat-box .num { font-size: 28px; font-weight: 800; color: var(--red); }
.stat-box .label { font-size: 12px; color: var(--gray); text-transform: uppercase; letter-spacing: 0.5px; }

.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--gray); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
tr:hover td { background: #fbfafa; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 700; color: #fff; }
.badge.red { background: var(--red); }
.badge.gray { background: var(--gray); }
.badge.good { background: var(--good); }
.badge.warn { background: var(--warn); }

.btn {
  display: inline-block;
  background: var(--red);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.btn:hover { background: var(--red-dark); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--dark); border: 1px solid var(--line); }
.btn.small { padding: 5px 12px; font-size: 12px; }
.btn.gray { background: var(--gray); }

label { display: block; font-weight: 700; font-size: 13px; margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=date], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
textarea { resize: vertical; min-height: 70px; }

.stars { display: inline-flex; gap: 2px; }
.stars input { display: none; }
.stars label {
  display: inline-block; margin: 0; cursor: pointer; font-size: 22px; color: var(--line); user-select: none;
}

/* Half-star rating widget (0.5 increments) — see public/js/ratings.js.
   Each star is rendered and filled INDEPENDENTLY (not as one clipped text
   run) so font kerning/letter-spacing can never throw off which fraction of
   which star appears filled — this was a real bug in an earlier version. */
.half-star-input { display: flex; align-items: center; gap: 10px; }
.hs-track {
  position: relative; display: inline-flex; align-items: center; gap: 4px;
  height: 28px; user-select: none;
}
.hs-star { position: relative; display: inline-block; width: 22px; height: 26px; font-size: 24px; line-height: 26px; text-align: center; }
.hs-star-bg { position: absolute; inset: 0; color: #d9d9dc; }
.hs-star-fg { position: absolute; inset: 0; width: 0%; overflow: hidden; white-space: nowrap; color: var(--red); pointer-events: none; transition: width 0.08s ease; }
.hs-floor-marker {
  display: none; position: absolute; top: -3px; width: 2px; height: 34px;
  background: var(--dark); opacity: 0.35; pointer-events: none;
}
.hs-hitzone { position: absolute; inset: -6px 0; cursor: pointer; }
.hs-hitzone:focus { outline: 2px solid var(--red); outline-offset: 2px; border-radius: 4px; }
.half-star-input .hs-value { font-weight: 700; font-size: 14px; color: var(--dark); min-width: 32px; }
.skill-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
.skill-row .name { font-weight: 700; width: 160px; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.flash.success { background: #eaf7ee; color: var(--good); border: 1px solid #c9ecd3; }
.flash.error { background: #fdecec; color: #b4232c; border: 1px solid #f7c6c8; }

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: #fff; border-radius: 12px; padding: 36px; width: 360px; box-shadow: 0 10px 40px rgba(0,0,0,0.08); border-top: 5px solid var(--red); }
.login-card h1 { text-align: center; color: var(--red); }
.login-card p.subtitle { text-align: center; }
.demo-note { font-size: 12px; color: var(--gray); margin-top: 18px; background: #f7f6f5; padding: 10px; border-radius: 6px; }

.footer-band { background: var(--red); color: #fff; text-align: center; padding: 12px; font-weight: 700; font-size: 12px; letter-spacing: 1px; margin-top: 40px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
/* Responsive collapse for grid-2/grid-3 is handled in the consolidated
   breakpoints near the top of this file (768px and 1024px). */

.rec-checklist label { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 6px 0; }
.rec-checklist input[type=checkbox] { width: auto; }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.player-link { font-weight: 700; }

.status-draft { color: var(--warn); font-weight: 700; }
.status-submitted { color: var(--good); font-weight: 700; }

.empty-state { text-align: center; color: var(--gray); padding: 40px 0; }

/* ---------- Developer console theme ---------- */
.dev-console {
  background: linear-gradient(135deg, #17171a 0%, #26262a 100%);
  border-radius: 12px;
  padding: 22px 26px;
  margin-bottom: 20px;
  color: #d7f7d7;
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  position: relative;
  overflow: hidden;
  border: 1px solid #3a3a40;
}
.dev-console::before {
  content: "";
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(0deg, rgba(255,255,255,0.02) 0px, rgba(255,255,255,0.02) 1px, transparent 1px, transparent 3px);
  pointer-events: none;
}
.dev-console .prompt { color: #6bd97a; font-size: 13px; }
.dev-console .prompt .path { color: #f0a860; }
.dev-console h1 { color: #fff; font-family: -apple-system, BlinkMacSystemFont, sans-serif; margin: 6px 0 4px; font-size: 24px; }
.dev-console .cursor { display: inline-block; width: 8px; height: 16px; background: #6bd97a; margin-left: 2px; animation: dev-blink 1s steps(1) infinite; vertical-align: middle; }
@keyframes dev-blink { 50% { opacity: 0; } }
.dev-console .sub { color: #9a9aa5; font-size: 13px; margin-top: 4px; }

.dev-tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.dev-tile {
  display: block; background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 14px; text-align: center; transition: transform 0.1s ease, border-color 0.15s ease;
}
.dev-tile:hover { border-color: var(--red); transform: translateY(-2px); text-decoration: none; }
.dev-tile .dt-icon { font-size: 26px; display: block; margin-bottom: 6px; }
.dev-tile .dt-label { font-weight: 700; font-size: 12.5px; color: var(--dark); }
.dev-tile .dt-desc { font-size: 10.5px; color: var(--gray); margin-top: 2px; }

.ai-btn {
  background: linear-gradient(135deg, #8B1220, #b3213a);
  color: #fff;
  border: none;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  margin-left: 8px;
  vertical-align: middle;
}
.ai-btn:hover { opacity: 0.9; }
.ai-btn:disabled { opacity: 0.6; cursor: default; }
.ai-status { font-size: 12px; color: var(--gray); min-height: 16px; margin: 2px 0 8px; }
.ai-status-error { color: #b4232c; }

.autocomplete-dropdown {
  position: absolute; z-index: 20; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; width: 100%; max-height: 260px; overflow-y: auto; display: none;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12); margin-top: 4px;
}
.suggestion-item { padding: 10px 12px; cursor: pointer; border-bottom: 1px solid #f0f0f0; }
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover, .suggestion-item.active { background: #fbecee; }
.suggestion-meta { font-size: 12px; color: var(--gray); margin-top: 2px; }

.computed-rating {
  display: flex; align-items: center; gap: 10px; background: #f7f6f5;
  border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px;
}
.computed-rating .stars-preview { font-size: 22px; color: var(--red); letter-spacing: 2px; }
.computed-rating .rating-label { font-weight: 700; color: var(--dark); font-size: 14px; }
.email-connected-badge { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
#parentEmailDisplay { padding-right: 90px; }

/* ==========================================================================
   Responsive breakpoints — deliberately placed at the END of this file.
   CSS resolves equal-specificity conflicts by source order, so a mobile
   override declared earlier than a base rule of the same selector loses to
   it even when the media query matches — that exact bug bit the bottom tab
   bar earlier in this project, and bit font-size here too. Keeping every
   responsive override after all base styles avoids the whole bug class.
   ========================================================================== */
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
  .dev-tile-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px;
    gap: 10px;
  }
  .topbar > div:last-child {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
  }
  .topbar nav {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
    width: 100%;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .topbar nav::-webkit-scrollbar { display: none; }
  .topbar nav a {
    margin-left: 0;
    white-space: nowrap;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: 8px;
    font-size: 13px;
  }
  .topbar nav a.active { background: var(--red); color: #fff; }
  .topbar .user-pill { margin-left: 0; }
  .topbar a[href="/account/change-password"] { margin-left: 0 !important; padding: 4px 0; }
  .topbar form { margin-left: 0; }
  .topbar button.link-btn { padding: 4px 0; }

  .container { padding: 16px; padding-bottom: 84px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }

  h1 { font-size: 21px; }
  h2 { font-size: 17px; margin: 22px 0 10px; }
  .card { padding: 16px; }
  .card-header { margin: -16px -16px 14px -16px; padding: 10px 14px; }

  /* Tables: scroll horizontally inside their own container rather than
     squeezing columns illegibly — see .table-responsive wrapper in the
     view templates. A sensible min-width keeps text readable; the
     container (not the whole page) scrolls when it's wider than the screen. */
  .table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-responsive table { min-width: 480px; }
  table { font-size: 13px; }
  th, td { padding: 9px 6px; }

  /* 16px minimum on form fields prevents iOS Safari's automatic zoom when a
     field is focused — everything else about the fields stays the same. */
  input[type=text], input[type=email], input[type=password], input[type=date],
  input[type=month], input[type=number], select, textarea, .btn {
    font-size: 16px;
  }
  .btn.small { font-size: 13px; }

  /* Comfortable tap targets throughout, without changing desktop density */
  .btn { padding: 12px 18px; }
  .btn.small { padding: 9px 14px; }
  input[type=checkbox], input[type=radio] { width: 18px; height: 18px; }
  .rec-checklist label { padding: 4px 0; min-height: 28px; align-items: flex-start; }

  .login-wrap { padding: 20px; }
  .login-card { width: 100%; max-width: 360px; padding: 28px 22px; }

  .skill-row { flex-wrap: wrap; row-gap: 6px; }
  .skill-row .name { width: auto; flex: 1 1 100%; }
  .half-star-input { flex-wrap: wrap; }

  .dev-console { padding: 16px 18px; }
  .dev-console .prompt { word-break: break-all; overflow-wrap: anywhere; }

  .bottom-tabbar {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
    background: rgba(255,255,255,0.97);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
  }
  .bt-tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; padding: 6px 2px; color: var(--gray); font-size: 10.5px; font-weight: 600;
    text-decoration: none; border-radius: 8px; min-height: 44px;
  }
  .bt-tab:hover { text-decoration: none; }
  .bt-tab .bt-icon { font-size: 20px; line-height: 1; }
  .bt-tab.active { color: var(--red); }
}

@media (max-width: 480px) {
  .container { padding: 12px; padding-bottom: 80px; }
  h1 { font-size: 19px; }
  .card { padding: 14px; }
  .card-header { margin: -14px -14px 12px -14px; font-size: 12px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-box { padding: 12px; }
  .stat-box .num { font-size: 22px; }
  .dev-tile-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .topbar .brand { font-size: 16px; }
  .login-card { padding: 24px 18px; }
  .half-star-input { gap: 6px; }
  .hs-star { width: 19px; }
}

@media (orientation: landscape) and (max-height: 480px) {
  .container { padding-bottom: 16px; }
  .bottom-tabbar { display: none; }
}
