:root {
  --green: #51C23C;
  --ink: #07080C;
  --bone: #F7F7F3;
}

* { box-sizing: border-box; }

/* Phase 9 (Performance / low-end fallback): body.lowfx is set once at load
   by a real frame-time probe in client.js (perfFallback()) -- the exact
   same real pattern/convention as games/ludo/index.html and
   games/penalty/index.html's own perfFallback() (short rAF frame sample,
   gated first by prefers-reduced-motion, falls back to fps<40 or
   navigator.hardwareConcurrency<=2), never a device/UA guess. It only ever
   switches off decorative, continuously-looping CSS animation -- the same
   category Ludo/Penalty gate (crowd dots, bloom, confetti) -- never server
   state, movement, the wallet, or any socket/game logic. The canvas-side
   decorative draws (ground grid, celebration-ring growth) are gated the
   same way inside client.js's draw(), since this slice's decorative cost
   lives in canvas calls, not CSS, for everything beyond these two. */
body.lowfx #activity-dot { animation: none; box-shadow: 0 0 0 0 rgba(81,194,60,0.35); }
body.lowfx #discovery-banner { animation: none; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--bone);
  font-family: Inter, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

header {
  width: 100%;
  max-width: 820px;
  padding: 14px 4px 4px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

header h1 {
  font-family: "Arial Black", Impact, sans-serif;
  font-size: 20px;
  margin: 0;
  letter-spacing: 0.5px;
}

header h1 span { color: var(--green); }

#hud {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Phase 10 (Final Acceptance Test): real mobile bug found during this
   phase's own live verification -- on a real phone-width viewport, header
   (title + HUD) never wrapped, so the Achievements button (the 4th item:
   rank, wallet, Live Events, Achievements) was pushed off the right edge
   of the screen, outside the viewport and behind the Live Events button's
   hit area -- unreachable by tap. flex-wrap above lets the HUD drop to a
   second line instead of overflowing; this just shrinks everything a bit
   more so all 4 fit more comfortably on one or two lines on a real phone. */
@media (max-width: 480px) {
  header { flex-wrap: wrap; row-gap: 6px; }
  #hud { gap: 6px; }
  #rank, #wallet { font-size: 11px; padding: 5px 9px; }
  #live-events-btn, #achievements-btn { font-size: 11px; padding: 5px 9px; }
}

#rank {
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--green);
  border: 1px solid rgba(81,194,60,0.5);
  border-radius: 999px;
  padding: 6px 12px;
}

#wallet {
  font-size: 15px;
  font-weight: bold;
  background: rgba(81, 194, 60, 0.12);
  border: 1px solid var(--green);
  border-radius: 999px;
  padding: 6px 14px;
}

#wisdom-card {
  width: 100%;
  max-width: 820px;
  margin-top: 10px;
  background: linear-gradient(135deg, rgba(81,194,60,0.1), rgba(81,194,60,0.02));
  border: 1px solid rgba(81,194,60,0.4);
  border-radius: 10px;
  padding: 14px 16px;
  transition: opacity 0.25s;
}
#wisdom-card.hidden { opacity: 0; pointer-events: none; height: 0; padding: 0; margin: 0; border: none; overflow: hidden; }
#wisdom-text { font-size: 14px; margin: 0 0 6px; line-height: 1.4; }
#wisdom-source { font-size: 11px; color: rgba(247,247,243,0.5); margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.5px; }
#wisdom-card button {
  background: transparent;
  color: var(--green);
  border: 1px solid var(--green);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
}

#stage {
  position: relative;
  margin-top: 10px;
  border: 1px solid rgba(247,247,243,0.15);
  border-radius: 10px;
  overflow: hidden;
  background: #0d0f14;
  /* Phase 10 (Final Acceptance Test): real mobile bug found during this
     phase's own live verification -- the canvas is a fixed 800x560 with no
     responsive sizing at all, so on a real phone viewport (e.g. 390px
     wide) it rendered at full size, pushed off the right edge of the
     screen with no way to scroll/scale it into view. #stage now matches
     the same max-width:820px/centered pattern the header/login/footer
     already use elsewhere in this file, and the canvas below scales to
     fill it while keeping its real aspect ratio -- CSS-only, since
     nothing in client.js reads click/touch coordinates off the canvas
     itself (confirmed: no canvas.addEventListener for input anywhere),
     so this cannot desync any click-to-world-position mapping. */
  width: 100%;
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
}

