/* ═══════════════ KINGDOM 2D UI ═══════════════ */

#kc-wrapper {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d1117;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  font-family: 'Crimson Text', serif;
  zoom: 1.4;
}

/* ─── HUD ─── */
#kc-hud {
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0,0,0,0.4);
  border-bottom: 1px solid rgba(255,215,0,0.15);
  z-index: 10;
  flex-shrink: 0;
}

#kc-back-btn {
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}
#kc-back-btn:hover {
  background: rgba(200,50,50,0.7);
}

/* ─── Title Badge ─── */
#kc-title-badge {
  flex-shrink: 0;
}
.kc-title-text {
  color: #ffd700;
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  background: rgba(255,215,0,0.08);
  padding: 4px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,215,0,0.2);
}

/* ─── Resource Bar ─── */
#kc-resource-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 0 12px;
}
.kc-res-item {
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  padding: 3px 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: #eee;
  white-space: nowrap;
}
.kc-res-icon {
  font-size: 0.9rem;
}
.kc-res-icon-img {
  width: 19px;
  height: 19px;
  object-fit: contain;
  vertical-align: middle;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}
.kc-res-weapons-icon {
  position: relative;
  display: inline-flex;
  width: 24px;
  height: 19px;
  align-items: center;
  justify-content: center;
}
.kc-res-weapons-icon .kc-res-icon-img {
  position: absolute;
}
.kc-res-weapons-icon .kc-res-icon-img:first-child {
  transform: rotate(160deg);
}
.kc-res-weapons-icon .kc-res-icon-img:last-child {
  transform: rotate(200deg) scaleX(-1);
}
.kc-prod-icon {
  width: 16px;
  height: 16px;
}
.kc-res-val {
  font-weight: bold;
  min-width: 20px;
  text-align: right;
}
.kc-res-gold .kc-res-val { color: #ffd700; }
.kc-res-food .kc-res-val { color: #8BC34A; }
.kc-res-ore .kc-res-val  { color: #90A4AE; }
.kc-res-wood .kc-res-val { color: #8D6E63; }
.kc-res-herbs .kc-res-val { color: #66BB6A; }
.kc-res-weapons .kc-res-val { color: #B0BEC5; }
.kc-res-medicine .kc-res-val { color: #E57373; }
.kc-res-stability .kc-res-val { color: #ef5350; }
.kc-res-workers .kc-res-val { color: #81D4FA; }
.kc-res-workers.kc-res-warn .kc-res-val { color: #ff7043; }
.kc-res-workers.kc-res-warn { border-color: rgba(255, 112, 67, 0.5); }

/* Pending resources (awaiting collection) */
.kc-res-pending {
  color: #4CAF50;
  font-size: 0.7rem;
  font-weight: bold;
  margin-left: 2px;
  animation: kc-pending-pulse 2s ease-in-out infinite;
}
@keyframes kc-pending-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* Collect button */
.kc-collect-btn {
  background: linear-gradient(180deg, #ffd700, #e6ac00);
  color: #1a1a1a;
  border: 2px solid #c89600;
  border-radius: 8px;
  padding: 4px 14px;
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  font-weight: bold;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  animation: kc-collect-glow 1.5s ease-in-out infinite;
  transition: transform 0.15s, box-shadow 0.15s;
}
.kc-collect-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 16px rgba(255, 215, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.kc-collect-btn:active {
  transform: scale(0.95);
}
@keyframes kc-collect-glow {
  0%, 100% { box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3); }
  50% { box-shadow: 0 2px 16px rgba(255, 215, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.3); }
}

/* Worker shortage warning banner */
.kc-worker-warning {
  background: rgba(255, 112, 67, 0.15);
  border: 1px solid rgba(255, 112, 67, 0.4);
  border-radius: 6px;
  padding: 6px 12px;
  margin: 4px 0 8px;
  font-size: 0.75rem;
  color: #ff7043;
  text-align: center;
}

/* Building card: ore consumption label */
.kc-prod-consume { color: #ef5350; font-size: 0.7rem; }

/* ═══════════════ TAB BAR ═══════════════ */
#kc-tabs {
  display: flex;
  gap: 0;
  padding: 8px 16px 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.5) 0%, rgba(10,8,4,0.6) 100%);
  border-bottom: 2px solid rgba(212, 165, 69, 0.15);
  flex-shrink: 0;
  position: relative;
}
#kc-tabs::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 16px;
  right: 16px;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(212,165,69,0.25), transparent);
}
.kc-tab {
  flex: 1;
  padding: 12px 10px 10px;
  background: linear-gradient(180deg, rgba(30,25,18,0.6) 0%, rgba(20,16,10,0.8) 100%);
  border: 1px solid rgba(212,165,69,0.1);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  color: rgba(200,180,140,0.45);
  font-family: 'Cinzel', serif;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  text-align: center;
  white-space: nowrap;
  letter-spacing: 0.03em;
  position: relative;
  margin: 0 1px;
}
.kc-tab:hover {
  background: linear-gradient(180deg, rgba(40,32,20,0.7) 0%, rgba(30,24,14,0.9) 100%);
  color: rgba(212,165,69,0.8);
  border-color: rgba(212,165,69,0.2);
}
.kc-tab.active {
  background: linear-gradient(180deg, rgba(212,165,69,0.1) 0%, rgba(15,12,8,0.95) 100%);
  border-color: rgba(212,165,69,0.3);
  color: #d4a545;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(212,165,69,0.25);
}
.kc-tab.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #d4a545, transparent);
  border-radius: 0 0 2px 2px;
}

/* ═══════════════ TAB CONTENT ═══════════════ */
#kc-tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  color: #ccc;
  background: linear-gradient(180deg, rgba(13,17,23,1) 0%, rgba(16,13,8,0.98) 100%);
  scrollbar-width: thin;
  scrollbar-color: rgba(212,165,69,0.2) transparent;
}
#kc-tab-content.kc-map-fullsize {
  padding: 0;
  overflow: hidden;
}
#kc-tab-content::-webkit-scrollbar { width: 8px; }
#kc-tab-content::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); border-radius: 4px; }
#kc-tab-content::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(212,165,69,0.3), rgba(212,165,69,0.15));
  border-radius: 4px;
  border: 1px solid rgba(212,165,69,0.08);
}
#kc-tab-content::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(212,165,69,0.4), rgba(212,165,69,0.25));
}

/* ═══════════════ SHARED SECTION STYLES ═══════════════ */
.kc-section-title {
  margin: 0 0 8px;
  color: #d4a545;
  font-family: 'Cinzel', serif;
  font-size: 1.3rem;
}
.kc-section-subtitle {
  margin: 0 0 12px;
  color: #d4a545;
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  letter-spacing: 0.05em;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(212,165,69,0.12);
  position: relative;
}
.kc-section-subtitle::after {
  content: '\u25C6';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.45rem;
  color: rgba(212,165,69,0.25);
  background: #0d1117;
  padding: 0 8px;
}

/* ═══════════════ BUILDINGS TAB ═══════════════ */
.kc-building-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.kc-building-card {
  background: linear-gradient(145deg, rgba(20,17,12,0.95) 0%, rgba(15,12,8,0.98) 100%);
  border: 1px solid rgba(212,165,69,0.12);
  border-radius: 8px;
  padding: 16px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}
.kc-building-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 20px; height: 20px;
  border-top: 2px solid rgba(212,165,69,0.18);
  border-left: 2px solid rgba(212,165,69,0.18);
  border-radius: 8px 0 0 0;
}
.kc-building-card::after {
  content: '';
  position: absolute;
  bottom: 0; right: 0;
  width: 20px; height: 20px;
  border-bottom: 2px solid rgba(212,165,69,0.18);
  border-right: 2px solid rgba(212,165,69,0.18);
  border-radius: 0 0 8px 0;
}
.kc-building-card:hover {
  border-color: rgba(212,165,69,0.35);
  box-shadow: 0 0 20px rgba(212,165,69,0.06);
  transform: translateY(-2px);
}
.kc-building-card.not-built {
  opacity: 0.5;
  border-style: dashed;
}
.kc-building-card.not-built::before,
.kc-building-card.not-built::after { display: none; }
.kc-building-card.not-built:hover { opacity: 0.75; }
.kc-building-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.kc-building-emoji {
  font-size: 1.6rem;
  filter: drop-shadow(0 0 6px rgba(212,165,69,0.15));
}
.kc-building-name {
  color: #d4a545;
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.kc-building-level {
  color: rgba(200,180,140,0.55);
  font-size: 0.8rem;
  margin-bottom: 8px;
}
.kc-building-prod {
  color: #aaa;
  font-size: 0.8rem;
  margin-top: 4px;
}
.kc-building-action {
  margin-top: 10px;
}
.kc-building-action .kc-action-btn {
  display: block;
  width: 100%;
  text-align: center;
  font-size: 0.8rem;
  padding: 8px 12px;
  margin-top: 0;
}

/* ═══════════════ ARMY TAB ═══════════════ */
.kc-army-empty {
  text-align: center;
  padding: 40px 20px;
  color: rgba(200,180,140,0.5);
}
.kc-army-empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 8px rgba(212,165,69,0.15));
}
.kc-army-empty h3 {
  color: #d4a545;
  font-family: 'Cinzel', serif;
  margin-bottom: 8px;
}

