:root {
  --bg: #fdf2e9;
  --panel: #fffaf5;
  --border: #ecd3c0;
  --text: #4a3228;
  --muted: #8c6d5e;
  --coral: #ff6f7d;
  --mint: #3fb395;
  --gold: #e59a28;
  --purple: #9d6be8;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body {
  background: radial-gradient(circle at top, #fff6ec 0%, #f7e4d4 100%);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  user-select: none;
  touch-action: manipulation;
}
.shell { width: 100%; max-width: 980px; display: flex; flex-direction: column; gap: 9px; }

.hud {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
  background: var(--panel); border: 2px solid var(--border); border-radius: 14px;
  padding: 8px 12px; box-shadow: 0 6px 18px rgba(130, 82, 54, 0.08);
}
.hud-left, .hud-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.brand { font-weight: 900; letter-spacing: 0.08em; color: var(--coral); font-size: 0.96rem; }
.pill {
  background: #fff1e6; border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 10px; display: flex; align-items: center; gap: 6px;
}
.lbl { font-size: 0.68rem; font-weight: 800; color: var(--muted); }
.val { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92rem; font-weight: 900; }
.coral { color: var(--coral); }
.mint { color: var(--mint); }
.gold { color: var(--gold); }
.icon-btn {
  background: #fff1e6; border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; width: 38px; height: 34px; cursor: pointer; font-size: 1rem;
}
.icon-btn:active { transform: scale(0.95); }

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

.room-wrap {
  position: relative; background: #f6e1cc; border: 3px solid var(--border);
  border-radius: 16px; overflow: hidden; aspect-ratio: 760 / 460;
  box-shadow: 0 12px 30px rgba(110, 68, 44, 0.14);
}
#gameCanvas { width: 100%; height: 100%; display: block; cursor: pointer; touch-action: none; image-rendering: pixelated; }

.room-bar {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(255, 250, 245, 0.9); border-top: 1px solid var(--border);
  padding: 6px 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-size: 0.78rem; font-weight: 800;
}
.lounge-name { color: var(--text); }
.love-wrap { display: flex; align-items: center; gap: 6px; color: var(--coral); font-size: 0.72rem; }
.love-track { width: 92px; height: 10px; background: #f3ded0; border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.love-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #ff9aa2, #ff6f7d); transition: width 0.18s; }

.challenge-pill {
  position: absolute; top: 8px; left: 8px; background: rgba(255, 250, 245, 0.95);
  border: 2px solid var(--mint); color: var(--mint); border-radius: 999px;
  padding: 4px 10px; font-size: 0.74rem; font-weight: 800;
}

.shop {
  background: var(--panel); border: 2px solid var(--border); border-radius: 16px;
  padding: 12px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 8px 20px rgba(110, 68, 44, 0.08);
}
.shop-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.76rem; font-weight: 900; letter-spacing: 0.08em; color: var(--muted);
}
.cps { color: var(--mint); font-family: ui-monospace, monospace; }
.shop-list { display: flex; flex-direction: column; gap: 7px; }
.upg-btn {
  background: #fff4ea; border: 2px solid var(--border); border-radius: 12px;
  padding: 10px 11px; color: var(--text); text-align: left; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  transition: transform 0.08s, border-color 0.14s, background 0.14s;
}
.upg-btn:hover:not(:disabled) { border-color: var(--coral); background: #ffede0; transform: translateY(-1px); }
.upg-btn:active:not(:disabled) { transform: scale(0.98); }
.upg-btn:disabled { opacity: 0.52; cursor: not-allowed; }
.upg-name { font-weight: 800; font-size: 0.86rem; }
.upg-desc { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }
.upg-right { text-align: right; white-space: nowrap; }
.upg-cost { font-family: ui-monospace, monospace; font-weight: 900; color: var(--gold); font-size: 0.86rem; }
.upg-lv { font-size: 0.7rem; color: var(--mint); font-weight: 800; }

.overlay {
  position: absolute; inset: 0; background: rgba(74, 50, 40, 0.65); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 14px; z-index: 10;
}
.card {
  background: var(--panel); border: 2px solid var(--border); border-radius: 18px;
  padding: 20px; max-width: 420px; width: 100%; max-height: 100%; overflow-y: auto;
  text-align: center; display: flex; flex-direction: column; gap: 11px;
  box-shadow: 0 18px 40px rgba(74, 50, 40, 0.28);
}
.card h1, .card h2 { color: var(--coral); letter-spacing: 0.04em; }
.card p { font-size: 0.86rem; color: var(--muted); line-height: 1.45; }
.primary-btn {
  background: linear-gradient(90deg, #ff7b89, #ff9a76); color: #fff; border: none; border-radius: 12px;
  padding: 12px 18px; font-weight: 900; font-size: 0.92rem; letter-spacing: 0.05em; cursor: pointer;
  box-shadow: 0 6px 16px rgba(255, 111, 125, 0.35);
}
.sec-btn {
  background: #eaf8f4; color: var(--mint); border: 2px solid #9be0cc; border-radius: 10px;
  padding: 10px 14px; font-weight: 800; cursor: pointer; font-size: 0.84rem;
}
.ok-btn {
  background: var(--mint); color: #fff; border: none; border-radius: 8px;
  padding: 8px 12px; font-weight: 800; font-size: 0.78rem; cursor: pointer;
}
.lb-list {
  background: #fff4ea; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px;
  font-family: ui-monospace, monospace; font-size: 0.78rem; text-align: left; display: flex; flex-direction: column; gap: 4px;
}
.lb-row { display: flex; justify-content: space-between; }
.lb-submit { display: flex; gap: 6px; }
.lb-submit input {
  flex: 1; background: #fff; color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 0.84rem;
}
.btn-row { display: flex; flex-direction: column; gap: 8px; }
.share-out {
  background: #fff4ea; color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px; font-size: 0.74rem; font-family: monospace; text-align: center;
}
.challenge-box {
  background: #eaf8f4; border: 1px solid #9be0cc; color: var(--mint);
  padding: 8px; border-radius: 10px; font-size: 0.82rem; font-weight: 800;
}
.footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; font-size: 0.74rem; color: var(--muted); padding: 0 4px; }
.footer a { color: var(--coral); text-decoration: none; font-weight: 800; }
.hidden { display: none !important; }

@media (max-width: 780px) {
  .brand { display: none; }
  .main-grid { grid-template-columns: 1fr; }
  .shop-list { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
  .upg-btn { flex-direction: column; align-items: flex-start; gap: 4px; padding: 9px; }
  .upg-right { display: flex; justify-content: space-between; width: 100%; align-items: center; }
}
@media (max-width: 440px) {
  .shop-list { grid-template-columns: 1fr; }
}
