:root {
  color-scheme: light;
  --bg: #f7f6f2;
  --panel: #ffffff;
  --ink: #1e2328;
  --muted: #69707a;
  --line: #d9dde3;
  --accent: #146c5d;
  --accent-dark: #0d4e44;
  --warn: #b94b35;
  --shadow: 0 18px 50px rgba(34, 39, 44, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app {
  min-height: 100vh;
}

.welcome {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.welcome__inner {
  width: min(640px, 100%);
  text-align: center;
}

.welcome__topline {
  display: inline-flex;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 10px;
}

.xtrix-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  text-decoration: none;
}

.xtrix-link__mark {
  display: inline-grid;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: #e3f2ec;
  color: var(--accent-dark);
  font-size: 22px;
  font-weight: 900;
}

.xtrix-link--compact {
  margin-top: 1px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.xtrix-link--sidebar {
  width: 100%;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
}

.xtrix-link__domain,
.xtrix-link__caption {
  display: block;
}

.xtrix-link__domain {
  font-size: 14px;
  font-weight: 900;
}

.xtrix-link__caption {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.eyebrow,
.label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 12px 0 28px;
  font-size: clamp(38px, 7vw, 72px);
  line-height: 1;
}

h2,
p {
  margin: 0;
}

.welcome__actions,
.dialog__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.how-to-play {
  margin: 28px auto 0;
  width: min(560px, 100%);
  text-align: left;
  color: var(--muted);
}

.how-to-play h2 {
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 22px;
}

.how-to-play ol {
  margin: 0;
  padding-left: 22px;
}

.how-to-play li {
  margin-bottom: 7px;
}

.language-switch {
  display: inline-grid;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.language-switch select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 7px 10px;
  font-weight: 700;
}

.language-switch--sidebar {
  margin-top: 22px;
}

.button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  padding: 10px 18px;
  font-weight: 700;
}

.button:hover {
  border-color: var(--accent);
}

.button--primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button--primary:hover {
  background: var(--accent-dark);
}

.icon-button {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.game {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #eef0ed;
  padding: 18px;
}

.sidebar__top,
.player-row,
.table__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.game-code {
  display: block;
  margin-top: 4px;
  font-size: 28px;
  letter-spacing: 2px;
  cursor: pointer;
}

.game-code-wrap {
  position: relative;
  display: inline-block;
}

.game-code-tip {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 4;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-3px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  white-space: nowrap;
}

.game-code-tip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.lock-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 22px 0;
  color: var(--muted);
}

.source-row {
  display: grid;
  gap: 6px;
  margin: 22px 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.source-row select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

.year-settings {
  display: grid;
  gap: 10px;
  margin: 22px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.year-settings__title {
  color: var(--ink);
  font-size: 14px;
}

.year-settings__bounds,
.year-settings__head,
.year-settings__weight-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: center;
}

.year-settings__bounds label {
  display: grid;
  gap: 5px;
}

.year-settings input,
.year-settings select {
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 7px 8px;
  font-weight: 700;
}

.year-settings__weights {
  display: grid;
  max-height: 220px;
  overflow: auto;
  gap: 6px;
  padding-right: 2px;
}

.players__list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.player-row {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 6px 8px 6px 12px;
}

.player-row.is-active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.feedback-box {
  margin-top: auto;
  padding-top: 24px;
}

.feedback-box__button {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
}

.feedback-box p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.remove-player {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: #f0d8d3;
  color: var(--warn);
  cursor: pointer;
}

.table {
  padding: 28px;
}

.table__header {
  margin-bottom: 20px;
}

.status {
  color: var(--muted);
  margin-bottom: 4px;
}

.message {
  scroll-margin-top: 18px;
  margin-bottom: 18px;
  border: 1px solid #ebc4b9;
  border-radius: 8px;
  background: #fff2ef;
  color: #793623;
  padding: 12px 14px;
  font-weight: 700;
}

.message--success {
  border-color: #9fcfba;
  background: #edf8f2;
  color: #1f6447;
}

.message--error {
  border-color: #ebc4b9;
  background: #fff2ef;
  color: #793623;
}

.year-error-panel {
  scroll-margin-top: 18px;
  display: grid;
  gap: 12px;
  margin: -6px 0 18px;
  border: 1px solid #d8c4a0;
  border-radius: 8px;
  background: #fff8ea;
  padding: 12px;
}

.year-error-panel p {
  margin: 0;
  color: #76592a;
  font-size: 14px;
  line-height: 1.4;
}

.year-error-panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.year-error-panel__song:empty {
  display: none;
}

.debug-panel {
  max-height: 360px;
  overflow: auto;
  margin: 0 0 18px;
  border: 1px solid #b8c7d9;
  border-radius: 8px;
  background: #f4f8fc;
  color: #1c344d;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font: 12px/1.45 Menlo, Consolas, monospace;
}

.preview-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.preview-panel audio {
  width: min(360px, 100%);
}

.boards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.board {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px;
}

.board__title {
  margin-bottom: 10px;
  font-size: 18px;
}

.song {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfbfa;
}

.song--success {
  border-color: #9fcfba;
  background: #edf8f2;
}

.song--error {
  border-color: #ebc4b9;
  background: #fff2ef;
}

.song__meta {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 4px;
}

.song__title {
  font-weight: 700;
}

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

.song__icon {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}

.song__icon:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.song__icon:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.song__doubt {
  border-color: #d8c4a0;
  background: #fff8ea;
  color: #8a5b13;
  font-weight: 800;
}

.add-slot {
  display: block;
  width: 100%;
  min-height: 28px;
  margin: 8px 0;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  background: #edf7f4;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.dialog {
  width: min(420px, calc(100% - 32px));
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.dialog::backdrop {
  background: rgba(20, 24, 28, 0.45);
}

.dialog form,
.field {
  display: grid;
  gap: 12px;
}

.field {
  margin-top: 16px;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.field input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
}

.form-error {
  min-height: 18px;
  color: var(--warn);
  font-size: 14px;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .welcome__topline {
    align-items: center;
    flex-direction: column;
    gap: 8px;
  }

  .xtrix-link--compact {
    margin-top: 0;
  }

  .game {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .table {
    padding: 18px;
  }

  .table__header,
  .preview-panel {
    align-items: flex-start;
    flex-direction: column;
  }
}
