/* ============================================================
   🍻 KANSALLINEN BAARIPELILIIGA - PERUSTYYLIT & PUBITEEMA
   ============================================================ */

/* 1. YLEISRAKENNE & PERUSTAUSTA (VAHVA & NÄKYVÄ PUBITEKSTUURI) */
html { 
  scroll-behavior: smooth; 
}

body,
body[data-theme],
body[data-theme="general"] { 
  font-family: 'Inter', system-ui, -apple-system, sans-serif; 
  background-color: #0e0805 !important; 
  background-image: 
    radial-gradient(circle at 50% 30%, rgba(65, 43, 29, 0.75) 0%, rgba(14, 8, 5, 0.98) 100%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.07) 0, rgba(255, 255, 255, 0.07) 2px, transparent 0, transparent 8px),
    repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.4) 0, rgba(0, 0, 0, 0.4) 2px, transparent 0, transparent 8px) !important;
  background-size: 100% 100%, 16px 16px, 16px 16px !important;
  background-attachment: fixed !important;
  margin: 0; 
  padding: 20px 10px; 
  color: #382a21; 
  transition: background 0.3s ease; 
}

h1, h2, h3, h4, h5, h6, .nav-tab, .btn-submit, th, .div-header, .avatar-fallback, .tag-verified, .fab-scroll-top, .toc a { 
  font-family: 'Oswald', sans-serif; 
}

/* 2. SOVELLUSSÄILIÖ (APP CONTAINER) - SYVEMPI LÄMPIMÄMPI PERGAMENTTI */
.app-container,
.app-container[data-theme="general"] { 
  background: #f5ebd9 linear-gradient(180deg, #f7eee0 0%, #e8dac5 100%) !important; 
  width: 100%; 
  max-width: 520px; 
  margin: 0 auto; 
  border-radius: 16px; 
  box-shadow: 
    0 35px 80px rgba(0, 0, 0, 0.9), 
    0 12px 25px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.6) !important; 
  border: 1px solid #bdab95 !important; 
  overflow: hidden; 
  position: relative; 
  transition: background 0.3s ease, border-color 0.3s ease; 
}

#ptr-indicator { 
  text-align: center; 
  padding: 12px; 
  font-size: 13px; 
  font-weight: 700; 
  color: #8c7362; 
  background: #e5d6c3; 
  display: none; 
  text-transform: uppercase; 
  font-family: 'Oswald', sans-serif; 
  letter-spacing: 1px; 
}

/* 3. YLÄPALKKI & LOGO (TÄYSIN YHTENÄISTETTY TAUSTA) */
.sticky-header { 
  position: sticky; 
  top: 0; 
  z-index: 100; 
  background: #f7eee0; 
  border-bottom: 1px solid #d8c8b2; 
  transition: background 0.3s ease; 
}

.logo-container { 
  text-align: center; 
  padding: 15px; 
  background: transparent !important; 
  border-bottom: 1px solid #d8c8b2; 
  cursor: pointer; 
  transition: background 0.2s; 
}
.logo-container:hover { background: rgba(0, 0, 0, 0.03) !important; }
.logo-container { 
  text-align: center; 
  padding: 4px 10px 0px 10px; 
  background: transparent !important; 
  border-bottom: 1px solid #d8c8b2; 
  cursor: pointer; 
  transition: background 0.2s; 
}

