* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    color: #fff8ee;
    background: #2a1608;
    font-family: 'Trebuchet MS', 'Segoe UI', Arial, Helvetica, sans-serif;
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
}

#app {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at 50% 30%, #4a2410 0%, #2a1608 70%);
}

/* ===== Challenge selector (menu) ===== */
.challenge-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}
.challenge-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  text-align: left;
  padding: 14px 14px 12px;
  border-radius: 14px;
  cursor: pointer;
  color: #fff3e0;
  background: rgba(36, 18, 7, 0.75);
  border: 2px solid rgba(255, 224, 102, 0.25);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.challenge-card:hover {
  background: rgba(52, 28, 12, 0.85);
  border-color: rgba(255, 224, 102, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}
.challenge-card:focus-visible {
  outline: 3px solid #fb923c;
  outline-offset: 2px;
}
.challenge-card.active,
.challenge-card[aria-pressed="true"] {
  background: rgba(64, 34, 14, 0.92);
  border-color: #ffe066;
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 0 0 1px #fb923c, 0 10px 26px rgba(251, 146, 60, 0.45);
}
.challenge-card.active::after,
.challenge-card[aria-pressed="true"]::after {
  content: "\2713";
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 16px;
  font-weight: 800;
  color: #ffe066;
}
.challenge-card { position: relative; }
.cc-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  color: #1a0e05;
  background: #ffe066;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}
.cc-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  color: #fff3e0;
}
.challenge-card.active .cc-name,
.challenge-card[aria-pressed="true"] .cc-name {
  font-weight: 800;
  color: #ffe066;
}
.cc-meta {
  font-size: 12px;
  line-height: 1.35;
  color: rgba(255, 224, 178, 0.82);
}
.cc-best {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fb923c;
}
.challenge-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  margin-left: 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #1a0e05;
  background: #ffe066;
  border: 1px solid #fb923c;
  vertical-align: middle;
}
/* Portrait phones: stack the challenge cards into a single column */
@media (max-width: 600px) {
  .challenge-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    max-width: 340px;
  }
  .challenge-card { padding: 11px 12px 10px; }
  .cc-name { font-size: 14px; }
  .cc-meta { font-size: 11px; }
}

/* Landscape phones (e.g. 844x390): compact 3-column rows, tighter spacing */
@media (max-height: 500px) and (orientation: landscape) {
  .challenge-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    max-width: 520px;
  }
  .challenge-card { padding: 8px 10px; gap: 3px; }
  .cc-name { font-size: 13px; }
  .cc-meta { font-size: 10px; }
  .cc-best { font-size: 10px; }
  .title { font-size: 28px; }
  .howto { font-size: 12px; margin-bottom: 8px; }
  .keys { font-size: 11px; gap: 6px 12px; }
  .btn-big { margin-top: 10px; padding: 10px 26px; min-height: 46px; font-size: 16px; }
  .panel { padding: 16px 18px; }
}

/* ===== end challenge selector ===== */

#game-container {
    width: 100%;
    height: 100%;
    touch-action: none;
}

#hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#hud button, #hud .prompt-card, #hud .panel { pointer-events: auto; }

kbd {
    display: inline-block;
    min-width: 20px;
    padding: 1px 6px;
    margin: 0 2px;
    border: 1px solid rgba(255, 248, 238, 0.5);
    border-bottom-width: 3px;
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.35);
    font-family: inherit;
    font-size: 0.78em;
    text-align: center;
}

/* ---------- top bar ---------- */
.topbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 16px;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }

.brand {
    font-weight: 800;
    letter-spacing: 2px;
    font-size: 15px;
    color: #ffe066;
    text-shadow: 0 2px 6px rgba(0,0,0,0.55);
}

.timer-wrap { flex: 1; max-width: 420px; text-align: center; }
.timer-label { font-size: 12px; font-weight: 800; letter-spacing: 1.5px; text-shadow: 0 1px 4px rgba(0,0,0,0.6); }
.timer-num { font-size: 16px; }
.timer-track {
    margin-top: 4px;
    height: 10px;
    border-radius: 6px;
    background: rgba(0,0,0,0.45);
    border: 1px solid rgba(255,255,255,0.25);
    overflow: hidden;
}
.timer-fill { height: 100%; border-radius: 6px; transition: width 0.15s linear; }

.icon-btn {
    width: 44px; height: 44px;
    border-radius: 12px;
    border: 2px solid rgba(255, 248, 238, 0.45);
    background: rgba(42, 22, 8, 0.6);
    color: #fff8ee;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.icon-btn:active { transform: scale(0.92); }

/* ---------- objective + speech ---------- */
.objective {
    position: absolute;
    top: 64px;
    padding: 7px 18px;
    border-radius: 999px;
    background: rgba(42, 22, 8, 0.72);
    border: 1px solid rgba(255, 224, 102, 0.4);
    font-size: 14px;
    font-weight: 600;
    color: #ffe9b8;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.speech {
    position: absolute;
    top: 110px;
    max-width: 460px;
    padding: 10px 16px;
    border-radius: 14px 14px 14px 4px;
    background: #fff8ee;
    color: #4a2410;
    font-size: 14px;
    font-style: italic;
    box-shadow: 0 6px 18px rgba(0,0,0,0.4);
}

/* ---------- prompts ---------- */
.prompt-card {
    position: absolute;
    bottom: 118px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 14px 22px;
    border-radius: 16px;
    background: rgba(42, 22, 8, 0.85);
    border: 2px solid #e9b949;
    box-shadow: 0 0 26px rgba(255, 224, 102, 0.35);
    animation: rise 0.25s ease-out;
}
@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }

