:root {
    --primary: #f06292;
    --secondary: #9c27b0;
    --background: #f8f5ff;
    --card-bg: #ffffff;
    --text: #333333;
    --border: #e0e0e0;
    --shadow: rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.6;
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
}

h1 {
    text-align: center;
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 2.5rem;
    text-shadow: 1px 1px 3px var(--shadow);
}

#options {
    margin-bottom: 20px;
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 2px 6px var(--shadow);
    padding: 10px 15px 5px 15px;
    border: 1.5px solid var(--border);
}

#options summary {
    font-weight: bold;
    color: var(--secondary);
    cursor: pointer;
    font-size: 1.1em;
}

#options:not([open]) summary {
    margin-bottom: 5px;
}

#options fieldset {
    border: none;
}

#options legend {
    color: var(--secondary);
    font-weight: bold;
}

#options label {
    margin-right: 10px;
    margin-bottom: 4px;
    display: inline-block;
}

#options input[type="checkbox"] {
    margin-right: 5px;
    cursor: pointer;
}

#pony-container {
    background-color: var(--card-bg);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px var(--shadow);
    min-height: 300px;
}

.pony {
    display: block;
    width: 100%;
    min-width: 0;
}

.pony img {
    float: left;
    max-width: 220px;
    max-height: 300px;
    border-radius: 8px;
    margin: 0 20px 8px 0;
    box-shadow: 0 4px 8px var(--shadow);
    flex-shrink: 0;
}

.pony-content {
    min-width: 0;
}

.pony-content h2 {
    color: var(--secondary);
    margin-bottom: 15px;
    text-align: left;
}

.pony-content p {
    margin-bottom: 10px;
    width: 100%;
}

.first-appearance {
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.first-appearance strong {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    height: 100%;
}

.first-appearance div {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-left: 0;
    background-color: #f0f0f0;
    padding: 2px 8px;
    border-radius: 4px;
    text-align: center;
    min-width: 40px;
}

details {
    width: 100%;
    margin-top: 15px;
    border-top: 1px solid var(--border);
    padding-top: 15px;
}

summary {
    cursor: pointer;
    color: var(--secondary);
    font-weight: bold;
    margin-bottom: 10px;
}

details ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    padding-left: 0;
}

details li {
    flex: 0 0 calc(33.333% - 10px);
}

details img {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
}

#new-pony {
    display: block;
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 8px var(--shadow);
}

#new-pony:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px var(--shadow);
}

#new-pony:active {
    transform: translateY(1px);
}

@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .pony img {
        float: none;
        display: block;
        margin: 0 auto 15px auto;
        max-width: 100%;
        height: auto;
    }

    .pony-content h2 {
        text-align: center;
    }

    details li {
        flex: 0 0 calc(50% - 10px);
    }
}

.color {
    display: inline-block;
    min-width: 5.5em;
    height: 2em;
    margin-left: 8px;
    border-radius: 6px;
    border: 1.5px solid var(--border);
    vertical-align: middle;
    text-align: center;
    line-height: 2em;
    font-family: monospace;
    font-size: 1.1em;
    background-color: #eee;
    color: #333;
    cursor: pointer;
    transition: box-shadow 0.2s, border-color 0.2s, background-color 0.2s,
        color 0.2s;
    box-shadow: 0 1px 3px var(--shadow);
    user-select: all;
    padding: 0 0.5em;
    box-sizing: border-box;
    white-space: nowrap;
    position: relative;
}

.color:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px var(--shadow);
}

.color.copied::before,
.color.error::before {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9em;
}

.color.copied::before {
    content: "COPIED";
    background-color: #c8e6c9;
    color: #256029;
    border: 1.5px solid #388e3c;
    box-shadow: 0 0 8px #388e3c55;
    animation: color-copied-fade 2s ease-out;
}

.color.error::before {
    content: "ERROR";
    background-color: #ffcdd2;
    color: #b71c1c;
    border: 1.5px solid #b71c1c;
    box-shadow: 0 0 8px #b71c1c55;
    animation: color-error-shake 0.3s;
}

