:root {
  --frame: #d7261e;
  --frame-dark: #a51a14;
  --screen: #c9c9c1;
  --ink: #2b2b2b;
  --bg: #f6efe6;
  --text: #3a2f2a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 32px 16px;
}

.toy {
  width: 100%;
  max-width: 640px;
  background: linear-gradient(160deg, var(--frame) 0%, var(--frame-dark) 100%);
  border-radius: 32px;
  padding: 20px 28px 24px;
  box-shadow: 0 24px 50px rgba(120, 20, 10, 0.35), inset 0 2px 0 rgba(255, 255, 255, 0.25);
}

.toy.is-shaking {
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  20% { transform: translateX(-14px) rotate(-2deg); }
  40% { transform: translateX(12px) rotate(2deg); }
  60% { transform: translateX(-8px) rotate(-1deg); }
  80% { transform: translateX(6px) rotate(1deg); }
}

.logo {
  margin: 0 0 14px;
  text-align: center;
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-style: italic;
  color: #f5d76e;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
  letter-spacing: 0.02em;
}

.screen {
  background: #8e8e86;
  padding: 10px;
  border-radius: 14px;
  box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.35);
}

.grid {
  display: grid;
  aspect-ratio: 4 / 3;
  background: var(--screen);
  border-radius: 6px;
  overflow: hidden;
  touch-action: none;
  cursor: crosshair;
}

.cell {
  background: transparent;
}

.grid.show-lines .cell {
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.06);
}

.controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 18px;
}

.knob {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff 0%, #e4e4e4 40%, #b5b5b5 100%);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

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

.modes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.mode,
.shake {
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 6px;
}

.mode {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.mode:hover {
  background: rgba(255, 255, 255, 0.3);
}

.mode.is-active {
  background: #fff;
  color: var(--frame-dark);
}

.size {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 0.85rem;
}

.size span {
  white-space: nowrap;
  min-width: 90px;
}

.size input {
  flex: 1;
  min-width: 0;
  accent-color: #f5d76e;
}

.shake {
  background: #f5d76e;
  color: #5a3d00;
  font-weight: 600;
}

.shake:hover {
  background: #f8e18d;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.hint {
  margin: 0;
  font-size: 0.9rem;
  text-align: center;
  opacity: 0.75;
}

@media (max-width: 520px) {
  .toy {
    padding: 16px 14px 18px;
    border-radius: 24px;
  }

  .knob {
    display: none;
  }

  .modes {
    grid-template-columns: repeat(2, 1fr);
  }
}