#canvas {
  display: block;
  width: 100%;
  height: auto;
}

#toast {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(7,8,12,0.85);
  border: 1px solid var(--green);
  color: var(--bone);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  white-space: nowrap;
}
#toast.show { opacity: 1; }

#activity-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 210px;
  background: rgba(7,8,12,0.78);
  border: 1px solid rgba(81,194,60,0.25);
  border-radius: 10px;
  padding: 8px 10px 10px;
  backdrop-filter: blur(2px);
}

#activity-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--green);
  margin-bottom: 6px;
}

#activity-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(81,194,60,0.6);
  animation: activity-pulse 1.6s ease-out infinite;
}

@keyframes activity-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(81,194,60,0.55); }
  70%  { box-shadow: 0 0 0 6px rgba(81,194,60,0); }
  100% { box-shadow: 0 0 0 0 rgba(81,194,60,0); }
}

#activity {
  width: 100%;
  font-size: 11px;
  line-height: 1.5;
  color: rgba(247,247,243,0.75);
  text-align: right;
}

#activity .npc-line {
  color: #D9A94A;
  font-style: italic;
}

footer {
  width: 100%;
  max-width: 820px;
  padding: 10px 4px 24px;
}

#chat-log {
  height: 90px;
  overflow-y: auto;
  font-size: 13px;
  background: rgba(247,247,243,0.04);
  border: 1px solid rgba(247,247,243,0.1);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 8px;
}
#chat-log div { margin-bottom: 3px; }
#chat-log b { color: var(--green); }

#chat-form {
  display: flex;
  gap: 8px;
}

#chat-input {
  flex: 1;
  background: rgba(247,247,243,0.06);
  border: 1px solid rgba(247,247,243,0.2);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--bone);
  font-family: inherit;
}

.hint {
  font-size: 12px;
  color: rgba(247,247,243,0.55);
  margin-top: 6px;
}

#login {
  position: fixed;
  inset: 0;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 10;
}

#login h2 {
  font-family: "Arial Black", Impact, sans-serif;
}

#login input {
  background: rgba(247,247,243,0.08);
  border: 1px solid rgba(247,247,243,0.25);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--bone);
  font-size: 15px;
  width: 240px;
}

#login button, #chat-form button {
  background: var(--green);
  color: var(--ink);
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: bold;
  cursor: pointer;
}

.opt-in {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  max-width: 260px;
  text-align: left;
  color: rgba(247,247,243,0.8);
}
.opt-in input { width: 16px; height: 16px; }

#login .note {
  max-width: 320px;
  text-align: center;
  font-size: 12px;
  color: rgba(247,247,243,0.5);
}

/* Real-auth fix (2026-10-20): login screen now has two sub-states instead
   of a name field -- "checking" (default, #login-status), "ready" (a real
   session was found) and "required" (none was). Both toggle via the same
   .hidden convention already used elsewhere on this page. */
/* UX sweep fix (2026-10-20): #login-status itself was missing a .hidden
   rule, so "Checking your CelebIsland login..." never actually disappeared
   -- it stayed stacked above the real "ready"/"required" message forever,
   showing two contradictory states at once. */
#login-status.hidden, #login-ready.hidden, #login-required.hidden { display: none; }
#login-ready, #login-required {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
#login-ready-name { color: var(--green); }
#login-link {
  background: var(--green);
  color: var(--ink);
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: bold;
  text-decoration: none;
}

/* --- Discovery Arena (Director's Directive 002) --- */

#discovery-banner {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #D9A94A, #B9842C);
  color: var(--ink);
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: bold;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 14px rgba(217,169,74,0.5);
  white-space: nowrap;
  animation: pulse-banner 1.6s ease-in-out infinite;
}
#discovery-banner.hidden { display: none; }
@keyframes pulse-banner {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.035); }
}

#discovery-modal {
  position: fixed;
  inset: 0;
  background: rgba(5,6,9,0.78);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
#discovery-modal.hidden { display: none; }

