/* ============================================================
   DRAW TOGETHER – Main Stylesheet
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #1a1a2e;
  --bg2:       #16213e;
  --bg3:       #0f3460;
  --accent:    #e94560;
  --accent2:   #4ecca3;
  --gold:      #f5a623;
  --text:      #eaeaea;
  --text-dim:  #9aa5b4;
  --radius:    12px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
}

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  font-size: 16px;
}

/* ---- Views ---- */
.view { display: none; width: 100%; height: 100%; }
.view.active { display: flex; }


/* ---- Typography ---- */
.game-title {
  font-family: 'Bangers', cursive;
  font-size: clamp(3rem, 8vw, 6rem);
  letter-spacing: 3px;
  color: var(--accent);
  text-shadow: 3px 3px 0 #000, 6px 6px 0 rgba(233,69,96,0.3);
  line-height: 1;
}

.game-title.small { font-size: clamp(2rem, 6vw, 3rem); }

.tagline {
  color: var(--text-dim);
  font-size: 1.1rem;
  margin-top: 0.5rem;
}

.label { color: var(--text-dim); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; }
.hint-text { color: var(--text-dim); font-size: 0.9rem; text-align: center; margin-top: 0.75rem; }
.error-text { color: var(--accent); font-size: 0.9rem; margin-top: 0.5rem; min-height: 1.2em; text-align: center; }


/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.75rem;
  border: none;
  border-radius: var(--radius);
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
  text-decoration: none;
  min-height: 48px;
  user-select: none;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #c73652; }

.btn-secondary { background: var(--bg3); color: var(--text); }
.btn-secondary:hover { background: #1a4a80; }

.btn-large { font-size: 1.2rem; padding: 1rem 2.5rem; min-height: 56px; }


/* ---- Inputs ---- */
.text-input {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 2px solid var(--bg3);
  border-radius: var(--radius);
  background: var(--bg2);
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  outline: none;
  min-height: 48px;
}
.text-input:focus { border-color: var(--accent); }
.text-input::placeholder { color: var(--text-dim); font-weight: 400; }

.code-input {
  text-transform: uppercase;
  letter-spacing: 4px;
  font-family: 'Bangers', cursive;
  font-size: 2rem;
  text-align: center;
}

.input-group { display: flex; flex-direction: column; gap: 0.75rem; width: 100%; }


/* ---- Room Code display ---- */
.room-code {
  font-family: 'Bangers', cursive;
  font-size: clamp(4rem, 12vw, 8rem);
  letter-spacing: 12px;
  color: var(--accent2);
  text-shadow: 3px 3px 0 #000;
  text-align: center;
  line-height: 1;
}
.room-code.small { font-size: 2.5rem; letter-spacing: 6px; }


/* ---- Player List ---- */
.player-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; width: 100%; }
.player-list li {
  padding: 0.6rem 1rem;
  background: var(--bg3);
  border-radius: 8px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.player-list li::before {
  content: '';
  width: 10px; height: 10px;
  background: var(--accent2);
  border-radius: 50%;
  flex-shrink: 0;
}


/* ---- Timer Bar ---- */
.timer-bar-container {
  width: 100%;
  height: 12px;
  background: var(--bg3);
  border-radius: 6px;
  overflow: hidden;
}
.timer-bar-container.slim { height: 6px; border-radius: 0; }

.timer-bar {
  height: 100%;
  width: 100%;
  background: var(--accent2);
  border-radius: 6px;
  transition: width 1s linear, background 1s;
}
.timer-bar.urgent { background: var(--accent); }


/* ---- Center Card ---- */
.center-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 2rem;
  max-width: 480px;
  width: 100%;
  text-align: center;
  margin: auto;
}


/* ============================================================
   ENTRY PAGE
   ============================================================ */
.entry-body { overflow: auto; }
.entry-body body { overflow: auto; }
.entry-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  gap: 1.5rem;
  padding: 2rem;
  text-align: center;
}
.entry-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 300px;
}


/* ============================================================
   HOST SCREEN
   ============================================================ */
.host-body { display: flex; flex-direction: column; }
.host-body .view { flex-direction: column; align-items: center; justify-content: center; }

/* Host – Lobby */
.lobby-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  width: 100%;
  max-width: 1100px;
  padding: 2rem;
  height: 100%;
  align-items: center;
}

.lobby-left, .lobby-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.lobby-left h2, .lobby-right h2 {
  font-size: 1.5rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.qr-container {
  background: #eaeaea;
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.qr-container img { display: block; width: 200px; height: 200px; }
.join-url { color: #333; font-size: 0.8rem; word-break: break-all; text-align: center; max-width: 220px; }

.room-code-section { text-align: center; }

#player-count { color: var(--accent2); }

.btn-large.host-start {
  width: 100%;
  font-size: 1.4rem;
  padding: 1.25rem;
}

/* Host – Round in progress */
.round-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  padding: 3rem;
  width: 100%;
  max-width: 800px;
}

.round-badge {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 3px;
}

.part-label {
  font-family: 'Bangers', cursive;
  font-size: clamp(5rem, 15vw, 10rem);
  letter-spacing: 8px;
  line-height: 1;
  color: var(--gold);
  text-shadow: 4px 4px 0 #000;
}

.drawing-hint {
  color: var(--text-dim);
  font-size: 1.1rem;
}

.submission-tracker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.dots {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}
.dot {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--bg3);
  border: 2px solid var(--bg3);
  transition: background 0.3s, border-color 0.3s;
}
.dot.done { background: var(--accent2); border-color: var(--accent2); }

#submission-text { color: var(--text-dim); font-weight: 700; font-size: 1.1rem; }

.round-display .timer-bar-container { width: 100%; max-width: 500px; }

/* Host – Transition */
#view-transitioning .view { flex-direction: column; }
.big-text {
  font-family: 'Bangers', cursive;
  font-size: clamp(3rem, 10vw, 6rem);
  letter-spacing: 4px;
  text-align: center;
  color: var(--text);
}

/* Host – Reveal */
#view-reveal {
  flex-direction: column;
  align-items: center;
  padding: 2rem;
  overflow-y: auto;
  gap: 2rem;
}

