/**
 * TikTok Supporter Tracker - Redesigned Display
 * NetDynamic
 * Version: 2.2.0-alpha
 * Screenshot-First Design - Matching Hand-Drawn Layout
 * Added: Stars display section (bottom right)
 */

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

:root {
    --display-bg: #ffffff;
    --header-bg: #FFD700;
    --text-dark: #000000;
    --text-light: #666666;
    --primary-color: #ff0050;
    --secondary-color: #00f2ea;
    --background: #000000;
    --surface: #1a1a1a;
    --border-color: #333333;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #d0d0d0;
    color: var(--text-dark);
    line-height: 1.4;
}

.app-container {
    max-width: 420px;
    margin: 0 auto;
    padding: 10px;
}

/* Daily Total */
.daily-total {
    text-align: center;
    padding: 8px 15px;
    margin-bottom: 10px;
    background: transparent;
}

.total-label {
    font-size: 14px;
    font-weight: 700;
    color: #000000;
    margin-right: 8px;
}

.total-amount {
    font-size: 16px;
    font-weight: 900;
    color: #ff0000;
    text-shadow:
        -1px -1px 0 #FFD700,
        1px -1px 0 #FFD700,
        -1px 1px 0 #FFD700,
        1px 1px 0 #FFD700;
}

.total-unit {
    font-size: 12px;
    font-weight: 700;
    color: #666;
    margin-left: 4px;
}

/* ===== DISPLAY MODE (Screenshot Ready) ===== */
.display-mode {
    background: transparent;
    background-color: transparent;
    -webkit-background-clip: padding-box;
    border-radius: 0;
    -webkit-border-radius: 0;
    overflow: visible;
    margin-bottom: 0;
    box-shadow: none;
    -webkit-box-shadow: none;
    width: 100%;
}

/* Leaderboard wrapper (white background area) */
.leaderboard-wrapper {
    background: #ffffff;
    overflow: hidden;
    position: relative;
}

/* Content wrapper below header */
.display-content {
    display: flex;
    align-items: stretch;
}

/* Leaderboard content (left side) */
.leaderboard-content {
    flex: 1;
    min-width: 0;
    margin-left: 7px;
    position: relative;
}

/* Score column (right side) */
.score-column {
    width: 14px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    margin-right: 3px;
}

/* Vertical label above score boxes (stacked letters) */
.score-column-label {
    font-family: 'Black Ops One', sans-serif;
    font-size: 8px;
    font-weight: 400;
    color: #000;
    text-align: center;
    line-height: 1.1;
    padding: 3px 0;
}

/* Wrapper to keep score boxes together */
.score-column-inner {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    margin-top: -15px;
}

.score-box {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 8px;
    line-height: 1;
    padding: 6px 1px;
}

.score-box.top {
    background: #000000;
    color: #ffffff;
}

.score-box.bottom {
    background: #ffffff;
    color: #000000;
    border: 1px solid #000000;
    border-top: none;
}

/* Rank hidden mode - expand leaderboard to fill space */
.display-content.rank-hidden .leaderboard-content {
    margin-right: 7px;
}

/* Coffee visible - same shift regardless of rank state */
.display-mode.coffee-visible .display-content .leaderboard-content,
.display-mode.coffee-visible .display-content.rank-hidden .leaderboard-content {
    margin-right: 28px;
}

/* Coffee visible - rank column becomes horizontal (two boxes side by side) */
.display-mode.coffee-visible .score-column {
    width: 0;
    margin-right: 0;
    position: static;
}

.display-mode.coffee-visible .score-column-inner {
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    margin-top: -5px;
    display: grid;
    grid-template-columns: auto auto;
    gap: 0;
    z-index: 5;
}

/* RANK label: horizontal above the boxes */
.display-mode.coffee-visible .score-column-label {
    grid-column: 1 / -1;
    text-align: center;
    font-size: 7px;
    padding: 0 0 1px 0;
}

.display-mode.coffee-visible .score-column-label br {
    display: none;
}

.display-mode.coffee-visible .score-box {
    padding: 4px 1px;
    font-size: 10px;
}

.display-mode.coffee-visible .score-box.bottom {
    border-top: 1px solid #000000;
    border-left: none;
}