#discovery-sheet {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--ink);
  border: 1px solid rgba(217,169,74,0.5);
  border-radius: 16px 16px 0 0;
  padding: 22px 18px 28px;
  box-sizing: border-box;
}
@media (min-width: 640px) {
  #discovery-modal { align-items: center; }
  #discovery-sheet { border-radius: 16px; margin-bottom: 0; }
}

#discovery-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: var(--bone);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}

.disc-eyebrow {
  color: #D9A94A;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 0 0 4px;
}
.disc-title {
  font-family: "Arial Black", Impact, sans-serif;
  font-size: 20px;
  margin: 0 0 12px;
}
.disc-hook, .disc-text {
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 14px;
}
.disc-clue {
  background: rgba(247,247,243,0.04);
  border: 1px solid rgba(247,247,243,0.1);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.disc-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 3px 9px;
  border-radius: 999px;
  margin-bottom: 8px;
}
.disc-badge.evidence { background: rgba(81,194,60,0.18); color: var(--green); border: 1px solid rgba(81,194,60,0.5); }
.disc-badge.attributed { background: rgba(217,169,74,0.18); color: #D9A94A; border: 1px solid rgba(217,169,74,0.5); }
.disc-badge.legend { background: rgba(214,80,80,0.18); color: #E08080; border: 1px solid rgba(214,80,80,0.5); }
.disc-source {
  font-size: 11px;
  color: rgba(247,247,243,0.55);
  margin: 8px 0 0;
}
.disc-note {
  font-size: 12px;
  color: rgba(247,247,243,0.6);
  margin: 6px 0 0;
  font-style: italic;
}
.disc-choice {
  display: block;
  width: 100%;
  text-align: left;
  background: rgba(247,247,243,0.06);
  border: 1px solid rgba(247,247,243,0.2);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  color: var(--bone);
  font-size: 14px;
  cursor: pointer;
}
.disc-choice:hover { border-color: #D9A94A; }
.disc-primary-btn {
  display: block;
  width: 100%;
  background: #D9A94A;
  color: var(--ink);
  border: none;
  border-radius: 10px;
  padding: 13px 14px;
  font-weight: bold;
  font-size: 14px;
  cursor: pointer;
  margin-top: 4px;
}
.disc-share-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}
.disc-share-btn {
  background: transparent;
  border: 1px solid rgba(217,169,74,0.6);
  color: #D9A94A;
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  cursor: pointer;
}
.disc-pending-note {
  font-size: 11px;
  color: rgba(247,247,243,0.45);
  margin-top: 10px;
}
.disc-share-result {
  font-size: 12px;
  background: rgba(247,247,243,0.05);
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 6px;
}

/* --- The Discovery Board (Phase 7: "DISCOVERY") --- */
/* Same banner/modal/sheet shape as the Discovery Arena above, in the
   site's green rather than the Plaza's gold, so the two zones read as
   visually distinct at a glance. */

#board-banner {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--green), #3a9c2b);
  color: var(--ink);
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: bold;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 14px rgba(81,194,60,0.5);
  white-space: nowrap;
  animation: pulse-banner 1.6s ease-in-out infinite;
}
#board-banner.hidden { display: none; }

#board-modal {
  position: fixed;
  inset: 0;
  background: rgba(5,6,9,0.78);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
#board-modal.hidden { display: none; }

#board-sheet {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--ink);
  border: 1px solid rgba(81,194,60,0.5);
  border-radius: 16px 16px 0 0;
  padding: 22px 18px 28px;
  box-sizing: border-box;
}
@media (min-width: 640px) {
  #board-modal { align-items: center; }
  #board-sheet { border-radius: 16px; margin-bottom: 0; }
}

#board-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: var(--bone);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}

#board-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0;
}
.board-tab {
  background: rgba(247,247,243,0.06);
  border: 1px solid rgba(247,247,243,0.2);
  color: var(--bone);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12px;
  cursor: pointer;
}
.board-tab:hover { border-color: var(--green); }
.board-tab.active {
  background: rgba(81,194,60,0.18);
  border-color: var(--green);
  color: var(--green);
  font-weight: bold;
}

