* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,0.04) 0 2px, transparent 2px 60px),
    #a9753f;
  color: #fff;
}

#app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 560px;
  margin: 0 auto;
}

#top {
  padding: 14px 16px 6px;
  text-align: center;
}

.wood-frame {
  display: inline-block;
  padding: 8px 26px;
  border-radius: 8px;
  background: linear-gradient(180deg, #6b4a2b, #4a2f18);
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.2), 0 4px 8px rgba(0,0,0,0.35);
  font-weight: 800;
  letter-spacing: 4px;
  font-size: 20px;
  color: #f2ddbc;
}

#level-name {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #f2ddbc;
  opacity: 0.85;
}

#levels {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 0 16px 12px;
}

#levels button {
  flex: 1;
  max-width: 160px;
  padding: 10px 12px;
  font-size: 15px;
  font-weight: 700;
  color: #3d2413;
  background: linear-gradient(180deg, #d3ab7c, #b28a56);
  border: none;
  border-radius: 10px;
  box-shadow: 0 3px 0 #7a5429, 0 4px 8px rgba(0,0,0,0.25);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#levels button.active {
  background: linear-gradient(180deg, #f2ddbc, #d3ab7c);
  box-shadow: 0 3px 0 #7a5429, 0 4px 8px rgba(0,0,0,0.35), inset 0 0 0 2px #f2ddbc;
  color: #2c1a0a;
}

#board {
  flex: 1;
  display: block;
  width: 100%;
  min-height: 0;
  touch-action: none;
}

#controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 0 16px 22px;
}

#controls button {
  flex: 1;
  max-width: 220px;
  padding: 14px;
  font-size: 17px;
  font-weight: 700;
  color: #3d2413;
  background: linear-gradient(180deg, #e0bf94, #c9a06b);
  border: none;
  border-radius: 10px;
  box-shadow: 0 4px 0 #7a5429, 0 6px 12px rgba(0,0,0,0.3);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#controls button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #7a5429, 0 2px 6px rgba(0,0,0,0.3);
}

#win {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade 0.3s ease;
  z-index: 10;
}

#win.hidden { display: none; }

.win-card {
  text-align: center;
  background: linear-gradient(180deg, #7a5226, #5a3a1c);
  border-radius: 16px;
  padding: 30px 40px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5), inset 0 2px 4px rgba(255,255,255,0.2);
}

#win-icon { font-size: 48px; }

.win-card h2 { margin: 8px 0 4px; font-size: 28px; color: #f2ddbc; }

.win-card p { font-size: 18px; margin-bottom: 20px; color: #ffe9c9; }

.win-card button {
  padding: 12px 26px;
  font-size: 17px;
  font-weight: 700;
  color: #3d2413;
  background: linear-gradient(180deg, #e0bf94, #c9a06b);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 0 #7a5429;
}

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

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
