:root {
  color-scheme: light;
  --bg: #eff6ff;
  --ink: #000000;
  --muted: #526171;
  --surface: #ffffff;
  --line: #d5e3f3;
  --primary: #c91c71;
  --secondary: #5abab6;
  --heading: #162a3f;
  --shadow: 0 14px 34px rgba(22, 42, 63, 0.16);
  font-family: Poppins, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(90, 186, 182, 0.22), transparent 34%),
    linear-gradient(315deg, rgba(201, 28, 113, 0.12), transparent 38%),
    var(--bg);
  color: var(--ink);
  overflow: hidden;
  touch-action: manipulation;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  gap: 8px;
  width: min(100vw, 520px);
  height: 100dvh;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom));
}

.header {
  display: grid;
  gap: 16px;
}

.logo-mark {
  justify-self: center;
  display: block;
  width: clamp(118px, 34vw, 170px);
  height: auto;
}

.topbar {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto 44px;
  gap: 8px;
  align-items: center;
  min-height: 44px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 2px solid var(--surface);
  border-radius: 8px;
  background: var(--surface);
  color: var(--secondary);
  font-size: 25px;
  font-weight: 800;
  line-height: 1;
  box-shadow: var(--shadow);
  transition:
    transform 160ms ease,
    border-color 160ms ease;
}

.icon-button.small {
  width: 38px;
  height: 38px;
  font-size: 22px;
  box-shadow: none;
}

.icon-button:active,
.action-button:active,
.show-button:active,
.slot:active {
  transform: scale(0.96);
}

.brand {
  display: grid;
  justify-items: center;
  gap: 1px;
  min-width: 0;
  color: var(--heading);
}

.brand strong {
  max-width: 100%;
  overflow: hidden;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-button {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--secondary);
  color: white;
  font-size: 13px;
  font-weight: 800;
  box-shadow: var(--shadow);
  transition: transform 160ms ease;
}

.counter {
  justify-self: center;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.deck {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
}

.card {
  position: relative;
  width: 100%;
  max-width: min(500px, calc(100dvh - 282px));
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface);
  border: 8px solid var(--surface);
  box-shadow: var(--shadow);
  cursor: grab;
  user-select: none;
  touch-action: none;
  will-change: transform;
}

.card.is-dragging {
  cursor: grabbing;
  transition: none;
}

.card.is-animating {
  transition:
    transform 220ms ease,
    opacity 220ms ease;
}

.card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1.05fr 1fr;
  gap: 10px;
}

.action-button {
  min-height: 48px;
  border-radius: 8px;
  background: var(--surface);
  border: 2px solid transparent;
  color: var(--heading);
  font-size: 14px;
  font-weight: 800;
  box-shadow: var(--shadow);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.action-button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.selection {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.slot {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 2px dashed var(--secondary);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--secondary);
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(22, 42, 63, 0.08);
}

.slot.has-card {
  border-style: solid;
  border-color: var(--secondary);
  background: var(--surface);
}

.slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.slot span {
  position: absolute;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary);
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(22, 42, 63, 0.14);
}

.slot.has-card span {
  top: 6px;
  left: 6px;
  background: var(--secondary);
  color: white;
}

.show-button {
  min-height: 48px;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-size: 15px;
  font-weight: 800;
  box-shadow: var(--shadow);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.show-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.overview {
  position: fixed;
  inset: max(4px, env(safe-area-inset-top)) 4px max(4px, env(safe-area-inset-bottom));
  z-index: 10;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 6px;
  width: min(calc(100vw - 8px), 520px);
  margin: 0 auto;
  padding: 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 20px 60px rgba(22, 42, 63, 0.25);
}

.presentation {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 14px;
  width: min(100vw, 680px);
  height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  background:
    linear-gradient(135deg, rgba(90, 186, 182, 0.24), transparent 34%),
    linear-gradient(315deg, rgba(201, 28, 113, 0.14), transparent 38%),
    var(--bg);
}

.presentation[hidden] {
  display: none;
}

.presentation-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
}

.presentation-head img {
  width: min(170px, 54vw);
  height: auto;
}

.presentation-copy {
  display: grid;
  gap: 2px;
  color: var(--heading);
}

.presentation-copy strong {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
}

.presentation-copy span {
  color: var(--primary);
  font-size: 14px;
  font-weight: 800;
}

