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

html, body {
  height: 100%;
  background: #0e0e11;
  color: #e8e6e3;
  font-family: "JetBrains Mono", "SF Mono", "Fira Code", monospace;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 2rem 1rem;
}

.board-wrapper {
  max-width: 900px;
  width: 100%;
}

.board {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  margin-bottom: 2rem;
  perspective: 800px;
}

.flap {
  width: 48px;
  height: 64px;
  background: #1a1a1f;
  border: 1px solid #2a2a32;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.flap .char {
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1;
  color: #e8e6e3;
  z-index: 2;
  position: relative;
  font-variant-numeric: tabular-nums;
}

.flap .flip-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    transparent 48%,
    rgba(0, 0, 0, 0.15) 48%,
    rgba(0, 0, 0, 0.15) 52%,
    transparent 52%
  );
  z-index: 3;
  pointer-events: none;
}

.flap::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
  z-index: 1;
  pointer-events: none;
}

.flap.flipping .char {
  animation: flapFlip 0.3s ease-in-out;
}

@keyframes flapFlip {
  0% { transform: rotateX(0deg); }
  40% { transform: rotateX(-90deg); opacity: 0.3; }
  60% { transform: rotateX(-90deg); opacity: 0.3; }
  100% { transform: rotateX(0deg); opacity: 1; }
}

.controls {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.controls input {
  background: #1a1a1f;
  border: 1px solid #2a2a32;
  border-radius: 6px;
  padding: 0.625rem 1rem;
  color: #e8e6e3;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.9rem;
  min-width: 240px;
  outline: none;
  transition: border-color 0.15s;
}

.controls input:focus {
  border-color: #5a5a6a;
}

.controls button {
  background: #2a2a32;
  border: 1px solid #3a3a45;
  border-radius: 6px;
  padding: 0.625rem 1.25rem;
  color: #e8e6e3;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.controls button:hover {
  background: #3a3a45;
  border-color: #5a5a6a;
}

.controls button:active {
  transform: scale(0.97);
}

.presets {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.presets button {
  background: transparent;
  border: 1px solid #2a2a32;
  border-radius: 20px;
  padding: 0.375rem 0.875rem;
  color: #888894;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}

.presets button:hover {
  border-color: #5a5a6a;
  color: #e8e6e3;
}

.header {
  text-align: center;
  margin-bottom: 2rem;
}

.header h1 {
  font-size: 1.1rem;
  font-weight: 500;
  color: #5a5a6a;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.header p {
  font-size: 0.7rem;
  color: #3a3a45;
  margin-top: 0.25rem;
  letter-spacing: 0.05em;
}

@media (max-width: 600px) {
  .flap {
    width: 36px;
    height: 50px;
  }
  .flap .char {
    font-size: 1.25rem;
  }
  .board {
    gap: 3px;
  }
  .controls input {
    min-width: 160px;
    font-size: 0.8rem;
  }
}
