/* ============================================================
   الطائر الأصفر — واجهة ملصق سفر دافئ (غابة عند الغروب)
   ============================================================ */
:root{
  --cream:#FBF3E1;
  --paper:#F5EAD2;
  --paper-2:#E6D3AC;
  --forest-1:#12301C;
  --forest-2:#1D452A;
  --forest-3:#2A5B36;
  --moss:#204228;
  --wood:#6B4A2B;
  --bark:#8A6238;
  --brass:#B08D3F;
  --brass-ink:#87661F;
  --brass-lt:#D9BC72;
  --brass-dk:#6E5320;
  --ink:#2A2014;
  --ink-soft:#63513A;
}

*{ box-sizing:border-box; }

html, body{
  height:100%;
  margin:0;
  padding:0;
}

body{
  background:var(--forest-1);
  color:var(--cream);
  font-family:'Tajawal', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing:antialiased;
  -webkit-tap-highlight-color:transparent;
  overscroll-behavior:none;
}

button{ font-family:inherit; }

.hidden{ display:none !important; }

/* ---------------- root ---------------- */
.game-root{
  position:relative;
  display:flex;
  flex-direction:column;
  height:100%;
  width:100%;
  overflow:hidden;
  background:
    radial-gradient(circle at 88% -10%, rgba(255,246,214,.20), transparent 55%),
    linear-gradient(180deg, var(--forest-3), var(--forest-1) 70%);
  color:var(--cream);
  user-select:none;
  -webkit-user-select:none;
}

/* ---------------- HUD ---------------- */
.hud{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  background:linear-gradient(180deg, #26512F, var(--forest-2) 60%, var(--forest-1));
  border-bottom:2px solid #0A1F12;
  box-shadow:0 3px 10px rgba(0,0,0,.25);
  min-height:52px;
  z-index:5;
}

.timer-panel{
  display:flex;
  align-items:center;
  gap:6px;
  padding:4px 10px 4px 9px;
  background:var(--cream);
  color:var(--ink);
  border:2px solid var(--bark);
  border-radius:12px;
  box-shadow:inset 0 1px 0 #FFFDF6, 0 3px 0 rgba(10,31,18,.45);
  min-width:0;
  flex:0 1 auto;
}

.clock-ico{
  width:17px;
  height:17px;
  flex:0 0 auto;
  color:var(--brass-ink);
}

.timer{
  font-family:'Baloo Bhaijaan 2', 'Tajawal', system-ui, sans-serif;
  font-weight:800;
  font-size:20px;
  line-height:1.1;
  letter-spacing:.4px;
  color:var(--brass-ink);
  font-variant-numeric:tabular-nums;
  white-space:nowrap;
}

.best-pill{
  display:flex;
  align-items:baseline;
  gap:5px;
  padding:4px 9px;
  border-radius:10px;
  background:rgba(251,243,225,.10);
  border:1px solid rgba(251,243,225,.20);
  color:var(--cream);
  min-width:0;
  flex:0 1 auto;
  overflow:hidden;
}

.best-label{
  font-size:11px;
  font-weight:700;
  color:var(--brass-lt);
  white-space:nowrap;
}

.best-value{
  font-family:'Baloo Bhaijaan 2', system-ui, sans-serif;
  font-weight:700;
  font-size:14px;
  color:var(--cream);
  font-variant-numeric:tabular-nums;
  white-space:nowrap;
}

.icon-btn{
  margin-inline-start:auto;
  width:44px;
  height:44px;
  flex:0 0 auto;
  display:grid;
  place-items:center;
  padding:0;
  border-radius:12px;
  border:2px solid rgba(251,243,225,.30);
  background:rgba(251,243,225,.12);
  color:var(--cream);
  cursor:pointer;
  touch-action:manipulation;
  transition:transform .12s ease, background-color .12s ease;
}
.icon-btn svg{ width:20px; height:20px; }
.icon-btn:active{ transform:scale(.94); background:rgba(251,243,225,.24); }
.icon-btn:focus-visible{ outline:3px solid var(--brass-lt); outline-offset:2px; }

/* ---------------- stage ---------------- */
.stage{
  position:relative;
  flex:1 1 auto;
  min-height:0;
  overflow:hidden;
  background:var(--paper-2);
  touch-action:none;
}

#gameCanvas{
  display:block;
  touch-action:none;
}

