:root {
  --bg: #f6f1e7;
  --text: #3b3a30;
  --shell: #8fb07a;
  --shell-shadow: #6e8f5c;
  --frame: #3b4a35;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--bg);
  color: var(--text);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* The toy's plastic shell, rounded like an egg */
.device {
  width: 100%;
  max-width: 360px;
  padding: 28px 24px 40px;
  border-radius: 48% 48% 40% 40% / 32% 32% 24% 24%;
  background: var(--shell);
  box-shadow:
    inset 0 -10px 0 var(--shell-shadow),
    0 12px 32px rgba(0, 0, 0, 0.18);
  text-align: center;
}

/* Title in the middle, menu button on the right, an empty column on the left to balance it */
.device-header {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  margin: 8px 16px 16px;
}

.device-title {
  grid-column: 2;
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  color: #fdfbf5;
  text-shadow: 0 2px 0 var(--shell-shadow);
}

.menu-button {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  color: var(--frame);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.menu-button:active {
  background: rgba(255, 255, 255, 0.75);
}

/* Dark bezel around the LCD */
.screen-frame {
  padding: 12px;
  border-radius: 16px;
  background: var(--frame);
}

/* The canvas keeps its sharp pixels when scaled up */
.screen {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  image-rendering: pixelated;
}

/* Big, finger-friendly buttons below the screen */
.need-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 20px;
}

.need-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 68px;
  padding: 10px 4px;
  border: none;
  border-radius: 18px;
  background: #fdfbf5;
  box-shadow: 0 4px 0 var(--shell-shadow);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.need-button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--shell-shadow);
}

.need-emoji {
  font-size: 1.5rem;
  line-height: 1;
}

/* Note that appears when Betula leaves a gift; tapping it closes it */
.gift-message {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 12px 16px;
  border: 2px solid var(--frame);
  border-radius: 14px;
  background: #fff7d6;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.gift-message[hidden] {
  display: none;
}

/* The collection shelf: one slot per gift, kept forever */
.shelf {
  margin-top: 24px;
  padding: 12px;
  border-radius: 18px;
  background: #fdfbf5;
  box-shadow: 0 4px 0 var(--shell-shadow);
}

.shelf-title {
  margin: 0 0 10px;
  font-size: 1rem;
}

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

.shelf-slot {
  position: relative;
  padding: 4px;
  border-radius: 10px;
  background: var(--frame);
}

.shelf-slot.rare {
  box-shadow: 0 0 0 3px #e2b84a;
}

.shelf-slot.missing .shelf-canvas {
  opacity: 0.35;
}

.shelf-canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  image-rendering: pixelated;
}

/* The menu window; its padding lives in the steps so a tap outside them closes it */
.menu {
  width: calc(100% - 32px);
  max-width: 300px;
  padding: 0;
  border: none;
  border-radius: 20px;
  background: #fdfbf5;
  color: var(--text);
  text-align: center;
}

.menu::backdrop {
  background: rgba(35, 38, 31, 0.5);
}

.menu-step {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
}

.menu-step[hidden] {
  display: none;
}

.menu-title {
  margin: 0 0 4px;
  font-size: 1.2rem;
}

.menu-text {
  margin: 0 0 6px;
  line-height: 1.4;
}

.menu-action {
  min-height: 48px;
  border: none;
  border-radius: 14px;
  background: #ece6d6;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.menu-action.danger {
  background: #f3d3cc;
  color: #8a2f22;
}

.shelf-count {
  position: absolute;
  right: -4px;
  bottom: -4px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #fdfbf5;
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 700;
}
