/* Phase 2: code button, sign-in sheet, cookie note, share card. */

#codeBtn {
  position: fixed; z-index: 10; left: 12px; top: calc(118px + env(safe-area-inset-top));
  padding: 9px 18px; border: 2px solid var(--ink); border-radius: 999px; background: var(--yellow);
  color: var(--ink); font: 800 15px 'Nunito', sans-serif; cursor: pointer; box-shadow: 0 3px 0 rgba(43,43,43,.18);
}
#codeBtn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(43,43,43,.18); }

#privacyBtn {
  position: fixed; z-index: 9; left: 12px; bottom: calc(18px + env(safe-area-inset-bottom));
  padding: 6px 12px; border: 2px solid var(--ink); border-radius: 999px; background: rgba(245,238,220,.92);
  color: var(--ink); font: 800 12px 'Nunito', sans-serif; cursor: pointer;
}

#cardExtra:empty { display: none; }
#cardExtra .row { display: flex; gap: 10px; flex-wrap: wrap; }
#cardExtra .mine { color: #3d6b34; font-weight: 800 !important; }

/* Sheet --------------------------------------------------------- */
#sheet[hidden] { display: none; }
#sheet { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 14px; }
#sheetBack { position: absolute; inset: 0; background: rgba(43,43,43,.45); }
#sheetCard {
  position: relative; width: min(420px, 100%); max-height: 92vh; overflow-y: auto;
  background: var(--cream); border: 2px solid var(--ink); border-radius: 26px; padding: 22px 22px 20px;
  box-shadow: 0 5px 0 rgba(43,43,43,.25); animation: sheetIn .25s ease-out;
}
@keyframes sheetIn { from { transform: translateY(26px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
#sheetClose {
  position: absolute; top: 12px; right: 14px; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--ink);
  background: #fff; font: 800 20px/1 'Nunito', sans-serif; cursor: pointer; color: var(--ink);
}
#sheetBody h2 { margin: 0 36px 4px 0; font-family: 'Caveat', 'Segoe Print', cursive; font-weight: 700; font-size: 34px; line-height: 1.05; }
#sheetBody p { margin: 6px 0; font-size: 15px; line-height: 1.45; font-weight: 600; }
#sheetBody .lead { color: #5b5545; }
#sheetBody .small { font-size: 13px; color: #6d6757; }
#sheetBody a { color: #8a5a00; font-weight: 800; }
#sheetBody label, #sheetBody .lbl { display: block; margin: 14px 0 6px; font-weight: 800; font-size: 14px; }
#sheetBody input[type=text] {
  width: 100%; height: 50px; border: 2px solid var(--ink); border-radius: 16px; background: #fff;
  padding: 0 14px; font: 800 20px 'Nunito', sans-serif; color: var(--ink); outline: none; appearance: none; -webkit-appearance: none;
}
#codeIn { text-align: center; letter-spacing: .12em; text-transform: uppercase; }
#sheetBody input[type=text]:focus { border-color: #B98A00; box-shadow: 0 0 0 3px rgba(242,201,76,.55); }
#sheetBody .msg { min-height: 20px; color: #B0432B; font-weight: 800; font-size: 14px; margin: 8px 0 0; }

.btn.big { width: 100%; margin-top: 8px; padding: 13px 20px; font-size: 17px; cursor: pointer; font-family: 'Nunito', sans-serif; }
.btn.small { margin-top: 8px; padding: 8px 16px; font-size: 14px; cursor: pointer; font-family: 'Nunito', sans-serif; }
.btn.ghost { background: #fff; }
.btn[disabled] { opacity: .6; cursor: wait; }

.levels { display: flex; gap: 8px; }
.lvl {
  flex: 1; padding: 11px 4px; border: 2px solid var(--ink); border-radius: 16px; background: #fff;
  font: 800 14px 'Nunito', sans-serif; color: var(--ink); cursor: pointer;
}
.lvl[aria-pressed=true] { background: var(--yellow); box-shadow: 0 3px 0 rgba(43,43,43,.2); }

/* The tiny cookie note */
.cookie {
  display: flex; gap: 12px; align-items: center; margin-top: 14px; padding: 10px 12px;
  border: 2px dashed #A9825A; border-radius: 18px; background: #FBF4E2;
}
.cookie svg { flex: none; animation: wobble 3.2s ease-in-out infinite; }
.cookie p { margin: 0 !important; font-size: 13px !important; line-height: 1.4 !important; }
@keyframes wobble { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }

/* The share card */
.share {
  margin: 14px 0 6px; padding: 16px 14px 14px; text-align: center; border: 2px solid var(--ink); border-radius: 22px;
  background: #CFE8F0; position: relative; overflow: hidden;
}
.share::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 26px; background: #8CC47A; border-top: 2px solid var(--ink); }
.share svg { position: relative; z-index: 1; display: block; margin: 0 auto 14px; }
.share .sname { position: relative; z-index: 1; font: 700 28px 'Caveat', cursive; }
.share .saddr { position: relative; z-index: 1; font-weight: 800; font-size: 16px; }
.share .stown { position: relative; z-index: 1; margin-top: 18px; font: 700 18px 'Caveat', cursive; color: #2f5a28; }

/* Little sparkles when a new house appears */
#world .plot.pop { animation: popin 1s ease-out; }
@keyframes popin { 0% { opacity: 0; } 55% { opacity: 1; } }
.spark {
  fill: var(--yellow); stroke: var(--ink); stroke-width: 1; transform-box: fill-box; transform-origin: center;
  animation: spark 1.1s ease-out forwards;
}
@keyframes spark {
  0% { transform: translate(0, 0) scale(.4); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.2); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .cookie svg, #sheetCard, #world .plot.pop, .spark { animation: none; }
}