/* Hide coffee-float image when rank column is visible (not hidden) */
.display-mode.coffee-visible .coffee-float {
    display: none;
}

.display-mode.coffee-visible .display-content.rank-hidden ~ .coffee-board .coffee-float {
    display: block;
}

/* Hide flags on bottom row stars (6-12) when coffee visible */
.display-mode.coffee-visible .bottom-ranking-row .ranking-flag {
    display: none;
}

/* Stars display shifts down and above coffee board when coffee visible */
.display-mode.coffee-visible .stars-display {
    position: relative;
    z-index: 25;
    top: 3px;
}

/* Score Editor (below leaderboard) - DEPRECATED, now in controls panel */
.score-editor {
    display: none; /* Hidden - moved to controls panel */
}

.score-editor label {
    color: #888;
    font-size: 12px;
}

.score-editor select,
.score-editor input {
    padding: 6px 8px;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: white;
    font-size: 13px;
}

.score-editor select {
    width: 60px;
}

.score-editor input {
    width: 50px;
    text-align: center;
}

/* Header bar with embedded labels */
.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to right, #FFD700, #FFA500, #FFD700);
    height: 18px;
    margin: 0;
    border-radius: 0;
    position: relative;
    z-index: 0;
}

.header-label {
    font-size: 11px;
    font-weight: 900;
    color: #CC5500;
    padding: 0 8px;
    text-transform: uppercase;
    text-shadow:
        1px 1px 0 rgba(255,255,255,0.5),
        -1px -1px 0 rgba(0,0,0,0.2);
}

/* ===== MAIN RANKING ROW (4, 2, 1, 3, 5) ===== */
.main-ranking-row {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 0;
    padding: 0;
}

/* ===== BOTTOM ROW (6-12) ===== */
.bottom-ranking-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 3px;
    padding: 0 2px 0 2px;
    flex-wrap: nowrap;
    margin-top: -18px;
}

