*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #fff;
  font-family: system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  user-select: none;
  -webkit-user-select: none;
}

.hidden {
  display: none !important;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
  background: #000;
}

/* Setup message */
.setup-message {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  z-index: 100;
  padding: 2rem;
  text-align: center;
}

.setup-message p {
  font-size: 1.125rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.75);
  max-width: 20rem;
}

/* Grid mode */
.grid-view {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
  padding: 2px;
  min-height: 100%;
}

.grid-item {
  position: relative;
  width: 100%;
  aspect-ratio: 941 / 1672;
  background: #0a0a0a;
  border: none;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  touch-action: manipulation;
}

.grid-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
  user-drag: none;
}

/* Fullscreen mode */
.fullscreen-view {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 10;
  touch-action: none;
}

.fullscreen-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: transform 0.22s ease-out;
}

.slide.dragging {
  transition: none;
}

.slide img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
  user-drag: none;
}

.slide-current {
  z-index: 2;
}

.slide-next {
  z-index: 1;
}

.slide.animating-left {
  transform: translate3d(-100%, 0, 0);
}

.slide.animating-right {
  transform: translate3d(100%, 0, 0);
}

.slide.enter-from-right {
  transform: translate3d(100%, 0, 0);
}

.slide.enter-from-left {
  transform: translate3d(-100%, 0, 0);
}

.slide.enter-active {
  transform: translate3d(0, 0, 0);
}

/* Tap zones */
.tap-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 30%;
  background: transparent;
  border: none;
  padding: 0;
  z-index: 5;
  cursor: default;
  touch-action: manipulation;
}

.tap-prev {
  left: 0;
}

.tap-next {
  right: 0;
}

/* Mode toggle */
.mode-toggle {
  position: fixed;
  bottom: max(12px, env(safe-area-inset-bottom));
  right: max(12px, env(safe-area-inset-right));
  z-index: 50;
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity 0.3s ease;
}

.mode-toggle:active {
  background: rgba(255, 255, 255, 0.12);
}

.mode-icon {
  width: 24px;
  height: 24px;
}

/* Landscape: keep 2 columns in grid */
@media (orientation: landscape) {
  .grid-container {
    grid-template-columns: repeat(2, 1fr);
  }
}
