:root {
  --bg-page: #F5F4EF;
  --bg-primary: #FFFFFF;
  --bg-secondary: #EDEBE3;
  --bg-tertiary: #E1DED4;
  --bg-success: #EAF3DE;
  --bg-danger: #FCEBEB;
  --bg-accent: #DCE7F1;
  --text-primary: #2C2C2A;
  --text-secondary: #5F5E5A;
  --text-tertiary: #8A867E;
  --text-success: #3B6D11;
  --text-danger: #A32D2D;
  --text-accent: #185FA5;
  --border: rgba(60,60,55,0.15);
  --border-2: rgba(60,60,55,0.3);
  --radius-md: 8px;
  --radius-lg: 12px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-primary);
  margin: 0;
  padding: 20px;
}

/* PAGRINDINIS LAYOUTAS - paprastas, kaip iš pradžių.
   Centruojam per margin:auto, ne per body flex - style.css (kraunamas po sim.css)
   landing'ui nustato body flex-direction:column ir sulaužydavo flex centravimą. */
.sim-wrap { max-width: 680px; width: 100%; margin: 0 auto; }

body.display-medium .sim-wrap { max-width: 1020px; }
body.display-fullscreen .sim-wrap { max-width: 100%; }

/* ---- Viršutinė juosta: brand (stilius iš style.css) + auth + kalbos ---- */
.sim-topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.sim-topbar .brand { font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

/* ---- Užduoties juosta: pasirinkimas, rekordas, aplinka, veiksmai ---- */
.task-bar {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px; margin-bottom: 12px;
}
.task-picker { position: relative; flex: 1 1 auto; min-width: 220px; max-width: 360px; }
.task-btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 0.5px solid var(--border-2); border-radius: 10px;
  font-family: inherit; font-size: 13px; color: var(--text-primary);
  cursor: pointer; text-align: left;
}
.task-btn:hover { border-color: var(--text-accent); }
.task-stars { color: #e8a33d; font-size: 12px; letter-spacing: 1px; white-space: nowrap; }
.task-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.task-caret { color: var(--text-tertiary); font-size: 10px; }
.task-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 60;
  min-width: 100%; width: max-content; max-width: min(420px, 92vw);
  max-height: 60vh; overflow-y: auto;
  background: var(--bg-primary);
  border: 0.5px solid var(--border-2); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(20, 20, 15, 0.18);
  padding: 6px;
}
.task-item {
  display: flex; gap: 10px; align-items: flex-start; width: 100%;
  padding: 8px 10px;
  background: transparent; border: none; border-radius: 8px;
  font-family: inherit; color: var(--text-primary);
  cursor: pointer; text-align: left;
}
.task-item:hover { background: var(--bg-secondary); }
.task-item.active { background: var(--bg-accent); }
.task-item .task-stars { padding-top: 1px; }
.task-item-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.t-name { font-size: 13px; font-weight: 500; }
.t-desc { font-size: 11px; color: var(--text-secondary); line-height: 1.35; }

/* Pill ženkliukai: rekordas ir aplinkos indikatorius */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 999px;
  background: var(--bg-primary); border: 0.5px solid var(--border);
  font-family: inherit; font-size: 12px; color: var(--text-secondary);
  cursor: pointer;
}
.chip:hover { border-color: var(--border-2); color: var(--text-primary); }
.chip[hidden] { display: none; }
.dir-arrow { display: inline-block; font-size: 11px; line-height: 1; }

/* Aplinkos slankikliai užduočių juostoje (dubliuoja Settings -> Environment) */
.env-panel {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px;
  padding: 5px 14px; border-radius: 999px;
  background: var(--bg-primary); border: 0.5px solid var(--border);
}
.env-ctl { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.env-ctl-ico { font-size: 12px; line-height: 1; }
.env-ctl input[type=range] { width: 62px; margin: 0; accent-color: var(--text-accent); cursor: pointer; }
.env-ctl-val {
  font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary);
  font-variant-numeric: tabular-nums; min-width: 30px;
}
.env-ctl .dir-arrow { color: var(--text-accent); font-size: 12px; }

/* Selektoriai su .task-actions - kad nugalėtų vėliau faile einantį bendrą .btn
   (ir style.css .btn, kuris kraunamas po sim.css) */