.kc-army-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}
.kc-army-stat {
  font-size: 0.82rem;
  color: #bbb;
  padding: 10px 12px;
  background: linear-gradient(145deg, rgba(20,17,12,0.9), rgba(15,12,8,0.95));
  border: 1px solid rgba(212,165,69,0.08);
  border-radius: 6px;
  text-align: center;
}
.kc-army-stat strong {
  display: block;
  color: #d4a545;
  font-family: 'Cinzel', serif;
  font-size: 1.05rem;
  margin-top: 2px;
}

.kc-army-section {
  margin-bottom: 20px;
}

.kc-recruit-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.kc-recruit-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: linear-gradient(145deg, rgba(20,17,12,0.9), rgba(15,12,8,0.95));
  border: 2px solid;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
  min-width: 110px;
}
.kc-recruit-btn:hover:not(.kc-disabled) {
  background: rgba(255,255,255,0.04);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.kc-recruit-btn.kc-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.kc-recruit-grade {
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  font-weight: bold;
}
.kc-recruit-acc {
  color: #999;
  font-size: 0.7rem;
}
.kc-recruit-cost {
  color: #d4a545;
  font-size: 0.8rem;
  font-weight: bold;
}

.kc-army-roster {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.kc-unit-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 5px 10px;
  background: rgba(0,0,0,0.35);
  border: 1px solid;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: bold;
}
.kc-unit-insured { font-size: 0.6rem; }
.kc-unit-wound { font-size: 0.6rem; }

.kc-mission-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.kc-mission-card {
  background: linear-gradient(145deg, rgba(20,17,12,0.95), rgba(15,12,8,0.98));
  border: 1px solid rgba(212,165,69,0.12);
  border-left: 3px solid rgba(212,165,69,0.25);
  border-radius: 8px;
  padding: 14px;
  transition: all 0.2s ease;
}
.kc-mission-card:hover:not(.kc-mission-completed) {
  border-color: rgba(212,165,69,0.25);
  box-shadow: 0 0 12px rgba(212,165,69,0.05);
}
.kc-mission-card.kc-mission-completed {
  opacity: 0.4;
}
.kc-mission-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.kc-mission-name {
  color: #d4a545;
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  font-weight: bold;
}
.kc-mission-diff {
  font-size: 0.7rem;
  font-weight: bold;
  text-transform: uppercase;
}
.kc-mission-details {
  display: flex;
  gap: 12px;
  font-size: 0.75rem;
  color: #999;
  margin-bottom: 8px;
}
.kc-mission-status {
  display: flex;
  align-items: center;
  gap: 8px;
}
.kc-mission-done {
  color: #4CAF50;
  font-weight: bold;
  font-size: 0.85rem;
}
.kc-mission-timer {
  color: #d4a545;
  font-family: monospace;
  font-size: 0.9rem;
  font-weight: bold;
}
.kc-mission-status .kc-action-btn {
  margin-top: 0;
  font-size: 0.8rem;
  padding: 6px 14px;
}

/* ─── Unit deployed state ─── */
.kc-unit-deployed {
  opacity: 0.5;
  border-style: dashed !important;
  position: relative;
}
.kc-unit-deploy-icon {
  font-size: 0.6rem;
  position: absolute;
  top: -2px;
  right: -2px;
}

/* ─── Mission assigned units ─── */
.kc-mission-assigned {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.kc-mini-unit {
  font-size: 0.7rem;
  padding: 2px 6px;
  border: 1px solid;
  border-radius: 4px;
  background: rgba(0,0,0,0.3);
  font-weight: bold;
}

/* ─── Unit picker ─── */
.kc-mission-card.kc-mission-picking {
  border-color: rgba(212,165,69,0.35);
  box-shadow: 0 0 16px rgba(212,165,69,0.1);
}
.kc-unit-picker {
  margin-top: 8px;
}
.kc-picker-title {
  color: #d4a545;
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  font-weight: bold;
  margin-bottom: 8px;
}
.kc-picker-units {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.kc-picker-unit {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.35);
  border: 2px solid;
  border-radius: 6px;
  transition: all 0.15s ease;
}
.kc-picker-unit:hover {
  transform: scale(1.05);
  background: rgba(212,165,69,0.08);
}
.kc-picker-unit.kc-picker-selected {
  background: rgba(212,165,69,0.2);
  box-shadow: 0 0 10px rgba(212,165,69,0.4);
}
.kc-picker-unit .kc-unit-id {
  font-size: 0.7rem;
  color: #ccc;
  font-weight: bold;
}
.kc-picker-unit .kc-unit-grade {
  font-size: 0.65rem;
  font-weight: bold;
  text-transform: uppercase;
}
.kc-picker-actions {
  display: flex;
  gap: 8px;
}
.kc-picker-send {
  background: linear-gradient(135deg, rgba(180,140,40,0.35), rgba(120,80,20,0.4)) !important;
  color: #ffd700 !important;
  border-color: rgba(212,165,69,0.5) !important;
}
.kc-picker-cancel {
  opacity: 0.7;
}

/* ═══════════════ EVENTS TAB ═══════════════ */
.kc-events-empty {
  text-align: center;
  padding: 40px 20px;
  color: rgba(200,180,140,0.5);
}
.kc-events-empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 8px rgba(212,165,69,0.15));
}
.kc-events-empty h3 {
  color: #d4a545;
  font-family: 'Cinzel', serif;
  margin-bottom: 8px;
}
.kc-events-hint {
  font-size: 0.8rem;
  color: rgba(200,180,140,0.35);
  margin-top: 8px;
}

.kc-event-active {
  max-width: 600px;
  margin: 0 auto;
  padding: 24px;
  background: linear-gradient(145deg, rgba(20,15,10,0.97), rgba(12,10,8,0.98));
  border: 2px solid rgba(212,165,69,0.3);
  border-radius: 12px;
  box-shadow: 0 0 40px rgba(212,165,69,0.06);
  position: relative;
}
.kc-event-active::before,
.kc-event-active::after {
  content: '\u2756';
  position: absolute;
  color: rgba(212,165,69,0.15);
  font-size: 0.8rem;
}
.kc-event-active::before { top: 8px; left: 12px; }
.kc-event-active::after { bottom: 8px; right: 12px; }

.kc-event-category {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  border: 1px solid;
}

