/* ============ Shopping Spree — cartoony supermarket theme ============ */
:root {
  --bg: #7ec8e3;
  --bg2: #a8e6cf;
  --panel: #fffaf0;
  --panel2: #fff3d6;
  --ink: #3a2e39;
  --ink-soft: #7a6a78;
  --accent: #ff6f61;
  --accent2: #ffb400;
  --green: #2ecc71;
  --red: #e74c3c;
  --gold: #ffd166;
  --purple: #9b5de5;
  --radius: 18px;
  --shadow: 0 6px 0 rgba(58, 46, 57, .18);
  font-size: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Baloo 2', 'Nunito', 'Comic Sans MS', system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%) fixed;
  min-height: 100vh;
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 1rem; }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }

/* ---------- nav ---------- */
#topnav {
  display: flex; align-items: center; gap: .9rem;
  padding: .55rem 1.1rem;
  background: #fff;
  border-bottom: 4px solid #ffd166;
  box-shadow: 0 3px 12px rgba(0,0,0,.08);
  position: sticky; top: 0; z-index: 50;
}
#topnav .logo { font-size: 1.35rem; font-weight: 800; color: var(--ink); display: flex; align-items: center; gap: .35rem; }
#topnav .logo em { color: var(--accent); font-style: normal; }
.navlink { font-weight: 700; color: var(--ink-soft); padding: .25rem .6rem; border-radius: 12px; }
.navlink:hover, .navlink.active { color: var(--ink); background: var(--panel2); }
#topnav .spacer { flex: 1; }
#navAuthed { display: flex; align-items: center; gap: .6rem; }

