/* ── Base ── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  font-family: 'Inter', sans-serif;
  background: #F7F4EE;
  color: #1B3A2D;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: #F7F4EE;
}

.hidden {
  display: none !important;
}

/* ── Header ── */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 9px;
  border-bottom: 1.5px solid #DDD8CE;
  background: #F7F4EE;
  flex-shrink: 0;
}

#logo {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 700;
  color: #1B3A2D;
  letter-spacing: -0.5px;
}

#logo span {
  color: #4A9B6F;
}

#lives-container {
  display: flex;
  gap: 6px;
}

.life {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #4A9B6F;
  transition: background 0.3s, transform 0.3s;
}

.life.lost {
  background: #DDD8CE;
  border: 1.5px solid #C9C4BB;
  transform: scale(0.85);
}

/* ── Loading ── */
#loading-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: #9B9589;
  font-size: 14px;
}

#loading-frog {
  width: 60px;
  height: 60px;
  animation: bounce 0.9s ease-in-out infinite alternate;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to   { transform: translateY(-16px); }
}

/* ── Game ── */
#game {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Canvas window ── */
#canvas-window {
  max-height: 52vh;
  margin: 12px 12px 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1.5px solid #DDD8CE;
  box-shadow:
    0 2px 8px rgba(27, 58, 45, 0.08),
    inset 0 1px 0 rgba(255,255,255,0.6);
  background: #2B7BB0;
  flex: 1;
  min-height: 0;
}

#river-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── Wordplay area ── */
#wordplay-area {
  padding: 10px 12px 28px;
  flex-shrink: 0;
  position: relative;
}

#clues-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #9B9589;
  text-align: center;
  margin-bottom: 8px;
}

/* ── Clues row ── */
#clues-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  align-items: start;
}

.clue-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.clue-chip {
  height: 36px;
  background: #EDE9E1;
  border: 1.5px solid #DDD8CE;
  border-radius: 6px;
  padding: 0 4px;
  font-size: 12px;
  font-weight: 700;
  color: #1B3A2D;
  text-align: center;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.4s, border-color 0.4s, color 0.4s, box-shadow 0.4s;
}

.clue-chip.lit {
  background: #E8C547;
  border-color: #D4AF35;
  color: #1B3A2D;
  box-shadow: 0 0 12px rgba(232, 197, 71, 0.4);
}
/* ── Centre column — mirrors side columns using grid ── */
#centre-col {
  display: grid;
  grid-template-rows: 36px 36px 36px;
  gap: 6px;
  position: relative;
}

#centre-empty-top,
#centre-empty-bottom {
  /* Empty cells that mirror the first and third chip rows */
}

#input-cell {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  /* Sits naturally in grid row 2 — aligned with middle chips */
}

/* Remove the old spacer rule entirely */
.centre-spacer {
  display: none;
}


/* ── Input cell ── */
#input-cell {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
}

#guess-input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  border: 2px solid #4A9B6F;
  border-radius: 6px;
  background: #fff;
  color: #1B3A2D;
  text-transform: uppercase;
  text-align: center;
  letter-spacing: 2px;
  transition: border-color 0.2s, background 0.2s;
  box-sizing: border-box;
  margin: 0;
}

#guess-input:focus {
  outline: none;
  border-color: #1B3A2D;
}

/* ── Connector lines ── */
#connector-line-left,
#connector-line-right {
  display: none;
  height: 2px;
  border-radius: 1px;
}

#connector-line-left {
  background: linear-gradient(90deg, transparent, #E8C547 80%);
  transform-origin: left center;
}

#connector-line-right {
  background: linear-gradient(90deg, #E8C547 20%, transparent);
  transform-origin: right center;
}

#connector-line-left.show,
#connector-line-right.show {
  display: block;
  animation: lineGrow 0.5s ease forwards;
}

@keyframes lineGrow {
  from { opacity: 0; transform: scaleX(0); }
  to   { opacity: 1; transform: scaleX(1); }
}

/* ── Message bar ── */
#message-bar {
  min-height: 16px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: #9B9589;
  letter-spacing: 0.3px;
  margin-top: 2px;
  position: absolute;
  bottom: 8px;
  left: 0;
  right: 0;
}

/* ── Keyboard ── */
#keyboard {
  padding: 6px 6px 10px;
  background: #F7F4EE;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  border-top: 1.5px solid #DDD8CE;
  flex-shrink: 0;
}

.kb-row {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.kb-key {
  width: 34px;
  height: 44px;
  background: #EDE9E1;
  color: #1B3A2D;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  border: 1.5px solid #DDD8CE;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.kb-key:active {
  transform: scale(0.92);
}

.kb-key.wide {
  width: 50px;
  font-size: 11px;
}

.kb-key.green {
  background: #4A9B6F;
  border-color: #3a7d58;
  color: #fff;
}

.kb-key.gray {
  background: #C9C4BB;
  border-color: #B5B0A8;
  color: #888;
}

/* ── Modal (loss state only) ── */
#modal {
  position: fixed;
  inset: 0;
  background: rgba(27, 58, 45, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

#modal-box {
  background: #F7F4EE;
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
  max-width: 300px;
  width: 90%;
  animation: popIn 0.3s ease;
  box-shadow: 0 20px 60px rgba(27, 58, 45, 0.25);
}

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

#modal-emoji {
  font-size: 40px;
  margin-bottom: 10px;
}

#modal-message {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  font-weight: 700;
  color: #1B3A2D;
  margin-bottom: 8px;
}

#modal-trail {
  font-size: 14px;
  font-style: italic;
  color: #6B6560;
  letter-spacing: 0.5px;
}

#modal-trail strong {
  color: #1B3A2D;
  font-style: normal;
  font-weight: 700;
}

/* ── Responsive — small phones ── */
@media (max-width: 380px) {
  .clue-chip { font-size: 10px; letter-spacing: 0; }
  .kb-key { width: 28px; height: 40px; font-size: 12px; }
  .kb-key.wide { width: 42px; }
  #canvas-window { margin: 8px 8px 0; border-radius: 10px; }
  #guess-input { font-size: 12px; letter-spacing: 1px; }
  #wordplay-area { padding: 8px 10px 24px; }
}