/* Event timer */
.kc-event-timer-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 10px 0;
}
.kc-event-timer-icon { font-size: 1.2rem; }
.kc-event-timer {
  font-family: 'Cinzel', serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: #d4a545;
  text-shadow: 0 0 10px rgba(212,165,69,0.3);
  letter-spacing: 2px;
}
.kc-event-timer-urgent {
  color: #ef5350;
  text-shadow: 0 0 14px rgba(239,83,80,0.4);
  animation: kc-timer-pulse 1s ease-in-out infinite;
}
@keyframes kc-timer-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.05); }
}

.kc-event-title {
  margin: 0 0 8px;
  color: #d4a545;
  font-family: 'Cinzel', serif;
  font-size: 1.3rem;
}
.kc-event-desc {
  margin: 0 0 16px;
  color: #bbb;
  font-size: 0.9rem;
  line-height: 1.5;
}
.kc-event-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.kc-event-option {
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  background: rgba(212,165,69,0.04);
  border: 1px solid rgba(212,165,69,0.15);
  border-left: 3px solid rgba(212,165,69,0.25);
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.kc-event-option:hover:not(.kc-disabled) {
  background: rgba(212,165,69,0.1);
  border-color: rgba(212,165,69,0.35);
  transform: translateX(4px);
}
.kc-event-option.kc-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.kc-event-opt-label {
  color: #d4a545;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 0.92rem;
}
.kc-event-opt-desc {
  color: #999;
  font-size: 0.78rem;
  margin-top: 3px;
}
.kc-event-opt-cost {
  color: #d4a545;
  font-size: 0.78rem;
  margin-left: 6px;
}
.kc-event-opt-chance {
  color: #4fc3f7;
  font-size: 0.72rem;
  margin-top: 3px;
  font-style: italic;
}
.kc-event-result {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-top: 12px;
  text-align: center;
  animation: kcFadeIn 0.3s ease-out;
}

/* Event toast timer */
.kc-event-toast-timer {
  font-size: 0.72rem;
  color: rgba(212,165,69,0.6);
  margin-top: 2px;
}

/* ═══════════════ PANEL ACTION BUTTONS ═══════════════ */
.kc-action-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 9px 22px;
  background: linear-gradient(135deg, #8b6914 0%, #b8860b 40%, #d4a545 100%);
  color: #1a1408;
  border: 1px solid rgba(212,165,69,0.25);
  border-radius: 4px;
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: all 0.2s;
  text-shadow: 0 1px 0 rgba(255,255,255,0.12);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.08);
}
.kc-action-btn:hover:not(.kc-disabled) {
  background: linear-gradient(135deg, #a07a18 0%, #d4a545 40%, #ffd700 100%);
  box-shadow: 0 4px 16px rgba(212,165,69,0.25), inset 0 1px 0 rgba(255,255,255,0.12);
  transform: translateY(-1px);
}
.kc-action-btn:active:not(.kc-disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.kc-action-btn.kc-disabled {
  background: #333;
  color: #666;
  border-color: #444;
  cursor: not-allowed;
  box-shadow: none;
}
.kc-max-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 12px;
  background: rgba(255,215,0,0.15);
  color: #ffd700;
  border: 1px solid rgba(255,215,0,0.3);
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: bold;
}

/* ─── Kingdom Projects ─── */
.kc-projects-section {
  margin-top: 24px;
  border-top: 2px solid rgba(212,165,69,0.3);
  padding-top: 16px;
}
.kc-projects-title {
  font-family: 'Cinzel', serif;
  color: #ffd700;
  font-size: 1.1rem;
  margin: 0 0 12px 0;
  text-align: center;
  letter-spacing: 1px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}
.kc-projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.kc-project-card {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 1px solid rgba(212,165,69,0.25);
  border-radius: 8px;
  padding: 14px;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
}
.kc-project-card::before {
  content: '\u2756';
  position: absolute;
  top: -1px; left: -1px;
  color: rgba(212,165,69,0.35);
  font-size: 0.7rem;
}
.kc-project-card::after {
  content: '\u2756';
  position: absolute;
  bottom: -1px; right: -1px;
  color: rgba(212,165,69,0.35);
  font-size: 0.7rem;
}
.kc-project-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.kc-project-name {
  font-family: 'Cinzel', serif;
  color: #e0c97f;
  font-size: 0.95rem;
  font-weight: bold;
}
.kc-project-check {
  color: #4CAF50;
  font-size: 1.2rem;
}
.kc-project-lock {
  font-size: 1rem;
  opacity: 0.6;
}
.kc-project-icon {
  font-size: 1.1rem;
}
.kc-project-desc {
  color: #aaa;
  font-size: 0.8rem;
  margin-bottom: 6px;
  line-height: 1.3;
}
.kc-project-bonus {
  color: #4CAF50;
  font-size: 0.8rem;
  margin-bottom: 6px;
  font-style: italic;
}
.kc-project-cost {
  color: #ccc;
  font-size: 0.78rem;
  margin-bottom: 8px;
}
.kc-project-reqs {
  color: #999;
  font-size: 0.78rem;
  margin-top: 6px;
}
.kc-req-met { color: #4CAF50; }
.kc-req-unmet { color: #f44336; }

/* Completed project */
.kc-project-complete {
  border-color: rgba(76,175,80,0.4);
  background: linear-gradient(135deg, #1a2e1a 0%, #16301e 100%);
}
.kc-project-complete .kc-project-name {
  color: #a5d6a7;
}

/* Locked project */
.kc-project-locked {
  opacity: 0.55;
  border-style: dashed;
}

/* Available project */
.kc-project-available {
  border-color: rgba(212,165,69,0.45);
}
.kc-project-available:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(212,165,69,0.15);
}

.kc-project-build-btn {
  width: 100%;
  margin-top: 4px;
}

/* ─── Result messages ─── */
.kc-npc-result {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 8px;
  white-space: pre-line;
}
.kc-result-ok {
  background: rgba(76,175,80,0.15);
  color: #8BC34A;
  border: 1px solid rgba(76,175,80,0.3);
}
.kc-result-fail {
  background: rgba(244,67,54,0.15);
  color: #ef5350;
  border: 1px solid rgba(244,67,54,0.3);
}

/* ═══════════════ PROGRESS BARS ═══════════════ */
.kc-progress {
  height: 6px;
  background: rgba(255,255,255,0.05);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid rgba(212,165,69,0.06);
}
.kc-progress-fill {
  height: 100%;
  transition: width 0.3s;
  border-radius: 3px;
  background: linear-gradient(90deg, #b8860b, #d4a545, #ffd700) !important;
  box-shadow: 0 0 5px rgba(212,165,69,0.25);
}

/* ═══════════════ VINDICTUS NPC DIALOG ═══════════════ */
/* ═══════════════ NPC DIALOG — VINDICTUS-STYLE DIALOGUE UI ═══════════════ */

/* ─── Fullscreen overlay: dim + background image ─── */
.kc-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.kc-dialog-overlay.active {
  opacity: 1;
}
.kc-dialog-overlay.closing {
  opacity: 0;
  transition: opacity 0.35s ease;
}

/* Background image layer */
.kc-dialog-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: brightness(0.55) saturate(0.85);
}
/* Vignette + gradient on top of BG */
.kc-dialog-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.6) 100%),
              linear-gradient(to top, rgba(5,3,0,0.85) 0%, transparent 35%);
}

.kc-dialog-container {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
}

/* ─── NPC Portrait — LEFT side, no border, natural PNG ─── */
.kc-dialog-portrait {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 42%;
  height: 92%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 2;
  transform: translateX(-30px);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.5s ease;
  pointer-events: none;
}
.kc-dialog-portrait.active {
  transform: translateX(0);
  opacity: 1;
}

.kc-dialog-portrait-inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: opacity 0.2s ease;
}
.kc-dialog-portrait-inner.kc-portrait-changing {
  opacity: 0;
}