.logo-container img { 
  display: block; 
  margin: 0 auto -22px auto; /* ⚡ Negatiivinen marginaali (-22px) vetää palkin kiinni tekstiin */
  max-width: 100%; 
  height: auto; 
  max-height: 195px; 
  pointer-events: none; 
} 
.nav-tabs { display: flex; flex-wrap: wrap; background: #e8d9c4; transition: background 0.3s ease; }
.nav-tab { flex: 1; padding: 12px 3px; text-align: center; font-size: 11px; font-weight: 700; color: #6b5546; cursor: pointer; border-right: 1px solid #d8c8b2; letter-spacing: 0.5px; display: flex; align-items: center; justify-content: center; gap: 3px; transition: all 0.2s ease; }
.nav-tab:last-child { border-right: none; }
.nav-tab.active { background: #f7eee0; color: #382a21; border-bottom: 3px solid #5c4333; }
.notif-dot { width: 8px; height: 8px; background-color: #d9534f; border-radius: 50%; display: inline-block; }

.tab-content { display: none; padding: 25px 20px; }
.tab-content.active { display: block; }

.spinner { border: 2px solid rgba(255,255,255,0.3); border-top: 2px solid #fff; border-radius: 50%; width: 14px; height: 14px; animation: spin 0.8s linear infinite; display: inline-block; vertical-align: middle; margin-right: 6px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes slideInUp { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }

.feed-card-header-title { font-family: 'Oswald', sans-serif; letter-spacing: 0.5px; }
.clash-icon { display: inline-block; animation: clashAnim 2s ease-in-out infinite; font-size: 15px; margin-right: 4px; transform-origin: center; }

/* 4. SÄÄNNÖT JA TOC */
.rules-text { line-height: 1.7; font-size: 15px; text-align: left; }
.rules-text h2 { color: #382a21; margin-top: 0; font-size: 28px; text-transform: uppercase; letter-spacing: 1px; text-align: center; margin-bottom: 20px;}
.rules-text h3 { color: #5c4333; margin-top: 0; margin-bottom: 15px; border-bottom: 2px solid #eae0d0; padding-bottom: 5px; font-size: 20px; letter-spacing: 0.5px; }
.rules-text h4 { color: #382a21; font-size: 16px; margin-top: 20px; margin-bottom: 8px; font-family: 'Inter', sans-serif; font-weight: 600; }
.rules-text p { margin-bottom: 15px; color: #4a3b30; }
.rules-card { background: #ffffff; border: 1px solid #d8c8b2; border-radius: 12px; padding: 20px; margin-bottom: 20px; box-shadow: 0 2px 8px rgba(90, 70, 50, 0.04); }
.callout-box { background: #fcf5ee; border-left: 3px solid #8c7362; padding: 8px 12px; margin: 10px 0 14px 0; border-radius: 0 6px 6px 0; font-size: 13px; line-height: 1.5; color: #382a21; display: flex; gap: 8px; align-items: flex-start; }
.callout-box.warning { background: #fff8f0; border-left-color: #c87a28; }
.callout-icon { font-size: 16px; line-height: 1.2; flex-shrink: 0; }
.callout-content { flex-grow: 1; }
.toc { background: #ffffff; padding: 15px; border-radius: 12px; margin-bottom: 25px; border: 1px solid #eae0d0; }
.toc ul { list-style: none; padding: 0; margin: 0; }
.toc li { margin-bottom: 6px; font-size: 13px; line-height: 1.4; }
.toc ul ul { padding-left: 15px; margin-top: 6px; }
.toc a { font-weight: 700; text-decoration: none; color: #5c4333; border: none; letter-spacing: 0.5px; font-size: 14px; }
.toc a:hover { text-decoration: underline; color: #8c7362; }
.fab-scroll-top { position: fixed; bottom: 25px; right: 25px; background: #8c7362; color: #fcf9f4 !important; padding: 10px 16px; border-radius: 30px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; text-decoration: none !important; border: none !important; box-shadow: 0 4px 12px rgba(92, 67, 51, 0.3); transition: background 0.2s, transform 0.2s; z-index: 999; cursor: pointer; }
.fab-scroll-top:hover { background: #5c4333; transform: translateY(-3px); }

.control-panel { background: #ebdcc9; padding: 12px 16px; border-bottom: 1px solid #d8c8b2; display: flex; flex-direction: column; gap: 8px; }
.control-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.control-row label { font-family: 'Oswald', sans-serif; font-size: 12px; font-weight: 700; color: #5c4333; text-transform: uppercase; }
.control-row input, .control-row select { width: 100%; padding: 8px 10px; border-radius: 8px; font-size: 13px; border: 1px solid #d9ccbb; background: #fffefb; outline: none; }

/* 5. TAULUKOT & RANKING */
table { width: 100%; border-collapse: collapse; text-align: left; }
th { background-color: #5c4333; color: #fdfbf7; padding: 10px 14px; font-size: 13px; text-transform: uppercase; transition: background-color 0.3s; }
td { padding: 10px 14px; font-size: 14px; }

.player-row { cursor: pointer; transition: background 0.1s, transform 0.1s; border-bottom: 1px solid rgba(0,0,0,0.05); } 
.player-row:hover { filter: brightness(0.95); }
.player-row.active-user { border-left: 4px solid #382a21; box-shadow: inset 0 0 10px rgba(0,0,0,0.05); font-weight: 600; filter: brightness(0.95); }

.row-theme-pronssi { background: linear-gradient(90deg, #fdf8f5 0%, #f4e8e1 100%); }
.row-theme-hopea { background: linear-gradient(90deg, #f8fafc 0%, #e2e8f0 100%); }
.row-theme-kulta { background: linear-gradient(90deg, #fffbeb 0%, #fef08a 100%); }
.row-theme-timantti { background: linear-gradient(90deg, #f0f9ff 0%, #bae6fd 100%); }

.sub-pronssi td { background-color: #e6b89c; color: #6a2a0a; border-bottom: 1px solid #d49a7a; }
.sub-hopea td { background-color: #cbd5e1; color: #334155; border-bottom: 1px solid #94a3b8; }
.sub-kulta td { background-color: #fde68a; color: #92400e; border-bottom: 1px solid #fcd34d; }
.sub-timantti td { background-color: #bae6fd; color: #0369a1; border-bottom: 1px solid #7dd3fc; }

.bg-pronssi { background: linear-gradient(135deg, #d97706, #9a3412) !important; }
.bg-hopea { background: linear-gradient(135deg, #94a3b8, #475569) !important; }
.bg-kulta { background: linear-gradient(135deg, #fcd34d, #d97706) !important; }
.bg-timantti { background: linear-gradient(135deg, #38bdf8, #0284c7) !important; }
.bg-pronssi .avatar-fallback, .bg-hopea .avatar-fallback, .bg-kulta .avatar-fallback, .bg-timantti .avatar-fallback { color: #ffffff !important; }

.rank-col { width: 25px; text-align: right; padding-right: 6px; padding-left: 10px; font-weight: 700; color: #5c4333; }
.player-col { padding-left: 4px; }

.you-tag { font-size: 10px; font-weight: 700; color: #fdfbf7; background: #382a21; padding: 2px 5px; border-radius: 4px; margin-left: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.avatar-container { width: 32px; height: 32px; border-radius: 50%; overflow: hidden; background: #e2d4c1; display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.avatar-img { width: 100%; height: 100%; object-fit: cover; }
.avatar-fallback { font-size: 14px; font-weight: 700; color: #5c4333; }

.div-main-header td { font-family: 'Oswald', sans-serif; font-size: 15px; font-weight: 700; text-transform: uppercase; text-align: center; letter-spacing: 2px; padding: 10px; border-bottom: none; text-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.div-sub-header td { font-family: 'Inter', sans-serif; font-size: 11px; font-weight: 700; text-transform: uppercase; text-align: center; letter-spacing: 1px; padding: 4px 10px; border-bottom: none; }

.timantti { background: linear-gradient(90deg, #0284c7, #38bdf8); color: white; }
.kulta { background: linear-gradient(90deg, #d97706, #fcd34d); color: white; }
.hopea { background: linear-gradient(90deg, #475569, #94a3b8); color: white; }
.pronssi { background: linear-gradient(90deg, #9a3412, #d97706); color: white; }

/* 6. KERÄILYKORTIT JA PROFIILIT */
.card { background: #ffffff; width: 100%; max-width: 380px; border-radius: 16px; box-shadow: 0 8px 25px rgba(90,70,50,0.1); border: 2px solid #e8dccb; margin: 0 auto 15px auto; transition: all 0.3s; position: relative; }
.card-header { padding: 22px 18px 18px 18px; text-align: center; border-bottom: 1px solid #eae0d0; position: relative; border-radius: 14px 14px 0 0; }
.card-gear-btn { position: absolute; top: 12px; right: 12px; background: rgba(255,255,255,0.8); border: 1px solid #d9ccbb; border-radius: 50%; width: 30px; height: 30px; cursor: pointer; font-size: 14px;}
.card-share-btn { position: absolute; top: 12px; left: 12px; background: rgba(255,255,255,0.8); border: 1px solid #d9ccbb; border-radius: 50%; width: 30px; height: 30px; cursor: pointer; font-size: 14px;}
.card-avatar-lg { width: 76px; height: 76px; border-radius: 50%; object-fit: cover; border: 3px solid #5c4333; margin: 0 auto 8px auto; box-shadow: 0 4px 10px rgba(0,0,0,0.15); background: #e2d4c1; }
.card-header h2 { margin: 0; font-size: 22px; text-transform: uppercase; }
.player-title-tag { font-size: 12px; font-weight: 600; color: #8c7362; font-style: italic; margin-bottom: 4px; }
.division-tag { font-weight: 700; color: #574614; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }

.promo-status { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 20px; font-size: 10px; font-weight: 700; margin-top: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.promo-status.chance { background: #e6f4ea; color: #1e7e34; border: 1px solid #b7e1cd; }
.promo-status.threat { background: #fce8e6; color: #d9534f; border: 1px solid #f5c6cb; }

.theme-blue { border-color: #93c5fd !important; border-top: 8px solid #2563eb !important; box-shadow: 0 8px 25px rgba(37,99,235,0.2) !important; } 
.theme-blue .card-header { background: linear-gradient(180deg, #eff6ff 0%, #ffffff 100%); }
.theme-green { border-color: #86efac !important; border-top: 8px solid #16a34a !important; box-shadow: 0 8px 25px rgba(22,163,74,0.2) !important; } 
.theme-green .card-header { background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 100%); }
.theme-yellow { border-color: #fde047 !important; border-top: 8px solid #eab308 !important; box-shadow: 0 8px 25px rgba(234,179,8,0.25) !important; } 
.theme-yellow .card-header { background: linear-gradient(180deg, #fefce8 0%, #ffffff 100%); }
.theme-red { border-color: #fca5a5 !important; border-top: 8px solid #dc2626 !important; box-shadow: 0 8px 25px rgba(220,38,38,0.2) !important; } 
.theme-red .card-header { background: linear-gradient(180deg, #fef2f2 0%, #ffffff 100%); }
.theme-bronze { border-color: #fcd34d !important; border-top: 8px solid #b45309 !important; box-shadow: 0 8px 25px rgba(217,119,6,0.2) !important; } 
.theme-bronze .card-header { background: linear-gradient(180deg, #fffbeb 0%, #ffffff 100%); }
.theme-silver { border-color: #cbd5e1 !important; border-top: 8px solid #64748b !important; box-shadow: 0 8px 25px rgba(100,116,139,0.2) !important; } 
.theme-silver .card-header { background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%); }
.theme-gold { border-color: #fcd34d !important; border-top: 8px solid #d97706 !important; box-shadow: 0 8px 25px rgba(217,119,6,0.25) !important; } 
.theme-gold .card-header { background: linear-gradient(180deg, #fffbeb 0%, #ffffff 100%); }
.theme-diamond { border-color: #7dd3fc !important; border-top: 8px solid #0284c7 !important; box-shadow: 0 8px 25px rgba(2,132,199,0.2) !important; } 
.theme-diamond .card-header { background: linear-gradient(180deg, #f0f9ff 0%, #ffffff 100%); }
.theme-black { border-color: #525252 !important; border-top: 8px solid #171717 !important; box-shadow: 0 8px 25px rgba(23,23,23,0.3) !important; } 
.theme-black .card-header { background: linear-gradient(180deg, #f5f5f5 0%, #ffffff 100%); }

.stat-row { display: flex; justify-content: space-between; padding: 8px 16px; border-bottom: 1px solid #eae0d0; font-size: 13px; }
.stat-row:last-child { border-bottom: none; }
.stat-label { color: #8c7362; font-weight: 500; }
.stat-value { color: #382a21; font-weight: 700; text-align: right; }
.hidden-stat { display: none !important; }

/* 7. PAINIKKEET JA PALIKAT */
.btn-submit { 
  width: 100%; 
  padding: 13px 20px; 
  background: linear-gradient(180deg, #674732 0%, #4a3120 100%) !important; 
  color: #fdfaf5 !important; 
  border: 1px solid #382415 !important; 
  border-radius: 12px !important; 
  font-size: 14px; 
  font-weight: 700; 
  cursor: pointer; 
  text-transform: uppercase; 
  letter-spacing: 0.8px; 
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important;
  text-shadow: none !important;
  transition: all 0.2s ease !important;
}

.btn-submit:hover:not(:disabled) { 
  background: linear-gradient(180deg, #78543c 0%, #573a27 100%) !important; 
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3) !important;
  transform: translateY(-1px);
}

.btn-submit:active:not(:disabled) { 
  transform: translateY(1px) !important; 
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2) !important; 
}

.btn-submit:disabled { 
  background: #c0b2a3 !important; 
  color: #8c7e70 !important; 
  border-color: #a89a8b !important; 
  box-shadow: none !important;
  cursor: not-allowed; 
}

.btn-secondary { 
  background: #ebdcc9 !important; 
  color: #4a3120 !important; 
  border: 1px solid #c8baa6 !important; 
  border-radius: 12px !important;
  box-shadow: none !important;
  margin-top: 10px; 
  font-weight: 600;
}

.btn-secondary:hover {
  background: #dfcfbc !important;
  color: #2e1d11 !important;
}

.btn-landing-join {
  background: linear-gradient(180deg, #674732 0%, #4a3120 100%) !important;
  color: #fdfaf5 !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  padding: 14px 28px !important;
  border-radius: 12px !important; 
  border: 1px solid #382415 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
  display: inline-block;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  transition: all 0.2s ease !important;
}

.btn-landing-join:hover {
  background: linear-gradient(180deg, #78543c 0%, #573a27 100%) !important;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28) !important;
}

/* 8. SAAVUTUKSET (ACHIEVEMENTS) */
.achievement-group h4 { font-size: 11px; color: #8c7362; margin: 10px 0 8px 0; text-transform: uppercase; }
.achievement-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.achievement-card { border: 1px solid #d8c8b2; border-radius: 8px; padding: 8px 4px; text-align: center; background: #fffefb; position: relative; }
.achievement-card.unlocked { border-color: #bdab95; background: #fdfbf7; }
.achievement-card.locked { opacity: 0.45; filter: grayscale(100%); background: #ebdcc9; }
.achievement-icon { font-size: 20px; margin-bottom: 2px; }
.achievement-name { font-size: 9px; font-weight: 700; line-height: 1.1; }

.achievement-card.card-blurred { position: relative; overflow: hidden; cursor: pointer; opacity: 1 !important; }
.achievement-card.card-blurred .achievement-content-blur { filter: blur(2.5px) grayscale(100%); opacity: 0.4; pointer-events: none; }
.ach-more-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(56, 42, 33, 0.75); color: #fdfbf7; display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: 'Oswald', sans-serif; font-size: 15px; font-weight: 700; border-radius: 7px; z-index: 5; transition: background 0.2s ease; }
.achievement-card.card-blurred:hover .ach-more-overlay { background: rgba(56, 42, 33, 0.88); }
.ach-more-sub { font-size: 8px; font-family: 'Inter', sans-serif; font-weight: 500; opacity: 0.9; margin-top: 1px; }

/* 9. FIIDI & KOMMENTIT */
.feed-empty-state { text-align: center; padding: 30px 15px; color: #8c7362; font-size: 14px; background: #ffffff; border: 1px dashed #d8c8b2; border-radius: 12px; margin-top: 10px; }
.feed-card { background: #ffffff; border: 1px solid #d8c8b2; border-radius: 12px; padding: 14px; margin-bottom: 12px; text-align: left; }
.feed-card-anim { opacity: 0; animation: slideInUp 0.4s ease forwards; }

.reaction-bar { display: flex; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed #eae0d0; align-items: center; }

.react-btn { 
  background: #fffefb; 
  border: 1px solid #d8c8b2; 
  font-size: 12px; 
  padding: 5px 9px; 
  border-radius: 8px; 
  cursor: pointer; 
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease; 
  display: flex; 
  align-items: center; 
  gap: 5px; 
  color: #8c7362; 
  user-select: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.react-btn:hover { 
  background: #fdf6ec; 
  border-color: #bdab95;
  transform: translateY(-1px) scale(1.04);
  color: #5c4333;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
}

.react-btn:active {
  transform: scale(0.92) !important;
}

.react-btn.active { 
  background: linear-gradient(180deg, #674732 0%, #4a3120 100%) !important; 
  color: #fdfbf7 !important; 
  border-color: #382415 !important; 
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(74, 49, 32, 0.3) !important;
}

/* Emojin elastinen hyppy kun luokka .active kytkeytyy */
.react-btn.active span:first-child {
  display: inline-block;
  animation: popEmoji 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.25);
}

@keyframes popEmoji {
  0% { transform: scale(0.6); }
  50% { transform: scale(1.45); }
  100% { transform: scale(1); }
}

/* ============================================================
   💬 KOMMENTTIOSIO & CHAT-PUHEKUPLAT
   ============================================================ */

.comments-container { 
  margin-top: 12px; 
  padding: 12px; 
  border-top: 1px solid #eae0d0; 
  background: rgba(245, 238, 224, 0.45); 
  border-radius: 12px; 
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: commentsSlideDown 0.25s ease-out;
}

@keyframes commentsSlideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Yksittäisen kommentin säiliö */
.comment-bubble-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* Valkoinen puhekupla (symmetrinen 12px pyöristys) */
.comment-bubble {
  position: relative;
  background: #ffffff;
  border: 1px solid #e2d4c1;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 12.5px;
  color: #382a21;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  max-width: 88%;
  line-height: 1.4;
  box-sizing: border-box;
  margin-left: 2px;
  margin-bottom: 6px;
}

/* Puhekuplan kärki (pito siististi alareunan tuntumassa) */
.comment-bubble::before {
  content: '';
  position: absolute;
  bottom: -7px;
  left: 12px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 7px 6px 0 6px;
  border-color: #e2d4c1 transparent transparent transparent;
}

.comment-bubble::after {
  content: '';
  position: absolute;
  bottom: -5.5px;
  left: 13px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 6px 5px 0 5px;
  border-color: #ffffff transparent transparent transparent;
}

.comment-text {
  word-break: break-word;
}

/* Poisto- ja ilmiantonapit kuplan sisällä */
.comment-actions { 
  display: flex; 
  gap: 4px; 
  align-items: center; 
  flex-shrink: 0; 
  opacity: 0.65;
  transition: opacity 0.2s;
}

.comment-actions:hover {
  opacity: 1;
}

.btn-comment-action { 
  background: none; 
  border: none; 
  cursor: pointer; 
  font-size: 11px; 
  padding: 0; 
}

/* Kuplan alapuolella oleva kirjoittajarivi (siirretty kohdalleen kärjen kanssa) */
.comment-author-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding-left: 9px;
}

.comment-author-name {
  font-size: 11px;
  font-weight: 700;
  color: #5c4333;
}

.comment-time {
  font-size: 9.5px;
  color: #8c7362;
  font-weight: 500;
}

/* Pyöristetty syöttökenttä */
.comment-input-box {
  display: flex; 
  gap: 6px; 
  margin-top: 4px;
  align-items: center;
}

.comment-input-box input {
  flex: 1; 
  padding: 8px 14px; 
  font-size: 12px; 
  border: 1px solid #d9ccbb; 
  border-radius: 20px; 
  outline: none;
  background: #ffffff;
  transition: border-color 0.2s;
}

.comment-input-box input:focus {
  border-color: #8c7362;
}

.comment-input-box button {
  width: auto !important; 
  padding: 7px 16px !important; 
  font-size: 11px !important; 
  margin: 0 !important;
  border-radius: 20px !important;
}

/* 10. LOMAKKEET & MODALIT */
.autocomplete-wrapper { position: relative; flex-grow: 1; min-width: 0; }
.input-control { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid #d8c8b2; font-family: 'Inter', sans-serif; font-size: 14px; box-sizing: border-box; outline: none; }
.autocomplete-results { position: absolute; top: 100%; left: 0; right: 0; background: #ffffff; border: 1px solid #d8c8b2; border-radius: 0 0 8px 8px; z-index: 50; max-height: 120px; overflow-y: auto; display: none; }
.autocomplete-item { padding: 6px 10px; font-size: 12px; cursor: pointer; border-bottom: 1px solid #f5ece0; }
.error-box { background: #fce8e6; border-left: 4px solid #d9534f; color: #a8201a; padding: 8px 12px; font-size: 12px; font-weight: 600; margin-bottom: 12px; display: none; }

.modal-overlay { position: fixed; top:0; left:0; right:0; bottom:0; background: rgba(56, 42, 33, 0.6); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 15px; }
.modal-overlay.active { display: flex; animation: modalOverlayFade 0.25s ease-out; }
.modal-card { background: #ffffff; border-radius: 14px; padding: 20px; width: 100%; max-width: 350px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); max-height: 85vh; overflow-y: auto; }

/* 🌟 MODALIN JA PELAAJAKORTIN NOUSUANIMAATIOT */
@keyframes modalOverlayFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes cardPopUp {
  0% {
    opacity: 0;
    transform: translateY(40px) scale(0.88);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

#playerModal.active #otherPlayerCard,
.modal-overlay.active .modal-card {
  animation: cardPopUp 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.25);
}

.footer-section { text-align: center; font-size: 12px; color: #8c7362; padding-top: 10px; padding-bottom: 20px; }
.footer-section a { color: #8c7362; border-bottom: 1px dotted #8c7362; text-decoration: none; }
.footer-section a:hover { color: #5c4333; border-bottom: 1px solid #5c4333; }

#toastNotification { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(100px); background: #5c4333; color: #fdfbf7; padding: 12px 24px; border-radius: 30px; font-size: 13px; font-weight: 700; box-shadow: 0 4px 15px rgba(92, 67, 51, 0.4); transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); z-index: 10000; pointer-events: none; white-space: nowrap; }
#toastNotification.show { transform: translateX(-50%) translateY(0); }
#toastNotification.error { background: #d9534f; box-shadow: 0 4px 15px rgba(217, 83, 79, 0.4); }

.top-user-nav { position: absolute; top: 10px; right: 10px; display: flex; align-items: center; gap: 8px; z-index: 120; }
.top-nav-btn { display: flex; align-items: center; justify-content: center; background: #e8d9c4; border: 1px solid #d8c8b2; border-radius: 50%; width: 38px; height: 38px; cursor: pointer; position: relative; box-shadow: 0 2px 5px rgba(0,0,0,0.1); transition: transform 0.15s, background 0.2s; }
.top-nav-btn:hover { background: #ebdcc9; transform: scale(1.05); }

#headerAvatarContainer { width: 100%; height: 100%; border-radius: 50%; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #e8d9c4; }
#headerAvatarContainer img { width: 100%; height: 100%; object-fit: cover; }
.notif-dot-top { position: absolute; top: 1px; right: 1px; width: 10px; height: 10px; background-color: #d9534f; border-radius: 50%; border: 2px solid #fcf9f4; }

#topFeedBtn { background: transparent !important; border: none !important; box-shadow: none !important; width: auto !important; height: auto !important; padding: 4px !important; }
#topFeedBtn:hover { background: transparent !important; transform: scale(1.15) !important; }

/* ============================================================
   🍻 11. PELIVALINTAPALKKI & PUBICHIPIT
   ============================================================ */

.game-bar-container { 
  position: relative; 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  width: 100%; 
  background: #e8d9c4 !important; 
  border-bottom: 1px solid #c8baa6 !important; 
  user-select: none; 
}

/* Palkin avausnappi (Puinen/nahkainen pubilätkä) */
.game-bar-trigger { 
  background: #4a3120 !important; 
  color: #fdfaf5 !important; 
  font-family: 'Oswald', sans-serif; 
  font-size: 11px; 
  font-weight: 700; 
  text-transform: uppercase; 
  letter-spacing: 1px; 
  padding: 4px 18px; 
  border-radius: 0 0 10px 10px; 
  border: 1px solid #382415;
  border-top: none;
  cursor: pointer; 
  transition: all 0.2s ease; 
  z-index: 2; 
  box-shadow: 0 3px 8px rgba(0,0,0,0.18) !important; 
}

.game-bar-trigger:hover { 
  background: #674732 !important; 
  color: #ffffff !important; 
  transform: translateY(1px);
}

.game-bar-content { 
  display: flex; 
  justify-content: center; 
  align-items: center; 
  gap: 6px; 
  width: 100%; 
  padding: 0 10px; 
  box-sizing: border-box; 
  max-height: 0; 
  opacity: 0; 
  transform: translateY(-6px); 
  overflow: hidden; 
  pointer-events: none; 
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease, transform 0.3s ease, padding 0.3s ease; 
}

.game-bar-container:hover .game-bar-content,
.game-bar-container.open .game-bar-content {
  max-height: 42px;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  padding: 6px 10px;
}

/* Pelichip-napit (Passiivinen tila) */
.game-chip { 
  background: #f7eee0 !important; 
  color: #4a3120 !important; 
  border: 1px solid #c8baa6 !important; 
  padding: 4px 12px; 
  font-family: 'Oswald', sans-serif; 
  font-size: 11.5px; 
  font-weight: 700; 
  border-radius: 12px; 
  cursor: pointer; 
  white-space: nowrap; 
  transition: all 0.2s ease; 
  outline: none; 
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.game-chip:hover { 
  background: #ffffff !important; 
  border-color: #4a3120 !important;
  transform: translateY(-1px);
}

/* Aktiiviset pelichipit (Syvät pubivärit + pehmeä hehku) */
.game-chip[data-game="kimble"].active { 
  background: linear-gradient(180deg, #0284c7 0%, #0369a1 100%) !important; 
  color: #ffffff !important; 
  border-color: #0284c7 !important; 
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4) !important; 
}

.game-chip[data-game="yatzy"].active { 
  background: linear-gradient(180deg, #16a34a 0%, #15803d 100%) !important; 
  color: #ffffff !important; 
  border-color: #16a34a !important; 
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.4) !important; 
}

.game-chip[data-game="alias"].active { 
  background: linear-gradient(180deg, #dc2626 0%, #b91c1c 100%) !important; 
  color: #ffffff !important; 
  border-color: #dc2626 !important; 
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.4) !important; 
}

.game-chip[data-game="afrikan_tahti"].active { 
  background: linear-gradient(180deg, #d97706 0%, #b45309 100%) !important; 
  color: #ffffff !important; 
  border-color: #d97706 !important; 
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.4) !important; 
}
/* ============================================================
   🍻 12. HARMONISET KOKONAISTEEMAT & DIVISIOONAKORJAUS
   ============================================================ */
   /* RANKING-SIVUN YLÄKORTIN PERUSTYYLI */
.ranking-header-card {
  padding: 20px 15px 10px 15px;
  background: #fcf9f4;
  border-bottom: 1px solid #eae0d0;
  transition: background 0.3s ease, color 0.3s ease;
}

.ranking-header-card h2 {
  text-align: center;
  font-family: 'Oswald', sans-serif;
  color: #5c4333;
  margin: 0 0 15px 0;
  font-size: 24px;
  letter-spacing: 1.5px;
}

.ranking-header-card label {
  font-size: 10px;
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  color: #5c4333;
  display: block;
  margin-bottom: 4px;
}

/* ------------------------------------------------------------
   RANKING-TAULUKON & DIVISIOONAOTSIKOIDEN TÄYDELLINEN TASAUS
   ------------------------------------------------------------ */
#tab-ranking table {
  width: 100% !important;
  border-collapse: collapse !important;
  margin: 10px 0 0 0 !important;
  padding: 0 !important;
}

#tab-ranking table tr {
  margin: 0 !important;
  padding: 0 !important;
}

#tab-ranking table td, 
#tab-ranking table th {
  box-sizing: border-box !important;
}

/* Divisioonaotsikot (Kulta, Hopea, Pronssi, I, II, III, IV jne.) */
#tab-ranking tr.div-main-header td,
#tab-ranking tr.div-sub-header td,
.div-main-header td,
.div-sub-header td {
  margin: 0 !important;
  padding: 8px 12px !important;
  border-left: none !important;
  border-right: none !important;
  text-align: center !important;
  position: relative;
  left: -2px; /* Siirtää palkkeja täsmälleen 2px vasemmalle poistaen raon */
  width: calc(100% + 2px) !important;
}

/* Ohjataan liukuvärit td-soluun, jotta taustaväri siirtyy 2px vasemmalle myös pääpalkeissa */
tr.div-main-header.pronssi td { background: linear-gradient(90deg, #9a3412, #d97706) !important; }
tr.div-main-header.hopea td { background: linear-gradient(90deg, #475569, #94a3b8) !important; }
tr.div-main-header.kulta td { background: linear-gradient(90deg, #d97706, #fcd34d) !important; }
tr.div-main-header.timantti td { background: linear-gradient(90deg, #0284c7, #38bdf8) !important; }

/* VÄLILEHTIEN PÄÄSÄILIÖIDEN TAUSTAN NOLLAUS */
#tab-ranking, 
#tab-raportoi,
#tab-saannot,
#tab-profiili, 
#tab-feed, 
#landing-general, 
#tab-etusivu {
  background: transparent !important;
}

/* FIIDIKORTTIEN SYÖTE REUNAMERKIT */
.game-card-general { background: #ffffff; border: 1px solid #d8c8b2; border-radius: 12px; padding: 20px; }
.game-card-kimble { background: #ffffff; border: 2px solid #7dd3fc; border-left: 6px solid #0284c7; border-radius: 12px; padding: 20px; }
.game-card-yatzy { background: #ffffff; border: 2px solid #86efac; border-left: 6px solid #15803d; border-radius: 12px; padding: 20px; }
.game-card-alias { background: #ffffff; border: 2px solid #fca5a5; border-left: 6px solid #b91c1c; border-radius: 12px; padding: 20px; }
.game-card-afrikan_tahti { background: #ffffff; border: 2px solid #fde047; border-left: 6px solid #ca8a04; border-radius: 12px; padding: 20px; }


/* ============================================================
   🔵 1. KIMBLE TEEMA (Jään- ja merensininen)
   ============================================================ */
body[data-theme="kimble"] { 
  background-color: #0e0805 !important; 
  background-image: 
    radial-gradient(circle at 50% 25%, rgba(2, 132, 199, 0.22) 0%, rgba(14, 8, 5, 0.98) 75%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.07) 0, rgba(255, 255, 255, 0.07) 2px, transparent 0, transparent 8px),
    repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.4) 0, rgba(0, 0, 0, 0.4) 2px, transparent 0, transparent 8px) !important;
}
.app-container[data-theme="kimble"] {
  background: #f1f7fc linear-gradient(180deg, #f5f9fd 0%, #e3eff8 100%) !important;
  border-color: #0284c7 !important;
  box-shadow: 0 35px 80px rgba(0, 0, 0, 0.9), 0 0 25px rgba(2, 132, 199, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.7) !important;
}
.app-container[data-theme="kimble"] .sticky-header,
.app-container[data-theme="kimble"] .logo-container { background: #f5f9fd !important; border-bottom-color: #cce3f5 !important; }
.app-container[data-theme="kimble"] .nav-tabs { background: #dcebf7 !important; }
.app-container[data-theme="kimble"] .nav-tab { color: #3b6280 !important; border-right-color: #cce3f5 !important; }
.app-container[data-theme="kimble"] .nav-tab.active { background: #f5f9fd !important; color: #0284c7 !important; border-bottom: 3px solid #0284c7 !important; }
.app-container[data-theme="kimble"] .game-bar-container { background: #dcebf7 !important; border-bottom-color: #cce3f5 !important; }
.app-container[data-theme="kimble"] .game-bar-trigger { background: #0369a1 !important; color: #ffffff !important; border-color: #0284c7 !important; }

/* KIMBLE: Ranking-otsikon TAUSTALAATIKKO (SININEN) */
.app-container[data-theme="kimble"] .ranking-header-card { 
  background: linear-gradient(180deg, #0284c7 0%, #0369a1 100%) !important; 
  color: #ffffff !important;
  border-bottom: 1px solid #0284c7 !important; 
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25) !important;
}
.app-container[data-theme="kimble"] .ranking-header-card label,
.app-container[data-theme="kimble"] .ranking-header-card h2 {
  color: #ffffff !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4) !important;
}
.app-container[data-theme="kimble"] #tab-ranking th { background-color: #0369a1 !important; color: #ffffff !important; }
.app-container[data-theme="kimble"] .btn-secondary,
.app-container[data-theme="kimble"] #tab-ranking button { 
  background: #ffffff !important; 
  color: #0369a1 !important; 
  border-color: #ffffff !important; 
  font-weight: 700 !important;
}

/* KIMBLE: Raportointi & Julkinen ottelu -laatikot */
.app-container[data-theme="kimble"] #tab-raportoi .content-box,
.app-container[data-theme="kimble"] #tab-raportoi .card,
.app-container[data-theme="kimble"] #tab-raportoi .control-panel,
.app-container[data-theme="kimble"] #tab-raportoi .callout-box,
.app-container[data-theme="kimble"] #tab-raportoi .control-row,
.app-container[data-theme="kimble"] #tab-raportoi .switch-row,
.app-container[data-theme="kimble"] #tab-raportoi .form-group { 
  background: #ffffff !important; 
  border: 1px solid #b3d5ef !important; 
  border-radius: 12px !important;
}
.app-container[data-theme="kimble"] #tab-raportoi .content-box { border-top: 4px solid #0284c7 !important; }
.app-container[data-theme="kimble"] .input-control { border-color: #b3d5ef !important; background: #ffffff !important; }

/* KIMBLE: Säännöt & Footer */
.app-container[data-theme="kimble"] .rules-card,
.app-container[data-theme="kimble"] .toc { background: #ffffff !important; border-color: #b3d5ef !important; }
.app-container[data-theme="kimble"] .callout-box { background: #edf6fd !important; border-left-color: #0284c7 !important; }
.app-container[data-theme="kimble"] .footer-section { background: #d4e5f3 !important; color: #2c516c !important; border-top: 1px solid #b3d5ef; }
.app-container[data-theme="kimble"] .footer-section a { color: #0284c7 !important; border-bottom-color: #0284c7 !important; }


/* ============================================================
   🟢 2. YATZY TEEMA (Sammalvihreä)
   ============================================================ */
body[data-theme="yatzy"] { 
  background-color: #0e0805 !important; 
  background-image: 
    radial-gradient(circle at 50% 25%, rgba(22, 163, 74, 0.22) 0%, rgba(14, 8, 5, 0.98) 75%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.07) 0, rgba(255, 255, 255, 0.07) 2px, transparent 0, transparent 8px),
    repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.4) 0, rgba(0, 0, 0, 0.4) 2px, transparent 0, transparent 8px) !important;
}
.app-container[data-theme="yatzy"] {
  background: #f1fbf3 linear-gradient(180deg, #f5fdf6 0%, #e2f6e7 100%) !important;
  border-color: #16a34a !important;
  box-shadow: 0 35px 80px rgba(0, 0, 0, 0.9), 0 0 25px rgba(22, 163, 74, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.7) !important;
}
.app-container[data-theme="yatzy"] .sticky-header,
.app-container[data-theme="yatzy"] .logo-container { background: #f5fdf6 !important; border-bottom-color: #cbeed4 !important; }
.app-container[data-theme="yatzy"] .nav-tabs { background: #daf2e1 !important; }
.app-container[data-theme="yatzy"] .nav-tab { color: #326340 !important; border-right-color: #cbeed4 !important; }
.app-container[data-theme="yatzy"] .nav-tab.active { background: #f5fdf6 !important; color: #16a34a !important; border-bottom: 3px solid #16a34a !important; }
.app-container[data-theme="yatzy"] .game-bar-container { background: #daf2e1 !important; border-bottom-color: #cbeed4 !important; }
.app-container[data-theme="yatzy"] .game-bar-trigger { background: #15803d !important; color: #ffffff !important; border-color: #16a34a !important; }

/* YATZY: Ranking-otsikon TAUSTALAATIKKO (VIHREÄ) */
.app-container[data-theme="yatzy"] .ranking-header-card { 
  background: linear-gradient(180deg, #16a34a 0%, #15803d 100%) !important; 
  color: #ffffff !important;
  border-bottom: 1px solid #16a34a !important; 
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.25) !important;
}
.app-container[data-theme="yatzy"] .ranking-header-card label,
.app-container[data-theme="yatzy"] .ranking-header-card h2 {
  color: #ffffff !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4) !important;
}
.app-container[data-theme="yatzy"] #tab-ranking th { background-color: #15803d !important; color: #ffffff !important; }
.app-container[data-theme="yatzy"] .btn-secondary,
.app-container[data-theme="yatzy"] #tab-ranking button { 
  background: #ffffff !important; 
  color: #15803d !important; 
  border-color: #ffffff !important; 
  font-weight: 700 !important;
}

/* YATZY: Raportointi & Julkinen ottelu -laatikot */
.app-container[data-theme="yatzy"] #tab-raportoi .content-box,
.app-container[data-theme="yatzy"] #tab-raportoi .card,
.app-container[data-theme="yatzy"] #tab-raportoi .control-panel,
.app-container[data-theme="yatzy"] #tab-raportoi .callout-box,
.app-container[data-theme="yatzy"] #tab-raportoi .control-row,
.app-container[data-theme="yatzy"] #tab-raportoi .switch-row,
.app-container[data-theme="yatzy"] #tab-raportoi .form-group { 
  background: #ffffff !important; 
  border: 1px solid #b0e3be !important; 
  border-radius: 12px !important;
}
.app-container[data-theme="yatzy"] #tab-raportoi .content-box { border-top: 4px solid #16a34a !important; }
.app-container[data-theme="yatzy"] .input-control { border-color: #b0e3be !important; background: #ffffff !important; }

/* YATZY: Säännöt & Footer */
.app-container[data-theme="yatzy"] .rules-card,
.app-container[data-theme="yatzy"] .toc { background: #ffffff !important; border-color: #b0e3be !important; }
.app-container[data-theme="yatzy"] .callout-box { background: #edfbf1 !important; border-left-color: #16a34a !important; }
.app-container[data-theme="yatzy"] .footer-section { background: #d1eed8 !important; color: #244f30 !important; border-top: 1px solid #b0e3be; }
.app-container[data-theme="yatzy"] .footer-section a { color: #16a34a !important; border-bottom-color: #16a34a !important; }


/* ============================================================
   🔴 3. ALIAS TEEMA (Roosanpunainen)
   ============================================================ */
body[data-theme="alias"] { 
  background-color: #0e0805 !important; 
  background-image: 
    radial-gradient(circle at 50% 25%, rgba(220, 38, 38, 0.22) 0%, rgba(14, 8, 5, 0.98) 75%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.07) 0, rgba(255, 255, 255, 0.07) 2px, transparent 0, transparent 8px),
    repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.4) 0, rgba(0, 0, 0, 0.4) 2px, transparent 0, transparent 8px) !important;
}
.app-container[data-theme="alias"] {
  background: #fcf2f2 linear-gradient(180deg, #fdf6f6 0%, #f9e3e3 100%) !important;
  border-color: #dc2626 !important;
  box-shadow: 0 35px 80px rgba(0, 0, 0, 0.9), 0 0 25px rgba(220, 38, 38, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.7) !important;
}
.app-container[data-theme="alias"] .sticky-header,
.app-container[data-theme="alias"] .logo-container { background: #fdf6f6 !important; border-bottom-color: #f5cccc !important; }
.app-container[data-theme="alias"] .nav-tabs { background: #f8dddd !important; }
.app-container[data-theme="alias"] .nav-tab { color: #7a3535 !important; border-right-color: #f5cccc !important; }
.app-container[data-theme="alias"] .nav-tab.active { background: #fdf6f6 !important; color: #dc2626 !important; border-bottom: 3px solid #dc2626 !important; }
.app-container[data-theme="alias"] .game-bar-container { background: #f8dddd !important; border-bottom-color: #f5cccc !important; }
.app-container[data-theme="alias"] .game-bar-trigger { background: #b91c1c !important; color: #ffffff !important; border-color: #dc2626 !important; }

/* ALIAS: Ranking-otsikon TAUSTALAATIKKO (PUNAINEN) */
.app-container[data-theme="alias"] .ranking-header-card { 
  background: linear-gradient(180deg, #dc2626 0%, #b91c1c 100%) !important; 
  color: #ffffff !important;
  border-bottom: 1px solid #dc2626 !important; 
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25) !important;
}
.app-container[data-theme="alias"] .ranking-header-card label,
.app-container[data-theme="alias"] .ranking-header-card h2 {
  color: #ffffff !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4) !important;
}
.app-container[data-theme="alias"] #tab-ranking th { background-color: #b91c1c !important; color: #ffffff !important; }
.app-container[data-theme="alias"] .btn-secondary,
.app-container[data-theme="alias"] #tab-ranking button { 
  background: #ffffff !important; 
  color: #b91c1c !important; 
  border-color: #ffffff !important; 
  font-weight: 700 !important;
}

/* ALIAS: Raportointi & Julkinen ottelu -laatikot */
.app-container[data-theme="alias"] #tab-raportoi .content-box,
.app-container[data-theme="alias"] #tab-raportoi .card,
.app-container[data-theme="alias"] #tab-raportoi .control-panel,
.app-container[data-theme="alias"] #tab-raportoi .callout-box,
.app-container[data-theme="alias"] #tab-raportoi .control-row,
.app-container[data-theme="alias"] #tab-raportoi .switch-row,
.app-container[data-theme="alias"] #tab-raportoi .form-group { 
  background: #ffffff !important; 
  border: 1px solid #ebafaf !important; 
  border-radius: 12px !important;
}
.app-container[data-theme="alias"] #tab-raportoi .content-box { border-top: 4px solid #dc2626 !important; }
.app-container[data-theme="alias"] .input-control { border-color: #ebafaf !important; background: #ffffff !important; }

/* ALIAS: Säännöt & Footer */
.app-container[data-theme="alias"] .rules-card,
.app-container[data-theme="alias"] .toc { background: #ffffff !important; border-color: #ebafaf !important; }
.app-container[data-theme="alias"] .callout-box { background: #fdf2f2 !important; border-left-color: #dc2626 !important; }
.app-container[data-theme="alias"] .footer-section { background: #f4d0d0 !important; color: #612323 !important; border-top: 1px solid #ebafaf; }
.app-container[data-theme="alias"] .footer-section a { color: #dc2626 !important; border-bottom-color: #dc2626 !important; }


/* ============================================================
   🟡 4. AFRIKAN TÄHTI TEEMA (Kultameripihka)
   ============================================================ */
body[data-theme="afrikan_tahti"] { 
  background-color: #0e0805 !important; 
  background-image: 
    radial-gradient(circle at 50% 25%, rgba(217, 119, 6, 0.24) 0%, rgba(14, 8, 5, 0.98) 75%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.07) 0, rgba(255, 255, 255, 0.07) 2px, transparent 0, transparent 8px),
    repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.4) 0, rgba(0, 0, 0, 0.4) 2px, transparent 0, transparent 8px) !important;
}
.app-container[data-theme="afrikan_tahti"] {
  background: #fdf8ee linear-gradient(180deg, #fefcf4 0%, #f8ebd1 100%) !important;
  border-color: #d97706 !important;
  box-shadow: 0 35px 80px rgba(0, 0, 0, 0.9), 0 0 25px rgba(217, 119, 6, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.7) !important;
}
.app-container[data-theme="afrikan_tahti"] .sticky-header,
.app-container[data-theme="afrikan_tahti"] .logo-container { background: #fefcf4 !important; border-bottom-color: #f3e2bf !important; }
.app-container[data-theme="afrikan_tahti"] .nav-tabs { background: #f8e7c5 !important; }
.app-container[data-theme="afrikan_tahti"] .nav-tab { color: #6e4e21 !important; border-right-color: #f3e2bf !important; }
.app-container[data-theme="afrikan_tahti"] .nav-tab.active { background: #fefcf4 !important; color: #d97706 !important; border-bottom: 3px solid #d97706 !important; }
.app-container[data-theme="afrikan_tahti"] .game-bar-container { background: #f8e7c5 !important; border-bottom-color: #f3e2bf !important; }
.app-container[data-theme="afrikan_tahti"] .game-bar-trigger { background: #b45309 !important; color: #ffffff !important; border-color: #d97706 !important; }

/* AFRIKAN TÄHTI: Ranking-otsikon TAUSTALAATIKKO (KULTAINEN) */
.app-container[data-theme="afrikan_tahti"] .ranking-header-card { 
  background: linear-gradient(180deg, #d97706 0%, #b45309 100%) !important; 
  color: #ffffff !important;
  border-bottom: 1px solid #d97706 !important; 
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.25) !important;
}
.app-container[data-theme="afrikan_tahti"] .ranking-header-card label,
.app-container[data-theme="afrikan_tahti"] .ranking-header-card h2 {
  color: #ffffff !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4) !important;
}
.app-container[data-theme="afrikan_tahti"] #tab-ranking th { background-color: #b45309 !important; color: #ffffff !important; }
.app-container[data-theme="afrikan_tahti"] .btn-secondary,
.app-container[data-theme="afrikan_tahti"] #tab-ranking button { 
  background: #ffffff !important; 
  color: #b45309 !important; 
  border-color: #ffffff !important; 
  font-weight: 700 !important;
}

/* AFRIKAN TÄHTI: Raportointi & Julkinen ottelu -laatikot */
.app-container[data-theme="afrikan_tahti"] #tab-raportoi .content-box,
.app-container[data-theme="afrikan_tahti"] #tab-raportoi .card,
.app-container[data-theme="afrikan_tahti"] #tab-raportoi .control-panel,
.app-container[data-theme="afrikan_tahti"] #tab-raportoi .callout-box,
.app-container[data-theme="afrikan_tahti"] #tab-raportoi .control-row,
.app-container[data-theme="afrikan_tahti"] #tab-raportoi .switch-row,
.app-container[data-theme="afrikan_tahti"] #tab-raportoi .form-group { 
  background: #ffffff !important; 
  border: 1px solid #e8ca96 !important; 
  border-radius: 12px !important;
}
.app-container[data-theme="afrikan_tahti"] #tab-raportoi .content-box { border-top: 4px solid #d97706 !important; }
.app-container[data-theme="afrikan_tahti"] .input-control { border-color: #e8ca96 !important; background: #ffffff !important; }

/* AFRIKAN TÄHTI: Säännöt & Footer */
.app-container[data-theme="afrikan_tahti"] .rules-card,
.app-container[data-theme="afrikan_tahti"] .toc { background: #ffffff !important; border-color: #e8ca96 !important; }
.app-container[data-theme="afrikan_tahti"] .callout-box { background: #fdf8eb !important; border-left-color: #d97706 !important; }
.app-container[data-theme="afrikan_tahti"] .footer-section { background: #f3debb !important; color: #553a13 !important; border-top: 1px solid #e8ca96; }
.app-container[data-theme="afrikan_tahti"] .footer-section a { color: #d97706 !important; border-bottom-color: #d97706 !important; }


/* FIIDIKORTTIEN REUNATEEMAT */
.feed-card-kimble { border-left: 4px solid #0284c7 !important; }
.feed-card-kimble .feed-card-header-title { color: #0284c7 !important; }
.feed-card-yatzy { border-left: 4px solid #16a34a !important; }
.feed-card-yatzy .feed-card-header-title { color: #16a34a !important; }
.feed-card-alias { border-left: 4px solid #dc2626 !important; }
.feed-card-alias .feed-card-header-title { color: #dc2626 !important; }
.feed-card-afrikan_tahti { border-left: 4px solid #d97706 !important; }
.feed-card-afrikan_tahti .feed-card-header-title { color: #d97706 !important; }
/* 13. ETUSIVU JA SISÄLLÖT (LÄPINÄKYVÄT TAUSTAT JOTTA KORTIN DYNAMINEN SÄVY NÄKYY) */
#tab-profiili, #tab-feed, #landing-general, #tab-etusivu {
  background: transparent !important;
  border-radius: 0 0 16px 16px;
}

.landing-hero-card {
  background: #ffffff;
  border: 2px solid #d8c8b2;
  border-radius: 16px;
  padding: 25px 20px;
  text-align: center;
  box-shadow: 0 4px 15px rgba(90, 70, 50, 0.05);
}

.landing-hero-card h2 { color: #5c4333; font-size: 26px; margin-top: 0; margin-bottom: 12px; letter-spacing: 1px; }
.landing-hero-card p { color: #4a3b30; font-size: 14px; line-height: 1.6; margin-bottom: 20px; }

/* 14. TASOELEMENTIT JA PELIRANKING-NAPIT */
.level-box { display: flex; flex-direction: column; align-items: center; margin: 6px 0 10px 0; }
.level-tag { font-family: 'Oswald', sans-serif; font-size: 13px; font-weight: 700; color: #5c4333; text-transform: uppercase; letter-spacing: 0.5px; }
.xp-container { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; margin-top: 4px; width: 100%; }
.xp-bar { width: 130px; height: 8px; background: #d8c8b2; border-radius: 4px; overflow: hidden; border: 1px solid #bdab95; }
.xp-fill { width: 0%; height: 100%; background: linear-gradient(90deg, #d97706, #fcd34d); border-radius: 4px; transition: width 0.4s ease-in-out; }
.xp-val { font-size: 8px; font-weight: 600; color: #8c7362; opacity: 0.85; text-align: center; }

.game-ranks-container { margin: 16px 0 4px 0; display: flex; flex-direction: column; align-items: center; }
.game-ranks-label { font-size: 9px; font-weight: 700; color: #8c7362; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.game-ranks-grid { display: flex; justify-content: center; gap: 8px; background: rgba(255, 255, 255, 0.55); padding: 6px 8px; border-radius: 8px; border: 1px solid #eae0d0; width: 100%; box-sizing: border-box; }

.game-rank-item { display: flex; flex-direction: column; align-items: center; flex: 1; min-width: 0; padding: 4px 2px; border-radius: 6px; cursor: pointer; transition: all 0.2s ease; user-select: none; }
.game-rank-item:hover { background: rgba(92, 67, 51, 0.08); }
.game-rank-item.active { background: #5c4333 !important; box-shadow: 0 2px 5px rgba(0,0,0,0.15); }
.game-rank-item.active .game-rank-title { color: #f0e4d5 !important; }
.game-rank-item.active .game-rank-div { color: #ffffff !important; }
.game-rank-item.active .game-rank-top { color: #fcd34d !important; }

.game-rank-title { font-size: 9px; color: #8c7362; font-weight: 700; text-transform: uppercase; line-height: 1.1; white-space: nowrap; }
.game-rank-div { font-size: 10px; font-weight: 700; color: #382a21; margin-top: 2px; white-space: nowrap; }
.game-rank-top { font-size: 9px; font-weight: 700; color: #d97706; margin-top: 1px; }

.global-stats-row { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 11px; font-weight: 600; color: #8c7362; margin: 4px 0 8px 0; }
.global-stat-sep { color: #d8c8b2; }

.coming-soon-box { background: #ffffff; border-radius: 12px; padding: 30px 20px; text-align: center; border: 2px dashed #d8c8b2; margin: 10px 0; box-shadow: 0 4px 12px rgba(90, 70, 50, 0.04); }
.coming-soon-badge { display: inline-block; background: #fef3c7; color: #92400e; font-family: 'Oswald', sans-serif; font-size: 11px; font-weight: 700; padding: 4px 12px; border-radius: 20px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px; border: 1px solid #fde68a; }
.coming-soon-box h3 { margin: 0 0 8px 0; font-size: 20px; color: #382a21; }
.coming-soon-box p { font-size: 13px; color: #8c7362; margin: 0 0 16px 0; line-height: 1.5; }
/* ============================================================
   🎛️ KUSTOMOINTI-MODALIN HYPER-TIIVIS NÄKYMÄ (EI RULLAUSTA)
   ============================================================ */

/* Ikkunan ja sisällön yleiset välit minimoitu */
#cardCustomModal .modal-card {
  padding: 10px 12px !important;
  max-width: 350px !important;
  max-height: 98vh !important;
}

#cardCustomModal h3 {
  font-size: 15px !important;
  margin-top: 0 !important;
  margin-bottom: 4px !important;
}

/* Profiilikuva-osio tiiviimmäksi */
#cardCustomModal .modal-card > div:first-of-type {
  margin-bottom: 6px !important;
  padding-bottom: 6px !important;
  gap: 10px !important;
}

#cardCustomModal #custAvatarPreview {
  width: 36px !important;
  height: 36px !important;
}

#cardCustomModal #btn-avatar-upload {
  padding: 4px 8px !important;
  font-size: 10px !important;
}

/* Labelit ja valikot mataliksi */
#cardCustomModal label {
  margin-top: 4px !important;
  margin-bottom: 2px !important;
  font-size: 9px !important;
  letter-spacing: 0.3px !important;
}

#cardCustomModal select {
  padding: 4px 6px !important;
  margin-bottom: 4px !important;
  font-size: 11px !important;
  border-radius: 6px !important;
}

/* Tilastokytkimet kahdessa sarakkeessa (puolittaa osion korkeuden) */
#cardCustomModal div[style*="fcf9f4"] {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 2px 8px !important;
  padding: 4px 8px !important;
  margin-bottom: 6px !important;
  background: #fcf9f4 !important;
  border-radius: 6px !important;
}

.switch-row {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  padding: 2px 0 !important;
  border-bottom: none !important;
  font-size: 10px !important;
  color: #382a21 !important;
}

/* Miniatyyri-kytkimet */
.switch {
  position: relative !important;
  display: inline-block !important;
  width: 28px !important;
  height: 15px !important;
  flex-shrink: 0 !important;
}

.switch input {
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
}

.slider {
  position: absolute !important;
  cursor: pointer !important;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #d8c8b2 !important;
  transition: 0.2s !important;
  border-radius: 15px !important;
}

.slider:before {
  position: absolute !important;
  content: "" !important;
  height: 11px !important;
  width: 11px !important;
  left: 2px !important;
  bottom: 2px !important;
  background-color: #ffffff !important;
  transition: 0.2s !important;
  border-radius: 50% !important;
}

input:checked + .slider {
  background-color: #2e7d32 !important;
}

input:checked + .slider:before {
  transform: translateX(13px) !important;
}

/* Teemaruudukko madallekudella */
.theme-grid {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 4px !important;
  margin-bottom: 6px !important;
}

.theme-box {
  background: #fffefb;
  border: 1px solid #d8c8b2;
  border-radius: 5px !important;
  padding: 4px 2px !important;
  text-align: center;
  font-size: 9.5px !important;
  font-weight: 700;
  color: #5c4333;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.theme-box.locked {
  opacity: 0.45;
  cursor: not-allowed;
  background: #f0e8dd !important;
  color: #8c7362;
}

/* Painikkeet matalammiksi */
#cardCustomModal .btn-submit {
  padding: 8px 12px !important;
  font-size: 11px !important;
  border-radius: 8px !important;
  margin-top: 4px !important;
}

#cardCustomModal .btn-secondary {
  margin-top: 4px !important;
}

/* Teemakohtaiset Aktiivivärit */
.theme-box[data-theme="theme-blue"].active { background: #dbeafe !important; border-color: #2563eb !important; color: #1e40af !important; box-shadow: 0 0 0 2px #2563eb !important; }
.theme-box[data-theme="theme-green"].active { background: #dcfce7 !important; border-color: #16a34a !important; color: #166534 !important; box-shadow: 0 0 0 2px #16a34a !important; }
.theme-box[data-theme="theme-yellow"].active { background: #fef9c3 !important; border-color: #ca8a04 !important; color: #854d0e !important; box-shadow: 0 0 0 2px #ca8a04 !important; }
.theme-box[data-theme="theme-red"].active { background: #fee2e2 !important; border-color: #dc2626 !important; color: #991b1b !important; box-shadow: 0 0 0 2px #dc2626 !important; }
.theme-box[data-theme="theme-bronze"].active { background: #ffedd5 !important; border-color: #b45309 !important; color: #7c2d12 !important; box-shadow: 0 0 0 2px #b45309 !important; }
.theme-box[data-theme="theme-silver"].active { background: #f1f5f9 !important; border-color: #64748b !important; color: #334155 !important; box-shadow: 0 0 0 2px #64748b !important; }
.theme-box[data-theme="theme-gold"].active { background: #fef3c7 !important; border-color: #d97706 !important; color: #92400e !important; box-shadow: 0 0 0 2px #d97706 !important; }
.theme-box[data-theme="theme-diamond"].active { background: #e0f2fe !important; border-color: #0284c7 !important; color: #075985 !important; box-shadow: 0 0 0 2px #0284c7 !important; }
.theme-box[data-theme="theme-black"].active { background: #262626 !important; border-color: #000000 !important; color: #ffffff !important; box-shadow: 0 0 0 2px #000000 !important; }
/* Otsikkorivi & pudotusvalikko näytettäville tilastoille */
.stats-header-row {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  margin-top: 8px !important;
  margin-bottom: 4px !important;
}

/* ============================================================
   🃏 KERÄILYKORTIN 3D-KELLUTUS & NOUSTO (FLAT SISÄLTÖ)
   ============================================================ */

.card {
  transform: perspective(1000px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateZ(var(--tz, 0px)) scale(var(--scale, 1)) !important;
  transition: transform 0.2s ease-out, box-shadow 0.2s ease-out !important;
  will-change: transform, box-shadow;
}

/* Varjo syvenee ja kääntyy kortin kallistuksen mukaan */
.card:hover {
  box-shadow: 
    calc(var(--ry, 0deg) * -2px) 
    calc(var(--rx, 0deg) * -2px + 20px) 
    35px 
    rgba(0, 0, 0, 0.45) !important;
}

/* Varmistetaan että sisäpuolen tekstit ja kuvat säilyvät täysin flat-tilassa */
.card-header, 
.card-content,
.card-avatar-lg,
.card-header h2,
.card-gear-btn, 
.card-share-btn,
.player-title-tag, 
.global-stats-row,
.level-box, 
.game-ranks-container,
.stat-row {
  transform: none !important;
}

/* Pehmeä valoheijastus kortin pinnassa */
.card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: radial-gradient(
    circle 260px at var(--mx, 50%) var(--my, 50%),
    rgba(255, 255, 255, 0.28) 0%,
    rgba(255, 255, 255, 0.08) 40%,
    transparent 70%
  ) !important;
  pointer-events: none;
  z-index: 10;
  opacity: var(--holo-opacity, 0);
  transition: opacity 0.3s ease;
  overflow: hidden;
}

.card:hover::after {
  opacity: 1;
}