@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700;800&display=swap');

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

body {
  font-family: 'Space Grotesk', sans-serif;
  background-color: #ffec3e;
  background-image: radial-gradient(#0000001f 1px, transparent 1px);
  background-size: 22px 22px;
  color: #111827;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.warning-banner {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  width: auto;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
  padding: 12px 16px;
  border-radius: 0;
  border: 3px solid #000;
  background: #ff8a8a;
  color: #111827;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
  box-shadow: 6px 6px 0 #000;
  z-index: 999;
  display: none;
}

.warning-banner.is-visible {
  display: block;
}

/* Main layout */
.container {
  display: flex;
  width: 90%;
  max-width: 1100px;
  height: 80vh;
  background: #ffffff;
  border: 4px solid #000;
  border-radius: 0;
  overflow: hidden;
  box-shadow: 10px 10px 0 #000;
}

/* Left panel */
.left-panel {
  flex: 1;
  background: #87ceeb;
  border-right: 4px solid #000;
}

.left-panel img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Right panel */
.right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 28px 24px;
  color: #111827;
  background: #fffdf4;
}

.narration-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  border: 3px solid #000;
  background: #ffffff;
}

/* Text display */
#text-display {
  height: 100%;
  font-size: 1.12rem;
  line-height: 1.82;
  color: #1f2937;
  background: transparent;
  border-radius: 0;
  padding: 18px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#text-display::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.intro-card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  background: #111827;
  border: 3px solid #000;
  border-radius: 0;
  padding: 24px;
  z-index: 2;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.intro-card.hidden {
  opacity: 0;
  visibility: hidden;
}

.intro-label {
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #93c5fd;
  font-weight: 800;
}

.intro-title {
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  line-height: 1.1;
  text-transform: uppercase;
  color: #f8fafc;
}

.intro-author {
  font-size: 1.02rem;
  color: #fcdfff;
  font-weight: 700;
}

.intro-hint {
  margin-top: 6px;
  font-size: 0.95rem;
  color: #93c5fd;
}

/* Animated words */
#text-display span {
  opacity: 0;
  transition: opacity 0.3s ease;
  margin-right: 5px;
}

#text-display span.active {
  color: #000;
  background: #ffec3e;
  box-shadow: 2px 2px 0 #000;
  font-weight: 800;
  padding: 1px 2px;
}

#text-display span.visible {
  opacity: 1;
}

/* Controls */
.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 3px solid #000;
  flex-wrap: nowrap;
}

.carry-link {
  display: inline-block;
  flex: 0 0 auto;
  line-height: 0;
}

.carry-link img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  display: block;
}

button {
  min-height: 44px;
  padding: 11px 16px;
  border: 3px solid #000;
  border-radius: 0;
  box-shadow: 4px 4px 0 #000;
  font-size: 0.84rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  white-space: nowrap;
  flex: 0 0 auto;
}

button:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #000;
}

button:hover:not(:disabled) {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 #000;
}

#startBtn {
  background: #22c55e;
  color: #04130a;
}

#stopBtn {
  background: #fcdfff;
  color: #2a1040;
}

#replayBtn {
  background: #87ceeb;
  color: #061521;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: 2px 2px 0 #000;
}

@media (max-width: 900px) {
  body {
    height: 100dvh;
    overflow: hidden;
  }

  .container {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    border-radius: 0;
    flex-direction: column;
    box-shadow: none;
  }

  .left-panel {
    flex: 0 0 36dvh;
    border-right: 0;
    border-bottom: 4px solid #000;
  }

  .right-panel {
    flex: 1 1 auto;
    min-height: 0;
    padding: 10px;
  }

  .narration-stage {
    overflow: hidden;
  }

  #text-display {
    height: 100%;
    padding: 12px;
    font-size: clamp(0.95rem, 3.6vw, 1.05rem);
    line-height: 1.7;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .controls {
    margin-top: 8px;
    gap: 6px;
    flex-wrap: nowrap;
    padding-top: 8px;
  }

  .intro-card {
    inset: 0;
    justify-content: flex-start;
    gap: 6px;
    padding: clamp(12px, 3vh, 18px) 14px 92px 14px;
    overflow: hidden;
  }

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

  .intro-title {
    font-size: clamp(1.32rem, 6.4vw, 1.86rem);
    line-height: 1.1;
  }

  .intro-author {
    font-size: 0.95rem;
    line-height: 1.2;
  }

  .intro-hint {
    margin-top: 2px;
    font-size: 0.82rem;
    line-height: 1.2;
  }

  button {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 0.76rem;
  }
}
