/* style.css */
@font-face {
    font-family: 'shag';
    src: url('shag.ttf') format('truetype');
    font-display: swap;
    font-weight: normal;
    font-style: normal;
}

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

body {
    font-family: 'shag', sans-serif;
    background-color: #f0f4f8;
    color: #1f2937;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    min-height: 100vh;
    padding: 16px;
    margin: 0;
    -webkit-text-size-adjust: 100%;
}

h1 {
    font-family: 'shag', sans-serif;
    font-size: clamp(1.5rem, 5vw, 2rem);
    color: #111827;
    margin-bottom: 20px;
    text-align: center;
    letter-spacing: 0.5px;
    word-wrap: break-word;
    width: 100%;
    max-width: 800px;
}

.user-info {
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: clamp(12px, 2vw, 20px);
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 800px;
}

.user-info > div {
    text-align: center;
}

.user-info > div > div:first-child {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 4px;
}

.user-info > div > div:last-child {
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    font-weight: 700;
    color: #111827;
}

.coin-display {
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    font-weight: 700;
    color: #3b82f6;
    word-break: break-word;
}

.gamble-button {
    display: block;
    width: 100%;
    max-width: 800px;
    padding: clamp(14px, 2.5vw, 18px);
    background: linear-gradient(#0096EE, #00ADF5);
    box-shadow: inset 0px -3px #0096EE;
    border: 3px solid #006ABA;
    border-radius: 8px;
    color: white;
    font-size: clamp(1rem, 2.5vw, 1.1rem);
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    text-align: center;
    font-family: 'shag', sans-serif;
    margin: 0 0 20px 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.gamble-button:hover {
    background: linear-gradient(#0088DD, #0099EE);
}

.gamble-button:active {
    transform: scale(0.98);
}

.gamble-button:disabled {
    background: #ACACAC;
    box-shadow: inset 0px -3px #9D9D9D;
    border: 2.5px solid #868686;
    cursor: not-allowed;
    transform: none;
}

.gamble-button:disabled:hover {
    background: #ACACAC;
}

.result-display {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: clamp(16px, 3vw, 24px);
    margin: 0 0 20px 0;
    min-height: clamp(100px, 20vh, 120px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    width: 100%;
    max-width: 800px;
}

.won-item {
    font-size: clamp(1.2rem, 4vw, 1.5rem);
    color: #3b82f6;
    margin: 5px 0;
    font-weight: 600;
    word-wrap: break-word;
    max-width: 100%;
}

.rarity-boil {
    color: #FFC10E;
    paint-order: stroke fill;
    -webkit-text-stroke: 5px #8E3703;
}

.inventory-item.rarity-boil {
    color: #FFC10E;
    paint-order: stroke fill;
    -webkit-text-stroke: 3px #8E3703;
}

.inventory-item.rarity-boil small {
    color: #612F01;
    -webkit-text-stroke: 3px transparent;
    font-weight: bold;
}

.won-item.rarity-boil + div {
    color: #612F01;
    -webkit-text-stroke: 3px transparent;
    font-weight: bold;
}

.rarity-uncommon {
    color: #22c55e;
}

.rarity-rare {
    color: #3b82f6;
}

.rarity-epic {
    color: #8b5cf6;
}

.rarity-legendary {
    color: #f59e0b;
}

.rarity-ultra {
    background: linear-gradient(
        to right,
        #ff0000,
        #ff8800,
        #ffff00,
        #00ff00,
        #0088ff,
        #8b00ff,
        #ff0000
    );
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: rainbow-shift 3s linear infinite;
}

@keyframes rainbow-shift {
    0% { background-position: 0% 50%; }
    100% { background-position: 300% 50%; }
}

.inventory-item .rarity-ultra {
    background: linear-gradient(
        to right,
        #ff0000,
        #ff8800,
        #ffff00,
        #00ff00,
        #0088ff,
        #8b00ff,
        #ff0000
    );
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: rainbow-shift 3s linear infinite;
}

@keyframes rainbow-shift {
    0% { background-position: 0% 50%; }
    100% { background-position: 300% 50%; }
}

.inventory-item.rarity-ultra .item-name {
    display: inline-block;
    color: #ff0000;
    background: linear-gradient(
        to right,
        #ff0000,
        #ff8800,
        #ffff00,
        #00ff00,
        #0088ff,
        #8b00ff,
        #ff0000
    );
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: rainbow-shift 3s linear infinite;
}

.inventory-item.rarity-ultra small {
    color: #616161;
}

.inventory {
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: clamp(16px, 3vw, 20px);
    width: 100%;
    max-width: 800px;
}

.inventory h2 {
    font-family: 'shag', sans-serif;
    font-size: clamp(1.1rem, 3vw, 1.25rem);
    color: #111827;
    margin-bottom: 16px;
    text-align: center;
    letter-spacing: 0.5px;
}

.inventory-items {
    display: flex;
    flex-wrap: wrap;
    gap: clamp(8px, 2vw, 12px);
    justify-content: center;
}

.inventory-item {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: clamp(6px, 1.5vw, 10px) clamp(10px, 2vw, 14px);
    min-width: clamp(80px, 20vw, 120px);
    text-align: center;
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    word-break: break-word;
}

@media (max-width: 480px) {
    body {
        padding: 8px;
    }
    
    h1 {
        font-size: 1.3rem;
        margin-bottom: 16px;
    }
    
    .user-info {
        flex-direction: column;
        gap: 8px;
        padding: 12px;
        margin-bottom: 16px;
    }
    
    .user-info > div > div:last-child {
        font-size: 1.1rem;
    }
    
    .gamble-button {
        padding: 14px 10px;
        font-size: 0.95rem;
        margin-bottom: 16px;
        border-width: 2px;
    }
    
    .result-display {
        min-height: 80px;
        padding: 14px;
        margin-bottom: 16px;
    }
    
    .inventory {
        padding: 14px;
    }
    
    .inventory-item {
        min-width: 70px;
        padding: 6px 8px;
        font-size: 0.75rem;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    body {
        padding: 12px;
    }
    
    .user-info {
        gap: 12px;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    body {
        padding: 8px 16px;
    }
    
    h1 {
        font-size: 1.2rem;
        margin-bottom: 10px;
    }
    
    .user-info {
        padding: 8px 16px;
        margin-bottom: 10px;
        gap: 8px;
    }
    
    .user-info > div > div:last-child {
        font-size: 1rem;
    }
    
    .result-display {
        min-height: 60px;
        padding: 10px;
        margin-bottom: 10px;
    }
    
    .gamble-button {
        padding: 10px;
        margin-bottom: 10px;
        font-size: 0.85rem;
    }
    
    .inventory {
        padding: 10px;
    }
    
    .inventory-items {
        gap: 6px;
    }
    
    .inventory-item {
        min-width: 60px;
        padding: 4px 6px;
        font-size: 0.7rem;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    body {
        padding: 20px;
    }
}

@media (min-width: 1025px) {
    body {
        padding: 30px;
    }
}

@media (hover: none) and (pointer: coarse) {
    .gamble-button {
        min-height: 48px;
        min-width: 48px;
    }
    
    .gamble-button:hover {
        background: linear-gradient(#0096EE, #00ADF5);
    }
    
    .gamble-button:active {
        transform: scale(0.97);
        background: linear-gradient(#0088DD, #0099EE);
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (max-width: 320px) {
    body {
        padding: 4px;
    }
    
    h1 {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }
    
    .user-info {
        flex-direction: column;
        gap: 4px;
        padding: 8px;
        margin-bottom: 12px;
    }
    
    .user-info > div > div:last-child {
        font-size: 0.9rem;
    }
    
    .gamble-button {
        padding: 12px 8px;
        font-size: 0.85rem;
        margin-bottom: 12px;
    }
    
    .result-display {
        min-height: 60px;
        padding: 10px;
        margin-bottom: 12px;
    }
    
    .inventory {
        padding: 10px;
    }
    
    .inventory-item {
        min-width: 55px;
        padding: 4px 6px;
        font-size: 0.65rem;
    }
}