@keyframes color-copied-fade {
    0% {
        opacity: 0;
    }

    5% {
        opacity: 1;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

@keyframes color-error-shake {
    0% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-3px);
    }

    40% {
        transform: translateX(3px);
    }

    60% {
        transform: translateX(-2px);
    }

    80% {
        transform: translateX(2px);
    }

    100% {
        transform: translateX(0);
    }
}

#pony-container.rolling {
    min-height: 320px;
    pointer-events: none;
    background: linear-gradient(120deg, #f8f5ff 60%, #f3e5f5 100%);
}

.image-or-text-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    min-width: 180px;
    width: 100%;
    height: 300px;
    overflow: hidden;
    transition: background 0.3s;
}

.image-or-text-container img {
    max-width: 180px;
    max-height: 260px;
    border-radius: 8px;
    box-shadow: 0 2px 8px var(--shadow);
    margin: 0;
    float: none;
    display: block;
}

.image-or-text-container p {
    font-size: 1.5rem;
    color: var(--secondary);
    font-weight: bold;
    text-align: center;
    margin: 0;
    width: 100%;
    text-shadow: 0 1px 4px var(--shadow);
    letter-spacing: 1px;
}

#new-pony:disabled,
#new-pony[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(0.2);
    background: linear-gradient(135deg, #bdbdbd, #ce93d8);
    color: #fff;
    box-shadow: 0 2px 4px var(--shadow);
    transform: none;
}

@keyframes rolling-bg-pulse {
    0% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.08);
    }

    100% {
        filter: brightness(1);
    }
}

#pony-container.rolling {
    min-height: 320px;
    pointer-events: none;
    background: linear-gradient(120deg, #f8f5ff 60%, #f3e5f5 100%);
    animation: rolling-bg-pulse 1.2s infinite;
}

@keyframes button-pulse {
    0% {
        filter: grayscale(0.2) brightness(1);
    }

    50% {
        filter: grayscale(0.2) brightness(1.08);
    }

    100% {
        filter: grayscale(0.2) brightness(1);
    }
}

#new-pony:disabled,
#new-pony[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(0.2) brightness(1);
    background: linear-gradient(135deg, #bdbdbd, #ce93d8);
    color: #fff;
    box-shadow: 0 2px 4px var(--shadow);
    transform: none;
    animation: button-pulse 1.5s infinite;
}

#roll-history {
    margin-bottom: 20px;
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 2px 6px var(--shadow);
    padding: 10px 15px;
    border: 1.5px solid var(--border);
}

#roll-history summary {
    font-weight: bold;
    color: var(--secondary);
    cursor: pointer;
    font-size: 1.1em;
    margin-bottom: 0;
}

#roll-history-ul {
    list-style: none;
    padding-left: 0;
    margin: 10px 0 0 0;
}

#roll-history-ul li {
    display: flex;
    align-items: center;
    gap: 8px;
}

#clear-roll-history {
    margin-top: 10px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 1em;
    cursor: pointer;
    transition: background 0.2s;
}

#clear-roll-history:hover {
    background: var(--secondary);
}

.range-slider {
    position: relative;
    width: 100%;
    max-width: 400px;
    /* margin: 0 auto 10px auto; */
    margin-top: 10px;
}

.range-slider__track {
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    position: relative;
}

.range-slider__range {
    height: 6px;
    background: var(--primary, #007bff);
    border-radius: 3px;
    position: absolute;
    top: 0;
}

.range-slider input[type="range"] {
    position: absolute;
    top: -7px;
    width: 100%;
    height: 20px;
    background: transparent;
    appearance: none;
    pointer-events: none;
    margin: 0;
}

.range-slider input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary, #007bff);
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    margin-top: 0;
}

.range-slider input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary, #007bff);
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    border: none;
}

.range-slider input[type="range"]::-webkit-slider-track {
    background: transparent;
    height: 20px;
}

.range-slider input[type="range"]::-moz-range-track {
    background: transparent;
    height: 20px;
}

.range-values {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-family: Arial, sans-serif;
    font-size: 14px;
}