:root {
  --ink: #34251b;
  --ink-soft: #68503d;
  --parchment: #f3e2bb;
  --parchment-light: #fff4d8;
  --parchment-deep: #d5b578;
  --wood: #542f1e;
  --wood-light: #815232;
  --red: #ba382f;
  --blue: #22669c;
  --green: #3f7653;
  --yellow: #c28c20;
  --orange: #cf642a;
  --brown: #74503a;
  --white-player: #f1eee3;
  --shadow: rgba(46, 25, 12, 0.2);
  --good: #34704a;
  --warning: #9c4f1d;
  --border: rgba(85, 50, 26, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 18% 15%, rgba(255, 225, 149, 0.2), transparent 30%),
    repeating-linear-gradient(90deg, rgba(43, 20, 8, 0.08) 0 3px, transparent 3px 22px),
    linear-gradient(145deg, #392012, #795034 45%, #362014);
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.wood-frame {
  width: min(1480px, calc(100% - 24px));
  min-height: calc(100vh - 24px);
  margin: 12px auto;
  border: 5px solid var(--wood);
  border-radius: 18px;
  background:
    linear-gradient(rgba(255, 246, 218, 0.78), rgba(239, 220, 175, 0.94)),
    radial-gradient(circle at 4px 6px, rgba(93, 62, 36, 0.09) 1px, transparent 2px);
  box-shadow: 0 12px 32px rgba(20, 9, 3, 0.43), inset 0 0 0 2px var(--parchment-deep);
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 2px solid var(--parchment-deep);
  background: rgba(255, 242, 207, 0.45);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand h1 {
  font-family: Georgia, serif;
  margin: 0;
  letter-spacing: 0.02em;
  font-size: clamp(1.35rem, 3vw, 2rem);
}

.kicker {
  color: var(--ink-soft);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.68rem;
  font-weight: bold;
  margin: 0 0 3px;
}

.brand-hex,
.player-hex {
  align-items: center;
  background: var(--red);
  color: white;
  display: inline-flex;
  font-weight: bold;
  height: 54px;
  justify-content: center;
  position: relative;
  width: 48px;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.save-indicator {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-right: 8px;
}

.app-shell {
  padding: clamp(14px, 2.7vw, 28px);
}

.hero {
  max-width: 950px;
  margin: clamp(26px, 8vh, 92px) auto;
  text-align: center;
}

.hero h2 {
  font-family: Georgia, serif;
  font-size: clamp(2rem, 5vw, 3.6rem);
  margin: 16px auto 12px;
  line-height: 1.12;
}

.hero p {
  max-width: 670px;
  margin: 0 auto 28px;
  color: var(--ink-soft);
  font-size: 1.08rem;
  line-height: 1.5;
}

.hex-row {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.decor-hex {
  height: 38px;
  width: 43px;
  background: var(--yellow);
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
}

.decor-hex:nth-child(2) {
  background: var(--green);
}

.decor-hex:nth-child(3) {
  background: var(--blue);
}

.action-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

button.primary,
button.secondary,
button.ghost,
.icon-btn {
  border-radius: 9px;
  padding: 11px 17px;
  border: 1px solid transparent;
  font-weight: bold;
  transition: transform 120ms ease, background 120ms ease;
}

button.primary:hover,
button.secondary:hover,
button.ghost:hover,
.icon-btn:hover {
  transform: translateY(-1px);
}

button.primary {
  background: var(--red);
  border-color: #8e2c25;
  color: white;
}

button.primary.small,
button.secondary.small,
button.ghost.small {
  padding: 8px 12px;
  font-size: 0.9rem;
}

button.secondary {
  background: var(--parchment-light);
  border-color: var(--parchment-deep);
  color: var(--ink);
}

button.ghost,
.icon-btn {
  color: var(--ink);
  background: transparent;
  border-color: var(--border);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.recover-card,
.panel,
.setup-section,
.winner-alert {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 246, 219, 0.7);
  box-shadow: 0 2px 7px var(--shadow);
}

.recover-card {
  margin: 30px auto 0;
  padding: 17px;
  max-width: 520px;
}

.recover-card p {
  margin: 0 0 12px;
  font-size: 0.92rem;
}

.setup {
  max-width: 1180px;
  margin: 0 auto;
}

.page-title {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 15px;
  margin-bottom: 18px;
}

.page-title h2,
.section-title h3 {
  font-family: Georgia, serif;
  margin: 0;
}

.page-title p {
  color: var(--ink-soft);
  margin: 4px 0 0;
}

.setup-grid {
  display: grid;
  gap: 14px;
}

.setup-section {
  padding: 18px;
}

.setup-section h3 {
  font-family: Georgia, serif;
  font-size: 1.2rem;
  margin: 0 0 12px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

label.field,
.input-label {
  display: flex;
  flex-direction: column;
  color: var(--ink-soft);
  gap: 5px;
  font-weight: bold;
  font-size: 0.85rem;
}

input,
select,
textarea {
  background: var(--parchment-light);
  color: var(--ink);
  border: 1px solid var(--parchment-deep);
  border-radius: 7px;
  padding: 9px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(34, 102, 156, 0.36);
  border-color: var(--blue);
}

.players-setup {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.player-setup-row {
  display: grid;
  grid-template-columns: 36px minmax(140px, 1.6fr) minmax(125px, 1fr) minmax(125px, 1fr);
  gap: 8px;
  align-items: center;
}

.player-index {
  color: var(--ink-soft);
  font-weight: bold;
}

.selection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 10px;
}

.check-card {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgba(255, 251, 236, 0.55);
}

.check-line {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: bold;
}

.check-line input {
  width: auto;
}

.scenario-list {
  margin: 9px 0 0 21px;
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
}

.scenario-list label {
  display: flex;
  align-items: start;
  gap: 6px;
}

.rule-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.rule-table th,
.rule-table td {
  padding: 7px 6px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.rule-table input {
  max-width: 82px;
  padding: 6px;
}

.muted {
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.dashboard {
  display: grid;
  gap: 15px;
}

.dashboard-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 15px;
  flex-wrap: wrap;
}

.dashboard-head h2 {
  font-family: Georgia, serif;
  margin: 0 0 3px;
}

.tag-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  background: rgba(63, 118, 83, 0.15);
  color: var(--green);
  font-size: 0.78rem;
  font-weight: bold;
  border-radius: 999px;
  padding: 4px 9px;
}

.winner-alert {
  border-color: #bd7f29;
  background: #fff0bd;
  padding: 13px 17px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
}

.winner-alert strong {
  display: block;
  font-family: Georgia, serif;
  color: var(--warning);
  font-size: 1.15rem;
}

.player-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(174px, 1fr));
  gap: 10px;
}

.player-card {
  position: relative;
  border: 2px solid var(--player-accent, var(--brown));
  background: rgba(255, 248, 226, 0.86);
  border-radius: 12px;
  padding: 12px;
  text-align: left;
}

.player-card-top {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
}

.player-card .player-hex {
  width: 43px;
  height: 48px;
  background: var(--player-accent, var(--brown));
  color: var(--player-ink, #fff);
  font-size: 0.68rem;
}

.player-card h3 {
  margin: 0;
  font-size: 1rem;
}

.score-total {
  font-size: 1.55rem;
  font-weight: bold;
}

.score-target {
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.river-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.river-badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: bold;
  padding: 3px 7px;
}

.river-badge.good {
  background: rgba(52, 112, 74, 0.14);
  color: var(--good);
}

.river-badge.bad {
  background: rgba(156, 79, 29, 0.14);
  color: var(--warning);
}

.panel {
  padding: 14px;
  overflow: hidden;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.score-table-wrap {
  overflow-x: auto;
}

.score-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 760px;
  width: 100%;
}

.score-table th,
.score-table td {
  border-bottom: 1px solid var(--border);
  padding: 7px;
  text-align: center;
  white-space: nowrap;
}

.score-table th:first-child,
.score-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #f5e4bc;
  text-align: left;
  min-width: 180px;
}

.score-table thead th {
  font-size: 0.9rem;
}

.category-note {
  display: block;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: normal;
}

.counter {
  align-items: center;
  display: inline-flex;
  gap: 4px;
}

.counter button {
  border: 1px solid var(--parchment-deep);
  background: var(--parchment-light);
  height: 27px;
  width: 27px;
  border-radius: 5px;
  padding: 0;
}

.counter input {
  padding: 4px;
  text-align: center;
  width: 48px;
}

.dashboard-columns {
  display: grid;
  grid-template-columns: minmax(310px, 1.15fr) minmax(300px, 0.85fr);
  gap: 14px;
}

.award-list,
.suggestion-list,
.history-list,
.session-list {
  display: grid;
  gap: 8px;
}

.award-row,
.suggestion,
.session-row {
  display: grid;
  grid-template-columns: minmax(135px, 1fr) minmax(135px, 1fr) auto;
  align-items: center;
  gap: 7px;
}

.award-row select {
  min-width: 0;
}

.award-state {
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.suggestion {
  border-left: 3px solid var(--yellow);
  background: rgba(194, 140, 32, 0.12);
  padding: 9px;
  grid-template-columns: 1fr auto;
}

.suggestion p {
  margin: 0;
  font-size: 0.88rem;
}

.history-list {
  max-height: 340px;
  overflow-y: auto;
}

.history-entry {
  padding: 8px;
  border-bottom: 1px dotted var(--border);
  font-size: 0.88rem;
}

.history-entry time {
  color: var(--ink-soft);
  display: block;
  font-size: 0.75rem;
}

.session-row {
  background: rgba(255, 251, 236, 0.55);
  border-radius: 8px;
  padding: 9px;
}

.modal-backdrop {
  align-items: center;
  background: rgba(25, 13, 6, 0.62);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 10;
}

.modal {
  background: var(--parchment);
  border: 4px solid var(--wood);
  border-radius: 15px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  padding: 18px;
  width: min(1050px, 100%);
}

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

.modal-head h2 {
  font-family: Georgia, serif;
  margin: 0;
}

.scorecard-grid {
  display: grid;
  grid-template-columns: minmax(240px, 0.7fr) minmax(330px, 1.3fr);
  gap: 14px;
}

.breakdown {
  width: 100%;
  border-collapse: collapse;
}

.breakdown td {
  padding: 6px 3px;
  border-bottom: 1px solid var(--border);
}

.breakdown td:last-child {
  text-align: right;
  font-weight: bold;
}

.route-card {
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 10px;
  margin-bottom: 9px;
  background: rgba(255, 248, 227, 0.65);
}

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

.segment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.segment {
  background: #e2c88e;
  border-radius: 7px;
  border: 1px solid var(--parchment-deep);
  padding: 6px;
  font-size: 0.76rem;
  text-align: center;
}

.segment.camel {
  border-color: var(--yellow);
  background: #f5da82;
}

.segment button {
  font-size: 0.72rem;
  border: none;
  color: var(--ink-soft);
  background: transparent;
  display: block;
  margin-top: 4px;
}

.route-controls,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.wonder-grid,
.fact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.toast-root {
  bottom: 18px;
  position: fixed;
  right: 18px;
  z-index: 20;
}

.toast {
  color: white;
  background: var(--wood);
  border-radius: 8px;
  box-shadow: 0 4px 17px rgba(0, 0, 0, 0.3);
  margin-top: 8px;
  padding: 12px 15px;
  max-width: 360px;
}

@media (max-width: 850px) {
  .dashboard-columns,
  .scorecard-grid {
    grid-template-columns: 1fr;
  }

  .app-header {
    align-items: start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: start;
  }
}

@media (max-width: 620px) {
  .wood-frame {
    margin: 0;
    min-height: 100vh;
    width: 100%;
    border-radius: 0;
    border-width: 0;
  }

  .app-header,
  .app-shell {
    padding: 13px;
  }

  .player-setup-row {
    grid-template-columns: 27px 1fr;
  }

  .player-setup-row select {
    grid-column: 2;
  }

  .award-row,
  .session-row {
    grid-template-columns: 1fr;
  }

  .winner-alert {
    flex-direction: column;
    align-items: start;
  }

  .modal-backdrop {
    align-items: start;
    padding: 0;
  }

  .modal {
    max-height: 100vh;
    min-height: 100vh;
    width: 100%;
    border-radius: 0;
    border-width: 0;
  }
}
