:root {
  color-scheme: dark;
  --background: #121419;
  --accent: #69c3ff;
  --surface: #1c2028;
  --border: #303744;
  --text: #f3f7fb;
  --muted: #a7b1bf;
  --burgundy: #80002f;
  --header-height: 76px;
  --side-space: 24px;
  --site-width: min(calc(100vw - var(--side-space) * 2), calc((100dvh - var(--header-height)) * 4 / 3));
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  background: var(--background);
  color: var(--text);
  font: 16px/1.5 Arial, Helvetica, sans-serif;
}

button, input { font: inherit; }

.page { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.page-signed-in { height: 100dvh; min-height: 0; }

.site-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 28px;
  width: var(--site-width);
  height: var(--header-height);
  margin: 0 auto;
  padding: 16px 34px;
  border-bottom: 3px solid var(--burgundy);
  background: var(--background);
  flex-shrink: 0;
}
.site-name {
  justify-self: start;
  color: var(--accent);
  font-size: 24px;
  font-weight: 900;
  line-height: 1.2;
  text-decoration: none;
}
.site-nav { display: flex; align-items: center; justify-content: center; gap: 20px; }
.site-nav a { color: var(--muted); text-decoration: none; white-space: nowrap; font-weight: 700; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--text); }
.site-nav a + a { display: flex; align-items: center; gap: 20px; }
.site-nav a + a::before { content: "/"; color: #596171; font-weight: 400; }
.site-name:focus-visible, .site-nav a:focus-visible { outline: 3px solid var(--accent); outline-offset: 5px; }
.account-menu { justify-self: end; position: relative; min-width: 0; color: var(--text); font-weight: 700; overflow-wrap: anywhere; z-index: 10; }
.account-menu summary { cursor: pointer; list-style: none; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu summary:hover, .account-menu[open] summary { color: var(--accent); }
.account-menu summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 5px; }
.account-dropdown { position: absolute; right: 0; top: calc(100% + 14px); width: 190px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px #0006; }
.account-dropdown a, .account-dropdown button { display: block; width: 100%; padding: 12px; border: 0; border-radius: 6px; text-align: left; text-decoration: none; color: var(--text); background: transparent; font: inherit; cursor: pointer; }
.account-dropdown a:hover, .account-dropdown button:hover { background: #29303b; color: var(--accent); }
.account-dropdown a:focus-visible, .account-dropdown button:focus-visible { outline: 2px solid var(--accent); }
.account-top { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.account-email { margin: 14px 0 24px; color: var(--muted); overflow-wrap: anywhere; }

.main {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
}

.panel {
  width: min(100%, 430px);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 34px;
  background: var(--surface);
  box-shadow: 0 24px 70px #0004;
}

h1 { margin: 0; font-size: 26px; line-height: 1.2; }
.login-title {
  margin-bottom: 28px;
  color: var(--accent);
  font: 900 30px/1.2 "Arial Black", Arial, Helvetica, sans-serif;
  text-align: center;
}

.stacked-form { display: flex; flex-direction: column; }
.stacked-form label { margin: 0 0 8px; font-weight: 700; font-size: 14px; }
.stacked-form input {
  width: 100%;
  height: 48px;
  margin-bottom: 19px;
  padding: 0 14px;
  border: 1px solid #414a59;
  border-radius: 9px;
  outline: none;
  background: #14171d;
  color: var(--text);
}
.stacked-form input::placeholder { color: #788391; }
.stacked-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #69c3ff33; }

.primary-button {
  min-height: 48px;
  margin-top: 6px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: #101923;
  font-weight: 800;
  cursor: pointer;
}
.primary-button:hover { background: #91d3ff; }
.primary-button:disabled { opacity: .5; cursor: not-allowed; }
.primary-button:focus-visible, .quiet-button:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.message { margin: 0 0 20px; padding: 11px 13px; border-radius: 8px; font-size: 14px; }
.error { color: #ffd6da; background: #672b33; }
.success { color: #d8ffeb; background: #20593e; }
.warning { color: #fff0cc; background: #5a4521; }

.workspace { container-type: size; min-height: 0; align-items: center; padding: 0 24px; }
.dashboard {
  display: flex;
  flex-direction: column;
  width: var(--site-width);
  aspect-ratio: 4 / 3;
  min-width: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  flex-shrink: 0;
}
.workspace-account { container-type: normal; align-items: flex-start; padding: 28px 24px; overflow-y: auto; }
.account-panel { width: min(100%, 620px); }
.dashboard > h1 { margin-bottom: 28px; }
.quiet-button { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--text); cursor: pointer; }
.quiet-button:hover { border-color: var(--accent); }
.empty-state { padding: 46px 18px; border: 1px dashed #414a59; border-radius: 12px; text-align: center; }
.empty-mark { display: inline-flex; width: 62px; height: 62px; align-items: center; justify-content: center; border-radius: 50%; background: #253b4a; color: var(--accent); font-size: 24px; font-weight: 900; }
.empty-state h2 { margin: 16px 0 4px; font-size: 20px; }
.empty-state p { margin: 16px 0 0; color: var(--muted); }
.dashboard .empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; }
.settings { margin-top: 26px; border-top: 1px solid var(--border); padding-top: 20px; }
.settings summary { width: fit-content; color: var(--accent); font-size: 20px; cursor: pointer; font-weight: 700; }
.settings .stacked-form { max-width: 390px; margin: 20px auto 0; }
.form-actions { display: flex; justify-content: center; gap: 12px; margin-top: 6px; }
.form-actions button { flex: 0 1 148px; min-width: 0; min-height: 48px; margin: 0; }
.collection-panel { overflow: auto; }
.collection-add { margin-bottom: 20px; }
.collection-add summary { color: var(--accent); cursor: pointer; font-weight: 700; }
.collection-form { display: grid; gap: 10px; max-width: 390px; margin-top: 18px; }
.collection-form input, .collection-form select { width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid #414a59; border-radius: 8px; background: #14171d; color: var(--text); font: inherit; }
.collection-list { overflow: auto; min-height: 90px; }
.collection-game { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 0; border-bottom: 1px solid var(--border); }
.collection-game strong { overflow-wrap: anywhere; }
.collection-game p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.collection-game form { flex-shrink: 0; }

.tops-panel { overflow: auto; }
.tops-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 24px; }
.tops-filters a { padding: 7px 13px; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); text-decoration: none; }
.tops-filters a:hover, .tops-filters a[aria-current="page"] { color: var(--accent); border-color: var(--accent); }
.tops-filters a:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.tops-table-wrap { flex: 1; min-height: 90px; overflow: auto; }
.tops-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; }
.tops-table th { color: var(--muted); font-weight: 700; }
.tops-table th, .tops-table td { padding: 16px 12px; border-bottom: 1px solid var(--border); }
.tops-table th:first-child, .tops-table td:first-child { padding-left: 0; }
.tops-table th:last-child, .tops-table td:last-child { padding-right: 0; }
.tops-game { display: flex; align-items: center; gap: 14px; min-width: 200px; }
.tops-game img { flex-shrink: 0; object-fit: contain; border-radius: 8px; }
.tops-icon-fallback { display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px; flex-shrink: 0; color: var(--accent); background: #253b4a; border-radius: 8px; font-size: 24px; font-weight: 900; }
.tops-percent { color: var(--accent); font-weight: 800; }
.tops-duration, .tops-table time { white-space: nowrap; font-variant-numeric: tabular-nums; }

@media (max-width: 1100px), (max-height: 760px) {
  :root { --header-height: 112px; }
  .site-header { grid-template-columns: minmax(0, 1fr) auto; gap: 16px 24px; }
  .site-nav { grid-column: 1 / -1; grid-row: 2; }
}

@media (max-width: 660px), (max-height: 620px) {
  :root { --header-height: 144px; }
  .site-header { padding: 16px 20px; }
  .site-name { font-size: 21px; }
  .site-nav { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 4px 0; gap: 8px 14px; font-size: 14px; }
  .site-nav a + a::before { display: none; }
}

@media (max-width: 480px) {
  :root { --side-space: 14px; }
  .main { padding: 20px 14px 40px; align-items: flex-start; }
  .panel { padding: 25px 20px; }
  .main.workspace { padding: 0 14px; align-items: center; }
  .main.workspace-account { padding: 20px 14px; align-items: flex-start; }
  .dashboard { padding: 16px; }
  .dashboard .empty-state { padding: 18px 12px; }
  .empty-mark { flex-shrink: 0; }
}
