html {
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

* {
  box-sizing: border-box;
}

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

img, svg, canvas, video {
  max-width: 100%;
  height: auto;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
  background: radial-gradient(circle at top, #f5f9ff 0%, #e7effd 40%, #d3def8 100%);
  color: #0e1a2e;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.container {
  width: 100%;
  max-width: 1140px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

.navbar {
  width: 100%;
}

.brand-navigation {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.footer {
  padding: 1rem 0;
}

main {
  overflow-x: hidden;
}

.teddy-studio-page {
  padding: 0.5rem 0 1rem;
}

.studio-panel {
  display: grid;
  gap: 0.9rem;
}

.studio-layout {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(230px, 280px) minmax(0, 1fr);
  align-items: start;
}

.studio-sidebar {
  display: grid;
  gap: 1rem;
}

.studio-section {
  display: grid;
  gap: 0.75rem;
}

.thumb-grid {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.thumb-card {
  display: grid;
  gap: 0.35rem;
  justify-items: center;
  padding: 0.55rem;
  border-radius: 18px;
  border: 1px solid #dfe8ff;
  background: #f7faff;
  color: #304160;
  font-weight: 600;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.thumb-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 12px;
}

.thumb-card.active {
  border-color: #1b6df5;
  box-shadow: 0 10px 22px rgba(27, 109, 245, 0.16);
  background: #eef4ff;
}

.custom-background-button {
  cursor: pointer;
  overflow: hidden;
}

.custom-background-plus {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 2px dashed #9fb2d9;
  border-radius: 12px;
  color: #5272ad;
  font-size: 2.5rem;
  line-height: 1;
}

.studio-main {
  display: grid;
  gap: 1rem;
}

.mobile-lock-button {
  display: none;
}

body.screen-locked {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

html.screen-locked {
  overflow: hidden;
  overscroll-behavior: none;
}

.preview-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  max-width: 100%;
  border-radius: 24px;
  overflow: hidden;
  background: #dce5ff;
  border: 1px solid #dfe8ff;
}

.preview-background {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-teddy {
  position: relative;
  max-width: 70%;
  max-height: 70%;
  object-fit: contain;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.studio-controls {
  display: grid;
  gap: 0.8rem;
  padding: 0.9rem;
  border-radius: 22px;
  background: #f7faff;
  border: 1px solid #dfe8ff;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.control-row .hero-button {
  min-height: 44px;
  padding: 0 0.8rem;
}

.control-group {
  display: grid;
  gap: 0.35rem;
}

.control-group input[type="range"] {
  width: 100%;
}

.scene-list {
  display: grid;
  gap: 0.55rem;
}

.scene-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 0.7rem;
  border-radius: 14px;
  border: 1px solid #dfe8ff;
  background: #f7faff;
  color: #304160;
  text-align: left;
}

.scene-list-item.active {
  border-color: #1b6df5;
  background: #eef4ff;
}

.scene-list-item span {
  font-size: 0.85rem;
  color: #5d7192;
}

.teddy-layer {
  position: absolute;
  inset: 0;
}

.scene-item {
  position: absolute;
  border: none;
  background: transparent;
  padding: 0;
  width: 110px;
  max-width: 28%;
  cursor: grab;
  transform-origin: center center;
  user-select: none;
  -webkit-user-select: none;
}

.scene-item img {
  width: 100%;
  height: auto;
  pointer-events: none;
}

.scene-item.selected {
  filter: drop-shadow(0 8px 20px rgba(27, 109, 245, 0.28));
}

body.dragging {
  cursor: grabbing;
}

.empty {
  padding: 0.6rem 0.7rem;
  border-radius: 14px;
  background: #f7faff;
  color: #64728f;
  font-size: 0.9rem;
}

.landing-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 4rem 1rem;
}

.hero {
  max-width: 780px;
  margin-bottom: 2.5rem;
}

.hero h1 {
  font-size: clamp(3rem, 4.5vw, 4.5rem);
  margin-bottom: 1rem;
  letter-spacing: -0.06em;
}

.logo {
  max-width: 250%;
  height: auto;
  margin-bottom: 2rem;
  max-height: 500px;
}

.nav-logo {
  height: 40px;
  width: auto;
}

.footer-logo {
  display: inline-block;
  height: 22px;
  width: auto;
  vertical-align: middle;
}

.slogan {
  font-size: 1.5rem;
  color: #334e87;
  margin: 0;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.button-grid {
  display: grid;
  gap: 1rem;
  width: 100%;
  max-width: 780px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

@media (max-width: 767.98px) {
  .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .landing-page {
    padding: 2.5rem 0.75rem;
  }

  .logo {
    max-width: min(100%, 360px);
    max-height: 280px;
    margin-bottom: 1.25rem;
  }

  .slogan {
    font-size: 1.15rem;
  }

  .button-grid {
    grid-template-columns: 1fr;
    max-width: 420px;
  }

  .hero-button {
    min-height: 56px;
  }

  .panel {
    padding: 1rem;
    border-radius: 22px;
  }

  .studio-layout {
    grid-template-columns: 1fr;
  }

  .studio-sidebar {
    order: 2;
  }

  .studio-main {
    order: 1;
  }

  .mobile-lock-button {
    display: block;
    width: 100%;
    min-height: 44px;
    border: 1px solid #b7c8ec;
    border-radius: 14px;
    background: #eef4ff;
    color: #23477f;
    font-weight: 700;
    cursor: pointer;
  }

  .mobile-lock-button.active {
    background: #1b6df5;
    border-color: #144db4;
    color: white;
  }

  .thumb-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .rng-page {
    padding: 0.75rem 0 1rem;
  }

  .rng-panel {
    gap: 0.75rem;
  }

  .rng-grid .panel {
    padding: 0.85rem;
  }

  .stat-label {
    font-size: 0.75rem;
  }

  .action-row .hero-button {
    flex: 1 1 100%;
    min-height: 48px;
  }

  .footer {
    font-size: 0.9rem;
  }
}

.hero-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  padding: 0 1rem;
  background: #1b6df5;
  color: white;
  text-decoration: none;
  border-radius: 18px;
  font-size: 1.05rem;
  font-weight: 600;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.hero-button:hover,
.hero-button:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 18px 30px rgba(27, 109, 245, 0.18);
  background: #225dce;
}

.panel {
  background: white;
  border-radius: 30px;
  box-shadow: 0 24px 55px rgba(15, 32, 91, 0.09);
  padding: 1.8rem;
}

.panel-header {
  margin-bottom: 1.25rem;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.hidden {
  display: none !important;
}

.time-row {
  display: flex;
  justify-content: space-between;
  color: #5b6a88;
  font-size: 0.95rem;
}

.song-description {
  background: #f7f9ff;
  padding: 1rem 1.15rem;
  border-radius: 18px;
  color: #3f4d73;
  line-height: 1.65;
}

.info {
  margin-top: 2rem;
  color: #224171;
}

.rng-page {
  padding: 2rem 1rem 3rem;
}

.rng-panel {
  display: grid;
  gap: 1rem;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.stat-card {
  background: #f4f7ff;
  border-radius: 18px;
  padding: 0.75rem;
  display: grid;
  gap: 0.25rem;
}

.stat-label {
  color: #5a6a8b;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.hero-button.secondary {
  background: #2c4d9b;
}

.last-roll {
  background: #f7f9ff;
  border-radius: 16px;
  padding: 0.7rem 0.85rem;
  color: #334766;
}

.rng-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.rng-grid .panel {
  display: grid;
  gap: 0.85rem;
  align-content: start;
}

.rng-grid .panel > h3 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #5a6a8b;
}

.list {
  display: grid;
  gap: 0.7rem;
}

.compact-list {
  max-height: 240px;
  overflow-y: auto;
  padding-right: 0.35rem;
  scrollbar-width: thin;
  scrollbar-color: #9fb2ff transparent;
}

.compact-list::-webkit-scrollbar {
  width: 6px;
}

.compact-list::-webkit-scrollbar-thumb {
  background: #9fb2ff;
  border-radius: 999px;
}

.list-item {
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-weight: 600;
}

.list-item.active {
  background: #1b6df5;
  color: white;
  border-color: #144db4;
}

.inventory-item,
.empty {
  width: 100%;
  text-align: left;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: 1px solid #dfe8ff;
  background: linear-gradient(135deg, #f9fbff 0%, #eef4ff 100%);
  color: #304160;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.18s ease, border-color 0.18s ease;
}

.inventory-item:hover,
.inventory-item.active {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(27, 109, 245, 0.14);
  background: linear-gradient(135deg, #1b6df5 0%, #225dce 100%);
  color: white;
  border-color: #144db4;
}

.inventory-item strong {
  display: block;
  margin-bottom: 0.25rem;
}

.empty {
  text-align: center;
  color: #6a7a97;
  border-style: dashed;
  background: #f7faff;
}

.sandbox-page {
  display: grid;
  gap: 2rem;
  grid-template-columns: 1fr;
  padding: 2rem 1rem;
}

.sandbox-palette {
  display: grid;
  gap: 1rem;
}

.palette-controls {
  display: grid;
  gap: 1rem;
}

.palette {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.reset-button {
  width: fit-content;
  padding: 0.85rem 1.2rem;
  border-radius: 20px;
  border: none;
  background: #1b6df5;
  color: white;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease;
}

.reset-button:hover,
.reset-button:focus-visible {
  background: #144db4;
  transform: translateY(-1px);
}

.palette-item {
  padding: 1rem 1.1rem;
  border-radius: 20px;
  border: 1px solid transparent;
  background: #f4f7ff;
  color: #1f2b51;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.palette-item.active,
.palette-item:hover {
  background: #1b6df5;
  color: white;
  border-color: #144db4;
}

.sandbox-grid-panel {
  display: grid;
  gap: 1rem;
}

.sandbox-grid {
  display: grid;
  grid-template-columns: repeat(28, minmax(0, 1fr));
  gap: 3px;
  background: #e8efff;
  padding: 8px;
  border-radius: 24px;
}

.sandbox-cell {
  min-height: 16px;
  border-radius: 6px;
  background: #f7f9ff;
  border: 1px solid rgba(27, 109, 245, 0.14);
  cursor: pointer;
  transition: transform 0.13s ease, filter 0.13s ease;
}

.sandbox-cell:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.sand-cell {
  background: #eed9a0;
}

.water-cell {
  background: #a1d8ff;
}

.wet-sand-cell {
  background: #d4bf98;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

@media (max-width: 767.98px) {
  .rng-page {
    padding: 0.75rem 0 1rem;
  }

  .rng-panel {
    gap: 0.75rem;
  }

  .stat-row,
  .rng-grid {
    gap: 0.6rem;
  }

  .stat-card,
  .rng-grid .panel {
    padding: 0.75rem;
  }

  .action-row {
    gap: 0.5rem;
  }

  .action-row .hero-button {
    flex: 1 1 100%;
    min-height: 48px;
  }
}