.task-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.task-actions .btn-reset {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--text-accent); color: #fff; border-color: var(--text-accent);
  border-radius: 999px; padding: 7px 16px; font-weight: 500; font-size: 13px;
}
.task-actions .btn-reset:hover { background: #134578; }
.task-actions .btn-icon {
  width: 34px; height: 34px; padding: 0; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; line-height: 1;
  color: var(--text-secondary);
}
.task-actions .btn-icon:hover { color: var(--text-primary); background: var(--bg-secondary); }
.task-actions .btn-icon svg { width: 17px; height: 17px; display: block; flex-shrink: 0; }

/* Canvas - dydis fiksuotas, kaip senai veikė */
.canvas-wrap {
  position: relative;
}
canvas {
  display: block;
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  background: #123f52;
  width: 100%;
  max-width: 660px;
  height: 420px;
  cursor: crosshair;
  outline: none;
}

/* Medium: didesnis canvas */
body.display-medium canvas {
  max-width: 1000px;
  height: 640px;
}

/* Fullscreen: canvas užima 90% lango aukščio, plotis kiek leidžia tėvas */
body.display-fullscreen canvas {
  max-width: 100%;
  height: calc(100vh - 190px);  /* 190px = topbar + task-bar + keys-row + info-bar + paddings */
}

.keys-row {
  margin-top: 12px; font-size: 12px;
  color: var(--text-secondary); line-height: 1.9;
}
.kbd {
  font-family: var(--font-mono); font-size: 11px;
  padding: 1px 5px; background: var(--bg-secondary);
  border: 0.5px solid var(--border); border-radius: 4px;
  color: var(--text-primary);
}

.btn {
  background: transparent; border: 0.5px solid var(--border-2);
  padding: 6px 14px; border-radius: var(--radius-md);
  font-family: inherit; font-size: 13px; cursor: pointer;
  color: var(--text-primary);
}
.btn:hover { background: var(--bg-secondary); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--text-accent); color: white; border-color: var(--text-accent); }
.btn-primary:hover { background: #134578; }

.banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  display: none;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.banner.show { display: block; }
.banner.ok { background: var(--bg-success); color: var(--text-success); }
.banner.bad { background: var(--bg-danger); color: var(--text-danger); }

.info-bar {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: var(--text-tertiary);
  font-style: italic;
}
.info-bar .lang-switcher { font-style: normal; }

.lang-switcher {
  display: flex;
  gap: 4px;
  font-size: 11px;
}
.lang-switcher button {
  background: transparent;
  border: none;
  padding: 3px 7px;
  cursor: pointer;
  color: var(--text-tertiary);
  font-family: inherit;
  font-size: 11px;
  border-radius: 3px;
}
.lang-switcher button:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}
.lang-switcher button.active {
  color: var(--text-accent);
  font-weight: 500;
}

/* ============= MODAL ============= */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20,20,18,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  width: 100%; max-width: 640px;
  max-height: 90vh; display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 0.5px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 16px; font-weight: 500; }
.modal-close {
  background: transparent; border: none;
  font-size: 22px; cursor: pointer; color: var(--text-secondary);
  width: 28px; height: 28px; line-height: 1; padding: 0;
  border-radius: 4px;
}
.modal-close:hover { background: var(--bg-secondary); }

.tabs {
  display: flex; gap: 2px;
  border-bottom: 0.5px solid var(--border);
  padding: 0 12px;
  flex-wrap: wrap;
}
.tab {
  background: transparent; border: none;
  padding: 10px 14px; cursor: pointer;
  font-family: inherit; font-size: 13px; color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text-primary); }
.tab.active {
  color: var(--text-accent); font-weight: 500;
  border-bottom-color: var(--text-accent);
}
.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
}
.tab-content { display: none; }
.tab-content.active { display: block; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px;
  border-top: 0.5px solid var(--border);
  background: var(--bg-secondary);
}

.section-header {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-accent);
  margin: 6px 0 10px;
  padding-bottom: 4px;
  border-bottom: 0.5px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.section-header:not(:first-child) { margin-top: 18px; }

