/* Zengram web — visuals mirror the Android client (ZengramColors + ZengramScreen).
 * No letter tiles: plain dark letters on sage, with a canvas-drawn selection
 * "snake". Haiku sits BELOW the grid; energy dots + hint chip beneath that. */
:root {
  --zg-bg: #CEDBCB;            /* ZengramColors.Background */
  --zg-ink: #1A1C1E;          /* TopBarContent / letters */
  --zg-selection: #B3E5FC;    /* SelectionBlue */
  --zg-found-theme: #81D4FA;  /* FoundThemeWord */
  --zg-found-zengram: #FFD54F;/* FoundZengram */
  --zg-muted: #5b6b58;
  --zg-cell: 44px;            /* set by JS to fit the viewport */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--zg-bg);
  color: var(--zg-ink);
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  touch-action: manipulation;
  overscroll-behavior: none;
}

.zg-app {
  max-width: 460px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 6px 14px 14px;
}

/* Header: back · title · refresh */
.zg-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.zg-header h1 {
  flex: 1;
  margin: 0;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.zg-icon-btn {
  border: none;
  background: transparent;
  color: var(--zg-ink);
  width: 38px; height: 38px;
  font-size: 1.3rem;
  cursor: pointer;
  display: grid; place-items: center;
  border-radius: 999px;
}
.zg-icon-btn:active { background: rgba(0,0,0,0.06); }

/* Status row: theme (left) · progress (right) */
.zg-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 2px;
}
.zg-theme { color: var(--zg-ink); }
.zg-progress { color: var(--zg-ink); }

/* Feedback / current-word line (fixed height, no layout shift) */
.zg-feedback {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.zg-feedback .zg-draft {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}
.zg-feedback .zg-msg {
  font-size: 1.05rem;
  font-weight: 700;
  color: #b00020;
}
.zg-feedback .zg-msg.zg-shake { animation: zg-shake 0.4s linear; }
@keyframes zg-shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* Board area: flexes to fill leftover height between header and haiku */
.zg-board-wrap {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 0;
}
.zg-board {
  position: relative;
  touch-action: none;
}
#zg-rain, #zg-snake {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#zg-snake { z-index: 0; pointer-events: none; }
#zg-rain { z-index: 3; }

.zg-letters {
  position: relative;
  z-index: 1;
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-columns: repeat(var(--zg-cols, 6), 1fr);
  grid-template-rows: repeat(var(--zg-rows, 8), 1fr);
  pointer-events: none; /* the board container handles pointer input */
}
.zg-letter {
  display: grid;
  place-items: center;
  font-size: calc(var(--zg-cell) * 0.5);
  font-weight: 800;
  color: var(--zg-ink);
  user-select: none;
  transition: transform 0.2s ease;
}
.zg-letter.zg-active { transform: scale(1.15); }

.zg-hidden { display: none !important; }

/* Haiku — below the grid (matches app). Found/leftover bold black;
 * hint-revealed gray italic; unfound = gray bullets per letter. */
.zg-haiku {
  text-align: center;
  line-height: 1.6;
  font-size: 0.95rem;
  min-height: 4.5em;
  padding: 4px 0 2px;
}
.zg-hk-line { white-space: nowrap; }
.zg-hk-word { margin: 0 0.18em; }
.zg-hk-shown { font-weight: 700; color: #000; }
.zg-hk-revealed { font-weight: 400; color: #555; font-style: italic; }
.zg-hk-hidden { font-weight: 400; color: #999; letter-spacing: 0.08em; }

/* Energy dots + hint chip */
.zg-hints {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 40px;
}
.zg-dots { display: flex; gap: 8px; }
.zg-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: rgba(120,120,120,0.3);
  transition: background 0.2s;
}
.zg-dot.on { background: var(--zg-selection); }
.zg-hint-chip {
  display: none;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
}
.zg-hint-chip.zg-on { display: inline-flex; }
.zg-hint-badge {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--zg-found-zengram);
  color: #000;
  display: grid; place-items: center;
  font-size: 0.72rem;
  font-weight: 800;
  animation: zg-pulse 0.8s ease-in-out infinite alternate;
}
@keyframes zg-pulse { from { transform: scale(1); } to { transform: scale(1.18); } }

/* Win overlay */
.zg-win {
  position: fixed; inset: 0;
  background: rgba(26,28,30,0.55);
  display: grid; place-items: center;
  padding: 24px; z-index: 20;
}
.zg-win-card {
  position: relative;
  background: var(--zg-bg);
  border-radius: 20px;
  padding: 26px 22px;
  max-width: 360px; width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.zg-win-close {
  position: absolute;
  top: 8px; right: 8px;
  width: 32px; height: 32px;
  font-size: 1.4rem;
  line-height: 1;
}
.zg-win-card h2 { margin: 0 0 12px; }
.zg-win-haiku { white-space: pre-line; line-height: 1.7; margin: 0 0 18px; }
.zg-btn {
  display: block; width: 100%;
  padding: 12px; margin: 8px 0;
  border: none; border-radius: 12px;
  background: var(--zg-found-zengram); color: #000;
  font-size: 1rem; font-weight: 700; cursor: pointer; text-decoration: none;
}
.zg-btn:active { transform: scale(0.98); }
.zg-btn-ghost { background: rgba(255,255,255,0.6); }
.zg-share-copied { color: var(--zg-muted); font-size: 0.85rem; margin: 6px 0 0; }

/* Streak / auth */
.zg-streak {
  margin: 12px 0 4px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.15);
  text-align: center;
}
.zg-streak-count {
  font-size: 1.1rem;
  margin: 0 0 4px;
}
.zg-streak-user {
  font-size: 0.8rem;
  color: var(--zg-muted);
  margin: 0;
}
.zg-streak-msg {
  font-size: 0.9rem;
  margin: 0 0 10px;
  color: var(--zg-muted);
}
.zg-btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #ffffff;
  color: #3c4c61;
  border: none;
}
.zg-btn-google:hover { opacity: 0.9; }

/* Landscape: keep board and haiku side-by-side so nothing clips. */
@media (orientation: landscape) and (max-height: 540px) {
  .zg-app { max-width: 820px; }
  .zg-feedback { height: 30px; }
  .zg-haiku { font-size: 0.85rem; min-height: 0; }
}
