/* ============================================================
   LET'S DRAW — design tokens
   Tema: buku sketsa + coretan spidol. Kertas hangat, aksen
   warna spidol (coral utk pemain A, sky blue utk pemain B).
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Permanent+Marker&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Space+Mono:wght@400;700&display=swap');

:root {
  --paper: #fbf7ef;
  --paper-2: #f3ecdd;
  --ink: #211c16;
  --ink-soft: #55503f;
  --line: #e4d9c2;
  --coral: #ff5a36;
  --coral-dark: #d6431f;
  --sky: #2f6fed;
  --sky-dark: #1e4fb8;
  --yellow: #ffc93c;
  --green: #2e9e5b;
  --radius: 18px;
  --shadow: 0 4px 0 rgba(33, 28, 22, 0.9);
  --shadow-sm: 0 2px 0 rgba(33, 28, 22, 0.9);
  --font-display: 'Permanent Marker', cursive;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'Space Mono', monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(circle at 1px 1px, rgba(33,28,22,0.06) 1px, transparent 0) 0 0/22px 22px,
    var(--paper);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container.wide { max-width: 720px; }

/* ---------- typography ---------- */

h1, h2, h3 { margin: 0; }

.brand {
  font-family: var(--font-display);
  font-size: 2.1rem;
  color: var(--coral);
  letter-spacing: 0.5px;
  transform: rotate(-2deg);
  display: inline-block;
}

.brand .dot { color: var(--sky); }

h1.title {
  font-family: var(--font-display);
  font-size: 2.4rem;
  line-height: 1.15;
  color: var(--ink);
  margin: 4px 0 8px;
}

h2.section-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--ink);
  margin-bottom: 4px;
}

p.subtitle {
  color: var(--ink-soft);
  font-size: 0.98rem;
  line-height: 1.5;
  margin: 0 0 24px;
}

/* marker-stroke highlight under key words */
.marker-underline {
  position: relative;
  white-space: nowrap;
}
.marker-underline::after {
  content: "";
  position: absolute;
  left: -2%;
  right: -2%;
  bottom: 2px;
  height: 0.5em;
  background: var(--yellow);
  z-index: -1;
  transform: rotate(-1deg);
  border-radius: 3px 6px 3px 6px;
}

/* ---------- buttons ---------- */

.btn {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  padding: 14px 22px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
}
.btn:hover { transform: translate(-2px, -2px) rotate(-0.5deg); box-shadow: 6px 6px 0 rgba(33,28,22,0.9); }
.btn:active { transform: translate(0,2px); box-shadow: var(--shadow-sm); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: var(--shadow-sm); }

.btn-block { width: 100%; }
.btn-primary { background: var(--coral); color: #fff; }
.btn-secondary { background: var(--sky); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 9px 14px; font-size: 0.88rem; border-width: 2px; box-shadow: var(--shadow-sm); }
.btn-icon { width: 46px; height: 46px; padding: 0; border-radius: 14px; }

.btn-google {
  background: #fff;
  color: var(--ink);
}
.btn-google img { width: 22px; height: 22px; }

/* ---------- cards ---------- */

.card {
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card + .card { margin-top: 16px; }

.mode-card {
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
  cursor: pointer;
  width: 100%;
  background: #fff;
}
.mode-card .emoji { font-size: 2.2rem; }
.mode-card h3 { font-family: var(--font-display); font-size: 1.2rem; margin-bottom: 2px; }
.mode-card p { margin: 0; color: var(--ink-soft); font-size: 0.88rem; }

/* ---------- badges / pills ---------- */

.pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--yellow);
}

/* ---------- inputs ---------- */

.input {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  letter-spacing: 4px;
  text-align: center;
  text-transform: uppercase;
  width: 100%;
  padding: 14px;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper-2);
  color: var(--ink);
}
.input:focus { outline: 3px solid var(--sky); outline-offset: 1px; }

/* ---------- header bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  object-fit: cover;
}

/* ---------- versus block ---------- */

