:root {
  --bg: #0b0d0a;
  --panel: #171913;
  --panel-2: #24251b;
  --text: #f0eadb;
  --muted: #b7ae99;
  --line: #49412f;
  --accent: #c8923c;
  --danger: #b75a43;
  --good: #7fa35d;
  --chip: #332f22;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.42);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

body {
  min-height: 100vh;
}

button,
select,
textarea {
  font: inherit;
}

button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;
}

button:hover {
  border-color: #85734d;
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

button.primary {
  background: linear-gradient(180deg, #d6a24a, #8e5d1d);
  color: #1b1307;
  border-color: #d0a04e;
}

button.good {
  background: #344a28;
  border-color: #6f9250;
}

button.ghost {
  background: transparent;
}

select {
  width: 100%;
  background: #10120d;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 16px;
}

label {
  display: block;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 6px;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 14px 0;
}

.siteHeader {
  padding: 22px 16px 12px;
  background:
    radial-gradient(900px 300px at 18% -10%, rgba(200, 146, 60, 0.24), transparent),
    radial-gradient(700px 260px at 82% 0%, rgba(86, 112, 58, 0.16), transparent),
    linear-gradient(180deg, #151811, #0b0d0a);
  border-bottom: 1px solid var(--line);
}

.wrap {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
}

.headerBar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.languageSwitcher {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.languageSwitcher button {
  min-width: 38px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 12px;
}

.languageSwitcher button.active {
  background: var(--accent);
  border-color: #e2b35f;
  color: #1b1307;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(26px, 5vw, 42px);
  line-height: 1.08;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 18px;
  margin: 0 0 12px;
}

.sub,
.hint,
.footerNote {
  color: var(--muted);
  line-height: 1.45;
}

.sub {
  margin: 0;
  max-width: 820px;
}

.hint,
.footerNote {
  font-size: 12px;
}

.appShell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 16px 0;
}

@media (min-width: 900px) {
  .appShell {
    grid-template-columns: minmax(420px, 0.9fr) minmax(720px, 1.1fr);
    align-items: start;
  }
}

@media (min-width: 900px) and (max-width: 1200px) {
  .appShell {
    grid-template-columns: 1fr;
  }
}

.card {
  background: linear-gradient(180deg, var(--panel), #10120d);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.fieldRow,
.buttonRow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.topGap {
  margin-top: 10px;
}

.startRows {
  display: grid;
  gap: 10px;
}

.startRow {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-radius: 14px;
  background: rgba(200, 146, 60, 0.045);
  border: 1px solid rgba(201, 170, 111, 0.12);
}

.startPicker {
  display: grid;
  grid-template-columns: repeat(7, minmax(34px, 1fr));
  gap: 6px;
}

.startValueBtn {
  min-height: 46px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid #5d523a;
  background: #11140f;
  color: #c9bea4;
  font-size: 16px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: rgba(200, 146, 60, 0.25);
}

.startValueBtn:hover {
  border-color: #927a4d;
  background: #1d2118;
}

.startValueBtn.active {
  background: var(--accent);
  border-color: #e2b35f;
  color: #1b1307;
}

.startValueBtn.goal:not(.active) {
  box-shadow: inset 0 0 0 2px rgba(127, 163, 93, 0.55);
}

.startValueBtn:focus-visible {
  outline: 3px solid rgba(200, 146, 60, 0.38);
  outline-offset: 2px;
}

.matrixWrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 14px;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 8px;
  text-align: center;
}

th {
  background: #12150f;
  color: var(--muted);
  font-size: 12px;
}

tr:last-child td {
  border-bottom: 0;
}

td:last-child,
th:last-child {
  border-right: 0;
}

.relBtn {
  width: 100%;
  min-width: 72px;
  padding: 8px 6px;
  border-radius: 10px;
  font-size: 12px;
}

.relBtn.same {
  background: #283d21;
  border-color: #698d4f;
  color: #e5f0d6;
}

.relBtn.opposite {
  background: #4a2b20;
  border-color: #9b6244;
  color: #f7dfcf;
}

.relBtn.none {
  background: #222117;
  color: #b7ae99;
}

.relBtn.fixed {
  opacity: 0.78;
  cursor: default;
}

.workArea {
  margin-top: 14px;
}

.status {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #10130e;
  border: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.45;
}

.status.ok {
  color: #e5f0d6;
  border-color: #526f3e;
  background: #152013;
}

.status.bad {
  color: #f7dfcf;
  border-color: #7a3f2e;
  background: #281711;
}

.solution {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 9px;
  border-radius: 999px;
  background: var(--chip-bg, var(--chip));
  border: 1px solid var(--chip-border, #5a4d31);
  color: var(--chip-text, #f8fbff);
  font-size: 13px;
  font-weight: 650;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}

.chip.color1 {
  --chip-bg: #1d4ed8;
  --chip-border: #93c5fd;
}

.chip.color2 {
  --chip-bg: #047857;
  --chip-border: #6ee7b7;
}

.chip.color3 {
  --chip-bg: #b45309;
  --chip-border: #fcd34d;
}

.chip.color4 {
  --chip-bg: #7e22ce;
  --chip-border: #d8b4fe;
}

.chip.color5 {
  --chip-bg: #be123c;
  --chip-border: #fda4af;
}

.chip.done {
  opacity: 0.45;
  text-decoration: line-through;
}

.copyArea {
  width: 100%;
  min-height: 88px;
  margin-top: 10px;
  background: #10120d;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.srOnly {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.siteFooter {
  padding: 0 0 18px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.donateForm {
  margin: 0 0 10px;
}

.donateForm input[type="image"] {
  display: block;
}

.siteFooter p {
  margin: 0;
}

.siteFooter .donateText {
  margin-bottom: 8px;
}

@media (max-width: 480px) {
  .wrap {
    width: min(100% - 20px, 1440px);
  }

  .card {
    padding: 12px;
  }

  .headerBar {
    align-items: center;
  }

  .startRow {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .startPicker {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
  }

  .startValueBtn {
    min-height: 42px;
    font-size: 15px;
  }

}
