:root {
  --bg-top: #1d1408;
  --bg-bottom: #0b0a08;
  --panel: rgba(26, 20, 12, 0.9);
  --panel-border: rgba(227, 187, 94, 0.28);
  --panel-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  --text-main: #f6edd7;
  --text-soft: #c8bb98;
  --accent: #e3bb5e;
  --accent-strong: #f5d789;
  --fog: #030303;
  --hex-width: 76px;
  --hex-height: 88px;
  --hex-gap: 2px;
  --hex-overlap: 18px;
  --row-offset: calc(var(--hex-width) / 2);
  --grid-scale: 1;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at top, rgba(227, 187, 94, 0.12), transparent 30%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

button {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 24px;
  min-height: 100vh;
  padding: 24px;
}

.sidebar,
.board-area {
  min-height: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: calc(100vh - 48px);
  overflow: hidden;
}

.panel,
.board-area {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(10px);
}

.panel {
  padding: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.78rem;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

h1 {
  font-size: 2rem;
  line-height: 1.1;
}

h2 {
  font-size: 1.45rem;
}

.lede,
.palette-header p,
.board-hint,
.current-tile-card p {
  color: var(--text-soft);
}

.lede {
  margin: 12px 0 0;
  font-size: 1rem;
  line-height: 1.5;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.utility-panel {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  flex-shrink: 0;
}

.palette-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.label {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--text-soft);
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.current-tile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(227, 187, 94, 0.12);
}

.current-tile-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1.05rem;
}

.current-tile-card p {
  margin: 0;
}

.history-panel {
  width: 100%;
}

.history-copy,
.history-status,
.schedule-note {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.45;
}

.history-copy {
  margin-bottom: 12px;
}

.history-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-bottom: 10px;
}

.history-select {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(227, 187, 94, 0.2);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  font: inherit;
}

.history-select:focus-visible {
  outline: 2px solid rgba(245, 215, 137, 0.45);
  outline-offset: 2px;
}

.secondary-button {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(227, 187, 94, 0.26);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.secondary-button:hover,
.secondary-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(245, 215, 137, 0.55);
  background: rgba(255, 255, 255, 0.08);
}

.secondary-button:disabled,
.history-select:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.history-status {
  min-height: 2.8em;
  margin-bottom: 8px;
}

.schedule-note {
  font-size: 0.92rem;
}

.reset-button {
  padding: 10px 14px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #d1492a, #8d2313);
  color: #fff7ef;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
  box-shadow: 0 10px 24px rgba(141, 35, 19, 0.35);
  align-self: flex-start;
}

.reset-button:hover,
.reset-button:focus-visible {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 14px 28px rgba(141, 35, 19, 0.45);
}

.palette-header {
  margin-bottom: 14px;
}

.palette-header p {
  margin: 8px 0 0;
}

.tile-palette {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.tile-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border-radius: 16px;
  border: 1px solid rgba(227, 187, 94, 0.14);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-main);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
  text-align: left;
}

.tile-option:hover,
.tile-option:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(245, 215, 137, 0.45);
  background: rgba(255, 255, 255, 0.05);
}

.tile-option.active {
  border-color: rgba(245, 215, 137, 0.85);
  background: rgba(227, 187, 94, 0.14);
  box-shadow: inset 0 0 0 1px rgba(245, 215, 137, 0.2);
}

.tile-option-name {
  font-weight: 600;
}

.board-area {
  display: flex;
  flex-direction: column;
  padding: 22px;
  overflow: hidden;
}

.board-scroll {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 14px;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0)),
    rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(227, 187, 94, 0.1);
}

.hex-grid-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.hex-grid {
  position: absolute;
  top: 50%;
  left: 50%;
  width: max-content;
  transform: translate(-50%, -50%) scale(var(--grid-scale));
  transform-origin: center center;
  will-change: transform;
}

.hex-row {
  display: flex;
  gap: var(--hex-gap);
}

.hex-row + .hex-row {
  margin-top: calc(var(--hex-overlap) * -1);
}

.hex-row.offset {
  margin-left: var(--row-offset);
}

.hex-cell,
.hex-thumb,
.current-hex {
  position: relative;
  width: var(--hex-width);
  height: var(--hex-height);
  clip-path: polygon(50% 0%, 94% 25%, 94% 75%, 50% 100%, 6% 75%, 6% 25%);
  background: #050505;
}

.hex-cell {
  border: 0;
  padding: 0;
  cursor: pointer;
  transition: transform 90ms ease, filter 90ms ease;
}

.hex-cell:hover,
.hex-cell:focus-visible {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.hex-fill {
  position: absolute;
  inset: 0;
  clip-path: inherit;
  background-color: var(--fog);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

.hex-thumb {
  flex: 0 0 auto;
  width: 54px;
  height: 62px;
}

.current-hex {
  flex: 0 0 auto;
  width: 64px;
  height: 74px;
}

.tile-option .hex-fill {
  background-size: 100% 100%;
}

.hex-cell[data-tile="fog"] .hex-fill {
  background-image: none;
  background-color: var(--fog);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: none;
    overflow: visible;
  }

  .board-area {
    min-height: 70vh;
  }
}

@media (max-width: 640px) {
  :root {
    --hex-width: 64px;
    --hex-height: 74px;
    --hex-overlap: 15px;
  }

  .app-shell {
    padding: 14px;
    gap: 16px;
  }

  .panel,
  .board-area {
    border-radius: 18px;
  }

  .tile-palette {
    grid-template-columns: 1fr;
  }
}