.prompt-title { font-size: 15px; font-weight: 700; color: #ffe9b8; }
.prompt-row { display: flex; gap: 12px; }

/* ---------- buttons ---------- */
.btn {
    padding: 12px 22px;
    min-height: 48px;
    border-radius: 12px;
    border: 2px solid transparent;
    font-family: inherit;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: transform 0.08s ease;
}
.btn:active { transform: scale(0.95); }

.btn-accept { background: #e9b949; color: #3d2008; }
.btn-accept:hover { background: #ffcf5e; }
.btn-refuse { background: transparent; color: #f8d9c2; border-color: rgba(248, 217, 194, 0.6); }
.btn-refuse:hover { border-color: #f87171; color: #fca5a5; }

.btn-big {
    margin-top: 18px;
    padding: 16px 40px;
    min-height: 56px;
    font-size: 19px;
    background: #e9b949;
    color: #3d2008;
    border-radius: 14px;
    box-shadow: 0 6px 0 #a97a1e, 0 10px 24px rgba(0,0,0,0.45);
}
.btn-big:active { transform: translateY(4px); box-shadow: 0 2px 0 #a97a1e; }

/* ---------- overlays ---------- */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 8, 2, 0.55);
    backdrop-filter: blur(3px);
    padding: 18px;
    overflow-y: auto;
}

/* ---------- Ethiopia wind HUD (EV.WIND listener) ---------- */
.wind-hud {
    position: absolute;
    top: 52px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 8px;
    background: rgba(10, 20, 14, 0.6);
    border: 1px solid rgba(127, 191, 154, 0.5);
    color: #dff5e6;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    pointer-events: none;
}
.wind-arrows { color: #ffe066; font-size: 14px; }
.wind-sheltered {
    color: #1a0e05;
    background: #7fbf9a;
    border-radius: 5px;
    padding: 2px 7px;
}
.overlay-dim { background: rgba(10, 4, 2, 0.72); }

.panel {
    max-width: 560px;
    width: 100%;
    text-align: center;
    padding: 30px 28px;
    border-radius: 22px;
    background: linear-gradient(160deg, #4a2410 0%, #2a1608 100%);
    border: 2px solid #b85d32;
    box-shadow: 0 18px 60px rgba(0,0,0,0.6);
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.panel-win { border-color: #ffe066; box-shadow: 0 0 50px rgba(255,224,102,0.35); }
.panel-broken { border-color: #7a4426; }

.title { margin: 0; font-size: 42px; letter-spacing: 1px; color: #fff8ee; text-shadow: 0 3px 12px rgba(0,0,0,0.6); }
.title span { color: #ffe066; }
.tagline { margin: 6px 0 14px; font-size: 17px; color: #e28a50; font-weight: 700; letter-spacing: 1px; }
.howto { margin: 0 auto 14px; max-width: 430px; font-size: 15px; line-height: 1.55; color: #f5e2c8; }
.fine { margin-top: 12px; font-size: 12px; color: rgba(255, 248, 238, 0.55); }

.keys {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 16px;
    font-size: 13px;
    color: #f5e2c8;
    margin-bottom: 6px;
}

.stats { display: flex; justify-content: center; gap: 40px; margin: 16px 0 4px; }
.stats > div { display: flex; flex-direction: column; }
.stat-num { font-size: 34px; font-weight: 800; color: #ffe066; }
.stat-lbl { font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: rgba(255,248,238,0.6); }

/* ---------- touch controls ---------- */
.touch-zone {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    display: none;
    justify-content: space-between;
    align-items: flex-end;
    padding: 14px 16px calc(18px + env(safe-area-inset-bottom, 0px));
}
.touch-left, .touch-right { display: flex; gap: 14px; align-items: flex-end; }

.touch-btn {
    width: 64px; height: 64px;
    border-radius: 50%;
    border: 2px solid rgba(255, 248, 238, 0.55);
    background: rgba(42, 22, 8, 0.55);
    color: #fff8ee;
    display: flex; align-items: center; justify-content: center;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}
.touch-btn:active { background: rgba(233, 185, 73, 0.45); transform: scale(0.92); }

/* Persistent Interact (ACT) button — visible label inside the 64px circle */
.touch-btn-interact { border-color: rgba(255, 224, 102, 0.75); }
.touch-btn-label {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #ffe066;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
    pointer-events: none;
}

@media (pointer: coarse) {
    .touch-zone { display: flex; }
    .objective { top: 58px; font-size: 12px; }
    .prompt-card { bottom: 130px; }
    .title { font-size: 32px; }
}