/* Shared visual language: deep ocean, oxidised metal and warm brass. */
:root {
  color-scheme: dark;
  --sea-950: #080f13;
  --sea-900: #0d191e;
  --panel: #13242b;
  --panel-raised: #1b3038;
  --line: #31474e;
  --line-bright: #50666a;
  --text: #e8e9df;
  --muted: #a4b6b9;
  --brass: #d9bc80;
  --teal: #92c9c3;
  --action-surface: #284650;
  --action-hover: #355b66;
  --action-border: #648a94;
  --danger: #ec9d91;
  --radius: 8px;
  --shadow: 0 16px 48px #0005, 0 1px 0 #ffffff05 inset;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--sea-950);
}
* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: #50666a #101e25; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
button, .button-link {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--line-bright); border-radius: 5px;
  background: #21373f; color: var(--text);
  font-size: .85rem; font-weight: 600; line-height: 1.4; text-decoration: none;
  cursor: pointer; transition: background .16s ease, border-color .16s ease, color .16s ease;
}
button:hover, .button-link:hover { background: #2c4851; border-color: var(--teal); color: #fff; }
button:active, .button-link:active { background: #162b33; }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary, form > button, #join, #active-game { background: var(--action-surface); border-color: var(--action-border); color: var(--text); }
.primary:hover, form > button:hover, #join:hover, #active-game:hover { background: var(--action-hover); border-color: var(--teal); color: #fff; }
.primary:active, form > button:active, #join:active, #active-game:active { background: #1c363e; }
.quiet { background: transparent; border-color: var(--line); }
.destructive { color: var(--danger); border-color: #80584f; background: #392b2b; }
.destructive:hover { background: #61372f; border-color: var(--danger); }
:where(button, a, input, select, textarea, summary):focus-visible { outline: 2px solid var(--teal); outline-offset: 4px; }
a { color: var(--teal); text-underline-offset: 4px; }
a:hover { color: #d5e9de; }
h1, h2, h3 { line-height: 1.25; font-weight: 600; }
h1 { font-size: 1.8rem; margin: 0 0 24px; letter-spacing: -.035em; }
h2 { font-size: 1.1rem; margin: 0 0 18px; }
h3 { font-size: .95rem; }
p { margin: 0 0 16px; }
label { display: block; margin: 16px 0; font-size: .85rem; color: var(--muted); }
input, select, textarea {
  display: block; width: 100%; min-width: 0; margin-top: 7px; padding: 11px 12px;
  border: 1px solid var(--line-bright); border-radius: 5px;
  background: #0b191f; color: var(--text); line-height: 1.4;
}
input:hover, select:hover, textarea:hover { border-color: var(--teal); }
input[type=checkbox] { display: inline; width: auto; margin-right: 8px; accent-color: var(--teal); }
textarea { resize: vertical; max-width: 100%; }
form { margin: 0 0 20px; }
form > button { margin-top: 6px; }
section { padding: 26px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; color: var(--muted); }
summary { cursor: pointer; color: var(--teal); }
details { border-top: 1px solid var(--line); padding-top: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-weight: 500; }
::selection { color: #fff; background: #446664; }
.eyebrow { color: var(--brass); font-size: .7rem; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; }
.ui-icon { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.brand { display: inline-flex; gap: 12px; align-items: center; color: var(--text); text-decoration: none; }
.brand-mark { width: 34px; height: 34px; color: var(--brass); flex-shrink: 0; }
.brand-name { font-size: .8rem; line-height: 1.35; font-weight: 700; letter-spacing: .15em; }
.brand-name small { display: block; color: var(--muted); font-size: .58rem; letter-spacing: .25em; font-weight: 400; margin-top: 3px; }
.account-page { min-height: 100dvh; background: radial-gradient(ellipse at 10% 20%, #1a363d70, transparent 55%), var(--sea-950); }
.account-header { max-width: 1280px; margin: auto; padding: 25px 40px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.account-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.account-nav a { color: var(--muted); text-decoration: none; padding: 8px 12px; border: 1px solid transparent; border-radius: 5px; font-size: .8rem; }
.account-nav a:hover { color: var(--text); background: var(--panel); }
body[data-page=home] a[href="/"].nav-link,
body[data-page=login] a[href="/login"],
body[data-page=admin] a[href="/admin"] { color: var(--teal); border-color: var(--line); background: #92c9c309; }
.account-layout { max-width: 1200px; margin: auto; display: grid; grid-template-columns: 1fr 1fr; gap: clamp(36px, 6vw, 90px); padding: 64px 40px 48px; align-items: start; }
.account-story { position: sticky; top: 40px; padding-top: 30px; }
.account-story h1 { font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.6rem, 4vw, 4.3rem); line-height: 1.12; letter-spacing: -.045em; font-weight: 400; margin: 20px 0 24px; }
.account-story h1 em { color: var(--brass); font-style: normal; }
.story-text { color: var(--muted); max-width: 390px; font-size: .95rem; }
.ship-illustration { display: block; width: 100%; max-width: 440px; margin: 36px 0 24px; color: var(--teal); }
.story-caption { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: .7rem; letter-spacing: .05em; }
.story-caption::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--brass); }
.account-content { min-width: 0; }
.account-content section { box-shadow: var(--shadow); margin-bottom: 18px; }
.account-content section > p:last-child { color: var(--muted); font-size: .83rem; margin-bottom: 0; }
.account-content form { max-width: none; }
.account-content .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
#message:empty { display: none; }
#message:not(:empty) { padding: 14px 18px; border: 1px solid var(--line); border-left: 3px solid var(--brass); border-radius: 5px; background: var(--panel-raised); font-size: .85rem; }
#profile { overflow-wrap: anywhere; color: var(--muted); margin-bottom: 16px; }
#active-game { margin-top: 12px; }
#account-games { padding-left: 20px; font-size: .85rem; }
#account-games:empty::after { content: "Здесь появятся завершённые партии."; color: var(--muted); }
#account-statistics { color: var(--muted); font-size: .85rem; }
.account-footer { max-width: 1200px; margin: auto; padding: 20px 40px 28px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: .7rem; border-top: 1px solid var(--line); }
@media (max-width: 850px) {
  .account-header { padding: 20px; flex-wrap: wrap; }
  .account-layout { grid-template-columns: 1fr; max-width: 620px; padding: 28px 20px; gap: 20px; }
  .account-story { position: static; padding-top: 0; }
  .account-story h1 { font-size: 2.8rem; }
  .ship-illustration, .story-caption { display: none; }
  .account-nav { gap: 0; }
  .account-nav a { padding: 8px; }
  .account-footer { margin: 0 20px; padding: 18px 0; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

.auth-switch { margin: 24px 0 0; color: var(--muted); }
.auth-help { margin-top: 24px; }
.auth-help form:last-child { margin-bottom: 0; }

/* Native modality blocks interaction; lock the page's scroll separately. */
html:has(dialog:modal), body:has(dialog:modal) { overflow: hidden; }
dialog:modal { overscroll-behavior: contain; }

#users-dialog, #audit-dialog, #games-dialog, #new-game-dialog {
  box-sizing: border-box;
  padding: clamp(16px, 4vw, 28px);
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
#users-dialog {
  width: min(42rem, calc(100% - 2rem));
  height: min(29rem, calc(100dvh - 2rem));
  min-width: min(20rem, calc(100% - 2rem));
  max-width: calc(100% - 2rem);
  min-height: min(25rem, calc(100dvh - 2rem));
  max-height: calc(100dvh - 2rem);
  resize: both;
  overflow: hidden;
}
#audit-dialog {
  width: min(72rem, calc(100% - 2rem));
  height: min(50rem, calc(100dvh - 2rem));
  overflow: hidden;
}
#audit { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
#games-dialog {
  width: min(48rem, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  overflow: hidden;
}
#games { min-height: 0; overflow: auto; overflow-wrap: anywhere; overscroll-behavior: contain; }
#new-game-dialog {
  width: min(36rem, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  overflow: auto;
}
#new-game-message:empty { display: none; }
#users-dialog::backdrop, #audit-dialog::backdrop, #games-dialog::backdrop, #new-game-dialog::backdrop { background: #080f13cc; }
#users-dialog[open], #audit-dialog[open], #games-dialog[open] { display: flex; flex-direction: column; }
.users-dialog-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
#users-dialog form, #audit-dialog form, #games-dialog form { margin: 0; }
#manage-users, .users-list { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#manage-users label { margin-block: 8px; }
#manage-users .actions { margin-bottom: 0; }
#manage-users button:disabled { opacity: .45; cursor: not-allowed; }
#manage-users select { display: block; width: 100%; min-width: 0; margin-top: 6px; }
#manage-users select[size] { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
#users-message:empty { display: none; }
#users-message { color: var(--brass); }