.board-card {
  background: rgba(247,247,243,0.04);
  border: 1px solid rgba(247,247,243,0.1);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.board-card-title {
  font-weight: bold;
  font-size: 15px;
  margin-bottom: 2px;
}
.board-card-subtitle {
  font-size: 12px;
  color: var(--green);
  margin-bottom: 6px;
}
.board-card-detail {
  font-size: 12px;
  color: rgba(247,247,243,0.65);
  line-height: 1.4;
  margin-bottom: 8px;
}
.board-card-action {
  display: inline-block;
  font-size: 12px;
  font-weight: bold;
  color: var(--ink);
  background: var(--green);
  border-radius: 6px;
  padding: 7px 12px;
  text-decoration: none;
}
.board-card-action:hover { opacity: 0.9; }

/* --- The Marketplace District (Island Life Phase 2: "World Zone
   Expansion") --- */
/* Same banner/modal/sheet shape as the Discovery Arena/Discovery Board
   above, in its own accent color (a cool blue) so all three zones read as
   visually distinct from one another at a glance. */

#marketplace-banner {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #4A90D9, #2C6CB9);
  color: var(--bone);
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: bold;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 14px rgba(74,144,217,0.5);
  white-space: nowrap;
  animation: pulse-banner 1.6s ease-in-out infinite;
}
#marketplace-banner.hidden { display: none; }
body.lowfx #marketplace-banner { animation: none; }

#marketplace-modal {
  position: fixed;
  inset: 0;
  background: rgba(5,6,9,0.78);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
#marketplace-modal.hidden { display: none; }

#marketplace-sheet {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--ink);
  border: 1px solid rgba(74,144,217,0.5);
  border-radius: 16px 16px 0 0;
  padding: 22px 18px 28px;
  box-sizing: border-box;
}
@media (min-width: 640px) {
  #marketplace-modal { align-items: center; }
  #marketplace-sheet { border-radius: 16px; margin-bottom: 0; }
}

#marketplace-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: var(--bone);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}

.mkt-sub {
  font-size: 13px;
  color: rgba(247,247,243,0.6);
  margin: 0 0 14px;
}

.mkt-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 640px) {
  .mkt-grid { grid-template-columns: repeat(3, 1fr); }
}

.mkt-card {
  display: block;
  background: rgba(247,247,243,0.04);
  border: 1px solid rgba(247,247,243,0.1);
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  color: var(--bone);
}
.mkt-card:hover { border-color: #4A90D9; }
.mkt-card-img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  display: block;
  background: rgba(247,247,243,0.06);
}
.mkt-card-img-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
}
.mkt-card-body { padding: 8px 10px 10px; }
.mkt-card-name {
  font-size: 12px;
  font-weight: bold;
  line-height: 1.3;
  margin-bottom: 3px;
  /* Long real product titles shouldn't blow out the grid on a phone. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mkt-card-price {
  font-size: 13px;
  font-weight: bold;
  color: #4A90D9;
  margin-bottom: 2px;
}
.mkt-card-seller {
  font-size: 10px;
  color: rgba(247,247,243,0.5);
}

/* Island Life Phase 2: the private "you crossed into a new zone" line in
   the activity feed — same italic treatment as an NPC line, its own color
   so it never reads as either an NPC remark or a player action. */
#activity .zone-line {
  color: #4A90D9;
  font-style: italic;
}

/* --- Island Life Phase 4 ("NPCs"): "Talk to <NPC>" + quest-giver hook ---
   Same banner/modal/sheet shape as the Discovery Arena/Board/Marketplace
   above, in the SAME amber (#D9A94A) already used everywhere else in this
   app to mean "this is an NPC, not a real player" (the dashed canvas
   ring, the .npc-line activity-feed color) — consistency is itself part
   of the clear-labeling requirement: amber always means NPC, on canvas,
   in the activity feed, and here. */

#npc-banner {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #D9A94A, #B9842C);
  color: var(--ink);
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: bold;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 14px rgba(217,169,74,0.5);
  white-space: nowrap;
  max-width: 92%;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: pulse-banner 1.6s ease-in-out infinite;
}
#npc-banner.hidden { display: none; }
body.lowfx #npc-banner { animation: none; }

#npc-modal {
  position: fixed;
  inset: 0;
  background: rgba(5,6,9,0.78);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
#npc-modal.hidden { display: none; }

