:root {
  --ink: #0e1a2b;
  --slate: #1f2a3d;
  --steel: #36455f;
  --mist: #e5e9f2;
  --paper: #f7f8fb;
  --accent: #0066b3;
  --accent-soft: #d6e6f7;
  --gold: #c59b2a;
  --success: #1b7f4f;
  --danger: #b63a3a;
  --shadow: 0 20px 45px rgba(14, 26, 43, 0.12);
}

body[data-theme="dark"] {
  --ink: #f1f4fb;
  --slate: #d7dde8;
  --steel: #a8b3c7;
  --mist: #1c2433;
  --paper: #141a26;
  --accent: #4aa3ff;
  --accent-soft: #12314f;
  --gold: #e0b54f;
  --success: #3fd38e;
  --danger: #ff7b7b;
  --shadow: 0 20px 45px rgba(6, 9, 15, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Avenir", "Gill Sans", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top, #f3f6ff 0%, #e9edf7 35%, #dde3f0 100%);
  min-height: 100vh;
  touch-action: manipulation;
}

body[data-theme="dark"] {
  background: radial-gradient(circle at top, #1c2434 0%, #151b27 45%, #101521 100%);
}

.page {
  padding: 32px 48px 64px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(120deg, #ffffff 0%, #f4f6fb 100%);
  padding: 18px 24px;
  border-radius: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 28px;
  animation: slideDown 0.8s ease;
}

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

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent) 0%, #0a4d84 100%);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  letter-spacing: 1px;
  font-size: 18px;
  box-shadow: 0 12px 24px rgba(0, 102, 179, 0.35);
}

.brand-title {
  font-size: 22px;
  font-weight: 700;
}

.brand-subtitle {
  font-size: 13px;
  color: var(--steel);
}

.top-actions {
  display: flex;
  gap: 12px;
}

.layout {
  display: grid;
  grid-template-columns: 1.05fr 1.3fr;
  gap: 28px;
}

.panel {
  background: #fff;
  border-radius: 22px;
  padding: 26px;
  box-shadow: var(--shadow);
}

body[data-theme="dark"] .panel,
body[data-theme="dark"] .topbar,
body[data-theme="dark"] .board-row,
body[data-theme="dark"] .dropdown-content,
body[data-theme="dark"] .variant-card {
  background: var(--paper);
  border-color: #232c3f;
}

.section {
  margin-bottom: 28px;
}

.section:last-child {
  margin-bottom: 0;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

h2 {
  margin: 0 0 10px 0;
  font-size: 18px;
  color: var(--slate);
}

p {
  margin: 0 0 16px 0;
  line-height: 1.5;
}

.muted {
  color: var(--steel);
  font-size: 14px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--steel);
}

select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #d7ddea;
  background: #f9fbff;
  font-size: 14px;
}

input[type="text"] {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #d7ddea;
  background: #f9fbff;
  font-size: 14px;
}

body[data-theme="dark"] select,
body[data-theme="dark"] input[type="text"] {
  background: #1b2232;
  border-color: #2b354b;
  color: var(--ink);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 10px;
}

.metric {
  padding: 12px;
  background: var(--paper);
  border-radius: 12px;
  border: 1px solid #e3e7f1;
}

.metric-label {
  font-size: 12px;
  color: var(--steel);
}

.metric-value {
  font-size: 20px;
  font-weight: 600;
  margin-top: 6px;
}

.guess-row,
.board-row {
  display: grid;
  grid-auto-flow: column;
  gap: 10px;
  align-items: center;
}

.guess-row {
  margin: 12px 0 16px;
}

.slot {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px dashed #c1c9d8;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: #f9fbff;
}

.slot.active {
  border: 1px solid var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 102, 179, 0.15);
}

.peg {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: 2px solid rgba(15, 25, 40, 0.12);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.peg svg {
  width: 16px;
  height: 16px;
}

.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.word-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #d7ddea;
  background: #fff;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 3px;
}

.palette-btn {
  border: none;
  background: #f0f3fb;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--slate);
}

.palette-btn span {
  display: inline-flex;
}

.action-row {
  display: flex;
  gap: 12px;
}

.primary-btn {
  padding: 10px 18px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 20px rgba(0, 102, 179, 0.2);
}

.ghost-btn {
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid #d7ddea;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  color: var(--slate);
}

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

