/* =========================================================
   Flappy Bird – style.css
   ========================================================= */

/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #0d0d1a;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ── App shell ─────────────────────────────────────────── */
#app {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: #0d0d1a;
}

/* ── Game wrapper (sized by JS to maintain aspect ratio) ── */
#game-wrap {
  position: relative;
  /* width/height set by JS */
  overflow: hidden;
  border-radius: 0;
  box-shadow: 0 0 40px rgba(0,0,0,0.8);
}

/* ── Canvas ─────────────────────────────────────────────── */
#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── Screens (all overlaid on canvas) ──────────────────── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.screen.active { pointer-events: all; }
.hidden { display: none !important; }

/* ── Shared helpers ────────────────────────────────────── */
.coin-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0,0,0,0.45);
  color: #FFD700;
  font-weight: 700;
  font-size: 16px;
  padding: 5px 12px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}
.coin-icon { font-size: 18px; }

/* ── Buttons ───────────────────────────────────────────── */
button { cursor: pointer; border: none; outline: none; font-family: inherit; }

.btn-primary {
  background: linear-gradient(135deg, #2ecc71, #27ae60);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  padding: 12px 28px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(46,204,113,0.45);
  transition: transform .12s, box-shadow .12s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-primary:hover  { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(46,204,113,0.5); }
.btn-primary:active { transform: translateY(1px);  box-shadow: 0 2px 6px rgba(46,204,113,0.3);  }

.btn-secondary {
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 11px 24px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(52,152,219,0.4);
  transition: transform .12s, box-shadow .12s;
}
.btn-secondary:hover  { transform: translateY(-2px); }
.btn-secondary:active { transform: translateY(1px);  }

.btn-ghost {
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.85);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.2);
  transition: background .15s;
}
.btn-ghost:hover  { background: rgba(255,255,255,0.2); }
.btn-ghost:active { background: rgba(255,255,255,0.08); }

.btn-back {
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.25);
  transition: background .15s;
}
.btn-back:hover  { background: rgba(255,255,255,0.25); }
.btn-back:active { background: rgba(255,255,255,0.1);  }

.btn-icon {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background .15s;
}
.btn-icon:hover { background: rgba(255,255,255,0.2); }

.btn-lg {
  font-size: 20px;
  padding: 14px 40px;
  border-radius: 14px;
  letter-spacing: .5px;
}

.btn-daily {
  background: linear-gradient(135deg, #f39c12, #e67e22);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── HUD ────────────────────────────────────────────────── */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: center;
  padding-top: 16px;
  pointer-events: none;
  z-index: 10;
}
#hud-score {
  font-size: 46px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.3);
  letter-spacing: -1px;
}

/* ── MENU SCREEN ───────────────────────────────────────── */
.menu-top {
  position: absolute;
  top: 16px; right: 16px;
}

.menu-title {
  text-align: center;
  margin-bottom: 8px;
}
.menu-title h1 {
  font-size: 48px;
  font-weight: 900;
  color: #fff;
  line-height: 1.1;
  text-shadow: 0 3px 0 rgba(0,0,0,0.35), 0 6px 20px rgba(0,0,0,0.25);
  letter-spacing: -1px;
}
.title-bird {
  font-size: 52px;
  animation: bob 1.4s ease-in-out infinite;
  display: inline-block;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.bird-showcase {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 8px 0;
}
#preview-canvas {
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.15);
}
.bird-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(255,255,255,0.9);
  font-size: 15px;
  font-weight: 600;
}

.highscore-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,0.35);
  padding: 8px 24px;
  border-radius: 999px;
  margin-bottom: 16px;
  backdrop-filter: blur(4px);
}
.hs-label { color: rgba(255,255,255,0.7); font-size: 14px; font-weight: 500; }
.hs-value { color: #FFD700; font-size: 26px; font-weight: 900; letter-spacing: -1px; }

.menu-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 0 48px;
}