#npc-sheet {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--ink);
  border: 1px solid rgba(217,169,74,0.5);
  border-radius: 16px 16px 0 0;
  padding: 22px 18px 16px;
  box-sizing: border-box;
}
@media (min-width: 640px) {
  #npc-modal { align-items: center; }
  #npc-sheet { border-radius: 16px; margin-bottom: 0; }
}

#npc-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: var(--bone);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}

/* Always visible at the top of the dialogue, independent of scroll —
   the hard, persistent "this is not a human" disclosure the directive
   asks for, not something that can scroll out of view mid-conversation. */
#npc-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: rgba(217,169,74,0.18);
  color: #D9A94A;
  border: 1px solid rgba(217,169,74,0.5);
  border-radius: 999px;
  padding: 4px 11px;
  margin-bottom: 10px;
}

#npc-title { margin-top: 0; }
#npc-bio { margin-bottom: 14px; }

#npc-quests { margin-bottom: 14px; }
.npc-quest-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  background: rgba(247,247,243,0.04);
  border: 1px solid rgba(247,247,243,0.1);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.npc-quest-row.npc-quest-claimed { opacity: 0.55; }
.npc-quest-main { flex: 1; min-width: 0; }
.npc-quest-title {
  font-size: 13px;
  font-weight: bold;
  margin-bottom: 2px;
}
.npc-quest-category {
  font-size: 9px;
  font-weight: normal;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: rgba(247,247,243,0.5);
  border: 1px solid rgba(247,247,243,0.25);
  border-radius: 999px;
  padding: 1px 6px;
  margin-left: 4px;
  vertical-align: middle;
}
.npc-quest-desc {
  font-size: 12px;
  color: rgba(247,247,243,0.65);
  margin-bottom: 4px;
}
.npc-quest-reward {
  font-size: 12px;
  font-weight: bold;
  color: var(--green);
}
.npc-quest-claim-btn {
  flex-shrink: 0;
  margin: 0;
  padding: 8px 14px;
  font-size: 12px;
}
.npc-quest-status {
  flex-shrink: 0;
  font-size: 11px;
  color: rgba(247,247,243,0.5);
  white-space: nowrap;
  align-self: center;
}

/* The dialogue log + input. Deliberately a SEPARATE element from #chat-log
   (real player chat) with its own classes below -- an NPC reply must never
   share markup/styling with a real player's message, so there is no way
   for either to be mistaken for the other even at a glance. */
#npc-chat-log {
  max-height: 160px;
  overflow-y: auto;
  font-size: 13px;
  background: rgba(247,247,243,0.04);
  border: 1px solid rgba(247,247,243,0.1);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 8px;
}
#npc-chat-log div { margin-bottom: 6px; line-height: 1.4; }
.npc-chat-you b { color: var(--bone); }
.npc-chat-reply {
  background: rgba(217,169,74,0.1);
  border-left: 3px solid #D9A94A;
  border-radius: 4px;
  padding: 4px 8px;
}
.npc-chat-reply b { color: #D9A94A; }
.npc-chat-error { opacity: 0.75; font-style: italic; }

#npc-chat-form {
  display: flex;
  gap: 8px;
}
#npc-chat-input {
  flex: 1;
  background: rgba(247,247,243,0.06);
  border: 1px solid rgba(247,247,243,0.2);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--bone);
  font-family: inherit;
}
#npc-chat-form button {
  background: #D9A94A;
  color: var(--ink);
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: bold;
  cursor: pointer;
}
#npc-chat-form button:disabled { opacity: 0.5; cursor: default; }
#npc-chat-note {
  font-size: 11px;
  color: rgba(247,247,243,0.5);
  margin: 6px 0 0;
  min-height: 1.2em;
}

/* Phase 6 ("Achievements -> Profile" + "Live Events" directives) */

#live-events-btn, #achievements-btn {
  font-size: 12px;
  font-weight: bold;
  background: rgba(217,169,74,0.12);
  border: 1px solid rgba(217,169,74,0.5);
  color: #D9A94A;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}

#live-events-modal, #achievements-modal, #games-modal {
  position: fixed;
  inset: 0;
  background: rgba(5,6,9,0.78);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
#live-events-modal.hidden, #achievements-modal.hidden, #games-modal.hidden { display: none; }