/* Portrait image — large, natural, no frame */
.kc-dialog-portrait-img {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(4px 4px 24px rgba(0,0,0,0.7));
}
/* When image fails, show emoji */
.kc-dialog-portrait-img[src=""] { display: none; }
.kc-dialog-portrait-img:not([src=""]) ~ .kc-portrait-fallback { display: none; }

.kc-dialog-portrait-emoji {
  font-size: 6rem;
  filter: drop-shadow(0 4px 20px rgba(0,0,0,0.5));
  margin-bottom: 40px;
}
.kc-portrait-fallback {
  z-index: 1;
}

/* ─── Dialog Panel — BOTTOM RIGHT, dark translucent ─── */
.kc-dialog-panel {
  position: absolute;
  right: 2%;
  bottom: 3%;
  width: min(520px, 52%);
  max-height: 85vh;
  background: rgba(8, 6, 4, 0.92);
  border: 1px solid rgba(212, 165, 69, 0.25);
  border-radius: 6px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7),
              inset 0 1px 0 rgba(212,165,69,0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 3;
  transform: translateY(20px);
  opacity: 0;
  transition: transform 0.4s ease-out 0.15s, opacity 0.4s ease-out 0.15s;
}
.kc-dialog-panel.active {
  transform: translateY(0);
  opacity: 1;
}

/* ─── Header: NPC name + role + close ─── */
.kc-dialog-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(180deg, rgba(212,165,69,0.12) 0%, rgba(212,165,69,0.03) 100%);
  border-bottom: 1px solid rgba(212,165,69,0.2);
}
.kc-dialog-npc-name {
  color: #d4a545;
  font-family: 'Cinzel', serif;
  font-size: 1.1rem;
  font-weight: bold;
  flex: 1;
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.kc-dialog-npc-role {
  color: rgba(200,180,140,0.6);
  font-size: 0.75rem;
  font-family: 'Cinzel', serif;
  letter-spacing: 0.05em;
}
.kc-dialog-close {
  background: none;
  border: 1px solid rgba(200,180,140,0.15);
  color: rgba(200,180,140,0.5);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 3px;
  transition: all 0.2s;
  font-family: 'Cinzel', serif;
}
.kc-dialog-close:hover {
  color: #d4a545;
  border-color: rgba(212,165,69,0.4);
  background: rgba(212,165,69,0.08);
}

/* ─── NPC Text Area (typewriter, scrollable) ─── */
.kc-dialog-text-area {
  padding: 18px 20px;
  color: #e8dcc8;
  font-size: 1.1rem;
  line-height: 1.7;
  min-height: 60px;
  max-height: 35vh;
  overflow-y: auto;
  border-bottom: 1px solid rgba(212,165,69,0.1);
  cursor: pointer;
  white-space: pre-line;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: rgba(212,165,69,0.15) transparent;
}
.kc-dialog-text-area::-webkit-scrollbar { width: 4px; }
.kc-dialog-text-area::-webkit-scrollbar-track { background: transparent; }
.kc-dialog-text-area::-webkit-scrollbar-thumb { background: rgba(212,165,69,0.2); border-radius: 3px; }
.kc-dialog-text-content {
  font-family: 'Crimson Text', serif;
  font-size: 1.15rem;
}

/* Legacy greeting (for fallback) */
.kc-dialog-greeting {
  padding: 14px 16px;
  color: #e8dcc8;
  font-style: italic;
  font-size: 0.95rem;
  line-height: 1.5;
  border-bottom: 1px solid rgba(212,165,69,0.1);
}

/* ─── Dialogue Options (player choices) ─── */
.kc-dialog-options {
  padding: 8px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  flex: 1;
  max-height: 45vh;
  scrollbar-width: thin;
  scrollbar-color: rgba(212,165,69,0.15) transparent;
}
.kc-dialog-options::-webkit-scrollbar { width: 4px; }
.kc-dialog-options::-webkit-scrollbar-track { background: transparent; }
.kc-dialog-options::-webkit-scrollbar-thumb { background: rgba(212,165,69,0.2); border-radius: 3px; }

.kc-dialog-option {
  display: flex;
  flex-direction: column;
  padding: 9px 14px;
  background: rgba(212,165,69,0.03);
  border: 1px solid rgba(212,165,69,0.1);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  position: relative;
  overflow: hidden;
}
.kc-dialog-option::before {
  content: '\25B8';
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  color: #d4a545;
  font-size: 0.85rem;
  transition: left 0.2s ease;
  opacity: 0;
}
.kc-dialog-option:hover:not(.kc-disabled)::before {
  left: 4px;
  opacity: 1;
}
.kc-dialog-option:hover:not(.kc-disabled) {
  background: rgba(212,165,69,0.08);
  border-color: rgba(212,165,69,0.3);
  padding-left: 20px;
}
.kc-dialog-option:active:not(.kc-disabled) {
  transform: scale(0.99);
  background: rgba(212,165,69,0.12);
}
.kc-dialog-option.kc-disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Option labels */
.kc-opt-label {
  color: #d4a545;
  font-weight: bold;
  font-size: 0.88rem;
  font-family: 'Crimson Text', serif;
}
.kc-opt-desc {
  color: rgba(200,180,140,0.55);
  font-size: 0.76rem;
  margin-top: 3px;
}
.kc-opt-locked {
  color: #b55555;
  font-weight: normal;
  font-size: 0.76rem;
}

/* Back button */
.kc-dialog-option.kc-opt-back {
  background: rgba(200,180,140,0.02);
  border-color: rgba(200,180,140,0.08);
  margin-top: 4px;
}
.kc-dialog-option.kc-opt-back .kc-opt-label {
  color: rgba(200,180,140,0.55);
  font-weight: normal;
}
.kc-dialog-option.kc-opt-back:hover {
  background: rgba(200,180,140,0.06);
  border-color: rgba(200,180,140,0.15);
}
.kc-dialog-option.kc-opt-back:hover .kc-opt-label { color: #c8b48c; }

/* Farewell button */
.kc-dialog-option.kc-opt-farewell {
  background: rgba(140,100,60,0.05);
  border-color: rgba(140,100,60,0.15);
  margin-top: 4px;
}
.kc-dialog-option.kc-opt-farewell .kc-opt-label {
  color: rgba(200,180,140,0.6);
  font-weight: normal;
  font-style: italic;
}
.kc-dialog-option.kc-opt-farewell:hover {
  background: rgba(140,100,60,0.1);
  border-color: rgba(140,100,60,0.25);
}

/* Cooldown badge */
.kc-dialog-cooldown {
  color: #d4a545;
  font-size: 0.72rem;
  margin-left: 6px;
}

/* ─── Legacy action list (for NPCs without trees) ─── */
.kc-dialog-actions {
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  flex: 1;
  max-height: 50vh;
}
.kc-dialog-action {
  display: flex;
  flex-direction: column;
  padding: 9px 14px;
  background: rgba(212,165,69,0.03);
  border: 1px solid rgba(212,165,69,0.1);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
  text-align: left;
}
.kc-dialog-action:hover:not(.kc-disabled) {
  background: rgba(212,165,69,0.1);
  border-color: rgba(212,165,69,0.3);
  transform: translateX(3px);
}
.kc-dialog-action.kc-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.kc-dialog-act-label {
  color: #d4a545;
  font-weight: bold;
  font-size: 0.88rem;
}
.kc-dialog-act-desc {
  color: rgba(200,180,140,0.5);
  font-size: 0.76rem;
  margin-top: 2px;
}

/* ─── Result toast (inline) ─── */
.kc-dialog-result {
  padding: 0 14px 10px;
  display: none;
}
.kc-dialog-result[style*="display: block"] .kc-npc-result {
  animation: kcFadeIn 0.3s ease-out;
}
.kc-npc-result {
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-line;
}
.kc-result-ok {
  background: rgba(30,60,30,0.7);
  border: 1px solid rgba(76,175,80,0.25);
  color: #8BC34A;
}
.kc-result-fail {
  background: rgba(60,25,25,0.7);
  border: 1px solid rgba(200,80,80,0.25);
  color: #e57373;
}

/* ─── Dialog Responsive ─── */
@media (max-width: 800px) {
  .kc-dialog-portrait {
    width: 38%;
    height: 80%;
  }
  .kc-dialog-panel {
    width: min(420px, 56%);
  }
}
@media (max-width: 600px) {
  .kc-dialog-portrait {
    width: 45%;
    height: 55%;
    left: -2%;
  }
  .kc-dialog-panel {
    right: 2%;
    bottom: 2%;
    width: 52%;
    max-height: 70vh;
  }
  .kc-dialog-portrait-emoji { font-size: 3.5rem; }
}
@media (max-width: 480px) {
  .kc-dialog-portrait {
    width: 40%;
    height: 45%;
    left: 0;
  }
  .kc-dialog-panel {
    right: 1%;
    left: 1%;
    bottom: 1%;
    width: auto;
    max-height: 50vh;
  }
  .kc-dialog-portrait-emoji { font-size: 2.5rem; }
}

/* ═══════════════ TOAST NOTIFICATIONS ═══════════════ */
.kc-toast {
  position: absolute;
  top: 120px;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 28px;
  border-radius: 10px;
  font-size: 1.15rem;
  font-weight: 600;
  z-index: 99999;
  pointer-events: none;
  white-space: nowrap;
  animation: kcToastIn 0.4s ease-out;
  box-shadow: 0 6px 24px rgba(0,0,0,0.6);
}

@keyframes kcToastIn {
  from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.kc-toast-out {
  animation: kcToastOut 0.5s ease-in forwards;
}

@keyframes kcToastOut {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

.kc-toast-ok {
  background: rgba(30, 70, 30, 0.95);
  color: #8BC34A;
  border: 1px solid rgba(76, 175, 80, 0.4);
}

.kc-toast-warn {
  background: rgba(80, 50, 10, 0.95);
  color: #FFB74D;
  border: 1px solid rgba(255, 152, 0, 0.4);
}

.kc-toast-icon {
  margin-right: 6px;
}

/* ═══════════════ ANIMATIONS ═══════════════ */
@keyframes kcFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ─── Utility ─── */
.kc-hidden {
  display: none !important;
}

/* ═══════════════ MOBILE RESPONSIVE ═══════════════ */
@media (max-width: 768px) {
  #kc-hud {
    padding: 8px 10px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .kc-res-item {
    padding: 2px 5px;
    font-size: 0.7rem;
    gap: 2px;
  }
  .kc-res-icon { font-size: 0.75rem; }
  .kc-res-icon-img { width: 17px; height: 17px; }
  #kc-resource-bar { gap: 4px; }
  .kc-collect-btn { font-size: 0.65rem; padding: 3px 10px; }
  .kc-res-pending { font-size: 0.6rem; }
  .kc-title-text { font-size: 0.75rem; padding: 3px 8px; }

  .kc-tab {
    font-size: 0.7rem;
    padding: 8px 4px;
  }

  #kc-tab-content {
    padding: 10px;
  }

  .kc-building-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
  }

}

@media (max-width: 480px) {
  #kc-back-btn {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }
  #kc-hud {
    padding: 6px 8px;
  }
  .kc-res-item {
    padding: 2px 4px;
    font-size: 0.65rem;
  }
  .kc-res-icon-img { width: 14px; height: 14px; }
  .kc-tab {
    font-size: 0.6rem;
    padding: 6px 2px;
  }

  .kc-building-grid {
    grid-template-columns: 1fr;
  }

  /* Dialog handled in dialog section responsive */

  .kc-event-active {
    padding: 14px;
  }
  .kc-event-title {
    font-size: 1.05rem;
  }
  .kc-toast {
    font-size: 1rem;
    padding: 10px 20px;
    max-width: 90vw;
    white-space: normal;
  }
}


/* ═══════════════════════════════════════════════════════════════════
   NPC CHALLENGE POPUP  (.ncc-*)
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Overlay ─── */
.ncc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  z-index: 10001;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
  transition: background 0.4s ease;
}
.ncc-overlay.active {
  background: rgba(0, 0, 0, 0.65);
  pointer-events: auto;
}
.ncc-overlay.ncc-closing {
  background: rgba(0, 0, 0, 0);
  pointer-events: none;
  transition: background 0.35s ease;
}