body[data-theme="dark"] .topbar {
  background: linear-gradient(120deg, #151c2a 0%, #101621 100%);
}

body[data-theme="dark"] .ghost-btn {
  background: #161d2a;
  border-color: #2b354b;
  color: var(--slate);
}

body[data-theme="dark"] .primary-btn {
  box-shadow: 0 12px 24px rgba(18, 44, 80, 0.45);
}

body[data-theme="dark"] .metric {
  background: #151c2a;
  border-color: #253149;
}

body[data-theme="dark"] .status {
  background: #151c2a;
  border-color: #2b354b;
  color: var(--steel);
}

body[data-theme="dark"] .board-row {
  background: #151c2a;
  border-color: #273149;
}

body[data-theme="dark"] .slot {
  background: #111827;
  border-color: #2d3a52;
}

body[data-theme="dark"] .slot.active {
  box-shadow: 0 0 0 2px rgba(74, 163, 255, 0.3);
}

body[data-theme="dark"] .palette-btn {
  background: #1b2232;
  border: 1px solid #2b354b;
  color: var(--slate);
}

body[data-theme="dark"] .word-input {
  background: #1b2232;
  border-color: #2b354b;
  color: var(--ink);
}

body[data-theme="dark"] .feedback-set {
  background: #111827;
  border-color: #2b354b;
}

body[data-theme="dark"] .feedback-text {
  color: #c7d2e6;
}

body[data-theme="dark"] .key-peg {
  background: #3a4356;
}

body[data-theme="dark"] .key-peg.black {
  background: #0b0f18;
}

body[data-theme="dark"] .key-peg.white {
  background: #f0d189;
  border-color: #d8b45e;
}

.status {
  font-size: 13px;
  color: var(--steel);
  background: var(--paper);
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid #e3e7f1;
}

.board {
  display: grid;
  gap: 12px;
  padding-top: 10px;
}

.board-row {
  padding: 10px 12px;
  border-radius: 14px;
  background: #f9fbff;
  border: 1px solid #e3e7f1;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  animation: fadeIn 0.4s ease;
}

.feedback {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
}

.feedback.double {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.feedback-set {
  background: #fff;
  border-radius: 10px;
  padding: 6px 8px;
  border: 1px solid #e3e7f1;
  display: grid;
  gap: 6px;
}

.feedback-label {
  font-size: 10px;
  color: var(--steel);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.feedback-pegs {
  display: grid;
  grid-template-columns: repeat(2, 10px);
  gap: 4px;
}

.key-peg {
  width: 10px;
  height: 10px;
  border-radius: 4px;
  background: #cfd6e6;
}

.key-peg.black {
  background: #20262f;
}

.key-peg.white {
  background: #f7f0d8;
  border: 1px solid #d1b45f;
}

.feedback-text {
  font-size: 11px;
  color: var(--steel);
  white-space: nowrap;
}

.variant-card {
  background: linear-gradient(150deg, #f6f8fd 0%, #eef2fa 100%);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid #e0e6f3;
}

.variant-card h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
}

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

.variant-item {
  font-size: 13px;
  color: var(--steel);
}

.dropdown {
  position: relative;
}

.dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.dropdown-control {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: 46px;
  display: none;
  flex-direction: column;
  gap: 6px;
  background: #fff;
  border: 1px solid #d7ddea;
  border-radius: 12px;
  padding: 10px;
  box-shadow: var(--shadow);
  min-width: 170px;
  z-index: 2;
}

.dropdown-menu.open {
  display: flex;
}

.menu-item {
  border: 1px solid #e2e6f1;
  background: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  color: var(--slate);
  text-align: left;
}

.menu-item:hover {
  background: #f6f8fd;
}

body[data-theme="dark"] .dropdown-menu,
body[data-theme="dark"] .menu-item {
  background: #161d2a;
  border-color: #2b354b;
}

body[data-theme="dark"] .menu-item:hover {
  background: #1f2838;
}

.win-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 22, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 4;
}

.win-overlay.show {
  display: flex;
}

.win-card {
  background: #fff;
  padding: 36px;
  border-radius: 22px;
  text-align: center;
  box-shadow: var(--shadow);
  max-width: 420px;
}

body[data-theme="dark"] .win-card {
  background: #121826;
}

.win-title {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 12px;
}

.win-message {
  color: var(--steel);
  font-size: 15px;
  margin-bottom: 20px;
}

.dropdown-content {
  background: var(--paper);
  border-radius: 12px;
  padding: 14px;
  border: 1px solid #e0e6f3;
  font-size: 14px;
  color: var(--slate);
  line-height: 1.55;
}

@keyframes slideDown {
  from {
    transform: translateY(-12px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  .page {
    padding: 24px;
  }
}

@media (max-width: 600px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .guess-row {
    grid-auto-flow: row;
    grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
  }

  .board-row {
    grid-template-columns: 1fr;
  }

  .feedback {
    justify-content: flex-start;
  }
}
