:root {
  color-scheme: dark;
  --ink: #090910;
  --panel: #10101a;
  --panel-raised: #171725;
  --line: rgba(255, 255, 255, .13);
  --line-strong: rgba(255, 255, 255, .28);
  --white: #fff;
  --muted: #9797ad;
  --blue: #2628dd;
  --pink: #c419be;
  --green: #35e792;
  --gold: #e6be52;
  --font-body: "Space Grotesk", system-ui, sans-serif;
  --font-display: "Oxanium", "Space Grotesk", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; min-height: 100%; scrollbar-color: transparent transparent; }
html.scrolling { scrollbar-color: rgba(196, 25, 190, .35) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; background: transparent; }
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 0;
  background-color: transparent;
  background-image: radial-gradient(circle, rgba(255,255,255,.72) 1px, transparent 1.3px);
  background-size: 4px 4px;
  background-clip: padding-box;
  transition: background-color .22s ease, border-color .22s ease;
}
html.scrolling::-webkit-scrollbar-thumb {
  border-color: rgba(255,255,255,.08);
  background-color: rgba(196,25,190,.32);
}

body {
  position: relative;
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  padding: 0 0 calc(42px + env(safe-area-inset-bottom));
  overflow-x: hidden;
  background: var(--ink);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  position: fixed;
  z-index: -2;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.028) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.028) 1px, transparent 1px);
  background-size: 44px 44px;
  content: "";
  mask-image: radial-gradient(ellipse at 50% 36%, #000 0%, transparent 78%);
}

body::after {
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 0 48%, rgba(255,255,255,.018) 48.15%, transparent 48.3% 100%);
  content: "";
}

button, input { font: inherit; }
button { color: inherit; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 2px solid rgba(255,255,255,.9); outline-offset: 4px; }
button:active { transform: scale(.975); }
[hidden] { display: none !important; }

.ambient {
  position: fixed;
  z-index: -1;
  width: min(42vw, 560px);
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(100px);
  opacity: .2;
  pointer-events: none;
}
.ambient--blue { top: -22vw; left: -14vw; background: var(--blue); }
.ambient--pink { right: -20vw; bottom: -28vw; background: var(--pink); opacity: .16; }

