/* Pic The Song — web (Play with Friends)
   Palette mirrors src/constants/theme.ts so the web build looks like the app. */

:root {
  --text:        #1E1E1E;
  --text-2:      #8E8E93;
  --bg:          #F2F2F7;
  --elem:        #E8E8ED;
  --surface:     #FFFFFF;
  --primary:     #2563EB;
  --primary-lt:  #DBEAFE;
  --green:       #22C55E;
  --yellow:      #EAB308;
  --youtube:     #FF0000;
  --hint-bg:     #FFF7ED;
  --hint-br:     #FED7AA;
  --hint-fg:     #EA580C;
  --shadow:      0 2px 8px rgba(0,0,0,.06);
  --radius:      20px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text:       #FFFFFF;
    --text-2:     #8E8E93;
    --bg:         #121212;
    --elem:       #212225;
    --surface:    #1E1E1E;
    --primary-lt: #1E3A5F;
    --hint-bg:    #2A1C0E;
    --hint-br:    #6B3F14;
    --hint-fg:    #FB923C;
    --shadow:     0 2px 8px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans Devanagari", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

/* The whole app is a single non-scrolling column, capped so a wide desktop
   window shows a phone-shaped board rather than a stretched one. This is the
   thing the Expo web export got wrong. */
#app {
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

.screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: max(12px, env(safe-area-inset-top)) 16px
           max(16px, env(safe-area-inset-bottom)) 16px;
  /* Normal viewports fit exactly and never scroll. This is only a release
     valve for pathologically short windows, where squashing the clues to a
     thumbnail would be worse than a scrollbar. */
  overflow-y: auto;
}

[hidden] { display: none !important; }

/* ── Buttons ─────────────────────────────────────────────────────────── */

