* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: Georgia, 'Times New Roman', serif;
  color: #3a3320;
  background:
    radial-gradient(circle at 8% 92%, rgba(180, 220, 140, 0.25) 0%, transparent 22%),
    radial-gradient(circle at 92% 8%, rgba(255, 230, 180, 0.3) 0%, transparent 25%),
    linear-gradient(180deg, #fffdf5 0%, #f3f0e4 100%);
}

.game {
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 14px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  user-select: none;
  -webkit-user-select: none;
}

.top { text-align: center; }
h1 { margin: 0 0 2px; color: #4a6b2a; font-size: 28px; }
.task { margin: 0; color: #5a4a20; font-size: 18px; font-style: italic; }

.levels {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.lvl {
  font-family: inherit;
  font-size: 15px;
  padding: 9px 14px;
  border: 1.5px solid #b8a86c;
  border-radius: 10px;
  background: #fffdf5;
  color: #5a4a20;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.lvl:hover { border-color: #5a8835; }
.lvl:active { transform: scale(0.97); }
.lvl[aria-pressed="true"] {
  background: #c8d8a4;
  border-color: #5a8835;
  color: #3a5520;
  font-weight: 700;
}
.lvl:focus-visible { outline: 3px solid #5a8835; outline-offset: 2px; }

.help { margin: 0; text-align: center; color: #8a7a4a; font-size: 14px; }

.board-wrap { position: relative; }

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

.board {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 24px;
}

.col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.node {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 2px solid #b8862c;
  border-radius: 14px;
  background: #fffdf5;
  cursor: pointer;
  touch-action: none;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
}
.col-right .node { flex-direction: row-reverse; }

.node:hover { border-color: #5a8835; }
.node.sel {
  border-color: #5a8835;
  background: #e9f1d6;
  box-shadow: 0 0 0 3px rgba(90, 136, 53, 0.3);
}
.node.done {
  border-color: #5a8835;
  background: #d6e4b6;
  cursor: default;
}
.node.bad {
  border-color: #c0552f;
  background: #fbe3df;
  animation: shake .35s;
}
.node:focus-visible { outline: 3px solid #5a8835; outline-offset: 2px; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.dot {
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #b8862c;
  background: #fff;
}
.node.done .dot { background: #5a8835; border-color: #3a5520; }

.face {
  flex: 1;
  text-align: center;
  line-height: 1;
}
.emoji { font-size: clamp(30px, 9vw, 46px); }
.sound { font-size: clamp(18px, 5vw, 26px); font-weight: 700; color: #1e63b0; }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.progress { font-size: 16px; color: #5a4a20; }
.progress b { color: #4a6b2a; }

.btn {
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  padding: 11px 18px;
  border: 1.5px solid #5a8835;
  border-radius: 10px;
  background: #c8d8a4;
  color: #3a5520;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn:hover { background: #d6e4b6; }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 3px solid #3a5520; outline-offset: 2px; }

.win {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(58, 53, 32, 0.45);
  padding: 16px;
  animation: fade .25s;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.win-card {
  background: #fffdf5;
  border: 2px solid #b8862c;
  border-radius: 18px;
  padding: 28px 32px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
  animation: pop .3s;
}
@keyframes pop { from { transform: scale(0.8); } to { transform: scale(1); } }

.win-emoji { font-size: 64px; animation: bounce 1s infinite; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.win-title { font-size: 30px; color: #4a6b2a; font-weight: 700; margin: 6px 0; }
.win-sub { font-size: 16px; color: #8a7a4a; margin-bottom: 20px; }

@media (max-width: 420px) {
  .board { gap: 12px; }
  .node { padding: 8px 8px; gap: 6px; border-radius: 12px; }
  h1 { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .node.bad, .win, .win-card, .win-emoji { animation: none; }
}