.versus {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 22px 0;
}
.player-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 96px;
}
.player-chip .avatar { width: 64px; height: 64px; border-width: 3px; }
.player-chip.coral .avatar { border-color: var(--coral); box-shadow: 0 0 0 4px rgba(255,90,54,0.15); }
.player-chip.sky .avatar { border-color: var(--sky); box-shadow: 0 0 0 4px rgba(47,111,237,0.15); }
.player-chip .name { font-size: 0.8rem; font-weight: 700; text-align: center; word-break: break-word; }
.player-chip .status { font-size: 0.7rem; color: var(--ink-soft); }

.vs-mark {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--yellow);
  -webkit-text-stroke: 2px var(--ink);
  transform: rotate(-6deg);
}

/* ---------- waiting / loading ---------- */

.pulse-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--coral);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 0.3; transform: scale(0.8);} 50% { opacity: 1; transform: scale(1.15);} }

.spinner-doodle {
  font-size: 2.5rem;
  display: inline-block;
  animation: wiggle 1.4s ease-in-out infinite;
}
@keyframes wiggle {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
}

/* ---------- game screen ---------- */

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.theme-banner {
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  padding: 14px 18px;
  text-align: center;
  margin-bottom: 14px;
}
.theme-banner .label { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 2px; color: var(--yellow); text-transform: uppercase; }
.theme-banner .word { font-family: var(--font-display); font-size: 1.6rem; margin-top: 4px; }

.timer {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.3rem;
  border: 3px solid var(--ink);
  border-radius: 12px;
  padding: 6px 12px;
  background: var(--yellow);
  min-width: 84px;
  text-align: center;
}
.timer.low { background: var(--coral); color: #fff; animation: pulse 0.8s infinite; }

.canvas-wrap {
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
  touch-action: none;
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
}
#drawCanvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.color-swatch {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--ink);
  cursor: pointer;
  flex-shrink: 0;
}
.color-swatch.active { outline: 3px solid var(--sky); outline-offset: 2px; }
.brush-range { flex: 1; min-width: 80px; accent-color: var(--coral); }

.tool-btn { background: #fff; }
.tool-btn.active { background: var(--ink); color: var(--paper); }

.color-picker-wrap {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--ink);
  flex-shrink: 0;
  cursor: pointer;
  overflow: hidden;
  display: inline-block;
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
}
.color-picker-wrap input[type="color"] {
  width: 140%; height: 140%;
  margin: -20%;
  border: none;
  cursor: pointer;
  padding: 0;
  background: none;
}
.color-picker-wrap input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-picker-wrap input[type="color"]::-webkit-color-swatch { border: none; }

.opponent-status {
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- result screen ---------- */

.result-banner {
  text-align: center;
  padding: 28px 18px;
}
.result-banner .trophy { font-size: 3rem; }
.result-banner h2 { font-family: var(--font-display); font-size: 2rem; margin: 8px 0; }
.result-reason {
  background: var(--paper-2);
  border: 2px dashed var(--ink-soft);
  border-radius: 14px;
  padding: 14px;
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin-top: 12px;
  text-align: left;
}
.result-images {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.result-images figure {
  flex: 1;
  margin: 0;
  border: 3px solid var(--ink);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}
.result-images img { width: 100%; display: block; }
.result-images figcaption {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-align: center;
  padding: 6px;
  border-top: 2px solid var(--ink);
}
.result-images figure.winner { box-shadow: 0 0 0 4px var(--yellow); }

/* ---------- misc ---------- */

.divider-doodle {
  border: none;
  height: 3px;
  margin: 22px 0;
  background: repeating-linear-gradient(90deg, var(--ink) 0 10px, transparent 10px 16px);
  opacity: 0.7;
}

.footer-note {
  margin-top: auto;
  padding-top: 24px;
  font-size: 0.75rem;
  color: var(--ink-soft);
  text-align: center;
}

.error-text { color: var(--coral-dark); font-size: 0.85rem; margin-top: 8px; }

.center-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
}

.hidden { display: none !important; }

@media (max-width: 400px) {
  h1.title { font-size: 2rem; }
  .vs-mark { font-size: 1.5rem; }
  .player-chip { width: 80px; }
}