.btn {
  font: inherit;
  font-weight: 700;
  border: none;
  border-radius: 16px;
  padding: 14px 18px;
  cursor: pointer;
  color: var(--text);
  background: var(--elem);
  transition: opacity .15s, transform .1s;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:active { transform: scale(.98); opacity: .85; }
.btn:disabled { opacity: .5; cursor: default; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-lg      { width: 100%; padding: 18px; font-size: 17px; border-radius: 18px; }
.btn-next    { background: var(--green); color: #fff; flex: 1 1 100%; font-size: 17px; height: 52px; }
.btn-youtube { background: var(--youtube); color: #fff; flex: 1 1 auto; font-size: 14px; }
.btn-ghost   { background: var(--elem); color: var(--text); flex: 1 1 auto; font-size: 14px; }

.btn-hint {
  flex: 1;
  background: var(--hint-bg);
  border: 1.5px solid var(--hint-br);
  color: var(--hint-fg);
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 20px;
}
.btn-hint:disabled { opacity: .45; }

.link-btn {
  background: none;
  border: none;
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  padding: 8px;
}

.icon-btn {
  background: none;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

/* ── Start screen ────────────────────────────────────────────────────── */

#start-screen { justify-content: center; }

.start-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  text-align: center;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--primary);
  display: grid;
  place-items: center;
  font-size: 20px;
  flex: none;
}
.brand-mark.small { width: 28px; height: 28px; border-radius: 8px; font-size: 14px; }

.brand-name { font-size: 26px; font-weight: 800; margin: 0; letter-spacing: -.5px; }

.tagline { margin: 0; font-size: 15px; color: var(--text-2); }

.how {
  list-style: none;
  margin: 4px 0 8px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
  width: 100%;
  font-size: 14px;
  line-height: 1.4;
}
.how li { display: flex; align-items: center; gap: 12px; }

.how-n {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--primary-lt);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  flex: none;
}
@media (prefers-color-scheme: dark) { .how-n { color: #93C5FD; } }

.error { color: #EF4444; font-size: 13px; margin: 0; }

/* ── Game: top bar ───────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: none;
}

.topbar-title { font-size: 16px; font-weight: 700; }

.pill {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 4px 10px;
  border-radius: 10px;
  background: var(--elem);
  color: var(--text-2);
}

/* ── Game: picture clues ─────────────────────────────────────────────── */

/* flex:1 + min-height:0 lets the grid absorb whatever vertical space is left,
   and the inner square is capped by BOTH width and height so the controls
   below are never pushed off screen. */
.media {
  flex: 1;
  /* Below this the clues stop being readable, so let the column scroll
     instead of shrinking them further. */
  min-height: 150px;
  display: grid;
  place-items: center;
  overflow: hidden;
  /* Lets the square below measure this box's HEIGHT via cqh. */
  container-type: size;
}

/* Fit a square into a box of unknown aspect: take the smaller of the
   container's width and height. `aspect-ratio` alone doesn't do this — when
   only max-height clamps it, the width keeps its own value and the grid
   overflows, which is exactly what broke on short viewports. */
.media-grid {
  width: min(100%, 100cqh);
  aspect-ratio: 1;
  max-height: 100%;
  max-width: 100%;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 8px;
}

.media-grid.g1 { grid-template: 1fr / 1fr; }
.media-grid.g2 { grid-template: 1fr / 1fr 1fr; }
.media-grid.g4 { grid-template: 1fr 1fr / 1fr 1fr; }

.media-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 14px;
  cursor: zoom-in;
  background: var(--elem);
  display: block;
}

.media-empty {
  display: grid;
  place-items: center;
  background: var(--elem);
  border-radius: 14px;
  color: var(--text-2);
  font-size: 14px;
  gap: 8px;
}

/* ── Game: hints ─────────────────────────────────────────────────────── */

.hint-row { display: flex; gap: 8px; flex: none; }

.hint-output { flex: none; display: flex; flex-direction: column; gap: 6px; }

.artist-hint {
  margin: 0;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
}
@media (prefers-color-scheme: dark) { .artist-hint { color: #93C5FD; } }

.title-words {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.title-words span {
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--elem);
  background: var(--elem);
}
.title-words span.masked { background: transparent; color: var(--elem); }

/* ── Game: countdown ─────────────────────────────────────────────────── */

.bottom { flex: none; display: flex; flex-direction: column; gap: 10px; }

.timer-hint {
  margin: 0;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-2);
}

.timer {
  position: relative;
  height: 56px;
  width: 100%;
  border: none;
  border-radius: 16px;
  background: var(--elem);
  overflow: hidden;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

/* Anchored right so it drains right-to-left, matching the app. */
.timer-fill {
  position: absolute;
  inset: 0 0 0 auto;
  width: 100%;
  background: var(--green);
  border-radius: 16px;
  transition: background-color .2s;
}
.timer.paused .timer-fill { background: var(--yellow); }

.timer-label {
  position: relative;
  z-index: 1;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .5px;
  text-shadow: 0 1px 2px rgba(0,0,0,.25);
}

/* ── Game: reveal ────────────────────────────────────────────────────── */

#reveal-area { display: flex; flex-direction: column; gap: 14px; }

.reveal-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 4px 0;
}

.disc {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: #1A1A2E;
  border: 6px solid #2D2D4E;
  display: grid;
  place-items: center;
  animation: spin 3s linear infinite;
  flex: none;
}
.disc-center { width: 13px; height: 13px; border-radius: 50%; background: #E11D48; }

@keyframes spin { to { transform: rotate(360deg); } }

.wave { display: flex; align-items: center; gap: 5px; height: 44px; }
.wave i {
  width: 5px;
  height: 40px;
  border-radius: 3px;
  background: var(--primary);
  animation: pulse 600ms ease-in-out infinite alternate;
}
@media (prefers-color-scheme: dark) { .wave i { background: #60A5FA; } }

.wave i:nth-child(1) { animation-duration: 500ms; animation-delay:   0ms; }
.wave i:nth-child(2) { animation-duration: 700ms; animation-delay: 150ms; }
.wave i:nth-child(3) { animation-duration: 600ms; animation-delay:  80ms; }
.wave i:nth-child(4) { animation-duration: 550ms; animation-delay: 220ms; }
.wave i:nth-child(5) { animation-duration: 650ms; animation-delay:  60ms; }

@keyframes pulse { from { transform: scaleY(.3); } to { transform: scaleY(1); } }

.song-info { text-align: center; }
.song-title  { margin: 0; font-size: 19px; font-weight: 800; }
.song-artist { margin: 4px 0 0; font-size: 14px; color: var(--text-2); }

.reveal-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Respect reduced-motion: keep the reveal legible, just still. */
@media (prefers-reduced-motion: reduce) {
  .disc, .wave i { animation: none; }
  .btn { transition: none; }
}

/* ── Lightbox ────────────────────────────────────────────────────────── */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.92);
  display: grid;
  place-items: center;
  z-index: 50;
  cursor: zoom-out;
  padding: 16px;
}
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ── Short viewports (landscape phones, small desktop windows) ───────── */

@media (max-height: 620px) {
  .how { display: none; }
  .reveal-visual { display: none; }
  .timer { height: 48px; }
  .screen { gap: 8px; }
}
