:root {
  --mint: #33b6a6;
  --mint-dark: #117b75;
  --ink: #193333;
  --soft-ink: #60706d;
  --paper: #fffaf1;
  --panel: #fffdf8;
  --line: rgba(25, 51, 51, 0.12);
  --good: #2f7a4f;
  --bad: #c94d42;
  --blue: #d7eef7;
  --blue-hot: #b9e3f2;
  --gold: #fff1c4;
  --gold-hot: #ffe08a;
  --green: #d8f3d6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans SC", "PingFang SC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 12%, rgba(255, 211, 77, 0.34), transparent 28%),
    linear-gradient(135deg, #e6fbf6 0%, #fff8e6 46%, #e8f5ff 100%);
}

button {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.stage {
  width: min(1080px, 100%);
  min-height: min(760px, calc(100vh - 32px));
  display: grid;
  grid-template-rows: auto auto minmax(420px, 1fr);
  border: 4px solid rgba(255, 255, 255, 0.8);
  border-radius: 28px;
  overflow: hidden;
  background: #fefefe;
  box-shadow: 0 24px 80px rgba(28, 92, 98, 0.18);
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 24px 16px;
  background: linear-gradient(90deg, #ffffff 0%, #e9fff8 100%);
  border-bottom: 1px solid rgba(51, 182, 166, 0.18);
}

.eyebrow {
  margin: 8px 0 4px;
  color: var(--mint-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

h1 {
  margin: 0 0 6px;
  font-family: "Fredoka", "Noto Sans SC", sans-serif;
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  line-height: 1.1;
}

.subtitle {
  margin: 0;
  color: var(--soft-ink);
  font-size: 0.95rem;
  font-weight: 700;
  max-width: 36em;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.pill {
  min-width: 88px;
  padding: 9px 12px;
  border-radius: 999px;
  background: #dffbf2;
  border: 2px solid #a4ead9;
  text-align: center;
  font-weight: 800;
  color: #0c5f5b;
}

.pill span {
  display: block;
  color: var(--soft-ink);
  font-size: 12px;
  font-weight: 700;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 0.9fr) minmax(220px, 1.2fr) auto;
  gap: 14px 18px;
  align-items: center;
  padding: 14px 24px;
  background: rgba(255, 250, 241, 0.72);
  border-bottom: 1px solid var(--line);
}

.progress-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--soft-ink);
  font-size: 13px;
  font-weight: 800;
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(17, 123, 117, 0.14);
}

.bar {
  height: 100%;
  width: 10%;
  background: linear-gradient(90deg, var(--mint), #8fd85a);
  transition: width 260ms ease;
}

.message {
  margin: 0;
  color: var(--soft-ink);
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.45;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.action {
  appearance: none;
  border: 0;
  border-radius: 16px;
  min-height: 40px;
  padding: 0 16px;
  background: var(--mint-dark);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.action.secondary {
  background: #dffbf2;
  color: #0c5f5b;
}

.action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr);
  gap: clamp(72px, 12vw, 140px);
  align-items: stretch;
  padding: 22px 28px 28px;
  background:
    linear-gradient(180deg, rgba(233, 255, 248, 0.35), transparent 28%),
    #fffefb;
}

.column {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  min-width: 0;
}

.column-title {
  margin: 0;
  color: var(--mint-dark);
  font-size: 0.92rem;
  font-weight: 900;
}

.card-stack {
  display: grid;
  grid-template-rows: repeat(5, minmax(72px, 1fr));
  gap: 12px;
  min-height: 420px;
}

.card-button {
  appearance: none;
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 72px;
  padding: 10px 16px;
  border: 3px solid transparent;
  border-radius: 18px;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 8px 0 rgba(25, 51, 51, 0.08);
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.letter .card-button {
  background: var(--blue);
}

.sound .card-button {
  background: var(--gold);
}

.card-button:hover {
  transform: translateY(-2px);
}

.card-button:focus-visible {
  outline: 3px solid rgba(17, 123, 117, 0.38);
  outline-offset: 2px;
}

.card-button.selected {
  border-color: #117b75;
  background: var(--blue-hot);
  box-shadow: 0 0 0 6px rgba(51, 182, 166, 0.18), 0 8px 0 rgba(25, 51, 51, 0.08);
}

.card-button.matched {
  background: var(--green);
  border-color: rgba(47, 122, 79, 0.45);
  color: #1d4f33;
  cursor: default;
  box-shadow: 0 6px 0 rgba(32, 120, 70, 0.16);
}

.card-button.wrong {
  border-color: var(--bad);
  animation: shake 180ms linear 2;
}

.letter-value {
  font-family: "Fredoka", "Noto Sans SC", sans-serif;
  font-size: clamp(34px, 4vw, 44px);
  font-weight: 700;
  line-height: 1;
}

.sound-value {
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 900;
  line-height: 1.1;
}

.lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.lines path {
  fill: none;
  stroke: #2f8d62;
  stroke-width: 5;
  stroke-linecap: round;
  filter: drop-shadow(0 2px 0 rgba(47, 141, 98, 0.18));
}

.lines circle {
  fill: #2f8d62;
  stroke: #fff;
  stroke-width: 2;
}

.finish {
  position: absolute;
  inset: 16px;
  z-index: 6;
  display: none;
  place-items: center;
  background: rgba(255, 253, 248, 0.94);
  border-radius: 22px;
}

.finish.show {
  display: grid;
}

.finish-card {
  max-width: 420px;
  padding: 28px;
  text-align: center;
}

.finish h2 {
  margin: 0 0 10px;
  font-family: "Fredoka", "Noto Sans SC", sans-serif;
  font-size: clamp(28px, 4vw, 42px);
}

.finish p {
  margin: 0 0 18px;
  color: var(--soft-ink);
  font-weight: 700;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  33% { transform: translateX(-6px); }
  66% { transform: translateX(6px); }
}

@media (max-width: 820px) {
  .shell {
    padding: 10px;
  }

  .stage {
    min-height: calc(100vh - 20px);
    border-radius: 22px;
  }

  .topbar,
  .toolbar,
  .board {
    padding-left: 14px;
    padding-right: 14px;
  }

  .topbar,
  .toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .stats,
  .actions {
    justify-content: flex-start;
  }

  .board {
    gap: 36px;
    padding-top: 16px;
    padding-bottom: 18px;
  }

  .card-stack {
    min-height: 360px;
    gap: 8px;
  }

  .card-button {
    min-height: 60px;
    border-radius: 14px;
  }
}

@media (max-width: 520px) {
  .board {
    gap: 22px;
  }

  .letter-value {
    font-size: 28px;
  }

  .sound-value {
    font-size: 18px;
  }
}
