* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f2f5;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.lang-selector {
    position: absolute;
    top: 20px;
    right: 20px;
}

.lang-selector select {
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background-color: white;
    cursor: pointer;
}

.container {
    text-align: center;
    width: 90%;
    max-width: 1200px;
    padding: 20px;
}

h1 {
    color: #333;
    margin-bottom: 30px;
}

.gacha-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
}

@media screen and (max-width: 480px) {
    .container {
        padding: 10px;
        width: 100%;
    }
    .gacha-grid {
        gap: 10px;
    }
    .card {
        width: 145px;
    }
}

/* Badge Container */
.card {
    background-color: transparent;
    width: 150px;
    aspect-ratio: 1 / 1;
    perspective: 1000px;
    cursor: pointer;
}

/* Inner Container */
.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 50%; /* Badge shape */
}

/* Do the flip */
.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-face-down, .card-face-up {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 50%; /* Badge shape */
    overflow: hidden;
}

.card-face-down img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-face-up {
    transform: rotateY(180deg);
    background-color: white;
    border: 1px solid #eee;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0; /* Let image fill the badge */
    box-sizing: border-box;
}

.card-face-up img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Badges usually fill the area */
}

/* Hidden name tooltip or label could be added here if needed, 
   but for a clean badge look we'll keep the image primary */
.card-face-up .name {
    position: absolute;
    bottom: 10%;
    background: rgba(255, 255, 255, 0.8);
    width: 100%;
    font-weight: bold;
    font-size: 0.75em;
    color: #333;
    padding: 2px 0;
    pointer-events: none;
}

.controls {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.control-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.control-row label {
    font-weight: bold;
    color: #555;
}

.control-row select {
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 14px;
}

#draw-btn {
    padding: 10px 20px;
    font-size: 16px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#draw-btn:hover {
    background-color: #0056b3;
}

#share-btn {
    padding: 6px 12px;
    font-size: 13px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#share-btn:hover {
    background-color: #218838;
}

#flip-all-btn {
    padding: 6px 12px;
    font-size: 13px;
    background-color: #17a2b8;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#flip-all-btn:hover {
    background-color: #138496;
}

#stats-btn {
    padding: 6px 12px;
    font-size: 13px;
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#stats-btn:hover {
    background-color: #5a6268;
}

/* Modal Styles */
.modal {
    display: none; 
    position: fixed; 
    z-index: 100; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgb(0,0,0); 
    background-color: rgba(0,0,0,0.4); 
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto; 
    padding: 20px;
    border: 1px solid #888;
    width: 80%; 
    max-width: 600px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ddd;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: #333;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

/* Stats Table */
#stats-table {
    width: 100%;
    border-collapse: collapse;
}

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

#stats-table th {
    background-color: #f2f2f2;
    color: #333;
}

#stats-table tr:hover {
    background-color: #f5f5f5;
}

#reset-stats-btn:hover {
    background-color: #c82333 !important;
}

/* Toast Notification */
.toast {
    visibility: hidden;
    min-width: 250px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 4px;
    padding: 16px;
    position: fixed;
    z-index: 1000;
    left: 50%;
    transform: translateX(-50%);
    bottom: 30px;
    font-size: 17px;
    opacity: 0;
    transition: opacity 0.5s, bottom 0.5s, transform 0.5s;
}

@media screen and (max-width: 600px) {
    .toast {
        width: 80%;
        min-width: unset;
    }
}

.toast.show {
    visibility: visible;
    opacity: 1;
    bottom: 50px;
}