.field-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  margin-bottom: 4px;
}
.field { display: flex; flex-direction: column; gap: 3px; }
.field-label { font-size: 12px; color: var(--text-secondary); }
.field-input-wrap { display: flex; align-items: center; gap: 6px; }
.field-input-wrap input[type=number],
.field-input-wrap input[type=text],
.field-input-wrap select {
  flex: 1; padding: 5px 7px;
  border: 0.5px solid var(--border-2); border-radius: 4px;
  font-family: var(--font-mono); font-size: 12px;
  background: var(--bg-primary); color: var(--text-primary);
  min-width: 0;
}
.field-input-wrap select { font-family: inherit; cursor: pointer; }
.field-input-wrap input[type=checkbox] { margin: 4px 0; }
.field-unit { font-size: 11px; color: var(--text-secondary); white-space: nowrap; }
.field-hint {
  font-size: 10px; color: var(--text-tertiary);
  font-style: italic; margin-top: 1px;
}
.field.full { grid-column: 1 / -1; }

.profile-intro {
  margin: 0 0 14px; font-size: 12px;
  color: var(--text-secondary); line-height: 1.5;
}
.profile-row {
  display: grid;
  grid-template-columns: 24px 1fr auto auto auto;
  gap: 8px; align-items: center;
  padding: 8px 0;
  border-bottom: 0.5px solid var(--border);
}
.profile-row:last-child { border-bottom: none; }
.profile-num { font-weight: 500; color: var(--text-secondary); }
.profile-name {
  padding: 5px 8px;
  border: 0.5px solid var(--border-2); border-radius: 4px;
  font-family: inherit; font-size: 13px;
  background: var(--bg-primary); color: var(--text-primary);
}
.profile-row .btn { padding: 4px 10px; font-size: 12px; }
.profile-row .profile-delete {
  width: 26px; height: 26px; padding: 0;
  font-size: 14px; line-height: 1;
}

/* ============= AUTH + REKORDAI ============= */

/* Rekordo ženkliukas task-bar'e (bazinis stilius - .chip) */
.record-line .record-mine { color: var(--text-tertiary); }
.record-note { font-weight: 500; }
.record-note.ok { color: var(--text-success); }
.record-note.bad { color: var(--text-danger); }

.info-right {
  display: flex; align-items: center; gap: 14px;
  font-style: normal;
}
.auth-area { display: flex; align-items: center; gap: 7px; min-height: 24px; }
@keyframes auth-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(24, 95, 165, 0); }
  50% { box-shadow: 0 0 0 7px rgba(24, 95, 165, 0.30); }
}
.auth-area.pulse { animation: auth-pulse 0.9s ease 3; border-radius: 6px; }
.auth-area img { width: 20px; height: 20px; border-radius: 50%; }
.auth-name { font-size: 11px; color: var(--text-secondary); }
.auth-logout {
  background: transparent; border: none;
  padding: 3px 7px; cursor: pointer;
  color: var(--text-tertiary);
  font-family: inherit; font-size: 11px; border-radius: 3px;
}
.auth-logout:hover { color: var(--text-primary); background: var(--bg-secondary); }

