:root {
  --arcade: 'Press Start 2P', 'Courier New', monospace;
  --ink: #1d2530;
  --paper: #fdf6e3;
  --accent: #ffcf3f;
  --accent-dark: #e6a817;
}

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

html, body {
  min-height: 100%;
  background: linear-gradient(180deg, #2b1d3a 0%, #3d2a52 60%, #4c3566 100%);
  font-family: var(--arcade);
  -webkit-user-select: none;
  user-select: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top, 0px)) 16px calc(24px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

button { touch-action: manipulation; }

header { text-align: center; }

.title {
  color: var(--accent);
  font-size: 20px;
  text-shadow: 3px 3px 0 #1d2530;
  letter-spacing: 2px;
  margin-bottom: 14px;
}

#total {
  color: #ffffff;
  font-size: 30px;
  text-shadow: 3px 3px 0 rgba(29, 37, 48, 0.8);
  margin-bottom: 8px;
  min-height: 30px;
}

#rate {
  color: #b8a3d6;
  font-size: 9px;
}

/* ---------- The Face ---------- */

main { position: relative; }

#face-btn {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  border: 6px solid #ffffff;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  background: #1d2530;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 0 6px rgba(255, 207, 63, 0.35);
  transition: transform 0.06s ease;
}

#face-btn:active { transform: scale(0.92); }

#face-btn img {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

#floats {
  position: absolute;
  inset: -40px;
  pointer-events: none;
  overflow: visible;
}

.float {
  position: absolute;
  color: var(--accent);
  font-size: 13px;
  text-shadow: 2px 2px 0 #1d2530;
  animation: rise 0.9s ease-out forwards;
}

@keyframes rise {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-70px) scale(1.3); }
}

/* ---------- Shop ---------- */

section {
  width: 100%;
  background: rgba(253, 246, 227, 0.07);
  border: 2px solid rgba(253, 246, 227, 0.18);
  border-radius: 12px;
  padding: 14px;
}

section h2 {
  color: var(--accent);
  font-size: 11px;
  margin-bottom: 12px;
  text-align: center;
  text-shadow: 2px 2px 0 #1d2530;
}

#items { display: flex; flex-direction: column; gap: 8px; }

.item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 3px solid #1d2530;
  border-radius: 8px;
  background: var(--paper);
  cursor: pointer;
  font-family: var(--arcade);
  text-align: left;
  transition: transform 0.06s ease;
}

.item:active:not(:disabled) { transform: scale(0.98); }

.item:disabled {
  background: #4a4358;
  border-color: #322c40;
  cursor: not-allowed;
}

.item .emoji { font-size: 20px; flex: none; }

.item .info { flex: 1; min-width: 0; }

.item .name { font-size: 9px; color: var(--ink); margin-bottom: 4px; }
.item:disabled .name { color: #b8a9cc; }

.item .desc { font-size: 7px; color: #7a8494; line-height: 1.5; }
.item:disabled .desc { color: #857a99; }

.item .buy { text-align: right; flex: none; }

.item .cost { font-size: 8px; color: var(--accent-dark); margin-bottom: 4px; }
.item:disabled .cost { color: #a08cb8; }

.item .owned { font-size: 8px; color: #7a8494; }

/* ---------- Leaderboard ---------- */

#board-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  min-height: 20px;
}

#board-list li {
  display: flex;
  gap: 8px;
  color: #e8ddf5;
  font-size: 9px;
  padding: 6px 8px;
  background: rgba(253, 246, 227, 0.06);
  border-radius: 6px;
}

#board-list .rank { color: var(--accent); width: 24px; flex: none; }
#board-list .bname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#board-list .bscore { color: var(--accent); }

.board-row { display: flex; gap: 8px; }

#player-name {
  font-family: var(--arcade);
  font-size: 9px;
  padding: 10px;
  flex: 1;
  min-width: 0;
  border: 3px solid #1d2530;
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  text-transform: uppercase;
  outline: none;
}

.btn {
  font-family: var(--arcade);
  font-size: 9px;
  padding: 10px 12px;
  border: 3px solid #1d2530;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 3px 0 #1d2530;
}

.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #1d2530; }

.btn-primary { background: var(--accent); }

#post-status {
  margin-top: 10px;
  font-size: 8px;
  color: #b8a3d6;
  text-align: center;
  line-height: 1.6;
  min-height: 10px;
}

footer { padding-bottom: 8px; }

.home-link {
  color: #9a86b8;
  font-size: 8px;
  text-decoration: none;
}

/* ---------- Toast ---------- */

#toast {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--ink);
  border: 3px solid #1d2530;
  border-radius: 8px;
  padding: 10px 14px;
  font-family: var(--arcade);
  font-size: 9px;
  line-height: 1.6;
  text-align: center;
  z-index: 10;
  max-width: 90vw;
}

#toast.hidden { display: none; }
