/* Atlas — Player chat (WhatsApp-style) */

body.player-page {
  background: #0a141a;
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.player-shell {
  display: grid;
  grid-template-columns: 320px 1fr 320px;
  gap: 16px;
  padding: 16px;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}

/* ─── Left rail: country + companion + lives ─── */

.rail {
  background: var(--atlas-surface);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: fit-content;
  position: sticky;
  top: 16px;
}

.rail-section h4 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--atlas-muted);
  margin-bottom: 8px;
}

.country-toggle {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.country-btn {
  padding: 6px 10px;
  border-radius: var(--r-pill);
  background: var(--atlas-bg);
  border: 1px solid var(--atlas-border);
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 500;
}
.country-btn.active {
  background: var(--atlas-navy);
  color: white;
  border-color: var(--atlas-navy);
}

.companion-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--atlas-bg);
  border-radius: var(--r-md);
}
.companion-card .ava { font-size: 1.6rem; }
.companion-card .name { font-weight: 600; font-size: 0.95rem; }
.companion-card .sub { font-size: 0.78rem; color: var(--atlas-muted); }

.lives {
  display: flex;
  gap: 4px;
  font-size: 1.2rem;
}
.heart { transition: opacity 0.3s; }
.heart.lost { opacity: 0.2; }

.gem-tracker {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 1.1rem;
}
.gem { opacity: 0.25; transition: opacity 0.4s, transform 0.4s; }
.gem.unlocked { opacity: 1; transform: scale(1.15); }

