:root {
  color-scheme: light;
  --bg: #f6f3ed;
  --ink: #17201c;
  --muted: #64706a;
  --line: #d9d2c4;
  --panel: #fffaf1;
  --accent: #245e57;
  --accent-strong: #184842;
  --shadow: 0 18px 50px rgba(41, 38, 30, 0.12);
  --cell-size: clamp(48px, 8vw, 76px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(36, 94, 87, 0.14), transparent 38%),
    radial-gradient(circle at 88% 12%, rgba(231, 175, 78, 0.2), transparent 28%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select {
  font: inherit;
}

.app {
  width: min(820px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 0;
  display: block;
}

.panel {
  background: rgba(255, 250, 241, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.game-panel {
  padding: 24px;
}

.topbar,
.status-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.home-link {
  width: fit-content;
  margin-top: 12px;
  display: inline-flex;
  color: var(--accent-strong);
  font-size: 0.92rem;
  font-weight: 800;
  text-decoration: none;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.icon-button,
.primary-button {
  border: 0;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, opacity 0.16s ease;
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: #e9dfcf;
  color: var(--ink);
  font-size: 1.4rem;
}

.primary-button {
  min-width: 112px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

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

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.status-strip {
  margin: 22px 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3eadc;
  color: var(--muted);
  font-weight: 700;
}

#attempt-counter {
  color: var(--accent-strong);
  white-space: nowrap;
}

.secret-row,
.guess-row {
  display: grid;
  grid-template-columns: repeat(var(--slots), var(--cell-size));
  gap: 10px;
  justify-content: start;
}

.secret-row {
  margin-bottom: 10px;
}

.code-row {
  display: grid;
  grid-template-columns: repeat(var(--slots), var(--cell-size));
  gap: 10px;
  justify-content: start;
}

.board {
  display: grid;
  gap: 10px;
}

.board:not(:empty) {
  margin-bottom: 12px;
}

.history-line {
  min-height: 56px;
  padding: 10px;
  display: grid;
  grid-template-columns: max-content;
  gap: 8px;
  align-items: start;
  justify-content: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.42);
}

.slot {
  width: 100%;
  aspect-ratio: 1;
  min-width: 0;
  border: 2px solid #cfc4b2;
  border-radius: 8px;
  background: #eadfce;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.08);
}

.slot.filled {
  border-color: rgba(23, 32, 28, 0.26);
}

.slot.secret {
  display: grid;
  place-items: center;
  color: #5f5548;
  font-weight: 900;
  font-size: 1.25rem;
  line-height: 1;
  text-align: center;
}

.slot.drop-target {
  cursor: copy;
}

.slot.drop-target.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(36, 94, 87, 0.14), inset 0 2px 6px rgba(0, 0, 0, 0.08);
}

.feedback {
  display: grid;
  grid-template-columns: repeat(var(--slots), var(--cell-size));
  gap: 10px;
  justify-content: start;
  align-items: center;
  justify-items: center;
}

.pin {
  width: 14px;
  height: 14px;
  display: inline-block;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.14);
}

.pin.exact {
  background: #2f9d63;
}

.pin.close {
  background: #f0bf3a;
}

.pin.miss {
  background: #bbc2bd;
}

.composer-wrap {
  display: grid;
  gap: 10px;
}

.palette-section {
  margin: 12px 0 18px;
}

.submit-area {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-top: 8px;
}

.submit-area .primary-button {
  width: min(220px, 100%);
  flex: 0 0 auto;
}

.palette {
  display: grid;
  grid-template-columns: repeat(auto-fit, var(--cell-size));
  gap: 10px;
  justify-content: start;
}

.color-button {
  width: var(--cell-size);
  aspect-ratio: 1;
  border: 2px solid rgba(23, 32, 28, 0.14);
  border-radius: 8px;
  cursor: pointer;
  box-shadow: inset 0 -8px 18px rgba(0, 0, 0, 0.14);
}

.color-button.selected {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.settings,
.rule-card {
  display: grid;
  gap: 12px;
}

.rule-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 0 10px;
}

.toggle {
  grid-template-columns: auto 1fr;
  align-items: center;
  color: var(--ink);
}

.toggle input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.legend {
  display: grid;
  gap: 10px;
}

.inline-legend {
  grid-template-columns: 1fr;
  gap: 6px;
  flex: 1 1 auto;
}

.legend div {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.92rem;
}

@media (max-width: 860px) {
  .submit-area {
    display: grid;
    align-items: stretch;
  }

  .submit-area .primary-button {
    width: min(100%, calc(var(--cell-size) * var(--slots) + 40px));
  }
}

@media (max-width: 560px) {
  .app {
    width: min(100vw - 20px, 1120px);
    padding: 10px 0;
  }

  .game-panel,
  .side-panel {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
  }

  .history-line {
    grid-template-columns: 1fr;
  }

  .feedback {
    justify-content: start;
  }

  .composer {
    align-items: stretch;
    display: grid;
  }
}