.reveal-title {
  font-family: 'Bangers', cursive;
  font-size: clamp(2.5rem, 6vw, 4rem);
  letter-spacing: 6px;
  color: var(--accent);
  text-shadow: 3px 3px 0 #000;
  text-align: center;
  flex-shrink: 0;
}

/* Reveal stage: one monster at a time */
.reveal-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.monster-display {
  display: flex;
  flex-direction: column;
  width: clamp(240px, 35vh, 360px);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  opacity: 0;
  transform: translateY(40px) scale(0.85);
}

.monster-display.revealed {
  animation: monster-pop 0.55s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes monster-pop {
  0%   { opacity: 0; transform: translateY(40px) scale(0.8); }
  65%  { opacity: 1; transform: translateY(-10px) scale(1.06); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.monster-part {
  width: 100%;
  display: block;
}

.monster-credits {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.5px;
}

.reveal-controls {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.monster-counter {
  font-family: 'Bangers', cursive;
  font-size: 1.8rem;
  color: var(--text-dim);
  letter-spacing: 2px;
}


/* ============================================================
   PLAYER SCREEN
   ============================================================ */
.player-body { display: flex; flex-direction: column; }
.player-body .view {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Player – Drawing View */
.player-body .view.drawing-view {
  align-items: stretch;
  justify-content: flex-start;
  flex-direction: column;
  overflow-y: auto;
  padding: 0;
  gap: 0;
  background: var(--bg);
}

.drawing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  flex-shrink: 0;
  background: var(--bg2);
}

.part-pill {
  font-family: 'Bangers', cursive;
  font-size: 1.5rem;
  letter-spacing: 3px;
  color: var(--gold);
  background: var(--bg3);
  padding: 0.2rem 0.8rem;
  border-radius: 20px;
}

.timer-display {
  font-family: 'Bangers', cursive;
  font-size: 1.8rem;
  color: var(--accent2);
  min-width: 2.5rem;
  text-align: right;
  transition: color 0.3s;
}
.timer-display.urgent { color: var(--accent); }

.canvas-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
  background: #fff;
  overflow: hidden;
  cursor: crosshair;
}

#draw-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  display: block;
}

/* Hint strip – shows bottom of previous drawing, faintly, at top of canvas */
.hint-strip {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50px;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
  opacity: 0.25;
}
.hint-strip img {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  /* The image is full canvas size; bottom-aligned so we see the bottom edge only */
}

/* Hint label */
.hint-label {
  position: absolute;
  top: 50px;
  left: 0; right: 0;
  height: 2px;
  background: repeating-linear-gradient(90deg, rgba(78,204,163,0.5) 0 8px, transparent 8px 16px);
  pointer-events: none;
  z-index: 3;
}

/* Toolbar */
.toolbar {
  flex-shrink: 0;
  background: var(--bg2);
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-top: 2px solid var(--bg3);
}

.color-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.color-swatch {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s, border-color 0.1s;
}
.color-swatch:active { transform: scale(0.9); }
.color-swatch.active { border-color: #fff; transform: scale(1.15); }

.tool-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.tool-btn {
  padding: 0.4rem 0.7rem;
  background: var(--bg3);
  color: var(--text-dim);
  border: 2px solid transparent;
  border-radius: 8px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
  min-height: 36px;
  white-space: nowrap;
}
.tool-btn:active { transform: scale(0.95); }
.tool-btn.active { background: var(--accent2); color: #000; border-color: var(--accent2); }

.submit-btn {
  margin-left: auto;
  padding: 0.4rem 1.25rem;
  font-size: 1rem;
  min-height: 40px;
}

/* Player – Waiting View */
.submitted-icon {
  width: 72px; height: 72px;
  background: var(--accent2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: #000;
  font-weight: 900;
}

.waiting-text { color: var(--text-dim); font-size: 1rem; }

/* Player – Reveal View */
.reveal-phone-text { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.big-emoji { font-size: 4rem; display: block; }


/* ============================================================
   RESPONSIVE TWEAKS
   ============================================================ */
@media (max-width: 700px) {
  .lobby-layout {
    grid-template-columns: 1fr;
    overflow-y: auto;
    align-items: start;
  }
  .lobby-left { order: 2; }
  .lobby-right { order: 1; }
  .qr-container img { width: 160px; height: 160px; }
  .room-code { font-size: clamp(3rem, 18vw, 5rem); letter-spacing: 8px; }
  .part-label { font-size: clamp(3.5rem, 20vw, 6rem); }
}

@media (max-width: 400px) {
  .color-swatch { width: 28px; height: 28px; }
}