.daily-banner {
  position: absolute;
  bottom: 24px;
  left: 16px; right: 16px;
  background: linear-gradient(135deg, rgba(243,156,18,0.9), rgba(230,126,34,0.9));
  border-radius: 12px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  backdrop-filter: blur(4px);
  animation: slideUp .4s ease;
}

/* ── READY SCREEN ──────────────────────────────────────── */
.ready-box {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  border-radius: 16px;
  padding: 24px 36px;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.15);
  animation: popIn .3s ease;
}
.ready-title {
  font-size: 36px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,0.4);
  letter-spacing: 2px;
}
.ready-hint {
  color: rgba(255,255,255,0.75);
  font-size: 15px;
  margin-top: 8px;
}
.kbd {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.4);
  padding: 2px 8px;
  border-radius: 5px;
  font-weight: 700;
  font-size: 13px;
}

/* ── GAME OVER SCREEN ──────────────────────────────────── */
.result-card {
  background: rgba(255,255,255,0.95);
  border-radius: 20px;
  padding: 24px 28px;
  width: calc(100% - 48px);
  max-width: 300px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: popIn .35s ease;
}
.gameover-title {
  text-align: center;
  font-size: 26px;
  font-weight: 900;
  color: #e74c3c;
  letter-spacing: 2px;
  margin-bottom: 16px;
}
.result-rows { border-top: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8; margin: 4px 0 16px; }
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 15px;
  color: #555;
}
.result-row:last-child { border-bottom: none; }
.highlight-row { background: rgba(243,156,18,0.08); border-radius: 6px; }
.rv { font-weight: 800; font-size: 18px; color: #2c3e50; }
.coins-rv { color: #e67e22; }
.new-best {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: #f39c12;
  padding: 4px 0 8px;
  animation: pop 0.4s ease;
}
.ach-banner {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #8e44ad;
  background: rgba(142,68,173,0.1);
  padding: 6px 10px;
  border-radius: 8px;
  margin-bottom: 8px;
}
.gameover-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── SHOP SCREEN ───────────────────────────────────────── */
#screen-shop {
  background: linear-gradient(180deg, rgba(20,20,40,0.97) 0%, rgba(10,10,25,0.99) 100%);
  justify-content: flex-start;
  overflow-y: auto;
}
.shop-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.shop-header h2 { color: #fff; font-size: 20px; font-weight: 800; }

.shop-tabs {
  display: flex;
  width: 100%;
  gap: 2px;
  padding: 12px 16px 0;
  flex-shrink: 0;
}
.tab-btn {
  flex: 1;
  padding: 10px 4px;
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.6);
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px 10px 0 0;
  border: 1px solid rgba(255,255,255,0.1);
  border-bottom: none;
  transition: background .15s, color .15s;
}
.tab-btn.active {
  background: rgba(255,255,255,0.13);
  color: #fff;
  border-color: rgba(255,255,255,0.18);
}

.tab-panel {
  width: 100%;
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 16px;
  background: rgba(255,255,255,0.04);
  border-top: 1px solid rgba(255,255,255,0.08);
}

.items-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Shop item card */
.shop-item {
  background: rgba(255,255,255,0.07);
  border: 1.5px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 14px 10px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: border-color .15s, background .15s;
}
.shop-item.owned    { border-color: rgba(46,204,113,0.5); background: rgba(46,204,113,0.06); }
.shop-item.equipped { border-color: #2ecc71; background: rgba(46,204,113,0.12); box-shadow: 0 0 0 1px #2ecc71; }
.shop-item.locked   { opacity: 0.7; }

.item-preview {
  width: 64px; height: 64px;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255,255,255,0.05);
  display: flex; align-items: center; justify-content: center;
}
.item-preview canvas { display: block; }
.item-preview.bg-thumb {
  width: 64px; height: 42px;
  border-radius: 8px;
}

.item-name {
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.item-price {
  color: #FFD700;
  font-size: 12px;
  font-weight: 600;
}

.item-action {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 7px;
  cursor: pointer;
  border: none;
  transition: transform .12s;
  width: 100%;
}
.item-action:active { transform: scale(0.96); }
.item-action.act-buy    { background: linear-gradient(135deg,#f39c12,#e67e22); color:#fff; }
.item-action.act-equip  { background: linear-gradient(135deg,#3498db,#2980b9); color:#fff; }
.item-action.act-active { background: #2ecc71; color:#fff; cursor:default; }
.item-action.act-locked { background: rgba(255,255,255,0.12); color:rgba(255,255,255,0.5); cursor:not-allowed; }

/* ── SHARE SCREEN ──────────────────────────────────────── */
#screen-share {
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
}
.share-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 0 16px;
}
.share-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
}
.share-header h2 { color: #fff; font-size: 18px; font-weight: 800; }
#share-canvas, #shared-canvas {
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  max-width: 100%;
  display: block;
}
.share-actions { display: flex; gap: 10px; justify-content: center; width: 100%; }

.copy-toast {
  background: rgba(46,204,113,0.9);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 8px 20px;
  border-radius: 999px;
  animation: fadeInOut 2s ease forwards;
}

/* ── SHARED SCORE VIEW ─────────────────────────────────── */
#screen-shared {
  background: linear-gradient(180deg, #0d1b2a 0%, #1a2a4a 100%);
}
.shared-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px 16px;
}
.shared-footer { display: flex; justify-content: center; }

/* ── RENAME MODAL ──────────────────────────────────────── */
.modal {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-bg {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(3px);
}
.modal-box {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 20px;
  padding: 28px 24px;
  width: calc(100% - 48px);
  max-width: 300px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  animation: popIn .25s ease;
}
.modal-box h3 {
  font-size: 20px;
  font-weight: 800;
  color: #2c3e50;
  margin-bottom: 16px;
  text-align: center;
}
#name-input {
  width: 100%;
  font-size: 16px;
  padding: 12px 14px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  outline: none;
  font-family: inherit;
  color: #2c3e50;
  transition: border-color .15s;
  margin-bottom: 14px;
}
#name-input:focus { border-color: #3498db; }
.modal-btns { display: flex; gap: 8px; }
.modal-btns .btn-primary { flex: 1; }
.modal-btns .btn-ghost   { flex: 1; }

/* ── ACHIEVEMENT TOAST ─────────────────────────────────── */
.ach-toast {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(20,10,40,0.95);
  border: 1.5px solid rgba(155,89,182,0.7);
  color: #fff;
  padding: 10px 18px;
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  z-index: 200;
  pointer-events: none;
  animation: slideDown .4s ease;
  white-space: nowrap;
}
.ach-toast-icon { font-size: 22px; }
.ach-toast-title { font-size: 11px; color: rgba(255,255,255,0.6); font-weight: 600; }
.ach-toast-name  { font-size: 14px; font-weight: 800; color: #e0a0ff; }
.ach-toast-reward{ font-size: 12px; font-weight: 700; color: #FFD700; }

/* ── KEYFRAME ANIMATIONS ───────────────────────────────── */
@keyframes bob {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}
@keyframes popIn {
  0%   { transform: scale(0.8); opacity: 0; }
  80%  { transform: scale(1.04); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}
@keyframes slideUp {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes slideDown {
  from { transform: translateX(-50%) translateY(-30px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);     opacity: 1; }
}
@keyframes fadeInOut {
  0%   { opacity: 0; }
  15%  { opacity: 1; }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ── SCROLLBAR (shop) ──────────────────────────────────── */
.tab-panel::-webkit-scrollbar { width: 4px; }
.tab-panel::-webkit-scrollbar-track { background: transparent; }
.tab-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 99px; }

/* ── Desktop layout tweaks ─────────────────────────────── */
@media (min-width: 500px) {
  #game-wrap {
    border-radius: 16px;
  }
}