.records-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.records-table th {
  text-align: left; font-size: 11px; font-weight: 500;
  color: var(--text-secondary);
  padding: 4px 8px;
  border-bottom: 0.5px solid var(--border-2);
}
.records-table td { padding: 6px 8px; border-bottom: 0.5px solid var(--border); }
.records-table td.rank { color: var(--text-tertiary); width: 28px; }
.records-table td.time {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.records-table .user-cell { display: flex; align-items: center; gap: 8px; }
.records-table .user-cell img { width: 22px; height: 22px; border-radius: 50%; }
.records-my-best { margin-top: 10px; font-size: 12px; color: var(--text-secondary); }
.records-all-link { display: inline-block; margin-top: 12px; font-size: 13px; }

/* Rekordų puslapis (records.html).
   body.records-body specifiškumas nugali style.css body taisykles:
   grąžinam paddingą (html,body {padding:0}) ir turinį lygiuojam į viršų,
   ne į vertikalų centrą (body flex-column + justify-content išvestinė). */
body.records-body {
  background: var(--bg-page);
  padding: 20px 20px 48px;
  justify-content: flex-start;
  align-items: center;
}
body.records-body .sim-wrap { max-width: 1020px; }
.records-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px 16px;
  margin: 10px 0 18px;
}
.records-head h1 {
  margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.01em;
}
.records-back {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: 999px;
  background: var(--text-accent); color: #fff;
  font-size: 13px; font-weight: 500; white-space: nowrap;
}
.records-back:hover { background: #134578; color: #fff; }
.records-page {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.records-card {
  background: var(--bg-primary);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px 10px;
}
.records-card h2 {
  font-size: 14px; font-weight: 600; margin: 0 0 8px;
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  padding-bottom: 8px;
  border-bottom: 0.5px solid var(--border);
}
.records-card .records-table { width: 100%; }
.records-card .records-table tbody tr:last-child td { border-bottom: none; }
/* TOP 3 vietos paryškintos "medalių" spalvomis */
.records-card .records-table tbody tr:nth-child(1) td.rank { color: #d9971f; font-weight: 700; }
.records-card .records-table tbody tr:nth-child(2) td.rank { color: #8f979f; font-weight: 600; }
.records-card .records-table tbody tr:nth-child(3) td.rank { color: #b4713f; font-weight: 600; }
.records-stars { color: #e8a33d; font-size: 12px; white-space: nowrap; }
.records-empty { color: var(--text-tertiary); font-size: 12px; font-style: italic; padding: 2px 0 8px; }
/* Kraunama / klaida - per visą tinklelio plotį */
.records-page > .records-status {
  grid-column: 1 / -1;
  text-align: center; padding: 48px 0; font-size: 13px;
}

/* Jūrinio stiliaus pranešimas virš canvas apačios (svečio TOP 10 laikas) -
   tamsus "prietaiso stiklas" su mėtiniu akcentu kaip kontaktų racijoje */
.sea-toast {
  position: absolute; left: 50%; bottom: 26px;
  transform: translate(-50%, 14px);
  display: flex; align-items: center; gap: 10px;
  max-width: min(86%, 460px);
  padding: 10px 16px;
  background: linear-gradient(180deg, rgba(16,52,70,0.96), rgba(10,36,50,0.96));
  border: 1px solid rgba(127,240,200,0.45);
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0,10,20,0.45), inset 0 1px 0 rgba(255,255,255,0.08);
  color: #eaf6f2; font-size: 13px; line-height: 1.45;
  opacity: 0; pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
  z-index: 12;
}
.sea-toast.show { opacity: 1; transform: translate(-50%, 0); }
.sea-toast-flag { font-size: 18px; }

/* Pagalbos modalas */
.help-modal { max-width: 480px; }
.help-goal, .help-text {
  margin: 2px 0 12px; font-size: 13px;
  color: var(--text-secondary); line-height: 1.5;
}
.help-keys { border-collapse: collapse; margin: 2px 0 6px; }
.help-keys td { padding: 4px 12px 4px 0; font-size: 13px; vertical-align: top; }
.help-keys td:first-child { white-space: nowrap; }
.help-list {
  margin: 2px 0 6px; padding-left: 18px;
  font-size: 13px; color: var(--text-secondary); line-height: 1.5;
}
.help-list li { margin: 3px 0; }

/* Svečio užrakto juosta nustatymų tabuose (Boat/Environment/Physics/Profile) */
.guest-lock {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px 12px;
  margin: 0 0 14px; padding: 10px 12px;
  background: var(--bg-accent);
  border: 0.5px solid var(--border);
  border-radius: 6px;
  font-size: 12px; color: var(--text-accent);
  line-height: 1.4;
}

.account-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 8px;
  font-size: 13px; color: var(--text-secondary);
}
.account-row .profile-name { flex: 1; }
.account-delete { color: var(--text-danger); border-color: var(--text-danger); }
.account-delete:hover { background: var(--bg-danger); }

@media (max-width: 520px) {
  .field-grid { grid-template-columns: 1fr; }
  .profile-row {
    grid-template-columns: 24px 1fr;
    grid-template-areas:
      "num name"
      "btns btns";
  }
  .profile-num { grid-area: num; }
  .profile-name { grid-area: name; }
  .profile-row > .btn,
  .profile-row > .profile-delete {
    grid-area: btns;
  }
}
