/* Reset and base styles */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* Screen containers */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.screen.hidden {
  display: none;
}

/* ========================================
   Setup Mode
   ======================================== */

#setup {
  background: #f5f5f5;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
}

.setup-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  padding: 2rem;
  width: 100%;
  max-width: 400px;
}

.setup-title {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #1a1a1a;
}

/* Counter controls */
.counter {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.counter-btn {
  width: 64px;
  height: 64px;
  border: none;
  border-radius: 50%;
  background: #1a1a1a;
  color: #fff;
  font-size: 2rem;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s, transform 0.1s;
}

.counter-btn:active {
  background: #333;
  transform: scale(0.95);
}

.count {
  font-size: 4rem;
  font-weight: 700;
  min-width: 3ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Suffix input */
.suffix-input {
  width: 100%;
  padding: 1rem;
  border: 2px solid #ddd;
  border-radius: 8px;
  background: #fff;
  color: #1a1a1a;
  font-size: 1rem;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
}

.suffix-input::placeholder {
  color: #999;
}

.suffix-input:focus {
  border-color: #1a1a1a;
}

/* Start button */
.start-btn {
  width: 100%;
  padding: 1.25rem;
  border: none;
  border-radius: 8px;
  background: #1a1a1a;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.1s;
}

.start-btn:active {
  background: #333;
  transform: scale(0.98);
}

/* Install link */
.install-link {
  margin-top: 1rem;
  color: #007aff;
  text-decoration: none;
  font-size: 0.9rem;
  cursor: pointer;
}

.install-link.hidden {
  display: none;
}

/* Install Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  padding: 2rem;
  border-radius: 16px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  color: #1a1a1a;
}

.modal-content h2 {
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.modal-content ol {
  margin: 1.5rem 0;
  padding-left: 1.5rem;
  line-height: 1.6;
}

.modal-content li {
  margin-bottom: 0.5rem;
}

.share-icon {
  display: inline-flex;
  vertical-align: middle;
  color: #007aff;
  margin: 0 4px;
}

.share-icon svg {
  width: 1.2em;
  height: 1.2em;
}

.modal-close {
  width: 100%;
  padding: 1rem;
  background: #1a1a1a;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 1rem;
}

/* Landscape Mobile Layout */
@media (max-height: 500px) and (orientation: landscape) {
  .setup-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "title input"
      "counter start"
      ". link";
    gap: 4rem;
    max-width: 800px;
    padding: 1rem 3rem;
  }

  .setup-title {
    grid-area: title;
    font-size: 2rem;
    justify-self: center;
    align-self: center;
    margin: 0;
  }

  .counter {
    grid-area: counter;
    justify-self: center;
    align-self: start;
  }

  .suffix-input {
    grid-area: input;
    align-self: center;
  }

  .start-btn {
    grid-area: start;
    align-self: start;
  }

  .install-link {
    grid-area: link;
    justify-self: center;
    margin-top: 0;
  }
}

/* ========================================
   Display Mode
   ======================================== */

#display {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-color, #000);
  color: var(--text-color, #fff);
  transition: background-color 0.3s, color 0.3s;
}

#display.hidden {
  display: none;
}

.scroll-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.scroll-text {
  font-size: min(40vh, 200px);
  font-weight: 700;
  white-space: nowrap;
  will-change: transform;
  padding-left: 100%;
  animation: scroll-left var(--scroll-duration, 5s) linear infinite;
}

@keyframes scroll-left {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-100%);
  }
}

/* ========================================
   Tap Zones
   ======================================== */

.tap-zone {
  position: absolute;
  width: 25%;
  height: 25%;
  min-width: 80px;
  min-height: 80px;
  z-index: 100;
  cursor: pointer;
  display: flex;
  padding: 24px;
}

.tap-zone.top-left {
  top: 0;
  left: 0;
  align-items: flex-start;
  justify-content: flex-start;
}

.tap-zone.top-right {
  top: 0;
  right: 0;
  align-items: flex-start;
  justify-content: flex-end;
}

.tap-zone.bottom-left {
  bottom: 0;
  left: 0;
  align-items: flex-end;
  justify-content: flex-start;
}

.tap-zone.bottom-right {
  bottom: 0;
  right: 0;
  align-items: flex-end;
  justify-content: flex-end;
}

.zone-icon {
  width: 48px;
  height: 48px;
  opacity: 0.5;
  transition: opacity 0.3s;
  pointer-events: none;
}

.tap-zone:hover .zone-icon {
  opacity: 1.0;
}

/* Tap zone flash feedback */
.tap-zone::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.3);
  opacity: 0;
  transition: opacity 0.1s;
  pointer-events: none;
}

.tap-zone.flash::after {
  opacity: 1;
}

/* ========================================
   Theme Colors (CSS Custom Properties)
   ======================================== */

/* Themes are applied via JS setting CSS variables on #display */