/* ─── Container ─── */
.ncc-container {
  display: flex;
  align-items: flex-end;
  gap: 0;
  width: 100%;
  max-width: 900px;
  height: 70vh;
  max-height: 600px;
  margin-bottom: 24px;
  padding: 0 16px;
}

/* ─── Panel (left side) ─── */
.ncc-panel {
  flex: 1;
  background: linear-gradient(145deg, rgba(15,12,8,0.98), rgba(25,20,14,0.96));
  border: 1px solid rgba(212,165,69,0.3);
  border-radius: 10px 0 0 10px;
  padding: 24px 28px;
  transform: translateX(-60px);
  opacity: 0;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.4s ease;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 40px rgba(0,0,0,0.7),
              inset 0 1px 0 rgba(212,165,69,0.04);
  position: relative;
}
.ncc-panel::before {
  content: '\u25C8';
  position: absolute;
  top: 8px; left: 12px;
  color: rgba(212,165,69,0.18);
  font-size: 0.7rem;
}
.ncc-panel::after {
  content: '\u25C8';
  position: absolute;
  bottom: 8px; right: 12px;
  color: rgba(212,165,69,0.18);
  font-size: 0.7rem;
}
.ncc-panel.active {
  transform: translateX(0);
  opacity: 1;
}
.ncc-overlay.ncc-closing .ncc-panel {
  transform: translateX(-60px);
  opacity: 0;
}

/* ─── Header ─── */
.ncc-header {
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(255, 215, 0, 0.15);
  padding-bottom: 10px;
}
.ncc-challenger-name {
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: #ffd700;
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.3);
  letter-spacing: 0.03em;
}
.ncc-challenger-role {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.55);
  font-style: italic;
  margin-top: 2px;
}

/* ─── Challenge Text ─── */
.ncc-challenge-text {
  font-size: 1.05rem;
  color: #e0e0e0;
  line-height: 1.6;
  font-style: italic;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  border-left: 3px solid rgba(255, 215, 0, 0.4);
  border-radius: 0 6px 6px 0;
}

/* ─── Game Badge ─── */
.ncc-game-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 215, 0, 0.1);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 20px;
  padding: 6px 16px;
  margin-bottom: 14px;
}
.ncc-game-icon {
  font-size: 1.3rem;
}
.ncc-game-name {
  font-family: 'Cinzel', serif;
  font-size: 0.95rem;
  color: #ffd700;
  font-weight: 600;
}

/* ─── Stakes ─── */
.ncc-stakes {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  font-size: 0.82rem;
  flex-wrap: wrap;
}
.ncc-stakes-win {
  color: #d4a545;
  background: rgba(212,165,69,0.08);
  padding: 6px 14px;
  border-radius: 4px;
  border: 1px solid rgba(212,165,69,0.2);
  font-family: 'Cinzel', serif;
  font-weight: 600;
}
.ncc-stakes-lose {
  color: #ef5350;
  background: rgba(239,83,80,0.08);
  padding: 6px 14px;
  border-radius: 4px;
  border: 1px solid rgba(239,83,80,0.2);
  font-family: 'Cinzel', serif;
  font-weight: 600;
}

