/* DAD-O-MATIC — quirky, but only slightly. */

:root {
  --cream: #fdf6e3;
  --ink: #29221c;
  --paper: #fffaf0;
  --mustard: #eab308;
  --mustard-deep: #b45309;
  --teal: #0f766e;
  --coral: #e11d48;
  --shadow: 6px 6px 0 rgba(41, 34, 28, 0.9);
  --shadow-sm: 3px 3px 0 rgba(41, 34, 28, 0.9);
  --radius: 18px;
  --reel-h: 9rem;
  --reel-w: min(34rem, 100%);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background-color: var(--cream);
  background-image:
    radial-gradient(rgba(41, 34, 28, 0.055) 1.4px, transparent 1.4px);
  background-size: 26px 26px;
  color: var(--ink);
  font-family: 'Trebuchet MS', 'Segoe UI', Verdana, sans-serif;
  line-height: 1.45;
  display: flex;
  justify-content: center;
  padding: 2.5rem 1rem 4rem;
}

/* ---------- masthead ---------- */

.stage {
  width: min(46rem, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.masthead {
  text-align: center;
  margin-bottom: 1.75rem;
}

.badge {
  display: inline-block;
  background: var(--teal);
  color: var(--paper);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 2px solid var(--ink);
  box-shadow: var(--shadow-sm);
  transform: rotate(-2deg);
}

.title {
  font-size: clamp(2.6rem, 9vw, 4.2rem);
  letter-spacing: 0.04em;
  margin: 0.9rem 0 0.25rem;
  line-height: 1;
  text-shadow: 4px 4px 0 var(--mustard);
}

.title .flip {
  display: inline-block;
  transform: rotate(180deg);
}

.tagline {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.75;
  font-style: italic;
}

/* ---------- mode tabs ---------- */

.tabs {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.1rem;
}

.tab {
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: var(--paper);
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 0.55rem 1.35rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.tab:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 rgba(41, 34, 28, 0.9);
}

.tab.is-active {
  background: var(--ink);
  color: var(--cream);
}

.pun-row {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 1.1rem;
}

.pun-row input {
  font: inherit;
  width: min(26rem, 100%);
  text-align: center;
  background: var(--paper);
  border: 2.5px dashed var(--ink);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  box-shadow: var(--shadow-sm);
}

.pun-row input:focus-visible {
  outline: 3px solid var(--mustard);
  outline-offset: 2px;
}

/* ---------- the machine ---------- */

.machine {
  position: relative;
  width: min(38rem, 100%);
  background: var(--mustard);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.reel-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.65;
}

.viewport {
  height: var(--reel-h);
  overflow: hidden;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  box-shadow: inset 0 10px 14px -12px rgba(41, 34, 28, 0.55),
    inset 0 -10px 14px -12px rgba(41, 34, 28, 0.55);
}

.strip {
  display: flex;
  flex-direction: column;
}

.cell {
  height: var(--reel-h);
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.5rem 1.25rem;
  font-size: clamp(1rem, 2.6vw, 1.25rem);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.cell .glyph {
  font-size: 1.1rem;
  margin-bottom: 0.2rem;
  opacity: 0.45;
}

.marquee {
  position: absolute;
  top: -1.25rem;
  right: 1.5rem;
  width: 2.6rem;
  height: 2.6rem;
  display: grid;
  place-items: center;
  background: var(--coral);
  color: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  font-size: 1.2rem;
  transform: rotate(8deg);
}

.marquee span {
  display: block;
}

.machine.is-spinning .marquee span {
  animation: star-spin 0.5s linear infinite;
}

@keyframes star-spin {
  from {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(180deg) scale(1.25);
  }
  to {
    transform: rotate(360deg) scale(1);
  }
}

/* ---------- status + lever ---------- */

.status {
  min-height: 1.5em;
  margin: 1.1rem 0 0;
  font-size: 0.95rem;
  opacity: 0.8;
}

.lever {
  font: inherit;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  cursor: pointer;
  margin-top: 0.8rem;
  padding: 1rem 3.2rem;
  color: var(--ink);
  background: var(--mustard);
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: var(--shadow);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.15s ease;
}

.lever:hover:not(:disabled) {
  transform: translate(-2px, -2px);
  box-shadow: 8px 8px 0 rgba(41, 34, 28, 0.9);
}

.lever:active:not(:disabled) {
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 rgba(41, 34, 28, 0.9);
}

.lever:disabled {
  cursor: wait;
  background: #f3e3b3;
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 rgba(41, 34, 28, 0.9);
  opacity: 0.85;
}

.lever:focus-visible,
.tab:focus-visible,
.chip:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

/* ---------- afterglow + footer ---------- */

.afterglow {
  margin-top: 1.1rem;
  display: flex;
  gap: 0.6rem;
}

.chip {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0.45rem 1.1rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease;
}

.chip:hover {
  transform: translate(-1px, -1px);
}

.chip--ghost {
  background: transparent;
  box-shadow: none;
  border-style: dashed;
}

.foot {
  margin-top: 2.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.foot-note {
  font-size: 0.8rem;
  opacity: 0.55;
  font-style: italic;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.6rem;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--cream);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  animation: toast-in 0.25s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ---------- motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  .machine.is-spinning .marquee span {
    animation: none;
  }
}