:root {
  --bg: #2a1e3a;
  --panel: #362851;
  --grid: #4a3a68;
  --accent: #ff9ecb;
  --accent-dim: #e07fae;
  --gold: #ffd76b;
  --text: #fff6fb;
  --muted: #c3b3dd;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

.wrap {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
}

.board {
  position: relative;
  width: min(94vw, calc(82vh * 3 / 4));
  aspect-ratio: 3 / 4;
  max-height: 82vh;
  border: 2px solid var(--grid);
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(180deg, #4a3468 0%, #362851 60%, #241a38 100%);
}

.wrap:fullscreen,
.wrap:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  padding: 0;
  gap: 0;
}
.wrap:fullscreen .board,
.wrap:-webkit-full-screen .board {
  width: min(100vw, calc(100vh * 3 / 4));
  max-height: 100vh;
  border-radius: 0;
  border: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* HUD bar */
.bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  pointer-events: none;
  z-index: 3;
}
.bar h1 { font-size: 13px; font-weight: 700; letter-spacing: 0.3px; text-shadow: 0 1px 3px rgba(0,0,0,.7); }
.scores { display: flex; align-items: center; gap: 8px; }
.score  { font-size: 12px; font-weight: 700; color: var(--gold); text-shadow: 0 1px 3px rgba(0,0,0,.7); }

.mute {
  pointer-events: auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(54, 40, 81, 0.75);
  border: 1px solid var(--grid);
  color: var(--text);
  border-radius: 8px;
  font-size: 14px; line-height: 1;
  padding: 5px 7px;
  cursor: pointer;
  text-decoration: none;
}
.mute:hover { border-color: var(--accent); }

/* Panels */
.pick {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(30, 21, 46, 0.96);
  padding: 16px;
  z-index: 5;
  overflow-y: auto;
}
.pick.hidden { display: none; }
.pick-title { font-size: 18px; font-weight: 700; color: var(--accent); text-align: center; }
.pick-title.small { font-size: 13px; margin-top: 6px; }

.cover-grid, .pick-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 340px;
}
.cover-btn {
  background: var(--panel);
  border: 2px solid var(--grid);
  border-radius: 10px;
  font-size: 20px;
  padding: 8px 0;
  cursor: pointer;
}
.cover-btn.selected { border-color: var(--accent); background: #4a3a68; }

.text-input {
  width: 100%;
  max-width: 280px;
  background: var(--panel);
  border: 2px solid var(--grid);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
  font-family: inherit;
}
.text-input:focus { outline: none; border-color: var(--accent); }
.notes-input { min-height: 54px; resize: none; }

.char-card {
  background: var(--panel);
  border: 2px solid var(--grid);
  border-radius: 12px;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
  color: var(--text);
}
.char-card:hover  { transform: translateY(-2px); }
.char-card.selected { border-color: var(--accent); background: #4a3a68; }
.char-card.locked { opacity: .45; cursor: not-allowed; }
.char-card canvas { width: 54px; height: 66px; }
.char-card .c-name { font-size: 10px; font-weight: 700; }
.char-card .c-price { font-size: 9px; color: var(--muted); }

.play {
  background: var(--accent);
  color: #3a0e28;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 13px;
  padding: 9px 16px;
  cursor: pointer;
  transition: opacity .15s, transform .15s;
}
.play:disabled { opacity: .4; cursor: not-allowed; }
.play:not(:disabled):hover { transform: translateY(-1px); }
.play.ghost { background: var(--panel); color: var(--text); border: 1px solid var(--grid); }

/* Shop */
.tab-row { display: flex; gap: 8px; }
.tab-btn {
  background: var(--panel);
  border: 2px solid var(--grid);
  color: var(--text);
  border-radius: 9px;
  font-size: 12px;
  padding: 6px 12px;
  cursor: pointer;
}
.tab-btn.selected { border-color: var(--accent); background: #4a3a68; }
.shop-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 300px;
  max-height: 44vh;
  overflow-y: auto;
}
.shop-list.hidden { display: none; }
.shop-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--panel);
  border: 2px solid var(--grid);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
}
.shop-item .si-name { flex: 1; }
.shop-item .si-price { color: var(--gold); font-weight: 700; font-size: 11px; }
.shop-item button {
  background: var(--accent);
  color: #3a0e28;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 11px;
  padding: 6px 10px;
  cursor: pointer;
}
.shop-item button:disabled { opacity: .4; cursor: not-allowed; }
.shop-item button.owned { background: var(--panel); color: var(--muted); border: 1px solid var(--grid); }

