/* SmartPunch web portal: the app's neutral menu look (lib/subapps/sp_menu_style.dart): charcoal panels, 1.5 px borders,
   one accent (SmartPunch blue), status colours only for status, no glow. Logical properties so Arabic mirrors. */

:root {
  --bg0: #121418;
  --bg1: #1a1d23;
  --bar: #111317;
  --panel: #1f232a;
  --panel-hi: #272c34;
  --field: #16191e;
  --line: #3a414c;
  --row-line: #2c323b;
  --blue: #319def;
  --green: #4fb37e;
  --red: #d95b5b;
  --text: #edeff2;
  --text-dim: #a6aeba;
  --text-faint: #6e7784;
  --gold: #d9b341;
  --silver: #b8c0cc;
  --bronze: #c98a52;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { background: var(--bg0); }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--bg1), var(--bg0) 420px);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Arabic", Arial, sans-serif;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 3px solid #fff; outline-offset: 2px; border-radius: 6px; }

h1 { font-size: 26px; margin: 8px 0 6px; font-weight: 700; letter-spacing: 0.2px; }
h2 { font-size: 19px; margin: 0; font-weight: 700; }
h3 { font-size: 16px; margin: 0; font-weight: 600; }

.dim { color: var(--text-dim); }
.small { font-size: 13.5px; }
.intro { color: var(--text-dim); margin: 0 0 18px; max-width: 70ch; }
.error { color: var(--red); }

/* --- Bar --------------------------------------------------------------------------------------------------------- */

.bar {
  background: var(--bar);
  border-bottom: 1.5px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.bar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px 18px;
  flex-wrap: wrap;
}

/* The app's title font (Eurostile Bold Extended), drawn as outlines: img/logo.svg */
.brand { display: inline-flex; align-items: center; padding: 6px 0; text-decoration: none !important; }
.brand-logo { display: block; height: 16px; width: auto; }

.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1 1 auto; }

.nav-link {
  color: var(--text-dim);
  padding: 7px 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 15px;
  border: 1.5px solid transparent;
  background: none;
  font-family: inherit;
  cursor: pointer;
}
.nav-link:hover { color: var(--text); background: var(--panel); text-decoration: none; }
.nav-link.current { color: var(--text); border-color: var(--line); background: var(--panel); }

.tools { display: flex; gap: 8px; }

select, input {
  font: inherit;
  color: var(--text);
  background: var(--field);
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
select { padding: 6px 8px; font-size: 14px; }
input:focus, select:focus { border-color: var(--blue); outline: none; }

/* --- Layout ------------------------------------------------------------------------------------------------------ */

.main { width: 100%; max-width: 1080px; margin: 0 auto; padding: 18px 16px 48px; flex: 1; }

.footer {
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  padding: 18px 16px 24px;
  border-top: 1.5px solid var(--line);
}

.panel {
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  margin: 0 0 18px;
}
.panel.narrow { max-width: 560px; }

.section-label {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 22px 0 10px;
}

.table-wrap { overflow-x: auto; }

/* --- Buttons ----------------------------------------------------------------------------------------------------- */

.button {
  display: inline-block;
  font: inherit;
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: 0.3px;
  color: #fff;
  background: var(--blue);
  border: 1.5px solid var(--blue);
  border-radius: 10px;
  padding: 11px 20px;
  cursor: pointer;
  text-align: center;
  text-decoration: none !important;
}
.button:hover { filter: brightness(1.08); }
.button:disabled { opacity: 0.6; cursor: default; }
.button.secondary { background: var(--panel-hi); border-color: var(--line); color: var(--text); }
.button.small { font-size: 14px; padding: 7px 14px; }

/* --- Leaderboards ------------------------------------------------------------------------------------------------ */

.app-picker { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 24px; margin-bottom: 8px; }
.app-group .section-label { margin-top: 4px; }
.app-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }

.app-tile {
  display: grid;
  grid-template-columns: 40px 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  padding: 8px;
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  text-decoration: none !important;
}
.app-tile .logo { grid-row: 1 / 3; }
.app-tile:hover { background: var(--panel-hi); }
.app-tile.current { border-color: var(--blue); background: var(--panel-hi); }
.app-tile-name { font-weight: 600; font-size: 14.5px; line-height: 1.2; }
.app-tile-count { color: var(--text-faint); font-size: 12.5px; }

.logo { border-radius: 8px; display: block; object-fit: cover; background: var(--field); flex: none; }

.board-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.board-head p { margin: 2px 0 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none !important;
}
.chip:hover { color: var(--text); background: var(--panel-hi); }
.chip.current { color: #fff; background: var(--blue); border-color: var(--blue); }

table { border-collapse: collapse; width: 100%; }
th {
  text-align: start;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--text-dim);
  padding: 8px 10px;
  border-bottom: 1.5px solid var(--line);
  white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--row-line); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }

.board .rank { width: 56px; font-weight: 700; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.board .player { font-weight: 600; width: 100%; white-space: normal; word-break: break-word; }
.board .value { font-weight: 700; text-align: end; font-variant-numeric: tabular-nums; }
.board th:nth-child(3) { text-align: end; }
.board .date, .sessions-table .date { color: var(--text-faint); font-size: 13.5px; }
.board tr.me td { background: rgba(49, 157, 239, 0.14); }
.board tr.me td:first-child { box-shadow: inset 3px 0 0 var(--blue); }
[dir="rtl"] .board tr.me td:first-child { box-shadow: inset -3px 0 0 var(--blue); }
.board tr.gap td { text-align: center; color: var(--text-faint); padding: 2px; }

.medal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: #15171b;
  font-size: 13.5px;
}
.medal.m1 { background: var(--gold); }
.medal.m2 { background: var(--silver); }
.medal.m3 { background: var(--bronze); }

.empty { padding: 18px 0 8px; }

/* --- My scores --------------------------------------------------------------------------------------------------- */

.me-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.label { font-size: 13.5px; font-weight: 600; letter-spacing: 0.4px; color: var(--text-dim); }
.public-id { font-size: 28px; font-weight: 800; letter-spacing: 0.5px; word-break: break-word; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; align-items: start; }
.card.open { grid-column: 1 / -1; }
.card {
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  min-width: 0;
}
.card.unplayed { opacity: 0.55; }
.card.unplayed .card-head { margin-bottom: 4px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }

.stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.stat { background: var(--field); border: 1.5px solid var(--line); border-radius: 8px; padding: 6px 10px; min-width: 70px; }
.stat-value { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--text-faint); font-size: 12.5px; }

.bests { list-style: none; padding: 0; margin: 0 0 12px; }
.bests li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--row-line);
}
.bests li:last-child { border-bottom: none; }
.best-label { color: var(--text-dim); flex: 1 1 auto; }
.best-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.best-rank { font-size: 13px; font-weight: 600; padding: 1px 8px; border: 1.5px solid var(--line); border-radius: 999px; }

.card-actions { display: flex; gap: 8px; }
.sessions { margin-top: 10px; }
.sessions .more { margin-top: 10px; }
.sessions-table td, .sessions-table th { padding: 6px 8px; font-size: 13.5px; }

/* --- Forms ------------------------------------------------------------------------------------------------------- */

.form .field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form input[type="text"], .form input[type="email"], .form input[type="password"], .form input[type="number"] { width: 100%; padding: 11px 12px; }
.hint { color: var(--text-faint); font-size: 13px; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 14px; }
.form input { min-width: 0; }
.code-input { font-size: 20px; letter-spacing: 3px; text-transform: uppercase; font-family: ui-monospace, Consolas, monospace; }

.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.segment { position: relative; }
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment span {
  display: inline-block;
  padding: 8px 14px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--text-dim);
  font-weight: 600;
  cursor: pointer;
}
.segment input:checked + span { background: var(--blue); border-color: var(--blue); color: #fff; }
.segment input:focus-visible + span { outline: 3px solid #fff; outline-offset: 2px; }

.message { min-height: 1.4em; margin: 0 0 12px; }
.message.ok { color: var(--green); }

/* Log in / Sign up / Google: one centred card */
.auth-page { max-width: 460px; margin: 8px auto 0; }
.auth h2 { margin-bottom: 6px; }
.auth .button, .auth-actions .button { width: 100%; }
.auth .button + .button, .auth .button + .google-slot { margin-top: 10px; }
/* Google's own button (an iframe, 40 px high) is centred; the slot keeps its height while the script loads */
.google-slot.gsi { display: flex; justify-content: center; min-height: 44px; }
/* Google's frame is a light page: with the same color-scheme the browser keeps it transparent (no white box) */
.google-slot iframe { color-scheme: light; }

/* "Log in with Google": the app's grey account button with a white disc and a blue G (GoogleGlyph) */
.button.google { display: flex; align-items: center; justify-content: center; gap: 10px;
                 background: var(--panel-hi); border-color: var(--line); color: var(--text); }
.g-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  color: #4285f4;
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
}

.switch { text-align: center; font-size: 14px; color: var(--text-dim); margin: 16px 0 0; }
.switch a { font-weight: 700; }

.code-login { margin-top: 16px; text-align: center; }
.code-login summary { display: inline-block; cursor: pointer; color: var(--text-faint); font-size: 13.5px; padding: 4px 8px; }
.code-login summary:hover { color: var(--text-dim); }
.code-login[open] .form {
  text-align: start;
  margin-top: 10px;
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 18px;
}
.code-login .button { width: 100%; }

.google-panel h2 { display: flex; align-items: center; gap: 10px; }
.device-link { display: inline-block; font-size: 22px; font-weight: 800; margin: 0 0 14px; word-break: break-all; }
.device-code {
  font: 800 34px/1.2 ui-monospace, Consolas, monospace;
  letter-spacing: 4px;
  text-align: center;
  background: var(--field);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin: 0 0 14px;
}
.auth-actions { display: flex; flex-direction: column; gap: 10px; }
.auth-page + .auth-page { margin-top: 0; }
.pair-step { text-align: center; font-weight: 600; margin: 0 0 4px; }

@media (max-width: 760px) {
  .app-picker { grid-template-columns: minmax(0, 1fr); }
  .brand-logo { height: 14px; }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .app-tiles { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .panel { padding: 14px; }
  h1 { font-size: 22px; }
  .bar-inner { gap: 6px 10px; }
  .board .date, .board th:nth-child(4) { display: none; }
}