/* ─── Buttons ─── */
.ncc-buttons {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}
.ncc-accept-btn {
  flex: 1;
  padding: 14px 24px;
  font-family: 'Cinzel', serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1a1408;
  background: linear-gradient(135deg, #8b6914 0%, #b8860b 30%, #d4a545 70%, #ffd700 100%);
  border: 1px solid rgba(255,215,0,0.5);
  border-radius: 6px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: all 0.2s;
  box-shadow: 0 4px 20px rgba(212,165,69,0.4);
  text-shadow: 0 1px 0 rgba(255,255,255,0.2);
  animation: ncc-accept-pulse 2s ease-in-out infinite;
}
@keyframes ncc-accept-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(212,165,69,0.4); }
  50% { box-shadow: 0 4px 30px rgba(212,165,69,0.6), 0 0 40px rgba(212,165,69,0.12); }
}
.ncc-accept-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(212,165,69,0.6);
  background: linear-gradient(135deg, #a07a18 0%, #d4a545 30%, #ffd700 70%, #ffe44d 100%);
}
.ncc-accept-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(212,165,69,0.3);
}
.ncc-decline-btn {
  padding: 12px 20px;
  font-family: 'Crimson Text', serif;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.ncc-decline-btn:hover {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
}

/* ─── Result / Mockery ─── */
.ncc-result {
  margin-top: 14px;
}
.ncc-mockery {
  font-size: 1rem;
  color: #ef5350;
  font-style: italic;
  line-height: 1.5;
  padding: 12px 16px;
  background: rgba(239, 83, 80, 0.08);
  border-left: 3px solid rgba(239, 83, 80, 0.5);
  border-radius: 0 6px 6px 0;
  animation: ncc-fade-in 0.4s ease;
}

/* ─── Portrait (right side, dialog-style — large, no frame) ─── */
.ncc-portrait {
  width: 38%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex-shrink: 0;
  transform: translateX(40px);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.1s,
              opacity 0.45s ease 0.1s;
  position: relative;
  pointer-events: none;
}
.ncc-portrait.active {
  transform: translateX(0);
  opacity: 1;
}
.ncc-overlay.ncc-closing .ncc-portrait {
  transform: translateX(40px);
  opacity: 0;
}
.ncc-portrait-img {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(4px 4px 24px rgba(0,0,0,0.7));
}
.ncc-portrait-emoji {
  font-size: 6rem;
  filter: drop-shadow(0 4px 20px rgba(0,0,0,0.5));
  margin-bottom: 40px;
}
.ncc-portrait-name {
  display: none;
}

/* ─── Animations ─── */
@keyframes ncc-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes ncc-portrait-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
/* Portrait loading shimmer */
.ncc-portrait-loading .ncc-portrait-img {
  opacity: 0;
}
@keyframes ncc-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}


/* ═══════════════════════════════════════════════════════════════════
   POST-CHALLENGE RESULT POPUP
   ═══════════════════════════════════════════════════════════════════ */

.ncc-post-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  z-index: 10002;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: background 0.4s ease;
}
.ncc-post-overlay.active {
  background: rgba(0, 0, 0, 0.7);
  pointer-events: auto;
}
.ncc-post-overlay.ncc-closing {
  background: rgba(0, 0, 0, 0);
  pointer-events: none;
}

.ncc-post-card {
  background: linear-gradient(145deg, rgba(15,12,8,0.98), rgba(25,20,14,0.96));
  border-radius: 14px;
  padding: 32px 36px;
  text-align: center;
  min-width: 300px;
  max-width: 420px;
  transform: scale(0.8);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.4s ease;
  box-shadow: 0 12px 48px rgba(0,0,0,0.7);
  border: 1px solid rgba(212,165,69,0.2);
  backdrop-filter: blur(12px);
}
.ncc-post-overlay.active .ncc-post-card {
  transform: scale(1);
  opacity: 1;
}
.ncc-post-overlay.ncc-closing .ncc-post-card {
  transform: scale(0.8);
  opacity: 0;
}

/* Win / Lose / Draw borders */
.ncc-post-win {
  border-color: rgba(212,165,69,0.5);
  box-shadow: 0 12px 48px rgba(0,0,0,0.7), 0 0 40px rgba(212,165,69,0.15);
}
.ncc-post-lose {
  border-color: rgba(239,83,80,0.5);
  box-shadow: 0 12px 48px rgba(0,0,0,0.7), 0 0 30px rgba(239,83,80,0.1);
}
.ncc-post-draw {
  border-color: rgba(212,165,69,0.4);
  box-shadow: 0 12px 48px rgba(0,0,0,0.7), 0 0 30px rgba(212,165,69,0.1);
}

.ncc-post-portrait {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 2.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  position: relative;
}
.ncc-post-portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}
.ncc-post-title {
  font-family: 'Cinzel', serif;
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: 0.05em;
}
.ncc-post-win .ncc-post-title {
  color: #d4a545;
  text-shadow: 0 0 20px rgba(212,165,69,0.5);
  animation: ncc-victory-flash 0.6s ease-out;
}
.ncc-post-lose .ncc-post-title { color: #ef5350; text-shadow: 0 0 14px rgba(239,83,80,0.4); }
.ncc-post-draw .ncc-post-title { color: #d4a545; text-shadow: 0 0 14px rgba(212,165,69,0.4); }
@keyframes ncc-victory-flash {
  0% { opacity: 0; transform: scale(1.5); }
  50% { opacity: 1; transform: scale(1.1); }
  100% { transform: scale(1); }
}

.ncc-post-name {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 14px;
}
.ncc-post-text {
  font-size: 1rem;
  color: #e0e0e0;
  font-style: italic;
  line-height: 1.5;
  margin-bottom: 18px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
}
.ncc-post-rewards {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 20px;
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  font-weight: 600;
}
.ncc-post-gold.positive { color: #ffd700; }
.ncc-post-gold.negative { color: #ef5350; }
.ncc-post-fame.positive { color: #ce93d8; }
.ncc-post-fame.negative { color: #ef5350; }

.ncc-post-close {
  padding: 10px 32px;
  font-family: 'Cinzel', serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.ncc-post-close:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}


/* ─── NCC Mobile Responsive ─── */
@media (max-width: 700px) {
  .ncc-container {
    flex-direction: column-reverse;
    align-items: center;
    gap: 0;
    margin-bottom: 12px;
    padding: 0 8px;
  }
  .ncc-panel {
    border-radius: 0 0 12px 12px;
    padding: 18px 20px;
    transform: translateY(40px);
    width: 100%;
  }
  .ncc-panel.active {
    transform: translateY(0);
  }
  .ncc-overlay.ncc-closing .ncc-panel {
    transform: translateY(40px);
  }
  .ncc-portrait {
    width: 100%;
    height: 200px;
    transform: translateY(-30px);
  }
  .ncc-portrait.active {
    transform: translateY(0);
  }
  .ncc-overlay.ncc-closing .ncc-portrait {
    transform: translateY(-30px);
  }
  .ncc-portrait-img {
    max-height: 200px;
  }
  .ncc-portrait-emoji {
    font-size: 4rem;
    margin-bottom: 10px;
  }
  .ncc-buttons {
    flex-direction: column;
    gap: 8px;
  }
  .ncc-stakes {
    flex-direction: column;
    gap: 6px;
  }
  .ncc-post-card {
    min-width: 0;
    width: 90vw;
    padding: 24px 20px;
  }
}

/* ═══════════════ CINEMATIC TRANSITION ═══════════════ */
.kc-cinematic-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  z-index: 99999;
  pointer-events: none;
  transition: opacity 0.4s ease-in;
}
.kc-cinematic-overlay.active {
  opacity: 1;
}
.kc-cinematic-overlay.fading-out {
  opacity: 0;
  transition: opacity 0.5s ease-out;
}

/* ═══════════════ EVENT TOAST NOTIFICATION ═══════════════ */
.kc-event-toast {
  position: absolute;
  top: 120px;
  left: 50%;
  transform: translateX(-50%) translateY(-30px);
  z-index: 100001;
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, rgba(20, 15, 8, 0.95), rgba(40, 30, 15, 0.95));
  border: 1px solid rgba(212, 165, 69, 0.5);
  border-left: 4px solid #d4a545;
  border-radius: 10px;
  padding: 14px 20px;
  min-width: 380px;
  max-width: 520px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7), 0 0 20px rgba(212,165,69,0.15);
  opacity: 0;
  transition: all 0.4s ease-out;
  pointer-events: auto;
}
.kc-event-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.kc-event-toast-icon {
  font-size: 2rem;
  flex-shrink: 0;
}
.kc-event-toast-body {
  flex: 1;
  min-width: 0;
}
.kc-event-toast-title {
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  font-weight: 700;
  color: #d4a545;
  margin-bottom: 3px;
  letter-spacing: 0.5px;
}
.kc-event-toast-desc {
  font-family: 'Crimson Text', serif;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.75);
  line-height: 1.3;
}
.kc-event-toast-btn {
  flex-shrink: 0;
  background: rgba(212, 165, 69, 0.15);
  border: 1px solid rgba(212, 165, 69, 0.4);
  color: #d4a545;
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.kc-event-toast-btn:hover {
  background: rgba(212, 165, 69, 0.3);
  border-color: #d4a545;
}

/* ═══════════════════════════════════════════════════
   TAVERN GAMES PANEL
   ═══════════════════════════════════════════════════ */

.kc-tavern-panel {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0);
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}
.kc-tavern-panel.active {
  background: rgba(0,0,0,0.85);
  opacity: 1;
  pointer-events: all;
}

.kc-tavern-inner {
  width: 700px;
  max-width: 95vw;
  max-height: 85vh;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(22,15,8,0.97), rgba(12,8,3,0.98));
  border: 2px solid;
  border-image: linear-gradient(180deg, #5a4012, #d4a545, #5a4012) 1;
  padding: 30px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8), 0 0 60px rgba(212,165,69,0.1);
  animation: quizIn 0.3s ease;
}

.kc-tavern-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(212,165,69,0.3);
}
.kc-tavern-header h2 {
  font-family: 'Cinzel', serif;
  font-size: 1.6rem;
  color: #d4a545;
  margin: 0;
  text-shadow: 0 0 10px rgba(212,165,69,0.3);
}
.kc-tavern-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(212,165,69,0.3);
  background: rgba(0,0,0,0.4);
  color: #d4a545;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
}
.kc-tavern-close:hover {
  border-color: #d4a545;
  background: rgba(212,165,69,0.15);
}