.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  background: var(--panel2); border: 2px solid #f0ddaa; border-radius: 999px;
  padding: .3rem .8rem; font-weight: 800; font-size: .95rem;
}
.pill.coins b { color: #b07d00; }
.pill.gold { background: var(--gold); border-color: #e0b34a; cursor: pointer; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { transform: scale(1);} 50% { transform: scale(1.06);} }

.iconbtn { background: none; border: none; font-size: 1.3rem; }
.avatarbtn { background: none; border: none; padding: 0; }

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--gold); overflow: hidden;
  border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.15);
  width: 48px; height: 48px; font-size: 26px; flex: none;
}
.avatar.sm { width: 38px; height: 38px; font-size: 20px; }
.avatar.lg { width: 96px; height: 96px; font-size: 54px; border-width: 4px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- buttons ---------- */
.btn {
  border: none; border-radius: var(--radius);
  font-weight: 800; font-size: 1.05rem;
  padding: .65rem 1.4rem;
  box-shadow: var(--shadow);
  transition: transform .08s, box-shadow .08s;
  color: #fff; background: var(--accent);
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(58,46,57,.18); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); }
.btn.green { background: var(--green); }
.btn.gold { background: var(--accent2); color: #5c4300; }
.btn.purple { background: var(--purple); }
.btn.ghost { background: #fff; color: var(--ink); border: 2px solid #e8dccc; box-shadow: none; }
.btn.sm { font-size: .9rem; padding: .4rem .9rem; border-radius: 13px; }
.btn.xl { font-size: 1.5rem; padding: .9rem 2.2rem; border-radius: 24px; }

/* ---------- layout ---------- */
#view { max-width: 1280px; margin: 0 auto; padding: 1.1rem; }
.game-layout { display: grid; grid-template-columns: 300px 1fr; gap: 1.1rem; align-items: start; }
.game-layout > * { min-width: 0; }
@media (max-width: 980px) { .game-layout { grid-template-columns: 1fr; } .players-panel { order: 2; } }

.card {
  background: var(--panel);
  border-radius: var(--radius);
  border: 3px solid #efe3cf;
  box-shadow: 0 8px 22px rgba(31, 58, 82, .13);
  padding: 1rem;
}

/* ---------- players sidebar ---------- */
.players-panel { padding: .8rem; }
.players-panel h3 { display: flex; justify-content: space-between; align-items: center; font-size: 1rem; margin-bottom: .5rem; }
.players-panel .online { font-size: .8rem; color: var(--ink-soft); font-weight: 700; }
.player-row {
  display: flex; align-items: center; gap: .5rem;
  padding: .35rem .45rem; border-radius: 12px; margin-bottom: .25rem;
  background: #fff; border: 2px solid #f1e8d8;
  font-size: .9rem;
}
.player-row .avatar { width: 30px; height: 30px; font-size: 16px; border-width: 2px; }
.player-row .pname { font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-row .pname a { color: inherit; }
.player-row .tierbadge { font-size: .85rem; }
.player-row .pbet { font-weight: 800; color: #b07d00; white-space: nowrap; }
.player-row.cashed { background: #e9fbef; border-color: #bfe8cd; }
.player-row.cashed .pstatus { color: var(--green); font-weight: 800; }
.player-row.busted { background: #fdecea; border-color: #f2c4bf; opacity: .8; }
.player-row.busted .pstatus { color: var(--red); font-weight: 800; }
.player-row .pstatus { font-size: .8rem; white-space: nowrap; }
.player-row.anon .avatar { background: #cfd8dc; }

/* ---------- game area ---------- */
.game-panel { padding: .9rem; }
.history-chips { display: flex; gap: .4rem; flex-wrap: nowrap; overflow: hidden; margin-bottom: .6rem; }
.chip {
  font-size: .8rem; font-weight: 800; padding: .15rem .55rem; border-radius: 999px;
  background: #fdecea; color: var(--red); border: 2px solid #f2c4bf; white-space: nowrap; cursor: pointer;
}
.chip.good { background: #e9fbef; color: #1d8f4e; border-color: #bfe8cd; }
.chip.great { background: #fff6d8; color: #a06b00; border-color: #ecd489; }

#gameCanvas { width: 100%; border-radius: 14px; display: block; background: #bde5f2; }

.bet-bar {
  display: flex; gap: .7rem; align-items: stretch; margin-top: .8rem; flex-wrap: wrap;
}
.bet-input-wrap {
  display: flex; align-items: center; background: #fff; border: 3px solid #efe3cf;
  border-radius: var(--radius); padding: .2rem .4rem .2rem .9rem; gap: .3rem;
}
.bet-input-wrap b { color: #b07d00; }
#betAmount {
  border: none; outline: none; width: 110px; font-size: 1.2rem; font-weight: 800; color: var(--ink);
  background: transparent;
}
.bet-quick { display: flex; gap: .25rem; }
.bet-quick button {
  border: 2px solid #e8dccc; background: var(--panel2); border-radius: 10px;
  font-weight: 800; font-size: .8rem; padding: .25rem .5rem;
}
#mainActionBtn { flex: 1; min-width: 220px; }

.fairness-line { margin-top: .6rem; font-size: .78rem; color: var(--ink-soft); word-break: break-all; }
.fairness-line a { font-weight: 800; }

/* ---------- store / house / profile ---------- */
.page-title { font-size: 1.7rem; font-weight: 800; margin-bottom: .8rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.tabs { display: flex; gap: .4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tab { border: 2px solid #e8dccc; background: #fff; border-radius: 999px; font-weight: 800; padding: .35rem .95rem; }
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .8rem; }
.shop-item { text-align: center; padding: .9rem .6rem; position: relative; }
.shop-item .bigemoji { font-size: 3rem; display: block; margin-bottom: .3rem; filter: drop-shadow(0 3px 2px rgba(0,0,0,.15)); }
.shop-item h4 { font-size: .95rem; }
.shop-item .price { color: #b07d00; font-weight: 800; margin: .25rem 0 .5rem; }
.shop-item .owned-badge { position: absolute; top: .5rem; right: .5rem; font-size: .7rem; background: var(--green); color: #fff; padding: .1rem .45rem; border-radius: 999px; font-weight: 800; }

.coinpack { text-align: center; padding: 1.2rem .8rem; }
.coinpack .bigemoji { font-size: 3.4rem; }
.coinpack .coins { font-size: 1.3rem; font-weight: 800; color: #b07d00; }
.coinpack .usd { color: var(--ink-soft); font-weight: 700; margin-bottom: .6rem; }

/* house */
.house-header { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.house-scene {
  border-radius: var(--radius); padding: 1.2rem;
  background: linear-gradient(180deg, #ffe8b8 0%, #ffd9a0 100%);
  border: 3px solid #eccb8f;
}
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .6rem; }
.slot {
  aspect-ratio: 1; border-radius: 14px; border: 3px dashed #d9b877;
  background: rgba(255,255,255,.55);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.4rem; cursor: pointer; transition: transform .08s;
  filter: drop-shadow(0 3px 2px rgba(0,0,0,.08));
}
.slot:hover { transform: scale(1.05); background: rgba(255,255,255,.85); }
.slot.filled { border-style: solid; border-color: #c9a25e; background: #fff; }
.garage-scene { background: linear-gradient(180deg, #d7e3ea 0%, #c3d2dc 100%); border-color: #a9bcc9; margin-top: 1rem; }
.garage-scene .slot { border-color: #9fb4c2; }

.inv-drawer { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.inv-item {
  border: 2px solid #e8dccc; background: #fff; border-radius: 12px; padding: .4rem .6rem;
  font-weight: 700; font-size: .9rem; cursor: pointer; display: flex; gap: .35rem; align-items: center;
}
.inv-item:hover { background: var(--panel2); }
.inv-item.placed { opacity: .45; }

/* profile */
.profile-head { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.tier-progress { height: 14px; border-radius: 999px; background: #eee3d0; overflow: hidden; margin-top: .3rem; }
.tier-progress > div { height: 100%; background: linear-gradient(90deg, var(--accent2), var(--gold)); border-radius: 999px; }
table.simple { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.simple th, table.simple td { text-align: left; padding: .45rem .5rem; border-bottom: 2px solid #f3ead9; }
table.simple th { color: var(--ink-soft); font-size: .8rem; text-transform: uppercase; }
.win { color: var(--green); font-weight: 800; }
.loss { color: var(--red); font-weight: 800; }

/* ---------- modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(37, 24, 34, .55);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem;
}
.modal {
  background: var(--panel); border-radius: 22px; border: 4px solid #ffd166;
  max-width: 480px; width: 100%; padding: 1.4rem; position: relative;
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
  max-height: 92vh; overflow-y: auto;
}
.modal h2 { margin-bottom: .9rem; }
.modal .close { position: absolute; top: .7rem; right: .9rem; background: none; border: none; font-size: 1.4rem; }
.field { margin-bottom: .8rem; }
.field label { display: block; font-weight: 800; font-size: .85rem; margin-bottom: .25rem; color: var(--ink-soft); }
.field input[type=text], .field input[type=password], .field input[type=number], .field textarea {
  width: 100%; border: 3px solid #efe3cf; border-radius: 12px; padding: .55rem .8rem; outline: none;
  background: #fff;
}
.field input:focus, .field textarea:focus { border-color: var(--accent2); }
.field .hint { font-size: .78rem; color: var(--ink-soft); margin-top: .2rem; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .5rem 0; }
.switch-row .lab b { display: block; } .switch-row .lab span { font-size: .8rem; color: var(--ink-soft); }
.emoji-grid { display: flex; flex-wrap: wrap; gap: .3rem; }
.emoji-grid button { font-size: 1.5rem; background: #fff; border: 2px solid #eee; border-radius: 10px; padding: .2rem .35rem; }
.emoji-grid button.sel { border-color: var(--accent); background: #ffeceb; }
.error-msg { color: var(--red); font-weight: 700; font-size: .9rem; margin-top: .5rem; min-height: 1.2rem; }

/* ---------- receipt ---------- */
.receipt-wrap { display: flex; flex-direction: column; align-items: center; gap: .9rem; }
#receiptCanvas { border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.3); max-width: 100%; height: auto; }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: .5rem; align-items: center; }
.toast {
  background: var(--ink); color: #fff; font-weight: 700; border-radius: 999px;
  padding: .55rem 1.3rem; box-shadow: 0 8px 24px rgba(0,0,0,.3);
  animation: toast-in .25s ease-out;
}
.toast.error { background: var(--red); }
.toast.gold { background: var(--accent2); color: #4a3600; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

/* verify page */
.mono { font-family: ui-monospace, Menlo, monospace; font-size: .8rem; word-break: break-all; }
.verify-ok { color: var(--green); font-weight: 800; }
.verify-bad { color: var(--red); font-weight: 800; }
.scan-list { max-height: 300px; overflow-y: auto; }
