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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

#app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

h1 {
    color: #333;
    font-size: 2em;
}

#wallet-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

#user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

#wallet-address {
    font-family: monospace;
    background: #f0f0f0;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.9em;
}

#coin-balance {
    font-weight: bold;
    color: #f39c12;
}

.btn-primary, .btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

main {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.welcome-section {
    text-align: center;
    padding: 60px 20px;
}

.welcome-section h2 {
    margin-bottom: 20px;
    color: #333;
}

.game-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid #ecf0f1;
    padding-bottom: 15px;
}

.nav-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.3s ease;
    font-weight: bold;
}

.nav-btn.active {
    background: #3498db;
    color: white;
}

.nav-btn:hover:not(.active) {
    background: #ecf0f1;
}

.section {
    display: none;
}

.section.active {
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h3 {
    color: #333;
}

.offers-grid, .inventory-grid, .market-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.offer-card, .item-card, .listing-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.offer-card:hover, .item-card:hover, .listing-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.npc-info {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
}

.npc-name {
    font-weight: bold;
    color: #2c3e50;
}

.npc-personality {
    font-size: 0.9em;
    color: #7f8c8d;
    font-style: italic;
}

.item-info {
    margin-bottom: 15px;
}

.item-name {
    font-weight: bold;
    font-size: 1.1em;
    color: #2c3e50;
}

.item-category {
    color: #7f8c8d;
    font-size: 0.9em;
}

.item-rarity {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: bold;
    margin: 5px 0;
}

.rarity-common { background: #95a5a6; color: white; }
.rarity-uncommon { background: #27ae60; color: white; }
.rarity-rare { background: #3498db; color: white; }
.rarity-epic { background: #9b59b6; color: white; }
.rarity-legendary { background: #f39c12; color: white; }

.condition-bar {
    width: 100%;
    height: 20px;
    background: #ecf0f1;
    border-radius: 10px;
    overflow: hidden;
    margin: 10px 0;
}

.condition-fill {
    height: 100%;
    background: linear-gradient(90deg, #e74c3c 0%, #f39c12 50%, #27ae60 100%);
    transition: width 0.3s ease;
}

.price-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
}

.ask-price {
    font-weight: bold;
    color: #e74c3c;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: bold;
}

.status-new { background: #2ecc71; color: white; }
.status-in-progress { background: #f39c12; color: white; }
.status-sold { background: #95a5a6; color: white; }
.status-declined { background: #e74c3c; color: white; }
.status-bought { background: #27ae60; color: white; }
.status-withdrawn { background: #c0392b; color: white; }

.patience-indicator {
    margin-top: 8px;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 5px;
}

.patience-dots {
    font-size: 1.2em;
}

.patience-warning {
    color: #e74c3c;
    font-weight: bold;
    animation: pulse 1s infinite;
}

.patience-status {
    margin: 10px 0;
    text-align: center;
    font-size: 1.1em;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.card-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.card-actions button {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
}

.item-clickable {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.item-clickable:hover {
    background-color: rgba(52, 152, 219, 0.1);
    border-radius: 5px;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-content h3 {
    margin-bottom: 20px;
    color: #333;
}

.bargain-form, .repair-form, .listing-form {
    margin-top: 20px;
}

.bargain-form label, .repair-form label, .listing-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.bargain-form input, .repair-form input, .listing-form input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-bottom: 15px;
    font-size: 1em;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-actions button {
    flex: 1;
}

#bargain-result {
    margin-top: 20px;
    padding: 15px;
    border-radius: 5px;
    display: none;
}

.result-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.result-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.result-counter {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.leaderboard-tabs {
    display: flex;
    gap: 10px;
}

.tab-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 5px;
    font-weight: bold;
}

.tab-btn.active {
    background: #3498db;
    color: white;
}

.market-tabs {
    display: flex;
    gap: 10px;
}

.market-tab-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 5px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.market-tab-btn.active {
    background: #3498db;
    color: white;
}

.market-tab-btn:hover {
    background: #2980b9;
    color: white;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.leaderboard-table th {
    background: #f8f9fa;
    font-weight: bold;
}

.leaderboard-table tr:hover {
    background: #f8f9fa;
}

.ownership-history {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 10px;
}

.ownership-entry {
    padding: 8px;
    border-bottom: 1px solid #eee;
    font-size: 0.9em;
}

.ownership-entry:last-child {
    border-bottom: none;
}

.ownership-entry div {
    margin: 2px 0;
}

.own-listing {
    border: 2px solid #27ae60;
    background: rgba(39, 174, 96, 0.05);
    position: relative;
}

.own-listing::before {
    content: "YOUR LISTING";
    position: absolute;
    top: 10px;
    right: 10px;
    background: #27ae60;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75em;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.ownership-toggle {
    user-select: none;
}

.ownership-toggle:hover {
    color: #3498db;
}

.ownership-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding: 10px;
    border-top: 1px solid #eee;
}

.ownership-pagination button {
    padding: 5px 10px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.9em;
}

.ownership-pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ownership-page-info {
    font-size: 0.9em;
    color: #666;
}

#loading {
    text-align: center;
    padding: 40px;
    font-size: 1.2em;
    color: #666;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 5px;
    margin: 20px 0;
    border: 1px solid #f5c6cb;
}

.success-message {
    background: #d4edda;
    color: #155724;
    padding: 15px;
    border-radius: 5px;
    margin: 20px 0;
    border: 1px solid #c3e6cb;
}

/* Condition width classes - 100% CSP compliant */
.condition-fill { width: 0%; } /* default */
.cw-0  { width: 0% } .cw-1  { width: 1% } .cw-2  { width: 2% } .cw-3  { width: 3% } .cw-4  { width: 4% }
.cw-5  { width: 5% } .cw-6  { width: 6% } .cw-7  { width: 7% } .cw-8  { width: 8% } .cw-9  { width: 9% }
.cw-10 { width: 10% } .cw-11 { width: 11% } .cw-12 { width: 12% } .cw-13 { width: 13% } .cw-14 { width: 14% }
.cw-15 { width: 15% } .cw-16 { width: 16% } .cw-17 { width: 17% } .cw-18 { width: 18% } .cw-19 { width: 19% }
.cw-20 { width: 20% } .cw-21 { width: 21% } .cw-22 { width: 22% } .cw-23 { width: 23% } .cw-24 { width: 24% }
.cw-25 { width: 25% } .cw-26 { width: 26% } .cw-27 { width: 27% } .cw-28 { width: 28% } .cw-29 { width: 29% }
.cw-30 { width: 30% } .cw-31 { width: 31% } .cw-32 { width: 32% } .cw-33 { width: 33% } .cw-34 { width: 34% }
.cw-35 { width: 35% } .cw-36 { width: 36% } .cw-37 { width: 37% } .cw-38 { width: 38% } .cw-39 { width: 39% }
.cw-40 { width: 40% } .cw-41 { width: 41% } .cw-42 { width: 42% } .cw-43 { width: 43% } .cw-44 { width: 44% }
.cw-45 { width: 45% } .cw-46 { width: 46% } .cw-47 { width: 47% } .cw-48 { width: 48% } .cw-49 { width: 49% }
.cw-50 { width: 50% } .cw-51 { width: 51% } .cw-52 { width: 52% } .cw-53 { width: 53% } .cw-54 { width: 54% }
.cw-55 { width: 55% } .cw-56 { width: 56% } .cw-57 { width: 57% } .cw-58 { width: 58% } .cw-59 { width: 59% }
.cw-60 { width: 60% } .cw-61 { width: 61% } .cw-62 { width: 62% } .cw-63 { width: 63% } .cw-64 { width: 64% }
.cw-65 { width: 65% } .cw-66 { width: 66% } .cw-67 { width: 67% } .cw-68 { width: 68% } .cw-69 { width: 69% }
.cw-70 { width: 70% } .cw-71 { width: 71% } .cw-72 { width: 72% } .cw-73 { width: 73% } .cw-74 { width: 74% }
.cw-75 { width: 75% } .cw-76 { width: 76% } .cw-77 { width: 77% } .cw-78 { width: 78% } .cw-79 { width: 79% }
.cw-80 { width: 80% } .cw-81 { width: 81% } .cw-82 { width: 82% } .cw-83 { width: 83% } .cw-84 { width: 84% }
.cw-85 { width: 85% } .cw-86 { width: 86% } .cw-87 { width: 87% } .cw-88 { width: 88% } .cw-89 { width: 89% }
.cw-90 { width: 90% } .cw-91 { width: 91% } .cw-92 { width: 92% } .cw-93 { width: 93% } .cw-94 { width: 94% }
.cw-95 { width: 95% } .cw-96 { width: 96% } .cw-97 { width: 97% } .cw-98 { width: 98% } .cw-99 { width: 99% }
.cw-100 { width: 100% }

/* Listed item indicator */
.item-listed {
    color: #4CAF50;
    font-weight: bold;
}

/* Insufficient coins warning */
.insufficient-coins {
    color: red;
}

/* Success message inline */
.success-inline {
    color: green;
}

/* Error message inline */
.error-inline {
    color: red;
}

/* Ownership section styles */
.ownership-section {
    margin-top: 20px;
}

.ownership-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
}

.toggle-arrow {
    margin-left: 10px;
}

.ownership-history-container {
    display: none;
}

/* Display utility classes - CSP compliant */
.hidden { display: none !important; }
.show-block { display: block !important; }
.show-flex { display: flex !important; }
.show-inline { display: inline !important; }

/* Modal result states - emniyet kemeri */
#bargain-result.result-success,
#bargain-result.result-counter,
#bargain-result.result-error { display: block; }

@media (max-width: 768px) {
    #app {
        padding: 10px;
    }
    
    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .game-nav {
        flex-wrap: wrap;
    }
    
    .offers-grid, .inventory-grid, .market-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        padding: 20px;
    }
}