.kc-tavern-body {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.kc-tavern-games h3,
.kc-tavern-patrons h3 {
  font-family: 'Cinzel', serif;
  font-size: 1.1rem;
  color: #c9a44a;
  margin: 0 0 14px 0;
  letter-spacing: 1px;
}

/* Game list */
.kc-tavern-game-list {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.kc-tavern-game-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  flex: 1;
  min-width: 220px;
  border-radius: 6px;
  border: 1px solid rgba(100,75,35,0.5);
  background: rgba(0,0,0,0.35);
  color: #e8d5b5;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}
.kc-tavern-game-btn:hover {
  border-color: #d4a545;
  background: rgba(212,165,69,0.12);
  box-shadow: 0 0 12px rgba(212,165,69,0.2);
  transform: translateY(-2px);
}
.kc-tavern-game-icon {
  font-size: 2rem;
  flex-shrink: 0;
}
.kc-tavern-game-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kc-tavern-game-name {
  font-family: 'Cinzel', serif;
  font-size: 1.1rem;
  color: #d4a545;
}
.kc-tavern-game-desc {
  font-family: 'Crimson Text', serif;
  font-size: 0.9rem;
  color: rgba(200,180,150,0.7);
}

/* Tavern NPCs / Patrons */
.kc-tavern-npc-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.kc-tavern-npc-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 4px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(60,45,20,0.4);
}
.kc-tavern-npc-portrait {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.kc-tavern-npc-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.kc-tavern-npc-name {
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  color: #d4a545;
}
.kc-tavern-npc-role {
  font-size: 0.7rem;
  color: rgba(200,180,150,0.6);
  font-family: 'Crimson Text', serif;
}
.kc-tavern-npc-quote {
  font-size: 0.75rem;
  color: rgba(200,180,150,0.8);
  font-style: italic;
  font-family: 'Crimson Text', serif;
  line-height: 1.3;
}

/* Tavern picker icon (on map) */
.kc-tavern-games-icon {
  font-size: 1.8rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Mobile */
@media (max-width: 600px) {
  .kc-tavern-inner { padding: 18px; }
  .kc-tavern-game-list { flex-direction: column; }
  .kc-tavern-npc-list { grid-template-columns: 1fr; }
  .kc-tavern-header h2 { font-size: 1.2rem; }
}

/* ═══════════════════════════════════════════════
   PRESTIGE SYSTEM
   ═══════════════════════════════════════════════ */

/* Prestige info badge (shown when prestigeLevel > 0) */
.kc-prestige-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, rgba(255,215,0,0.15), rgba(255,140,0,0.10));
  border: 1px solid rgba(255,215,0,0.35);
  border-radius: 6px;
  font-family: 'Cinzel', serif;
  font-size: 0.95rem;
  color: #ffd700;
}
.kc-prestige-star {
  font-size: 1.3rem;
}
.kc-prestige-bonus {
  margin-left: auto;
  font-size: 0.85rem;
  color: #8BC34A;
  font-weight: bold;
}

/* Prestige available banner */
.kc-prestige-available {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, rgba(255,215,0,0.12), rgba(180,130,0,0.08));
  border: 2px solid rgba(255,215,0,0.5);
  border-radius: 8px;
  animation: kc-prestige-glow 2s ease-in-out infinite alternate;
}
.kc-prestige-available-text {
  flex: 1;
  font-size: 0.9rem;
  color: #e0c880;
  line-height: 1.4;
}

@keyframes kc-prestige-glow {
  0%   { box-shadow: 0 0 8px rgba(255,215,0,0.2); }
  100% { box-shadow: 0 0 20px rgba(255,215,0,0.4); }
}

/* Prestige button */
.kc-prestige-btn {
  flex-shrink: 0;
  padding: 10px 22px;
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  font-weight: bold;
  color: #1a1a0e;
  background: linear-gradient(180deg, #ffd700 0%, #e6a800 50%, #cc8800 100%);
  border: 2px solid #b8860b;
  border-radius: 6px;
  cursor: pointer;
  text-shadow: 0 1px 0 rgba(255,255,255,0.3);
  box-shadow: 0 2px 8px rgba(255,215,0,0.3), inset 0 1px 0 rgba(255,255,255,0.25);
  transition: transform 0.15s, box-shadow 0.15s;
}
.kc-prestige-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(255,215,0,0.5), inset 0 1px 0 rgba(255,255,255,0.25);
}