/* Friends */
.friend-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 300px;
  max-height: 26vh;
  overflow-y: auto;
}
.friend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 2px solid var(--grid);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
}
.friend-item .f-icon { font-size: 18px; }
.friend-item .f-name { flex: 1; }
.friend-item .f-actions { display: flex; gap: 6px; }
.friend-item button {
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 11px;
  padding: 6px 10px;
  cursor: pointer;
}
.friend-item .btn-add, .friend-item .btn-accept { background: var(--accent); color: #3a0e28; }
.friend-item .btn-delete { background: #5a2e40; color: #ffd0dc; }
.friend-item .btn-chat { background: var(--panel); color: var(--text); border: 1px solid var(--grid); }

/* Chat */
.chat-log {
  width: 100%;
  max-width: 300px;
  min-height: 120px;
  max-height: 34vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-bubble {
  max-width: 80%;
  border-radius: 12px;
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.4;
}
.chat-bubble.them { align-self: flex-start; background: var(--panel); border: 1px solid var(--grid); }
.chat-bubble.me   { align-self: flex-end; background: var(--accent); color: #3a0e28; }

/* Events */
.room-card {
  background: linear-gradient(135deg, #fff0f8, #ffe0f0);
  color: #5a1240;
  border-radius: 12px;
  padding: 14px 18px;
  text-align: center;
  font-size: 13px;
  line-height: 1.6;
  border: 2px solid var(--accent);
  min-width: 220px;
}
.room-card b { font-size: 15px; }

/* Bottom action bar (home / dressup / cafe / bath) */
.touch {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 10px 12px;
  z-index: 3;
  pointer-events: none;
  gap: 6px;
}
.touch.hidden { display: none; }
.tgroup { display: flex; gap: 8px; pointer-events: none; align-items: flex-end; }
.tbtn {
  pointer-events: auto;
  border-radius: 50%;
  border: 2px solid var(--grid);
  background: rgba(54, 40, 81, 0.9);
  color: var(--text);
  font-weight: 700;
  font-size: 18px;
  width: 46px; height: 46px;
  cursor: pointer;
  -webkit-user-select: none; user-select: none;
  touch-action: none;
  box-shadow: 0 3px 0 rgba(0,0,0,.35);
}
.tbtn:active { transform: translateY(2px); box-shadow: none; }
.tbtn.action { width: 56px; height: 56px; font-size: 22px; background: var(--accent); border-color: var(--accent-dim); color: #3a0e28; }
.tbtn.small  { width: 40px; height: 40px; font-size: 16px; }

.canvas-hint {
  position: absolute;
  top: 34px; left: 0; right: 0;
  text-align: center;
  font-size: 10px;
  color: var(--muted);
  z-index: 2;
  padding: 0 10px;
  text-shadow: 0 1px 3px rgba(0,0,0,.7);
}
.canvas-hint.hidden { display: none; }

.corner-done {
  position: absolute;
  top: 34px; right: 10px;
  z-index: 4;
}
.corner-done.hidden { display: none; }

/* Rack (dress-up clothes / cafe food tray) */
.rack {
  pointer-events: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  max-width: 100%;
  justify-content: center;
}
.rack-item {
  background: rgba(54, 40, 81, 0.9);
  border: 2px solid var(--grid);
  border-radius: 10px;
  font-size: 20px;
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  touch-action: none;
  position: relative;
}
.rack-item.locked { opacity: .4; }
.rack-item.worn { border-color: var(--accent); background: #4a3a68; }
.rack-item.dragging { opacity: .5; }

.colour-row {
  pointer-events: auto;
  display: flex;
  gap: 8px;
  justify-content: center;
}
.colour-swatch {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 3px solid var(--grid);
  cursor: pointer;
}
.colour-swatch.selected { border-color: var(--text); box-shadow: 0 0 0 2px var(--accent); }

.foot { font-size: 11px; color: var(--muted); }
