:root {
  color-scheme: light;
  --ink: #17211b;
  --muted: #66736c;
  --line: #d6ddd7;
  --panel: #f8faf7;
  --paper: #ffffff;
  --accent: #207c62;
  --accent-2: #b7453f;
  --gold: #b98928;
  --tile: #fffdf7;
  --tile-edge: #d5cec0;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #e7ece8;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  cursor: pointer;
}

button:hover {
  border-color: #9ab4a7;
}

button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.app {
  min-height: 100vh;
  padding: 18px;
}

.workspace {
  max-width: 1500px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 14px;
}

.app-tabs {
  display: flex;
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  background: #f0f4f1;
  border-radius: 8px;
}

.app-tab {
  border-color: transparent;
  background: transparent;
}

.app-tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
}

#status {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.modebar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.view[hidden] {
  display: none;
}

.content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.left-pane,
.advisor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.left-pane {
  padding: 14px;
}

.quick-input {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.claim-input {
  display: grid;
  grid-template-columns: auto minmax(72px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 6px;
}

.claim-input span {
  color: var(--muted);
  font-size: 13px;
}

.claim-input strong {
  font-size: 18px;
}

.claim-input button {
  min-height: 32px;
  padding: 0 10px;
}

.quick-input label {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.quick-input input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: var(--paper);
  color: var(--ink);
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.summary div {
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 6px;
}

.summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary strong {
  display: block;
  font-size: 22px;
  line-height: 1.25;
}

#board {
  display: block;
  width: 100%;
  aspect-ratio: 31 / 18;
  border: 1px solid #c9d3cb;
  background: #eef3ef;
  border-radius: 8px;
}

#battleBoard {
  display: block;
  width: 100%;
  aspect-ratio: 62 / 45;
  border: 1px solid #c9d3cb;
  background: #eef3ef;
  border-radius: 8px;
}

.advisor {
  padding: 14px;
  position: sticky;
  top: 18px;
}

.advisor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.battle-head-actions {
  display: flex;
  gap: 8px;
}

.best-move {
  min-height: 76px;
  padding: 12px;
  border: 1px solid #c9d3cb;
  background: var(--paper);
  border-radius: 8px;
  margin-bottom: 12px;
}

.best-move .tile-name {
  display: block;
  font-size: 28px;
  font-weight: 750;
  line-height: 1.1;
}

.best-move .meta {
  color: var(--muted);
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.35;
}

.recommendations {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
  max-height: min(56vh, 620px);
  overflow: auto;
}

.recommendations li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 6px;
  cursor: pointer;
}

.recommendations li:first-child {
  border-color: #93b7a8;
  box-shadow: inset 4px 0 0 var(--accent);
}

.rank {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.rec-name {
  font-weight: 700;
}

.rec-value {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.waits {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.battle-content {
  grid-template-columns: minmax(0, 1fr) 320px;
}

.battle-table-pane {
  padding: 14px;
}

.battle-sidebar {
  min-height: 320px;
}

.battle-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.battle-summary strong {
  font-size: 20px;
}

.battle-message {
  min-height: 96px;
  line-height: 1.45;
}

.battle-message .tile-name {
  font-size: 23px;
}

.claim-advice {
  border-color: #cfb06a;
  background: #fffaf0;
}

.battle-hint {
  border-color: #93b7a8;
  background: #f2faf5;
}

.hint-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.hint-list div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.hint-list span {
  color: var(--ink);
  font-weight: 700;
}

.battle-log {
  max-height: min(58vh, 560px);
}

.battle-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.battle-actions[hidden] {
  display: none;
}

.battle-actions button {
  min-width: 0;
  font-weight: 700;
}

.battle-log li {
  grid-template-columns: 64px minmax(0, 1fr);
  cursor: default;
}

@media (max-width: 980px) {
  .app {
    padding: 10px;
  }

  .topbar,
  .content {
    display: block;
  }

  .topbar {
    align-items: stretch;
  }

  .app-tabs,
  .modebar {
    justify-content: flex-start;
    margin-top: 12px;
  }

  .toolbar {
    justify-content: flex-start;
    margin-top: 12px;
  }

  .advisor {
    position: static;
    margin-top: 12px;
  }

  .quick-input {
    grid-template-columns: 1fr auto;
  }

  .quick-input label {
    grid-column: 1 / -1;
  }

  h1 {
    font-size: 24px;
  }
}