/* Prestige confirmation overlay */
.kc-prestige-confirm {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  opacity: 0;
  transition: opacity 0.3s;
}
.kc-prestige-confirm.visible {
  opacity: 1;
}
.kc-prestige-confirm-inner {
  background: linear-gradient(180deg, #2a1f12 0%, #1a1408 100%);
  border: 2px solid #d4a545;
  border-radius: 10px;
  padding: 28px 32px;
  max-width: 440px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
.kc-prestige-confirm-inner h3 {
  font-family: 'Cinzel', serif;
  font-size: 1.3rem;
  color: #ffd700;
  margin: 0 0 14px;
}
.kc-prestige-confirm-inner p {
  font-size: 0.9rem;
  color: #c8b88a;
  margin: 8px 0;
  line-height: 1.4;
}
.kc-prestige-confirm-inner strong {
  color: #ffd700;
}
.kc-prestige-confirm-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}
.kc-prestige-confirm-yes {
  background: linear-gradient(180deg, #ffd700 0%, #cc8800 100%) !important;
  color: #1a1a0e !important;
  border-color: #b8860b !important;
  font-weight: bold;
}
.kc-prestige-confirm-no {
  background: rgba(80,60,40,0.6) !important;
  color: #c8b88a !important;
  border-color: #665533 !important;
}

@media (max-width: 600px) {
  .kc-prestige-available { flex-direction: column; text-align: center; }
  .kc-prestige-confirm-inner { padding: 20px; }
}

/* ═══════════════════════════════════════════════
   MAIL / INBOX
   ═══════════════════════════════════════════════ */

/* Badge on Mail tab */
.kc-mail-badge {
  display: inline-block;
  background: #cc3333;
  color: #fff;
  font-size: 0.6rem;
  font-weight: bold;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 8px;
  padding: 0 4px;
  margin-left: 6px;
  vertical-align: middle;
  animation: kcMailPulse 2s ease-in-out infinite;
}

@keyframes kcMailPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Container */
.kc-mail-container {
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
}

.kc-mail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.kc-mail-readall {
  background: transparent;
  border: 1px solid rgba(212,165,69,0.4);
  color: #d4a545;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}
.kc-mail-readall:hover {
  background: rgba(212,165,69,0.15);
  border-color: #d4a545;
}

.kc-mail-empty {
  color: #706050;
  text-align: center;
  padding: 40px 0;
  font-style: italic;
  font-size: 0.9rem;
}

/* Message list */
.kc-mail-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kc-mail-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(40,30,20,0.6);
  border: 1px solid rgba(212,165,69,0.2);
  border-left: 3px solid #d4a545;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.kc-mail-item:hover {
  background: rgba(60,45,30,0.7);
  border-color: rgba(212,165,69,0.4);
}
.kc-mail-item--read {
  opacity: 0.6;
  border-left-color: #504030;
}
.kc-mail-item--read:hover {
  opacity: 0.8;
}

.kc-mail-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.kc-mail-body {
  flex: 1;
  min-width: 0;
}

.kc-mail-title {
  color: #e0d0b0;
  font-size: 0.85rem;
  font-weight: bold;
  margin-bottom: 2px;
}
.kc-mail-item--read .kc-mail-title {
  font-weight: normal;
}

.kc-mail-text {
  color: #a09080;
  font-size: 0.75rem;
  line-height: 1.3;
  margin-bottom: 4px;
}

.kc-mail-time {
  color: #605040;
  font-size: 0.65rem;
}

/* Claim button */
.kc-mail-claim {
  display: inline-block;
  background: linear-gradient(135deg, #d4a545, #b8942e);
  border: none;
  border-radius: 4px;
  color: #1a1208;
  font-size: 0.7rem;
  font-weight: bold;
  padding: 3px 10px;
  cursor: pointer;
  margin-right: 8px;
  transition: filter 0.15s;
}
.kc-mail-claim:hover { filter: brightness(1.15); }

.kc-mail-claimed {
  color: #66bb6a;
  font-size: 0.7rem;
  margin-right: 8px;
}

/* Delete button */
.kc-mail-delete {
  background: transparent;
  border: none;
  color: #605040;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s;
}
.kc-mail-delete:hover { color: #cc4444; }

/* Responsive */
@media (max-width: 600px) {
  .kc-mail-container { padding: 10px; }
  .kc-mail-item { padding: 8px 10px; gap: 8px; }
  .kc-mail-title { font-size: 0.8rem; }
  .kc-mail-text { font-size: 0.7rem; }
}


/* ═══════════════════════════════════════════════
   KINGDOM CHAT — floating panel bottom-left
   ═══════════════════════════════════════════════ */

/* Floating panel — on document.body, above kc-wrapper zoom */
.kc-chat-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 290px;
  z-index: 10001;
  font-family: 'Crimson Text', serif;
}

/* Resize handle — top-right corner */
.kc-chat-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  z-index: 10;
}
.kc-chat-resize-handle::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 8px;
  height: 8px;
  border-top: 2px solid #5a3e20;
  border-right: 2px solid #5a3e20;
}

/* Header: tabs + toggle */
.kc-chat-header {
  display: flex;
  align-items: stretch;
  background: linear-gradient(180deg, #2e1f0e 0%, #1a1005 100%);
  border: 1px solid #5a3e20;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
}
.kc-chat-header-tabs {
  display: flex;
  flex: 1;
}
.kc-chat-tab {
  flex: 1;
  background: transparent;
  border: none;
  border-right: 1px solid #3a2510;
  color: #806040;
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  padding: 5px 10px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.kc-chat-tab:last-child { border-right: none; }
.kc-chat-tab:hover:not(:disabled) { color: #d4a545; background: rgba(255,200,80,0.06); }
.kc-chat-tab.active { color: #d4a545; background: rgba(255,200,80,0.1); }
.kc-chat-tab:disabled { opacity: 0.4; cursor: not-allowed; }

.kc-chat-toggle {
  background: transparent;
  border: none;
  border-left: 1px solid #3a2510;
  color: #806040;
  font-size: 0.7rem;
  padding: 5px 10px;
  cursor: pointer;
  transition: color 0.15s;
}
.kc-chat-toggle:hover { color: #d4a545; }

/* Body */
.kc-chat-body {
  display: flex;
  flex-direction: column;
  background: rgba(10, 6, 2, 0.88);
  border: 1px solid #5a3e20;
  border-top: 1px solid #3a2510;
}
.kc-chat-body--hidden { display: none; }

/* Messages list */
.kc-chat-messages {
  height: 200px;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scroll-behavior: smooth;
}
.kc-chat-messages::-webkit-scrollbar { width: 4px; }
.kc-chat-messages::-webkit-scrollbar-thumb { background: #4a2e10; border-radius: 4px; }

/* Single message */
.kc-chat-msg {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  animation: kcChatFadeIn 0.15s ease-out;
}
.kc-chat-msg--me .kc-chat-bubble { background: rgba(70, 45, 10, 0.6); border-color: #6a4520; }
@keyframes kcChatFadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Avatar */
.kc-chat-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid #4a3018;
  flex-shrink: 0;
  object-fit: cover;
}
.kc-chat-avatar--placeholder {
  background: linear-gradient(135deg, #2a1a08, #120a02);
}

/* Bubble */
.kc-chat-bubble {
  background: rgba(20, 12, 4, 0.7);
  border: 1px solid #2e1e0a;
  border-radius: 4px;
  padding: 3px 7px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-width: calc(100% - 34px);
  word-break: break-word;
}
.kc-chat-name {
  font-family: 'Cinzel', serif;
  font-size: 0.58rem;
  color: #c89830;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.kc-chat-text { font-size: 0.78rem; color: #b8a888; line-height: 1.35; }
.kc-chat-time { font-size: 0.55rem; color: #504030; align-self: flex-end; }

/* Input row */
.kc-chat-input-row {
  display: flex;
  border-top: 1px solid #2e1e0a;
}
.kc-chat-input {
  flex: 1;
  background: rgba(15, 9, 3, 0.9);
  border: none;
  color: #c8b898;
  font-size: 0.8rem;
  padding: 6px 10px;
  outline: none;
  font-family: 'Crimson Text', serif;
}
.kc-chat-input::placeholder { color: #3a2810; }
.kc-chat-send {
  background: linear-gradient(180deg, #9a7420 0%, #6a4e10 100%);
  border: none;
  border-left: 1px solid #5a3e18;
  color: #f0d878;
  font-family: 'Cinzel', serif;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 6px 12px;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: filter 0.15s;
}
.kc-chat-send:hover { filter: brightness(1.2); }

/* Responsive */
@media (max-width: 600px) {
  .kc-chat-panel { width: 260px; }
  .kc-chat-messages { height: 160px; }
}
