:root {
  color-scheme: light;
  --paper: #f8f4ea;
  --panel: #fffdf8;
  --ink: #25231e;
  --muted: #746f65;
  --line: #ded6c8;
  --teal: #16756f;
  --teal-dark: #0e4e4b;
  --amber: #e2a233;
  --red: #b84a3a;
  --green: #2f7d4f;
  --shadow: 0 18px 50px rgba(43, 36, 24, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(22, 117, 111, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(226, 162, 51, 0.1) 1px, transparent 1px),
    var(--paper);
  background-size: 34px 34px;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  background: var(--teal);
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: var(--teal-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.secondary {
  background: #f0e6d1;
  color: var(--ink);
  border: 1px solid var(--line);
}

button.secondary:hover {
  background: #e5d7bc;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
}

input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(22, 117, 111, 0.16);
}

.app {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: start;
  padding: 26px 0;
}

.play {
  display: grid;
  gap: 18px;
}

.topbar,
.leaderboard,
.panel {
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar {
  min-height: 110px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.08;
}

h1 {
  font-size: 4.2rem;
}

h2 {
  font-size: 1.6rem;
}

.score-pill {
  min-width: 112px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff7df;
  padding: 12px 14px;
  text-align: right;
}

.score-pill span,
.result-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.score-pill strong {
  display: block;
  margin-top: 2px;
  font-size: 2rem;
  line-height: 1;
}

.panel {
  padding: 22px;
}

.start-panel {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 420px);
  gap: 20px;
  align-items: stretch;
}

.glyph-wall {
  display: grid;
  grid-template-columns: repeat(4, minmax(74px, 1fr));
  gap: 10px;
}

.glyph-wall span {
  min-height: 74px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--teal-dark);
  font-weight: 950;
}

.start-form {
  display: grid;
  align-content: center;
  gap: 10px;
}

.start-form label {
  color: var(--muted);
  font-weight: 800;
}

.inline-form,
.guess-form {
  display: grid;
  gap: 10px;
}

.inline-form {
  grid-template-columns: minmax(0, 1fr) auto;
}

.game-panel {
  display: grid;
  gap: 18px;
}

.round-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 14px;
}

.progress {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.progress span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 900;
}

.progress .active {
  border-color: var(--teal);
  color: var(--teal-dark);
  background: rgba(22, 117, 111, 0.12);
}

.progress .solved {
  border-color: rgba(47, 125, 79, 0.5);
  color: #ffffff;
  background: var(--green);
}

.progress .failed {
  border-color: rgba(184, 74, 58, 0.45);
  color: #ffffff;
  background: var(--red);
}

.kroko-word {
  min-height: 86px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.kroko-word span {
  min-width: 58px;
  min-height: 58px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff9ea;
  font-size: 2.1rem;
  font-weight: 950;
}

.clue {
  margin: 0;
  color: var(--ink);
  font-size: 1.15rem;
  line-height: 1.45;
}

.facts,
.hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.facts span,
.hints span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #ffffff;
  color: var(--muted);
  font-weight: 800;
}

.hints span {
  color: var(--teal-dark);
  background: rgba(22, 117, 111, 0.08);
}

.guess-form {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.message {
  min-height: 24px;
  color: var(--red);
  font-weight: 800;
}

.attempts {
  display: grid;
  gap: 8px;
}

.attempt-row,
.leaderboard li {
  display: grid;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.attempt-row {
  grid-template-columns: minmax(100px, 1fr) repeat(3, minmax(62px, auto));
  padding: 10px;
}

.attempt-row strong {
  overflow-wrap: anywhere;
}

.attempt-row span {
  color: var(--muted);
  font-weight: 800;
  text-align: right;
}

.done-panel {
  display: grid;
  gap: 16px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.result-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
}

.result-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 1.7rem;
}

.leaderboard {
  position: sticky;
  top: 26px;
  padding: 20px;
}

.board-head {
  margin-bottom: 14px;
}

.leaderboard ol {
  list-style: none;
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.leaderboard li {
  grid-template-columns: 34px minmax(0, 1fr) auto;
  min-height: 54px;
  padding: 10px;
}

.leaderboard .rank {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f0e6d1;
  color: var(--ink);
  font-weight: 950;
}

.leaderboard .name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 900;
}

.leaderboard .meta {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.leaderboard .score {
  color: var(--teal-dark);
  font-weight: 950;
}

.hidden {
  display: none !important;
}

@media (max-width: 880px) {
  .app {
    grid-template-columns: 1fr;
    width: min(100% - 20px, 680px);
    padding: 10px 0 22px;
  }

  .leaderboard {
    position: static;
  }

  .start-panel {
    grid-template-columns: 1fr;
  }

  .glyph-wall {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .guess-form,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .topbar,
  .round-head {
    align-items: stretch;
    flex-direction: column;
  }

  .score-pill {
    text-align: left;
  }

  h1 {
    font-size: 3rem;
  }

  .kroko-word span {
    min-width: 50px;
    min-height: 50px;
    font-size: 1.55rem;
  }

  .progress {
    justify-content: flex-start;
  }

  .attempt-row {
    grid-template-columns: 1fr 1fr;
  }

  .attempt-row span {
    text-align: left;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }
}
