:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --ink: #18201d;
  --muted: #66716b;
  --panel: #ffffff;
  --line: #d9e0dc;
  --key: #edf1ef;
  --key-press: #d8e9df;
  --accent: #137c62;
  --accent-ink: #ffffff;
  --ok: #1f6f8b;
  --danger: #c84242;
  --danger-bg: #fff0ee;
  --success: #19734e;
  --success-bg: #eaf7ef;
  --warn: #936b15;
  --warn-bg: #fff7dc;
  --shadow: 0 18px 44px rgba(26, 44, 35, 0.12);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(180deg, #eef5f1 0%, #f7f8f5 56%, #eef4f7 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

.game {
  width: min(100%, 450px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.intro,
.hints {
  border: 1px solid #ccd8d2;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 20px rgba(36, 47, 42, 0.05);
}

.intro {
  position: relative;
  overflow: hidden;
  padding: 14px 15px 14px 18px;
  background: #eef7f2;
  border-color: #b8d8ca;
}

.intro::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent);
}

.intro__title {
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0;
}

.intro p {
  margin: 0;
  color: #33423b;
  font-size: 15px;
  font-weight: 620;
  line-height: 1.36;
}

.level {
  display: grid;
  justify-items: center;
}

.level-card {
  border: 1px solid #bfd1ca;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.66);
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 13px;
  margin-top: 2px;
  margin-bottom: 6px;
}

.level__title {
  color: var(--ink);
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
}

.round {
  display: grid;
  justify-items: center;
  gap: 4px;
}

.round__label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 820;
  text-transform: uppercase;
  letter-spacing: 0;
}

.round__letter {
  width: 86px;
  aspect-ratio: 1;
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow);
  font-size: 50px;
  font-weight: 850;
  line-height: 1;
}

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

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

.rule {
  min-height: 70px;
  border: 1px solid #ccd8d2;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  padding: 11px 12px;
  display: grid;
  align-content: center;
  gap: 4px;
  box-shadow: 0 8px 20px rgba(36, 47, 42, 0.05);
}

.rule__title {
  min-width: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 860;
  line-height: 1.12;
}

.rule__detail {
  min-width: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 640;
  line-height: 1.25;
}

.rule__detail strong {
  color: var(--ink);
  font-weight: 900;
}

.play-area {
  display: grid;
  gap: 12px;
  padding-top: 4px;
  padding-bottom: 6px;
}

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

.slot {
  position: relative;
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  display: grid;
  grid-template-columns: 34px 1fr 36px;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 8px 14px;
  text-align: left;
  box-shadow: 0 8px 20px rgba(36, 47, 42, 0.06);
  cursor: default;
}

.slot__number {
  width: 28px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e5ece8;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.slot__word {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 22px;
  font-weight: 780;
  line-height: 1.1;
}

.slot.is-empty .slot__word {
  color: #b8c0bc;
}

.slot__delete {
  width: 36px;
  aspect-ratio: 1;
  border: 0;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #edf1ef;
  color: #6b7771;
  cursor: pointer;
}

.slot__delete svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.slot__delete:disabled {
  cursor: default;
  opacity: 0.45;
}

.slot__delete:not(:disabled):active {
  transform: translateY(1px);
}

.slot.is-valid {
  border-color: rgba(25, 115, 78, 0.28);
  background: var(--success-bg);
  color: var(--success);
}

.slot.is-valid .slot__number {
  background: #ccebd8;
  color: var(--success);
}

.slot.is-invalid {
  border-color: rgba(200, 66, 66, 0.34);
  background: var(--danger-bg);
  color: var(--danger);
}

.slot.is-invalid .slot__number {
  background: #ffd8d3;
  color: var(--danger);
}

.slot.is-invalid .slot__delete {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 8px 18px rgba(200, 66, 66, 0.22);
  animation: pulse-delete 1.1s ease-in-out infinite;
}

.slot.is-valid .slot__delete {
  background: #d8ede0;
  color: var(--success);
}

.status {
  align-self: start;
  width: 100%;
  display: grid;
  gap: 8px;
}

.message {
  min-height: 42px;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 15px;
  line-height: 1.35;
}

.message.is-error {
  border-color: rgba(200, 66, 66, 0.34);
  background: var(--danger-bg);
  color: var(--danger);
}

.message.is-success {
  border-color: rgba(25, 115, 78, 0.28);
  background: var(--success-bg);
  color: var(--success);
}

.message.is-warn {
  border-color: rgba(147, 107, 21, 0.26);
  background: var(--warn-bg);
  color: var(--warn);
}

.next-round {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 820;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(19, 124, 98, 0.2);
}

.next-round:active,
.ok-button:active,
.key:active {
  transform: translateY(1px);
}

.input-panel {
  margin-top: 4px;
  display: grid;
  gap: 8px;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 76px;
  gap: 10px;
}

.word-input {
  min-width: 0;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 16px;
  font-size: 22px;
  font-weight: 760;
  outline: none;
  box-shadow: 0 8px 20px rgba(36, 47, 42, 0.06);
}

.word-input:focus {
  border-color: rgba(31, 111, 139, 0.58);
  box-shadow: 0 0 0 4px rgba(31, 111, 139, 0.12);
}

.ok-button {
  height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--ok);
  color: #fff;
  font-size: 18px;
  font-weight: 860;
  cursor: pointer;
}

.ok-button:disabled,
.word-input:disabled,
.key:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.keyboard {
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 28px rgba(36, 47, 42, 0.07);
}

.key {
  min-width: 0;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: var(--key);
  color: var(--ink);
  font-size: 16px;
  font-weight: 780;
  cursor: pointer;
}

.key--accent {
  background: var(--key-press);
  color: var(--accent);
}

.hints {
  margin-top: 6px;
  padding: 12px 14px;
}

.hints__title {
  color: var(--ink);
  font-size: 15px;
  font-weight: 860;
  line-height: 1.1;
}

.hints__body {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
}

@media (max-width: 370px) {
  .game {
    padding-left: 12px;
    padding-right: 12px;
    gap: 14px;
  }

  .intro p {
    font-size: 14px;
  }

  .level__title {
    font-size: 23px;
  }

  .level-card {
    padding: 10px;
    gap: 10px;
  }

  .round__letter {
    width: 78px;
    border-radius: 18px;
    font-size: 44px;
  }

  .slot {
    min-height: 50px;
    grid-template-columns: 30px 1fr 34px;
  }

  .slot__word,
  .word-input {
    font-size: 21px;
  }

  .rule {
    min-height: 64px;
    padding: 8px;
  }

  .rule__title {
    font-size: 15px;
  }

  .rule__detail {
    font-size: 13px;
  }

  .keyboard {
    gap: 6px;
    padding: 8px;
  }

  .key {
    height: 31px;
    font-size: 15px;
  }
}

@keyframes pulse-delete {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.08);
  }
}