.app-shell { position: relative; width: min(100%, 1500px); min-height: 100vh; margin: 0 auto; padding: 0 clamp(18px, 4vw, 56px); }
.view { min-height: calc(100vh - 42px); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.login-view { display: grid; min-height: 100svh; place-items: center; padding: 24px 0; }
.login-card {
  position: relative;
  display: grid;
  justify-items: center;
  width: min(400px, calc(100vw - 36px));
  padding: 42px 38px 45px;
  border: 1px solid rgba(255,255,255,.17);
  background: linear-gradient(145deg, rgba(255,255,255,.045), rgba(255,255,255,.012));
  box-shadow: 0 25px 100px rgba(0,0,0,.38), inset 0 1px rgba(255,255,255,.06);
  backdrop-filter: blur(16px);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.login-card::before, .login-card::after { position: absolute; width: 34px; height: 34px; border-color: rgba(255,255,255,.58); border-style: solid; content: ""; pointer-events: none; }
.login-card::before { top: -1px; left: -1px; border-width: 1px 0 0 1px; }
.login-card::after { right: -1px; bottom: -1px; border-width: 0 1px 1px 0; }
.login-card h1 { margin: 0 0 27px; font-family: var(--font-display); font-size: clamp(2.25rem, 8vw, 3rem); font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.login-card form { width: 100%; }
.login-error { width: 100%; margin: 13px 0 0; color: #ff8a92; font-size: .875rem; line-height: 1.4; text-align: center; }
.login-card input {
  display: block;
  width: 100%;
  min-height: 54px;
  padding: 12px 16px;
  border: 1px solid rgba(255,255,255,.32);
  border-radius: 1px;
  background: rgba(8,8,16,.72);
  color: var(--white);
  caret-color: var(--pink);
  letter-spacing: .12em;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.login-card input:focus { outline: none; border-color: rgba(255,255,255,.9); box-shadow: 0 0 0 3px rgba(38,40,221,.25), 0 0 26px rgba(38,40,221,.2); }
.login-card.is-success { animation: login-success .22s ease both; border-color: #fff; box-shadow: 0 0 36px rgba(255,255,255,.4), 0 25px 100px rgba(0,0,0,.38); }
.login-card.is-success input { border-color: #fff; box-shadow: 0 0 25px rgba(255,255,255,.35); }

.topbar { display: flex; align-items: center; min-height: 112px; border-bottom: 1px solid var(--line); }
.brand-button { display: inline-flex; align-items: center; gap: 13px; min-height: 52px; padding: 4px 0; border: 0; background: transparent; cursor: pointer; transition: color .2s ease, filter .2s ease, transform .15s ease; }
.brand-button:hover { color: #dedfff; filter: drop-shadow(0 0 14px rgba(38,40,221,.55)); }
.brand-button span { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; letter-spacing: .06em; }
.brand-mark { width: 37px; height: 27px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.1; }

.home-tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 14px; padding: clamp(28px, 5vw, 58px) 0 42px; }
.table-launch {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  min-height: 88px;
  padding: 17px 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(110deg, rgba(255,255,255,.055), rgba(255,255,255,.018));
  text-align: left;
  cursor: pointer;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease, background .2s ease;
  animation: rise-in .42s both;
  animation-delay: calc(var(--card-index, 0) * 35ms);
}
.table-launch::before { position: absolute; inset: 0 auto 0 0; width: 2px; background: linear-gradient(var(--blue), var(--pink)); content: ""; opacity: .9; }
.table-launch:hover { transform: translateY(-3px); border-color: rgba(255,255,255,.42); background: linear-gradient(110deg, rgba(38,40,221,.18), rgba(196,25,190,.09)); box-shadow: 0 12px 32px rgba(0,0,0,.25), 0 0 28px rgba(38,40,221,.14); }
.table-launch:active { transform: scale(.985); }
.table-launch-name { overflow: hidden; font-family: var(--font-display); font-size: clamp(1.08rem, 2.7vw, 1.35rem); font-weight: 700; line-height: 1.25; text-overflow: ellipsis; overflow-wrap: anywhere; }
.table-launch-mark { display: grid; flex: 0 0 35px; width: 35px; height: 35px; margin-left: 14px; place-items: center; border: 1px solid rgba(255,255,255,.24); color: rgba(255,255,255,.74); }
.table-launch-mark svg { width: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.6; }

.admin-view { display: grid; grid-template-columns: 10.25rem minmax(0, 1fr); gap: clamp(20px, 3vw, 42px); }
.admin-rail { position: sticky; top: 0; align-self: start; display: flex; flex-direction: column; width: 10.25rem; min-height: calc(100vh - 42px); padding: 29px 17px 30px 0; border-right: 1px solid var(--line); }
.admin-brand { gap: 8px; margin-bottom: 34px; }
.admin-brand .brand-mark { width: 30px; height: 23px; flex: 0 0 30px; }
.admin-brand span { font-size: 1.18rem; }
.admin-table-nav { display: grid; gap: 8px; width: 100%; }
.admin-table-button {
  display: -webkit-box;
  width: 100%;
  min-height: 54px;
  max-height: 66px;
  padding: 9px 10px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.025);
  color: rgba(255,255,255,.85);
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  text-overflow: ellipsis;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease, color .2s ease, transform .15s ease;
}
.admin-table-button:hover { border-color: rgba(196,25,190,.7); background: rgba(196,25,190,.13); color: var(--white); }
.admin-content { min-width: 0; padding: 29px 0 48px; }
.admin-toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 12px; min-height: 49px; margin-bottom: 36px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 11px 18px; border: 1px solid transparent; border-radius: 1px; font-weight: 700; letter-spacing: .015em; cursor: pointer; transition: transform .16s ease, border-color .2s ease, box-shadow .2s ease, background .2s ease; }
.button--primary { background: linear-gradient(112deg, var(--blue), #5432e5 58%, var(--pink)); box-shadow: 0 7px 23px rgba(38,40,221,.19); }
.button--primary:hover { box-shadow: 0 8px 30px rgba(196,25,190,.34); filter: brightness(1.1); }
.button:disabled { cursor: wait; opacity: .65; }
.sync-button { display: grid; width: 46px; height: 46px; padding: 10px; place-items: center; border: 1px solid var(--line-strong); background: rgba(255,255,255,.035); cursor: pointer; transition: color .2s ease, border-color .2s ease, background .2s ease, transform .16s ease; }
.sync-button:hover { border-color: var(--pink); background: rgba(196,25,190,.13); color: #ffc9fa; }
.sync-button svg { width: 23px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.sync-button.is-syncing svg { animation: spin .55s ease-in-out; }

.logs-panel { border-top: 1px solid var(--line-strong); }
.logs-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 69px; padding: 12px 3px; border: 0; border-bottom: 1px solid var(--line); background: transparent; font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; letter-spacing: .05em; text-align: left; cursor: pointer; transition: color .18s ease, padding .18s ease; }
.logs-toggle:hover { padding-left: 10px; color: #ffc9fa; }
.logs-caret { width: 12px; height: 12px; margin-right: 8px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translateY(-3px); transition: transform .2s ease; }
.logs-toggle[aria-expanded="true"] .logs-caret { transform: rotate(225deg) translate(-2px, -2px); }
.logs-content { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding-top: 21px; animation: reveal .25s ease both; }
.log-column { min-width: 0; padding: 0 clamp(14px, 2vw, 25px); }
.log-column:first-child { padding-left: 0; }
.log-column + .log-column { border-left: 1px solid var(--line-strong); }
.log-column h2 { margin: 0 0 13px; font-family: var(--font-display); font-size: 1.02rem; font-weight: 700; letter-spacing: .035em; }
.log-table-wrap { max-height: min(60vh, 650px); overflow: auto; border-top: 1px solid var(--line); scrollbar-width: thin; scrollbar-color: rgba(196,25,190,.35) transparent; }
.log-table { width: 100%; border-collapse: collapse; table-layout: auto; font-size: .875rem; }
.log-table th { position: sticky; top: 0; z-index: 1; padding: 10px 8px; background: #10101a; color: var(--muted); font-size: .8rem; font-weight: 600; text-align: left; white-space: nowrap; }
.log-table td { padding: 10px 8px; border-top: 1px solid rgba(255,255,255,.08); color: rgba(255,255,255,.9); vertical-align: top; overflow-wrap: anywhere; }
.log-table th:first-child, .log-table td:first-child { padding-left: 0; }

.table-view { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: clamp(12px, 2.4vw, 32px); padding-top: 22px; }
.table-rail { position: relative; min-width: 0; }
.table-title { position: sticky; top: 34vh; width: 52px; max-height: 60vh; padding: 0; border: 0; background: transparent; color: var(--white); font-family: var(--font-display); font-size: clamp(1.15rem, 2.1vw, 1.55rem); font-weight: 700; letter-spacing: .08em; line-height: 1.15; text-transform: uppercase; writing-mode: vertical-rl; transform: rotate(180deg); overflow-wrap: anywhere; text-align: left; cursor: pointer; transition: color .2s ease, filter .2s ease; }
.table-title:hover { color: #d6d5ff; filter: drop-shadow(0 0 12px rgba(38,40,221,.72)); }
.table-main { min-width: 0; padding-bottom: 30px; }
.rating-summary { width: 100%; margin: 0 0 17px; overflow-x: auto; border: 1px solid var(--line-strong); scrollbar-width: thin; scrollbar-color: transparent transparent; }
.rating-summary:hover { scrollbar-color: rgba(196,25,190,.4) transparent; }
.summary-row { display: grid; grid-template-columns: repeat(8, minmax(90px, 1fr)); min-width: 760px; }
.summary-row--head { min-height: 40px; border-bottom: 1px solid var(--line-strong); background: rgba(255,255,255,.035); }
.summary-row--games { min-height: 78px; }
.summary-cell { min-width: 0; padding: 10px 9px; border-right: 1px solid var(--line); color: rgba(255,255,255,.88); font-size: .875rem; line-height: 1.4; white-space: pre-line; overflow-wrap: anywhere; }
.summary-cell:last-child { border-right: 0; }
.summary-cell--head { padding-top: 10px; padding-bottom: 9px; color: var(--white); font-size: .875rem; font-weight: 700; }
.summary-cell--gold { color: var(--gold); }

.game-rows { display: grid; gap: 7px; }
.game-row { display: grid; grid-template-columns: 35px 116px minmax(0, 1fr); align-items: center; gap: 9px; min-width: 0; min-height: 53px; padding: 5px 11px; border: 1px solid rgba(255,255,255,.1); background: linear-gradient(100deg, rgba(255,255,255,.028), rgba(255,255,255,.012)); transition: border-color .2s ease, background .2s ease, box-shadow .2s ease; }
.game-row:hover { border-color: rgba(255,255,255,.25); background-color: rgba(255,255,255,.025); }
.game-row--gold { border-color: rgba(255,219,120,.78); background: linear-gradient(100deg, rgba(232,192,87,.96), rgba(245,216,136,.94) 72%, rgba(225,177,53,.95)); box-shadow: inset 3px 0 rgba(255,255,255,.68), 0 0 20px rgba(220,175,60,.11); }
.game-row--gold:hover { border-color: #ffecb6; background: linear-gradient(100deg, #e9c66c, #f7dfa0 72%, #e5bd58); }
.done-toggle { display: grid; width: 25px; height: 25px; margin: 0 auto; padding: 0; place-items: center; border: 1px solid rgba(255,255,255,.62); border-radius: 50%; background: transparent; color: var(--green); cursor: pointer; transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease; }
.done-toggle:hover { border-color: var(--green); box-shadow: 0 0 14px rgba(53,231,146,.27); }
.done-toggle.is-done { border-color: var(--green); background: rgba(53,231,146,.16); box-shadow: 0 0 11px rgba(53,231,146,.2); }
.done-toggle svg { width: 16px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.7; }
.row-rating { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 38px; padding: 3px 1px; border: 0; background: transparent; color: var(--white); font-size: 1.02rem; letter-spacing: -.1em; white-space: nowrap; cursor: pointer; transition: transform .16s ease, filter .16s ease; }
.row-rating:hover { transform: scale(1.06); filter: drop-shadow(0 0 7px rgba(196,25,190,.5)); }
.filled-stars { color: #ffdc63; }
.empty-stars { color: rgba(255,255,255,.38); }
.gold-star { color: #f1c548; letter-spacing: -.16em; }
.game-row--gold .row-rating--gold { color: #a77a13; filter: drop-shadow(0 1px rgba(255,255,255,.45)); }
.game-row--gold .game-title-input { color: var(--blue); }
.game-title-input { display: block; width: 100%; min-width: 0; min-height: 39px; padding: 6px 8px; border: 1px solid transparent; border-radius: 0; outline: none; background: transparent; color: var(--white); font-size: .98rem; font-weight: 500; transition: border-color .17s ease, background .17s ease, box-shadow .17s ease; }
.game-title-input:hover { border-color: rgba(255,255,255,.15); }
.game-title-input:focus { border-color: rgba(255,255,255,.7); background: rgba(0,0,0,.14); box-shadow: 0 0 0 2px rgba(38,40,221,.22); }
.game-row--gold .game-title-input:focus { border-color: var(--blue); background: rgba(255,255,255,.23); box-shadow: 0 0 0 2px rgba(38,40,221,.2); }

.version-label { position: fixed; z-index: 5; bottom: max(10px, env(safe-area-inset-bottom)); left: max(12px, env(safe-area-inset-left)); padding: 3px 6px; color: rgba(255,255,255,.62); font-family: var(--font-display); font-size: .72rem; font-weight: 600; letter-spacing: .035em; pointer-events: none; }

.glass-dialog { width: min(430px, calc(100vw - 32px)); max-width: 100%; padding: 0; overflow: visible; border: 1px solid rgba(255,255,255,.31); background: rgba(16,16,26,.78); color: var(--white); box-shadow: 0 26px 90px rgba(0,0,0,.6), 0 0 45px rgba(38,40,221,.18); backdrop-filter: blur(22px) saturate(145%); }
.glass-dialog::backdrop { background: rgba(4,4,10,.52); backdrop-filter: blur(8px); }
.dialog-card { display: grid; gap: 13px; padding: 25px; }
.dialog-card input { width: 100%; min-height: 49px; padding: 10px 13px; border: 1px solid rgba(255,255,255,.36); border-radius: 0; outline: none; background: rgba(5,5,12,.55); color: var(--white); }
.dialog-card input:focus { border-color: #fff; box-shadow: 0 0 20px rgba(38,40,221,.3); }
.dialog-card .button { width: 100%; }
.glass-dialog--rating { width: min(390px, calc(100vw - 32px)); }
.rating-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 19px; }
.rating-choice { display: flex; justify-content: center; align-items: center; min-height: 48px; border: 1px solid var(--line); background: rgba(255,255,255,.035); font-size: 1.08rem; letter-spacing: -.1em; cursor: pointer; transition: border-color .18s ease, background .18s ease, transform .15s ease, box-shadow .18s ease; }
.rating-choice:hover { border-color: var(--pink); background: rgba(196,25,190,.12); box-shadow: 0 0 18px rgba(196,25,190,.15); }
.rating-choice--gold { grid-column: 1 / -1; border-color: rgba(230,190,82,.62); background: rgba(230,190,82,.09); }
.rating-choice--gold:hover { border-color: var(--gold); background: rgba(230,190,82,.17); box-shadow: 0 0 18px rgba(230,190,82,.15); }

@keyframes login-success { from { transform: scale(1); outline: 0 solid rgba(255,255,255,0); } to { transform: scale(1.035); outline: 6px solid rgba(255,255,255,.8); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes reveal { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 760px) {
  .app-shell { padding-right: 18px; padding-left: 18px; }
  .admin-view { grid-template-columns: 8rem minmax(0, 1fr); gap: 18px; }
  .admin-rail { width: 8rem; padding-right: 12px; }
  .admin-brand { gap: 6px; }
  .admin-brand .brand-mark { width: 24px; flex-basis: 24px; }
  .admin-brand span { font-size: 1rem; }
  .admin-table-button { padding: 8px; font-size: .875rem; }
  .admin-toolbar { margin-bottom: 27px; }
  .logs-content { grid-template-columns: minmax(0, 1fr); gap: 23px; }
  .log-column, .log-column:first-child { padding: 0; }
  .log-column + .log-column { padding-top: 21px; border-top: 1px solid var(--line-strong); border-left: 0; }
  .table-view { grid-template-columns: 43px minmax(0, 1fr); gap: 10px; }
  .table-title { width: 40px; font-size: 1.08rem; }
}

@media (max-width: 480px) {
  .app-shell { padding-right: 14px; padding-left: 14px; }
  .topbar { min-height: 88px; }
  .brand-button span { font-size: 1.45rem; }
  .home-tables { grid-template-columns: minmax(0, 1fr); gap: 10px; padding-top: 25px; }
  .table-launch { min-height: 76px; padding: 14px 15px; }
  .admin-view { grid-template-columns: 7.25rem minmax(0, 1fr); gap: 13px; }
  .admin-rail { width: 7.25rem; padding-top: 19px; padding-right: 9px; }
  .admin-brand { flex-wrap: wrap; margin-bottom: 24px; }
  .admin-brand span { font-size: .96rem; }
  .admin-table-button { min-height: 49px; padding: 7px; font-size: .8125rem; }
  .admin-content { padding-top: 18px; }
  .admin-toolbar { gap: 8px; margin-bottom: 24px; }
  .button { min-height: 42px; padding: 9px 12px; font-size: .9rem; }
  .sync-button { width: 42px; height: 42px; }
  .logs-toggle { min-height: 60px; font-size: 1.2rem; }
  .log-table { font-size: .8125rem; }
  .log-table th { font-size: .75rem; }
  .log-table td, .log-table th { padding-right: 5px; padding-left: 5px; }
  .game-row { grid-template-columns: 30px 96px minmax(0, 1fr); gap: 5px; padding: 5px 6px; }
  .row-rating { font-size: .9rem; }
  .game-title-input { padding-right: 4px; padding-left: 5px; font-size: .91rem; }
  .rating-summary { margin-bottom: 12px; }
  .summary-row { grid-template-columns: repeat(8, minmax(84px, 1fr)); min-width: 672px; }
  .summary-cell { padding-right: 7px; padding-left: 7px; font-size: .8125rem; }
  .summary-cell--head { font-size: .8125rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
