:root {
  color-scheme: light;
  --bg: #f4efe5;
  --ink: #17201c;
  --muted: #65706a;
  --line: #d8ccbb;
  --panel: #fffaf0;
  --green: #245e57;
  --red: #b23c32;
  --gold: #d8a437;
  --shadow: 0 24px 70px rgba(32, 30, 23, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(36, 94, 87, 0.14), transparent 42%),
    radial-gradient(circle at 90% 12%, rgba(216, 164, 55, 0.24), transparent 26%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.game-shell {
  width: min(780px, calc(100vw - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  align-items: center;
}

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

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

.topbar a {
  color: var(--green);
  font-weight: 900;
}

.topbar button,
.guess-form button {
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: white;
  cursor: pointer;
  font-weight: 900;
}

.topbar button {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  font-size: 1.35rem;
}

.hero {
  margin: 32px 0 24px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(3rem, 10vw, 6.4rem);
  line-height: 0.9;
}

.hero p:last-child {
  max-width: 650px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.7;
}

.entry {
  display: grid;
  gap: 14px;
}

.digit-boxes {
  display: grid;
  grid-template-columns: repeat(4, minmax(56px, 88px));
  gap: 10px;
}

.digit-boxes span {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 2px solid #cfc4b2;
  border-radius: 8px;
  background: #eadfce;
  color: #5e5549;
  font-size: clamp(2rem, 7vw, 4rem);
  font-weight: 1000;
  line-height: 1;
}

.digit-boxes span.filled {
  border-color: rgba(36, 94, 87, 0.44);
  background: #f4ead8;
  color: var(--ink);
}

.guess-form {
  display: grid;
  gap: 8px;
}

.guess-form label {
  color: var(--muted);
  font-weight: 900;
}

.input-row {
  display: flex;
  gap: 10px;
}

.input-row input {
  width: min(100%, 280px);
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0.18em;
}

.input-row button {
  min-width: 118px;
  min-height: 52px;
  padding: 0 18px;
}

.input-row button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.status {
  min-height: 28px;
  color: var(--green);
  font-weight: 900;
}

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

.rules div {
  padding: 14px;
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
}

.rules strong {
  color: var(--red);
  font-size: 1.7rem;
}

.rules span {
  color: var(--muted);
  font-weight: 800;
}

.history-wrap {
  margin: 20px 0;
  display: grid;
  gap: 12px;
}

h2 {
  font-size: 1rem;
}

.history {
  display: grid;
  gap: 8px;
}

.history-line {
  min-height: 48px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 44px 1fr 78px;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
}

.history-line .turn {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.history-line strong {
  font-size: 1.25rem;
  letter-spacing: 0.16em;
}

.history-line em {
  color: var(--green);
  font-style: normal;
  font-weight: 1000;
}

.result-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  padding: 24px;
  display: grid;
  place-items: center;
  background: rgba(23, 32, 28, 0.34);
}

.result-modal[hidden] {
  display: none;
}

.result-dialog {
  width: min(420px, 100%);
  padding: 22px;
  display: grid;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.result-dialog p {
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 900;
  line-height: 1.55;
}

.result-dialog button {
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: white;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
}

@media (max-width: 560px) {
  .panel {
    padding: 16px;
  }

  .digit-boxes {
    grid-template-columns: repeat(4, 1fr);
  }

  .input-row,
  .rules {
    grid-template-columns: 1fr;
    display: grid;
  }

  .input-row input,
  .input-row button {
    width: 100%;
  }
}
