:root {
  color-scheme: light;
  --ink: #1d2528;
  --muted: #5a6466;
  --paper: #fff8ec;
  --cream: #f6ead4;
  --blue: #1f5f8b;
  --blue-dark: #123d5a;
  --orange: #e87824;
  --orange-soft: #f5b35a;
  --brown: #8b5937;
  --brown-dark: #4d321f;
  --line: rgba(29, 37, 40, 0.16);
  --shadow: 0 24px 70px rgba(77, 50, 31, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(31, 95, 139, 0.16), transparent 34%),
    radial-gradient(circle at 18% 18%, rgba(232, 120, 36, 0.22), transparent 26%),
    linear-gradient(160deg, var(--paper), var(--cream));
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--orange);
  color: #fffaf0;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0;
  padding: 0.85rem 1.1rem;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

button:hover {
  background: #d86519;
  box-shadow: 0 12px 24px rgba(232, 120, 36, 0.26);
  transform: translateY(-1px);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(31, 95, 139, 0.36);
  outline-offset: 3px;
}

.shell {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 48px;
}

.hero,
.header,
header[aria-labelledby="app-title"] {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  justify-items: center;
  gap: 0;
  min-height: 34vh;
  margin-bottom: 22px;
  text-align: center;
  width: 100%;
  overflow: hidden;
}

.hero-train,
.header-train {
  display: block;
  width: min(100%, 760px);
  margin-inline: auto;
  aspect-ratio: 2.35 / 1;
  object-fit: contain;
  border-radius: 8px;
  filter: drop-shadow(0 18px 24px rgba(77, 50, 31, 0.22));
}

.shell2,
.joke-kicker {
  margin: 0 0 0.5rem;
  color: var(--brown);
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
blockquote,
p {
  margin-top: 0;
}

h1 {
  max-width: 1080px;
  margin-bottom: 0;
  color: var(--blue-dark);
  font-size: clamp(2.35rem, 6vw, 5.8rem);
  line-height: 0.95;
  white-space: nowrap;
}

h2 {
  margin-bottom: 0;
  color: var(--blue-dark);
  font-size: 1.2rem;
}

.joke-panel,
.save-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 248, 236, 0.82);
  box-shadow: var(--shadow);
}

.joke-panel {
  position: relative;
  overflow: hidden;
  padding: clamp(1.2rem, 4vw, 2.5rem);
}

.joke-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 9px;
  background: repeating-linear-gradient(90deg, var(--blue) 0 90px, var(--orange) 90px 170px, var(--brown) 170px 245px);
}

blockquote {
  margin-bottom: 0;
  color: var(--ink);
  font-size: clamp(1.65rem, 4vw, 3rem);
  font-weight: 900;
  line-height: 1.12;
  white-space: pre-line;
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: end;
  gap: 14px;
  margin: 18px 0;
}

label {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--brown-dark);
  font-size: 0.9rem;
  font-weight: 900;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
  padding: 0.9rem 1rem;
}

input {
  min-height: 48px;
}

textarea {
  resize: vertical;
}

.secondary-button {
  background: var(--blue);
}

.secondary-button:hover {
  background: var(--blue-dark);
  box-shadow: 0 12px 24px rgba(31, 95, 139, 0.24);
}

.save-panel {
  padding: 1.1rem;
}

.section-heading,
.save-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 800;
}

.save-form {
  margin-top: 1rem;
}

.save-actions {
  margin-top: 0.8rem;
}

.text-button,
.install-button {
  background: transparent;
  color: var(--blue-dark);
  border: 1px solid rgba(31, 95, 139, 0.28);
}

.sound-toggle {
  min-width: 132px;
}

.text-button:hover,
.install-button:hover {
  background: rgba(31, 95, 139, 0.08);
  box-shadow: none;
}

.library {
  margin-top: 22px;
}

.custom-list {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(260px, 360px);
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

.custom-list li {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 14px;
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 248, 236, 0.72);
  padding: 1rem;
  color: var(--brown-dark);
  line-height: 1.35;
  scroll-snap-align: start;
}

.custom-list p {
  margin: 0;
}

.remove-joke {
  justify-self: start;
  min-height: 38px;
  padding: 0.55rem 0.8rem;
  background: transparent;
  color: var(--brown-dark);
  border: 1px solid rgba(77, 50, 31, 0.28);
  font-size: 0.9rem;
}

.remove-joke:hover {
  background: rgba(139, 89, 55, 0.1);
  box-shadow: none;
}

.empty-state {
  border-style: dashed;
  color: var(--muted);
}

.carousel-shell {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 10px;
  margin-top: 14px;
}

.arrow-button {
  width: 48px;
  min-height: 112px;
  padding: 0;
  background: var(--brown);
  font-size: 2rem;
  line-height: 1;
}

.arrow-button:hover {
  background: var(--brown-dark);
  box-shadow: 0 12px 24px rgba(77, 50, 31, 0.22);
}

.site-footer {
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto !important;
  padding: 0 0 28px;
  color: var(--brown);
  font-size: 0.85rem;
  font-weight: 800;
  text-align: center !important;
}

.site-footer p {
  width: 100%;
  margin: 0 auto;
  text-align: center;
}

.birthday-note {
  display: block;
  color: var(--blue-dark);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  opacity: 0.72;
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 24px, 1080px);
    padding-top: 18px;
  }

  .controls,
  .input-row,
  .section-heading,
  .save-actions {
    grid-template-columns: 1fr;
  }

  .hero,
  .header,
  header[aria-labelledby="app-title"] {
    min-height: auto;
    padding: 22px 0;
    margin-bottom: 14px;
  }

  .hero-train,
  .header-train {
    width: 100%;
    max-width: 100%;
    aspect-ratio: 2.35 / 1;
  }

  h1 {
    width: 100%;
    font-size: clamp(1.35rem, 7.6vw, 2.25rem);
    white-space: nowrap;
  }

  .section-heading,
  .save-actions {
    align-items: stretch;
    display: grid;
  }

  button {
    width: 100%;
  }

  .carousel-shell {
    grid-template-columns: 1fr;
  }

  .arrow-button {
    display: none;
  }

  .custom-list {
    grid-auto-columns: minmax(82%, 1fr);
  }
}