#live-events-sheet, #achievements-sheet, #games-sheet {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--ink);
  border: 1px solid rgba(217,169,74,0.5);
  border-radius: 16px 16px 0 0;
  padding: 22px 18px 28px;
  box-sizing: border-box;
}
@media (min-width: 640px) {
  #live-events-modal, #achievements-modal, #games-modal { align-items: center; }
  #live-events-sheet, #achievements-sheet, #games-sheet { border-radius: 16px; margin-bottom: 0; }
}
#live-events-close, #achievements-close, #games-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: var(--bone);
  font-size: 22px;
  cursor: pointer;
}

.le-group { margin: 16px 0; }
.le-group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; color: #D9A94A; margin: 0 0 8px; }
.le-card {
  display: block;
  padding: 10px 12px;
  margin-bottom: 6px;
  background: rgba(247,247,243,0.04);
  border: 1px solid rgba(247,247,243,0.1);
  border-radius: 10px;
  color: var(--bone);
  text-decoration: none;
}
.le-card:hover { border-color: rgba(217,169,74,0.5); }
.le-card .le-title { font-weight: bold; font-size: 14px; }
.le-card .le-meta { font-size: 12px; opacity: 0.7; margin-top: 2px; }
.le-card .le-live-dot { color: var(--green); font-weight: bold; }
.le-empty { font-size: 13px; opacity: 0.55; padding: 4px 0 2px; }

.ach-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 6px;
  border-radius: 10px;
  border: 1px solid rgba(247,247,243,0.1);
}
.ach-card.unlocked { background: rgba(81,194,60,0.08); border-color: rgba(81,194,60,0.4); }
.ach-card.locked { opacity: 0.45; }
.ach-card .ach-star { font-size: 20px; color: #D9A94A; }
.ach-card .ach-title { font-weight: bold; font-size: 14px; }
.ach-card .ach-desc { font-size: 12px; opacity: 0.75; margin-top: 2px; }

#achievement-earned-toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, rgba(217,169,74,0.95), rgba(190,140,40,0.95));
  color: var(--ink);
  border-radius: 12px;
  padding: 12px 18px;
  z-index: 30;
  max-width: 90vw;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  text-align: center;
}
#achievement-earned-toast.hidden { display: none; }

/* Phase 10 (Final Acceptance Test): on-screen D-pad for touch devices --
   see index.html's own comment on #touch-dpad for why this exists (real
   mobile bug: movement was keyboard-only, so a phone could never actually
   walk to the Library/NPCs/Plaza/Discovery Board/Marketplace -- every one
   of those needs real server-side proximity). Hidden by default so a real
   mouse+keyboard desktop never sees it; shown only under `(hover: none)`
   -- the standard "this is a touch device" media query, not a UA sniff --
   matching how Ludo/Penalty/the other CelebIsland games already gate
   their own touch controls. */
#touch-dpad {
  display: none;
  position: absolute;
  left: 14px;
  bottom: 14px;
  width: 132px;
  height: 132px;
  /* Audit fix (2026-11-03): was z-index: 15, higher than #login's
     z-index: 10. #login is a fixed, full-viewport, opaque gate ("Enter
     the Campus as ...") shown before the player has actually entered the
     world, and this D-pad has no JS gating of its own on #login's
     visibility -- so on every real touch device the D-pad rendered on
     TOP of the login/consent gate, overlapping its "Enter the Campus as"
     text (confirmed live on a real iPhone viewport). Dropping below 10
     puts it behind #login's opaque background while the gate is up;
     once Enter is clicked client.js sets #login's display to none, so
     the D-pad is unobscured during actual gameplay exactly as before. */
  z-index: 5;
}
@media (hover: none) {
  #touch-dpad { display: block; }
}
#touch-dpad button {
  position: absolute;
  width: 44px;
  height: 44px;
  border: 1px solid var(--green);
  border-radius: 10px;
  background: rgba(7,8,12,0.72);
  color: var(--bone);
  font-size: 16px;
  line-height: 1;
  user-select: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
#touch-dpad button:active { background: rgba(81,194,60,0.35); }
#dpad-up    { top: 0;    left: 44px; }
#dpad-left  { top: 44px; left: 0;    }
#dpad-down  { top: 88px; left: 44px; }
#dpad-right { top: 44px; left: 88px; }
#achievement-earned-toast a { color: var(--ink); font-weight: bold; text-decoration: underline; }