.presentation-stage {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  align-content: center;
  gap: 10px;
  min-height: 0;
}

.presentation-nav {
  display: grid;
  place-items: center;
  width: 44px;
  height: 58px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--secondary);
  font-size: 38px;
  font-weight: 800;
  line-height: 1;
  box-shadow: var(--shadow);
}

.presentation-nav:disabled {
  opacity: 0.32;
}

.presentation-card {
  position: relative;
  justify-self: center;
  width: min(100%, 460px);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  border: 8px solid var(--surface);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  touch-action: none;
  user-select: none;
  will-change: transform;
  cursor: zoom-in;
}

.presentation-card.is-dragging {
  transition: none;
}

.presentation-card.is-animating {
  transition: transform 180ms ease;
}

.presentation-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.presentation-card span {
  position: absolute;
  top: 8px;
  left: 8px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--secondary);
  color: white;
  font-size: 14px;
  font-weight: 800;
}

.presentation-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.zoom {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  background: rgba(22, 42, 63, 0.92);
}

.zoom[hidden] {
  display: none;
}

.zoom img {
  width: min(100%, 760px);
  max-height: 100%;
  border: 8px solid var(--surface);
  border-radius: 8px;
  object-fit: contain;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

.zoom-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  z-index: 1;
}

.overview[hidden] {
  display: none;
}

.overview-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  color: var(--heading);
}

.overview-head strong {
  font-size: 20px;
  font-weight: 800;
}

.overview-grid {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 4px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0;
}

.overview-card {
  position: relative;
  flex: 0 0 calc((100% - 8px) / 3);
  display: block;
  width: calc((100% - 8px) / 3);
  height: auto !important;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #eef6ff;
  box-shadow: 0 3px 8px rgba(22, 42, 63, 0.1);
}

.overview-card::before {
  content: "";
  display: block;
  grid-area: 1 / 1;
  width: 100%;
  padding-top: 100%;
}

.overview-card.is-current {
  border-color: var(--primary);
}

.overview-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.overview-card span {
  position: absolute;
  top: 5px;
  left: 5px;
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 800;
}

@media (max-height: 660px) {
  .app {
    gap: 9px;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .topbar {
    min-height: 38px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }

  .action-button {
    min-height: 40px;
  }

  .show-button {
    min-height: 42px;
  }

  .logo-mark {
    width: clamp(110px, 30vw, 145px);
  }

  .header {
    gap: 12px;
  }

  .presentation {
    gap: 10px;
    padding-top: max(10px, env(safe-area-inset-top));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .presentation-copy strong {
    font-size: 24px;
  }
}

@media (max-width: 380px) {
  .overview-grid {
    gap: 4px;
  }
}

@media (max-width: 560px) {
  .app {
    gap: 6px;
    padding: max(8px, env(safe-area-inset-top)) 10px max(8px, env(safe-area-inset-bottom));
  }

  .header {
    gap: 8px;
  }

  .logo-mark {
    width: clamp(104px, 34vw, 140px);
  }

  .topbar {
    grid-template-columns: 36px minmax(0, 1fr) auto 36px;
    gap: 6px;
    min-height: 36px;
  }

  .icon-button {
    width: 36px;
    height: 36px;
    font-size: 22px;
  }

  .brand strong {
    font-size: 14px;
  }

  .counter {
    font-size: 12px;
  }

  .overview-button {
    min-height: 36px;
    padding: 0 10px;
    font-size: 12px;
  }

  .actions {
    gap: 6px;
  }

  .action-button {
    min-height: 40px;
    font-size: 13px;
  }

  .selection {
    gap: 6px;
  }

  .slot {
    border-width: 2px;
  }

  .slot span {
    width: 24px;
    height: 24px;
    font-size: 13px;
  }

  .show-button {
    min-height: 40px;
    font-size: 14px;
  }

  .presentation-stage {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .presentation-nav {
    width: 100%;
    height: 54px;
    font-size: 34px;
  }

  .presentation-card {
    grid-column: 1 / -1;
    grid-row: 1;
    width: 100%;
    max-width: none;
  }

  #presentationPreviousButton {
    grid-column: 1;
    grid-row: 2;
  }

  #presentationNextButton {
    grid-column: 2;
    grid-row: 2;
  }
}