/* ---------------- controls dock ---------------- */
.dock{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:9px 12px 10px;
  background:linear-gradient(180deg, var(--forest-1), #0D2515);
  border-top:2px solid #0A1F12;
  z-index:5;
}

.flap-btn{
  width:100%;
  max-width:440px;
  min-height:60px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  padding:0 22px;
  border:none;
  border-radius:999px;
  background:var(--brass);
  color:#241B0C;
  font-family:'Baloo Bhaijaan 2', system-ui, sans-serif;
  font-weight:800;
  font-size:20px;
  letter-spacing:.2px;
  cursor:pointer;
  touch-action:manipulation;
  box-shadow:0 5px 0 var(--brass-dk), inset 0 2px 0 rgba(255,246,214,.45);
  transition:transform .1s ease, box-shadow .1s ease, background-color .12s ease;
}
.flap-ico{ width:26px; height:26px; }
.flap-btn:active{
  transform:translateY(4px);
  box-shadow:0 1px 0 var(--brass-dk), inset 0 2px 0 rgba(255,246,214,.35);
  background:#A5822F;
}
.flap-btn:focus-visible{ outline:3px solid var(--brass-lt); outline-offset:3px; }

/* ---------------- overlays / menus ---------------- */
.menu{
  position:absolute;
  inset:0;
  z-index:30;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:20px 16px;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  background:rgba(12,32,19,.58);
  backdrop-filter:blur(3px);
  -webkit-backdrop-filter:blur(3px);
}

.panel{
  position:relative;
  width:100%;
  max-width:340px;
  margin:auto;
  padding:22px 20px;
  text-align:center;
  color:var(--ink);
  background:
    radial-gradient(120% 80% at 50% 0%, #FFFCF2, var(--cream) 55%, var(--paper) 100%);
  border:3px solid var(--wood);
  border-radius:20px;
  box-shadow:0 7px 0 rgba(58,38,18,.55), 0 20px 44px rgba(0,0,0,.42);
}
.panel::before{
  content:'';
  position:absolute;
  inset:0;
  border-radius:inherit;
  pointer-events:none;
  background-image:radial-gradient(rgba(107,74,43,.09) 1px, transparent 1px);
  background-size:13px 13px;
  opacity:.55;
}

.bird-badge{
  width:96px;
  height:96px;
  margin:0 auto 6px;
  display:grid;
  place-items:center;
  border-radius:50%;
  background:radial-gradient(circle at 40% 30%, #FFFDF4, var(--paper-2));
  border:3px solid rgba(176,141,63,.55);
  animation:bob 2.6s ease-in-out infinite;
}
.bird-svg{ width:80px; height:80px; display:block; }

@keyframes bob{
  0%,100%{ transform:translateY(0) rotate(-1.5deg); }
  50%{ transform:translateY(-7px) rotate(1.5deg); }
}

.title{
  margin:6px 0 4px;
  font-family:'Baloo Bhaijaan 2', system-ui, sans-serif;
  font-weight:800;
  font-size:29px;
  line-height:1.25;
  color:var(--forest-2);
}

.sub{
  margin:0 0 16px;
  font-size:14px;
  line-height:1.6;
  color:var(--ink-soft);
}

.hint{
  margin:12px 0 0;
  font-size:12.5px;
  line-height:1.5;
  color:var(--ink-soft);
}

.best-line{
  margin-top:10px;
  padding:7px 12px;
  display:inline-block;
  border-radius:999px;
  background:rgba(107,74,43,.10);
  border:1px solid rgba(107,74,43,.22);
  color:#4B3A22;
  font-size:13px;
  font-weight:700;
}
.best-line span{
  font-family:'Baloo Bhaijaan 2', system-ui, sans-serif;
  color:var(--brass-ink);
  font-variant-numeric:tabular-nums;
}

/* ---------------- buttons ---------------- */
.btn-primary{
  display:block;
  width:100%;
  min-height:56px;
  margin-top:14px;
  padding:0 18px;
  border:none;
  border-radius:999px;
  background:var(--brass);
  color:#241B0C;
  font-family:'Baloo Bhaijaan 2', system-ui, sans-serif;
  font-weight:800;
  font-size:20px;
  cursor:pointer;
  touch-action:manipulation;
  box-shadow:0 5px 0 var(--brass-dk), inset 0 2px 0 rgba(255,246,214,.45);
  transition:transform .1s ease, box-shadow .1s ease, background-color .12s ease;
}
.btn-primary:active{
  transform:translateY(4px);
  box-shadow:0 1px 0 var(--brass-dk), inset 0 2px 0 rgba(255,246,214,.3);
  background:#A5822F;
}
.btn-primary:focus-visible{ outline:3px solid var(--forest-3); outline-offset:3px; }

.btn-ghost{
  display:block;
  width:100%;
  min-height:50px;
  margin-top:10px;
  padding:0 16px;
  border-radius:999px;
  border:2px solid rgba(107,74,43,.45);
  background:transparent;
  color:#4B3A22;
  font-family:'Baloo Bhaijaan 2', system-ui, sans-serif;
  font-weight:700;
  font-size:16px;
  cursor:pointer;
  touch-action:manipulation;
  transition:background-color .12s ease, transform .1s ease;
}
.btn-ghost:active{ transform:translateY(2px); background:rgba(107,74,43,.12); }
.btn-ghost:focus-visible{ outline:3px solid var(--forest-3); outline-offset:3px; }

.btn-mini{
  display:block;
  width:100%;
  min-height:44px;
  margin-top:8px;
  padding:0 14px;
  border-radius:999px;
  border:2px solid var(--brass);
  background:rgba(176,141,63,.12);
  color:var(--brass-ink);
  font-family:'Baloo Bhaijaan 2', system-ui, sans-serif;
  font-weight:700;
  font-size:15px;
  cursor:pointer;
  touch-action:manipulation;
}
.btn-mini:active{ background:rgba(176,141,63,.26); }
.btn-mini:focus-visible{ outline:3px solid var(--forest-3); outline-offset:3px; }

/* ---------------- game over panel ---------------- */
.eyebrow{
  margin:0;
  font-size:13px;
  font-weight:700;
  letter-spacing:.4px;
  color:#6B573C;
}

.big-time{
  margin:6px 0 0;
  font-family:'Baloo Bhaijaan 2', system-ui, sans-serif;
  font-weight:800;
  font-size:clamp(40px, 13vw, 56px);
  line-height:1.05;
  color:var(--brass-ink);
  font-variant-numeric:tabular-nums;
  letter-spacing:1px;
  text-shadow:0 2px 0 rgba(255,255,255,.65);
}
.big-time.small{ font-size:clamp(30px, 9vw, 40px); }

.time-label{
  margin:2px 0 10px;
  font-size:13px;
  color:var(--ink-soft);
}

.record-badge{
  display:inline-block;
  margin:0 0 10px;
  padding:5px 14px;
  border-radius:999px;
  background:var(--forest-3);
  color:#F4F7EC;
  font-size:12.5px;
  font-weight:700;
  box-shadow:0 3px 0 rgba(10,31,18,.35);
}

.best-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:8px 14px;
  border-radius:12px;
  background:rgba(107,74,43,.09);
  border:1px solid rgba(107,74,43,.20);
  color:#4B3A22;
  font-size:13.5px;
  font-weight:700;
}
.best-row span:last-child{
  font-family:'Baloo Bhaijaan 2', system-ui, sans-serif;
  color:var(--brass-ink);
  font-variant-numeric:tabular-nums;
  font-size:15px;
}
.best-row + .best-row{ margin-top:8px; }

.board-wrap{
  margin-top:14px;
  padding-top:12px;
  border-top:2px dashed rgba(107,74,43,.30);
  text-align:start;
}
.board-head{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:8px;
  margin-bottom:6px;
  font-size:12.5px;
  font-weight:700;
  color:#4B3A22;
}
.board-note{
  font-size:10.5px;
  font-weight:500;
  color:var(--ink-soft);
}
.board-list{ display:flex; flex-direction:column; gap:4px; }
.board-row{
  display:flex;
  align-items:center;
  gap:8px;
  padding:5px 9px;
  border-radius:9px;
  background:rgba(107,74,43,.07);
  font-size:12.5px;
  color:#3E2F1B;
}
.board-row.you{
  background:rgba(42,91,54,.16);
  box-shadow:inset 0 0 0 1.5px rgba(42,91,54,.45);
}
.board-row .rank{
  width:18px;
  flex:0 0 auto;
  font-family:'Baloo Bhaijaan 2', system-ui, sans-serif;
  font-weight:800;
  color:var(--brass-ink);
}
.board-row .who{
  flex:1 1 auto;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-weight:500;
}
.board-row .pts{
  flex:0 0 auto;
  font-family:'Baloo Bhaijaan 2', system-ui, sans-serif;
  font-variant-numeric:tabular-nums;
  color:var(--brass-ink);
  font-weight:700;
}
.board-empty{
  margin:4px 0 0;
  font-size:12px;
  color:var(--ink-soft);
}

/* ---------------- responsive tweaks ---------------- */
@media (max-width:380px){
  .best-pill{ display:none; }
  .timer{ font-size:19px; }
  .title{ font-size:26px; }
  .panel{ padding:18px 16px; }
}

@media (max-height:620px){
  .bird-badge{ width:74px; height:74px; margin-bottom:2px; }
  .bird-svg{ width:62px; height:62px; }
  .title{ font-size:24px; }
  .sub{ margin-bottom:10px; font-size:13px; }
  .panel{ padding:16px 16px; }
  .big-time{ font-size:clamp(34px, 11vw, 46px); }
  .btn-primary{ min-height:50px; font-size:18px; margin-top:10px; }
  .flap-btn{ min-height:54px; font-size:18px; }
}

@media (prefers-reduced-motion: reduce){
  .bird-badge{ animation:none; }
  .btn-primary, .btn-ghost, .flap-btn, .icon-btn{ transition:none; }
}