.bonus-gems {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
}
.bonus-gems .bonus {
  background: linear-gradient(90deg, #fff7d6, #ffe9a8);
  padding: 4px 8px;
  border-radius: var(--r-sm);
  font-weight: 600;
  color: #7a5a00;
}

/* ─── Center: phone chat ─── */

.phone-stage {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.phone {
  width: 380px;
  height: 760px;
  background: var(--wa-bg);
  border-radius: 36px;
  border: 10px solid #1f2c34;
  padding: 0;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wa-header {
  background: var(--wa-header);
  color: var(--wa-header-text);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.wa-header .wa-back { opacity: 0.8; }
.wa-header .wa-avatar {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}
.wa-header .wa-name { font-weight: 600; font-size: 0.95rem; }
.wa-header .wa-status { font-size: 0.72rem; opacity: 0.85; }

.wa-chat {
  flex: 1;
  background: var(--wa-bg);
  background-image: linear-gradient(rgba(239, 234, 226, 0.92), rgba(239, 234, 226, 0.92)),
    radial-gradient(circle at 20% 10%, #d8cfbf 1px, transparent 1px),
    radial-gradient(circle at 70% 30%, #d8cfbf 1px, transparent 1px);
  background-size: auto, 24px 24px, 32px 32px;
  padding: 14px 12px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wa-bubble {
  max-width: 85%;
  padding: 8px 11px 6px;
  border-radius: 8px;
  font-size: 0.92rem;
  color: var(--wa-text);
  white-space: pre-wrap;
  line-height: 1.35;
  position: relative;
  box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
  animation: bubble-in 0.25s ease;
  word-wrap: break-word;
}
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.wa-bubble.bot { background: var(--wa-bot); align-self: flex-start; border-top-left-radius: 0; }
.wa-bubble.user { background: var(--wa-user); align-self: flex-end; border-top-right-radius: 0; }
.wa-bubble.spark { background: #fff3d4; align-self: flex-start; border-top-left-radius: 0; }
.wa-bubble.system {
  align-self: center;
  background: rgba(255,234,158,0.95);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  border-radius: 12px;
  padding: 6px 14px;
  color: #7a5a00;
}
.wa-bubble.reveal {
  align-self: stretch;
  background: linear-gradient(135deg, #075e54, #128c7e);
  color: white;
  padding: 14px 16px;
  border-radius: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  white-space: pre-wrap;
  box-shadow: 0 4px 16px rgba(7,94,84,0.35);
}

.wa-bubble .meta { display: block; font-size: 0.65rem; color: var(--wa-muted); margin-top: 2px; text-align: right; }

.typing { display: flex; gap: 3px; padding: 8px 11px; background: var(--wa-bot); align-self: flex-start; border-radius: 8px; border-top-left-radius: 0; }
.typing span { width: 6px; height: 6px; background: var(--wa-muted); border-radius: 50%; animation: typing 1.4s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { opacity: 0.3; } 30% { opacity: 1; } }

/* HP bar for boss fight */
.hp-bar {
  background: var(--wa-bot);
  align-self: stretch;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--wa-text);
}
.hp-bar .label { font-weight: 600; margin-bottom: 4px; }
.hp-bar .bar {
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
}
.hp-bar .fill { height: 100%; background: linear-gradient(90deg, #ff5b3a, #f5b800, #2ec27e); transition: width 0.5s; }
.hp-bar .fill.spark { background: linear-gradient(90deg, #f5b800, #ff8c3a); }

/* ─── Input area ─── */

.wa-input {
  background: #f0f2f5;
  padding: 8px 10px;
  display: flex;
  gap: 6px;
  align-items: center;
  border-top: 1px solid #d4d6d8;
}
.wa-input input[type="text"] {
  flex: 1;
  border: none;
  background: white;
  border-radius: 24px;
  padding: 9px 14px;
  font-size: 0.92rem;
  outline: none;
}
.wa-input input[type="text"]:focus { box-shadow: 0 0 0 2px var(--atlas-cyan); }
.wa-input button {
  background: var(--wa-header);
  color: white;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wa-input button:hover { background: #128c7e; }
.wa-input button:disabled { opacity: 0.4; cursor: not-allowed; }

.wa-quickreplies {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px 10px;
  background: #f0f2f5;
}
.wa-quickreplies button {
  background: white;
  border: 1px solid #cfd2d6;
  border-radius: 18px;
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 500;
}
.wa-quickreplies button:hover { background: #e7f1ff; border-color: var(--atlas-blue); }

/* Weapon choice buttons (TRUST/STRIKE/PROBE) */
.weapon-row {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  background: #f0f2f5;
}
.weapon-btn {
  flex: 1;
  padding: 10px 8px;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.weapon-btn.trust { background: #e0f2fe; color: #0369a1; border-color: #7dd3fc; }
.weapon-btn.strike { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.weapon-btn.probe { background: #f3e8ff; color: #6b21a8; border-color: #d8b4fe; }
.weapon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.weapon-btn .ico { font-size: 1.1rem; }

/* ─── Right rail: live measurement ─── */

.measure-block { font-size: 0.82rem; }
.measure-block .row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--atlas-border); }
.measure-block .row:last-child { border-bottom: none; }
.measure-block .row .lbl { color: var(--atlas-muted); }
.measure-block .row .val { font-weight: 600; color: var(--atlas-navy); font-family: ui-monospace, "SF Mono", Menlo, monospace; }

.tier-bar {
  display: flex;
  gap: 3px;
  margin-top: 4px;
}
.tier-bar .seg {
  flex: 1;
  height: 8px;
  background: var(--atlas-border);
  border-radius: 2px;
}
.tier-bar .seg.fill { background: var(--atlas-blue); }
.tier-bar .seg.fill.t3 { background: linear-gradient(90deg, var(--atlas-cyan), var(--atlas-blue)); }
.tier-bar .seg.fill.t4 { background: linear-gradient(90deg, var(--atlas-gold), var(--atlas-cyan), var(--atlas-blue)); }

.skill-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.skill-chip {
  background: var(--atlas-bg);
  border: 1px solid var(--atlas-border);
  border-radius: var(--r-pill);
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 500;
}
.skill-chip.detected { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }

.privacy-tier {
  background: var(--atlas-bg);
  border-radius: var(--r-md);
  padding: 8px 10px;
  font-size: 0.78rem;
}
.privacy-tier .lvl { font-weight: 700; color: var(--atlas-navy); }

/* ─── Atlas Card reveal ─── */

.card-modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 26, 0.85);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fade-in 0.4s;
}
.card-modal.show { display: flex; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.atlas-card {
  width: 460px;
  max-width: 90vw;
  background: linear-gradient(135deg, #0a2540 0%, #1e6fd9 100%);
  color: white;
  border-radius: var(--r-lg);
  padding: 28px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.4);
  position: relative;
  animation: card-pop 0.6s cubic-bezier(.2,.9,.3,1.4);
}
@keyframes card-pop {
  from { transform: scale(0.7) rotate(-3deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}
.atlas-card h2 { color: white; font-size: 1.4rem; margin-bottom: 4px; }
.atlas-card .sub { font-size: 0.85rem; opacity: 0.85; margin-bottom: 18px; }
.atlas-card .row {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}
.atlas-card .row .k { font-size: 0.78rem; opacity: 0.75; }
.atlas-card .row .v { font-weight: 600; }
.atlas-card .row.big .v { font-size: 1.15rem; }
.atlas-card .doors {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 18px;
}
.atlas-card .door {
  background: rgba(255,255,255,0.12);
  padding: 12px 8px;
  border-radius: var(--r-md);
  text-align: center;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s;
}
.atlas-card .door:hover { background: rgba(255,255,255,0.22); }
.atlas-card .close-x {
  position: absolute;
  top: 12px;
  right: 16px;
  background: rgba(255,255,255,0.1);
  color: white;
  border: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
}
.atlas-card .share-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.atlas-card .share-btn {
  flex: 1;
  padding: 8px;
  background: rgba(255,255,255,0.18);
  border: none;
  color: white;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}
.atlas-card .share-btn.primary { background: var(--atlas-cyan); color: var(--atlas-navy); }

/* ─── Reset / Top bar ─── */

.player-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--atlas-navy);
  color: white;
}
.player-topbar a { color: var(--atlas-cyan); }
.player-topbar .restart-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.4);
  color: white;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  cursor: pointer;
  font-size: 0.85rem;
}
.player-topbar .restart-btn:hover { background: rgba(255,255,255,0.1); }

/* ─── Responsive ─── */

@media (max-width: 1100px) {
  .player-shell { grid-template-columns: 1fr; }
  .rail { position: relative; top: 0; }
}

/* ─── Audio Recording Styles ─── */
.wa-icon-btn {
  background: transparent !important;
  color: var(--atlas-muted) !important;
  font-size: 1.2rem !important;
  transition: color 0.2s, transform 0.2s;
}
.wa-icon-btn:hover { color: var(--atlas-blue) !important; }
.wa-icon-btn.recording {
  color: #ef4444 !important;
  animation: pulse-record 1.5s infinite;
}
@keyframes pulse-record {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}
.wa-bubble.audio {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--wa-user);
}
.wa-bubble.audio .play-icon {
  width: 24px;
  height: 24px;
  background: var(--atlas-blue);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
}
.wa-bubble.audio .waveform {
  height: 14px;
  width: 100px;
  background: repeating-linear-gradient(90deg, #128c7e, #128c7e 2px, transparent 2px, transparent 4px);
  opacity: 0.5;
}