/* ===== RANKING ENTRY (Base) ===== */
.ranking-entry {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.ranking-entry:hover {
    transform: scale(1.05);
}

.ranking-entry.empty {
    opacity: 0.5;
}

/* ===== TOP 3 MEDAL ENTRIES ===== */
.ranking-entry.top-3 {
    position: relative;
    margin: 0 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* First place - slightly larger and raised */
.ranking-entry.top-3.first {
    margin-top: -3px;
}

.ranking-entry.top-3.first .profile-circle,
.ranking-entry.top-3.first .medal-circle {
    width: 49px;
    height: 49px;
}

/* Border colors to match medal motif */
.ranking-entry.top-3.first .profile-circle {
    border-color: #FFD700;
}

.ranking-entry.top-3.second .profile-circle {
    border-color: #A0A0A0;
    border-width: 2px;
}

.ranking-entry.top-3.third .profile-circle {
    border-color: #CD7F32;
    border-width: 2px;
}

/* Medal/Image + Trophy container */
.medal-image-container {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
    position: relative;
}

/* Wrapper for image and topper together */
.image-topper-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Topper badge (positioned over image like a hat) */
.super-star-area {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

.super-star-badge {
    max-height: 22px;
    max-width: 56px;
}

/* Profile image (shown instead of medal when available) */
.profile-circle {
    width: 47px;
    height: 47px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #FFD700;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* Medal circle - solid colors */
.medal-circle {
    width: 47px;
    height: 47px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.medal-circle.gold {
    background: #FFD700;
    border: 3px solid #B8860B;
}

.medal-circle.silver {
    background: #C0C0C0;
    border: 3px solid #888;
}

.medal-circle.bronze {
    background: #CD7F32;
    border: 3px solid #8B4513;
}

.medal-threshold {
    font-size: 11px;
    font-weight: 900;
    color: #000;
    text-align: center;
}

/* Ribbon topper - 3px higher and 20% smaller than other toppers */
.ribbon-topper {
    top: -13px;
}

.ribbon-topper .super-star-badge {
    max-height: 18px;
    max-width: 45px;
}

/* Trophy container (rank + trophy stacked) */
.trophy-container {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    width: 17px;
}

/* Rank number above trophy */
.rank-number {
    font-size: 16px;
    font-weight: 900;
    text-shadow: 1px 1px 1px rgba(255,255,255,0.8);
}

.rank-number.rank-1 {
    color: #B8860B;
}

.rank-number.rank-2 {
    color: #757575;
}

.rank-number.rank-3 {
    color: #8B4513;
}

/* Trophy icon */
.trophy-icon {
    font-size: 20px;
    line-height: 1;
}

/* Name under medal */
.ranking-name {
    font-size: 11px;
    font-weight: 900;
    color: #000;
    margin-top: 0;
    text-shadow:
        -1px -1px 0 #FFD700,
        1px -1px 0 #FFD700,
        -1px 1px 0 #FFD700,
        1px 1px 0 #FFD700;
    white-space: nowrap;
}

/* Flag next to name */
.ranking-flag {
    margin-left: 0;
    font-size: 9px;
    position: relative;
    top: -1px;
}

/* Coins under name */
.ranking-coins {
    font-size: 12px;
    font-weight: 900;
    color: #006400;
    margin-top: -5px;
}

/* ===== SIDE ENTRIES (#4 and #5) - Star style ===== */
.ranking-entry.side {
    position: relative;
    width: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 5px;
    margin-top: 8px;
}

/* #4 position - move right 3px */
.main-ranking-row .ranking-entry.side:first-child {
    margin-right: -3px;
}

/* #5 position - move left 3px */
.main-ranking-row .ranking-entry.side:last-child {
    margin-left: -3px;
}

.side-star-bg {
    font-size: 51px;
    line-height: 1;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 0;
    opacity: 0.4;
    color: #FFA500;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.side-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.side-rank {
    font-size: 15px;
    font-weight: 900;
    color: #555;
    text-shadow: 1px 1px 0 #fff;
}

.side-name {
    font-size: 12px;
    font-weight: 900;
    color: #000;
    white-space: nowrap;
    margin-top: -7px;
}

.side-coins {
    font-size: 12px;
    font-weight: 900;
    color: #006400;
    margin-top: -6px;
    text-shadow:
        -1px -1px 0 #fff,
        1px -1px 0 #fff,
        -1px 1px 0 #fff,
        1px 1px 0 #fff;
}

/* Side entry toppers */
.side-topper-area {
    position: absolute;
    top: -7px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

.side-topper-badge {
    max-width: 29px;
    max-height: 29px;
}

.side-badge-text {
    font-size: 10px;
    font-weight: 900;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #8B4513;
    padding: 2px 4px;
    border-radius: 3px;
    text-align: center;
}

.side-badge-text.king { font-size: 16px; background: transparent; }
.side-badge-text.super { background: linear-gradient(135deg, #4169E1, #1E90FF); color: #fff; }
.side-badge-text.double { background: linear-gradient(135deg, #9400D3, #FF1493); color: #fff; }
.side-badge-text.supreme { background: linear-gradient(135deg, #FFD700, #FF4500); color: #fff; }

/* ===== BOTTOM STAR ENTRIES (6-12) ===== */
.ranking-entry.bottom-star {
    position: relative;
    width: 48px;
    height: 55px;
    flex-shrink: 0;
}

/* Move #6 and #12 up to create circular shape */
.bottom-ranking-row .ranking-entry.bottom-star:first-child,
.bottom-ranking-row .ranking-entry.bottom-star:last-child {
    margin-top: -8px;
}

/* Move #8, #9, #10 down to create circular shape */
.bottom-ranking-row .ranking-entry.bottom-star:nth-child(3),
.bottom-ranking-row .ranking-entry.bottom-star:nth-child(4),
.bottom-ranking-row .ranking-entry.bottom-star:nth-child(5) {
    margin-top: 5px;
}

.star-background {
    font-size: 43px;
    line-height: 1;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 0;
    opacity: 0.4;
    color: #FFA500;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.star-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.star-rank {
    font-size: 13px;
    font-weight: 900;
    color: #555;
    text-shadow: 1px 1px 0 #fff;
}

.star-name {
    font-size: 10px;
    font-weight: 900;
    color: #000;
    white-space: nowrap;
    margin-top: -6px;
}

.star-coins {
    font-size: 10px;
    font-weight: 900;
    color: #006400;
    margin-top: -5px;
    text-shadow:
        -1px -1px 0 #fff,
        1px -1px 0 #fff,
        -1px 1px 0 #fff,
        1px 1px 0 #fff;
}

/* Bottom star toppers */
.star-topper-area {
    position: absolute;
    top: -3px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

/* 6 and 12 toppers move up 1px more */
.bottom-ranking-row .ranking-entry.bottom-star:first-child .star-topper-area,
.bottom-ranking-row .ranking-entry.bottom-star:last-child .star-topper-area {
    top: -4px;
}

.star-topper-badge {
    max-width: 20px;
    max-height: 20px;
}

.star-badge-text {
    font-size: 8px;
    font-weight: 900;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #8B4513;
    padding: 1px 3px;
    border-radius: 2px;
    text-align: center;
}

.star-badge-text.king { font-size: 14px; background: transparent; }
.star-badge-text.super { background: linear-gradient(135deg, #4169E1, #1E90FF); color: #fff; }
.star-badge-text.double { background: linear-gradient(135deg, #9400D3, #FF1493); color: #fff; }
.star-badge-text.supreme { background: linear-gradient(135deg, #FFD700, #FF4500); color: #fff; }

/* ===== BOTTOM DISPLAY ROW (Goal left, Stars right) ===== */
.bottom-display-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-top: 2px;
}

/* ===== GOAL DISPLAY (Hangs Below Leaderboard, Left Side) ===== */
.goal-display {
    width: 75px;
    height: 18px;
    background-image: url('../uploads/goalbg.png');
    background-size: 100% 100%;
    background-position: center center;
    background-repeat: no-repeat;
    display: none;
    align-items: center;
    justify-content: center;
    margin-left: 0;
    margin-top: 0;
    transform-origin: left top;
    overflow: hidden;
}

/* ===== STARS DISPLAY (Bottom Right, Opposite Goal) ===== */
.stars-display {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 8px;
    margin-right: 0;
    margin-top: -3px;
}

.star-entry {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    overflow: visible;
}

.star-entry-name {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 8px;
    font-weight: 900;
    color: #000;
    text-shadow:
        -1px -1px 0 #FFD700,
        1px -1px 0 #FFD700,
        -1px 1px 0 #FFD700,
        1px 1px 0 #FFD700;
    white-space: nowrap;
    z-index: 2;
}

.star-entry-image {
    width: 28px;
    height: 28px;
    object-fit: contain;
    z-index: 1;
}

/* Star count circle */
.star-count-circle {
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 12px;
    background: #fff;
    border: 1px solid #000;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: 900;
    color: #000;
    z-index: 3;
    padding-bottom: 1px;
}

/* Today's stars have a subtle glow */
.star-entry.today .star-entry-image {
    filter: drop-shadow(0 0 3px rgba(255, 0, 0, 0.8));
}

/* ===== COFFEE BOARD (Over Star #12) ===== */
.coffee-board {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 75px;
    background: rgba(255, 248, 240, 0.98);
    border: 2px solid #ddd;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    overflow: visible;
    z-index: 20;
    box-shadow: 2px 2px 6px rgba(0,0,0,0.3);
}

.coffee-float {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 8px;
    max-width: 40px;
    height: auto;
    opacity: 0.6;
}

.coffee-board-title {
    background: #DDD;
    color: #000;
    text-align: center;
    padding: 1px 2px;
    font-size: 9px;
    font-weight: bold;
    white-space: nowrap;
    border-bottom: 1px solid #ccc;
}

.coffee-board-content {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1px;
    gap: 1px;
}

.coffee-avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.coffee-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #ddd;
}

.coffee-flag {
    display: none;
}

.coffee-info-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.1;
}

.coffee-name {
    font-size: 9px;
    font-weight: bold;
    color: #000;
    text-shadow: -1px -1px 0 #FFD700, 1px -1px 0 #FFD700, -1px 1px 0 #FFD700, 1px 1px 0 #FFD700;
    white-space: nowrap;
}

.coffee-amount {
    font-size: 9px;
    font-weight: bold;
    color: #fff;
    text-shadow: -1px -1px 0 #c00, 1px -1px 0 #c00, -1px 1px 0 #c00, 1px 1px 0 #c00;
    white-space: nowrap;
}

.coffee-date {
    font-size: 7px;
    color: #000;
    white-space: nowrap;
}

/* Toggle Coffee Button */
.btn-toggle-coffee {
    display: inline-block;
    padding: 4px 8px;
    background: linear-gradient(180deg, #666, #444);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
}

.btn-toggle-coffee:hover {
    background: linear-gradient(180deg, #777, #555);
}

.btn-toggle-coffee.active {
    background: linear-gradient(180deg, #228B22, #006400);
}

/* ===== INLINE SCORE EDITOR (inside controls panel) ===== */
.score-editor-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.score-editor-inline select,
.score-editor-inline input[type="number"] {
    padding: 8px;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: white;
    font-size: 14px;
    width: 65px;
}

.score-editor-inline input[type="text"] {
    padding: 8px;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: white;
    font-size: 14px;
    flex: 1;
    min-width: 100px;
}

/* ===== STARS MANAGEMENT UI ===== */
.stars-section {
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
    margin-top: 10px;
}

.stars-management {
    background: var(--background);
    border-radius: 8px;
    padding: 12px;
}

.today-stars-label {
    font-size: 12px;
    color: #cc3333;
    margin-bottom: 6px;
    font-weight: bold;
}

.today-stars-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.today-star-item {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--surface);
    border: 1px solid #cc3333;
    border-radius: 6px;
    padding: 4px 8px;
}

.today-star-img {
    width: 18px;
    height: 18px;
}

.today-star-name {
    font-size: 12px;
    color: #fff;
    font-weight: 600;
}

.stars-add-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.stars-add-row .input-search {
    flex: 1;
}

.btn-add-star {
    padding: 8px 12px;
    background: var(--secondary-color);
    border: none;
    border-radius: 6px;
    color: var(--background);
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    white-space: nowrap;
}

.btn-add-star:hover {
    opacity: 0.9;
}

.stars-user-results {
    display: none;
    background: var(--surface);
    border-radius: 6px;
    margin-bottom: 10px;
    max-height: 120px;
    overflow-y: auto;
}

.stars-user-results.active {
    display: block;
}

.stars-user-item {
    padding: 8px 12px;
    cursor: pointer;
    color: #fff;
    font-size: 13px;
    border-bottom: 1px solid var(--border-color);
}

.stars-user-item:last-child {
    border-bottom: none;
}

.stars-user-item:hover {
    background: var(--border-color);
}

.historical-stars-label {
    font-size: 12px;
    color: #888;
    margin-bottom: 6px;
    margin-top: 10px;
}

.historical-stars-list {
    background: var(--surface);
    border-radius: 6px;
    padding: 8px;
    max-height: 100px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.no-stars {
    color: #666;
    font-size: 12px;
    text-align: center;
    padding: 8px;
}

.historical-star-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    background: var(--background);
    border-radius: 4px;
    margin-bottom: 4px;
}

.historical-star-item:last-child {
    margin-bottom: 0;
}

.star-item-name {
    color: #fff;
    font-size: 13px;
}

.btn-remove-star {
    background: transparent;
    border: none;
    color: #ff6666;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.btn-remove-star:hover {
    color: #ff0000;
}

.stars-reset-row {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.btn-reset-stars {
    flex: 1;
    padding: 8px 10px;
    background: var(--border-color);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    cursor: pointer;
}

.btn-reset-stars:hover {
    background: #444;
    color: white;
}

.btn-reset-stars.danger {
    background: #440000;
    border-color: #880000;
    color: #ff8888;
}

.btn-reset-stars.danger:hover {
    background: #660000;
    color: #ffaaaa;
}

/* Toggle stars button */
.btn-toggle-stars {
    width: 100%;
    padding: 8px;
    background: var(--primary-color);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 10px;
}

.btn-toggle-stars:hover {
    opacity: 0.9;
}

.btn-toggle-stars.active {
    background: var(--secondary-color);
}

/* Color selector for adding stars */
.star-color-add {
    width: 60px;
    padding: 6px 2px;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: white;
    font-size: 12px;
    cursor: pointer;
}

/* Historical star item with count and color */
.historical-star-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    background: var(--background);
    border-radius: 4px;
    margin-bottom: 4px;
}

.star-item-name {
    flex: 1;
    color: #fff;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.star-count-input {
    width: 55px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: white;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
}

.star-color-select {
    width: 52px;
    padding: 4px 2px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: white;
    font-size: 11px;
    cursor: pointer;
}

.goal-text {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 7px;
    font-weight: 600 !important;
    color: #fff;
    text-align: center;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
    position: relative;
    top: 0px;
    left: -2px;
}

/* Slider styling */
.slider-input {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-color);
    border-radius: 4px;
    outline: none;
    margin: 10px 0;
}

.slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--secondary-color);
    border-radius: 50%;
    cursor: pointer;
}

.slider-input::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--secondary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Editor divider */
.editor-divider {
    width: 1px;
    height: 20px;
    background: var(--border-color);
    margin: 0 8px;
}

/* Goal input styling */
#goalInput {
    width: 130px;
    padding: 6px 8px;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: white;
    font-size: 13px;
    text-align: center;
}

/* Goal update button */
.btn-goal-update {
    padding: 6px 10px;
    background: var(--secondary-color);
    border: none;
    border-radius: 4px;
    color: var(--background);
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-goal-update:hover {
    opacity: 0.8;
}

/* ===== TOPPER TEXT BADGES (fallback) ===== */
.super-badge-text {
    font-size: 12px;
    font-weight: 900;
    background: linear-gradient(135deg, #4169E1, #1E90FF);
    color: #fff;
    padding: 3px 8px;
    border-radius: 5px;
    text-align: center;
    line-height: 1.2;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.super-badge-text.king {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #8B4513;
    font-size: 20px;
    padding: 0;
    background: transparent;
    text-shadow: none;
}

.super-badge-text.super {
    background: linear-gradient(135deg, #4169E1, #1E90FF);
}

.super-badge-text.double {
    background: linear-gradient(135deg, #9400D3, #FF1493);
}

.super-badge-text.supreme {
    background: linear-gradient(135deg, #FFD700, #FF4500);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

/* ===== EDIT MODE (Controls) ===== */
.edit-mode {
    background: var(--surface);
    border-radius: 10px;
    padding: 10px;
    margin-top: 35px;
    margin-bottom: 20px;
}

.toggle-controls-btn {
    display: none;
}

.toggle-controls-btn:hover {
    opacity: 0.9;
}

#toggleIcon {
    transition: transform 0.3s;
}

#toggleIcon.open {
    transform: rotate(180deg);
}

.controls-panel {
    padding: 15px 10px 5px;
    display: block !important;
}

.control-section {
    margin-bottom: 15px;
}

.control-section label {
    display: block;
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 6px;
}

/* Input Styles */
.input-search,
.input-text,
.input-amount {
    width: 100%;
    padding: 10px;
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: white;
    font-size: 15px;
}

.input-search:focus,
.input-text:focus,
.input-amount:focus {
    outline: none;
    border-color: var(--secondary-color);
}

.input-amount {
    text-align: center;
    font-size: 18px;
    font-weight: bold;
}

/* Buttons */
.btn-small {
    padding: 8px 15px;
    background: var(--secondary-color);
    border: none;
    border-radius: 6px;
    color: var(--background);
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 5px;
}

.btn-add-supporter {
    width: 100%;
    padding: 10px;
    background: var(--primary-color);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 8px;
}

.btn-submit {
    width: 100%;
    padding: 12px;
    background: #00ff88;
    border: none;
    border-radius: 8px;
    color: var(--background);
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
}

.action-buttons-row {
    display: flex;
    gap: 8px;
    margin-top: 15px;
}

.btn-secondary {
    flex: 1;
    padding: 8px 12px;
    background: var(--border-color);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #444;
    color: white;
}

/* Distinct control sections */
.action-section,
.tool-section,
.rank-goal-section {
    background: var(--background);
    border-radius: 8px;
    padding: 12px;
    margin-top: 10px;
}

.action-section {
    border-left: 3px solid var(--primary-color);
}

.tool-section {
    border-left: 3px solid var(--secondary-color);
}

.rank-goal-section {
    border-left: 3px solid #ffa500;
}

/* Rank & Goal header with button */
.rank-goal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.rank-goal-header label {
    margin-bottom: 0;
}

/* Checkbox row for hide rank */
.rank-hide-row {
    margin-bottom: 8px;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #ffa500;
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
    position: relative;
    top: -5px;
}

.checkbox-label span {
    line-height: 1;
    position: relative;
    top: -5px;
}

.btn-tool-link {
    display: block;
    width: 100%;
    padding: 10px;
    background: var(--border-color);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-tool-link:hover {
    background: var(--secondary-color);
    color: var(--background);
}

.btn-clear {
    padding: 6px 12px;
    background: var(--border-color);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 13px;
    cursor: pointer;
}

/* Supporter Search Results */
.supporter-results {
    max-height: 200px;
    overflow-y: auto;
    display: none;
    margin-top: 8px;
}

.supporter-results.active {
    display: block;
}

.supporter-item {
    display: flex;
    align-items: center;
    padding: 10px;
    background: var(--background);
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.supporter-item:hover {
    background: var(--border-color);
    transform: translateX(3px);
}

.supporter-avatar-small {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    margin-right: 10px;
    object-fit: cover;
    background: var(--border-color);
}

.supporter-name {
    flex: 1;
    font-size: 15px;
    color: white;
}

.supporter-stats {
    font-size: 11px;
    color: var(--text-light);
}

/* Edit button in search results */
.btn-edit-supporter {
    background: transparent;
    border: 1px solid var(--secondary-color);
    color: var(--secondary-color);
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 14px;
    margin-left: 8px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-edit-supporter:hover {
    background: var(--secondary-color);
    color: var(--background);
}

/* Selected Supporter */
.selected-supporter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: var(--background);
    border: 2px solid var(--secondary-color);
    border-radius: 8px;
    margin-top: 10px;
}

.supporter-info {
    display: flex;
    align-items: center;
}

.supporter-info span {
    color: white;
    font-weight: bold;
}

/* Currency Switch */
.currency-switch {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.currency-btn {
    flex: 1;
    padding: 10px;
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: white;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.currency-btn.active {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    color: var(--background);
    font-weight: bold;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: 15px;
    padding: 25px;
    padding-bottom: 100px; /* Extra space for iOS Safari bottom bar */
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    max-height: 80dvh; /* Dynamic viewport height for mobile browsers */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: var(--secondary-color);
}

.modal-content label {
    display: block;
    font-size: 13px;
    color: #cccccc;
    margin-bottom: 6px;
    margin-top: 10px;
}

.image-upload {
    margin: 15px 0;
}

.upload-label {
    display: block;
    cursor: pointer;
}

.image-preview {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: var(--background);
    border: 2px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    overflow: hidden;
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview span {
    color: var(--text-light);
    font-size: 13px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.btn-cancel {
    flex: 1;
    padding: 10px;
    background: var(--border-color);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 15px;
    cursor: pointer;
}

.btn-remove {
    width: 100%;
    padding: 10px;
    background: #cc0000;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 15px;
}

.btn-remove:hover {
    background: #aa0000;
}

.btn-delete {
    width: 100%;
    padding: 10px;
    background: #660000;
    border: 2px solid #cc0000;
    border-radius: 8px;
    color: #ff6666;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 15px;
    transition: all 0.2s;
}

.btn-delete:hover {
    background: #cc0000;
    color: white;
}

/* Toggle label for settings */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 10px 0;
}

.toggle-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.toggle-label span {
    color: #fff;
    font-size: 14px;
}

.modal-buttons .btn-submit {
    flex: 1;
}

/* Modal Tabs */
.modal-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.modal-tab {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-tab.active {
    color: var(--secondary-color);
    border-bottom-color: var(--secondary-color);
}

.modal-tab:hover {
    color: rgba(255, 255, 255, 0.8);
}

.modal-tab-content {
    display: none;
}

.modal-tab-content.active {
    display: block;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}
