.cf-tool {
    color: #111827;
    margin-bottom: 30px;
    min-height: 570px;
}

.cf-card {
    max-width: 600px;
    min-height: 570px;
    width: 100%;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    padding: 20px;
    margin: 0 auto;
    box-sizing: border-box;
}

.cf-title {
    font-size: 22px;
    font-weight: 500;
    text-align: center;
    margin-bottom: 16px;
    color: #2563eb;
}

/* Tabs */
.cf-tabs {
    display: flex;
    border-bottom: 2px solid #e5e7eb;
    justify-content: center;
    gap: 6px;
}

.cf-tab {
    border: none;
    color: #374151;
    background: #f3f4f6;
    padding: 10px 16px;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-weight: 500;
    font-size: 17px;
}

.cf-tool .cf-tab:hover,
.cf-tool .cf-tab:focus {
    color: #111827;
    background-color: #f3f4f6;
    outline: none;
    box-shadow: none;
}

.cf-tab.cf-active {
    background: #2563eb;
    color: #fff;
}

.cf-tool .cf-tab.cf-active:hover,
.cf-tool .cf-tab.cf-active:focus {
    color: #fff;
    background-color: #2563eb;
}

.cf-panel {
    display: none;
    padding: 18px 0;
}

.cf-panel.cf-active {
    display: block;
}

/* Coin */
.cf-coin-wrap {
    display: grid;
    place-items: center;
    margin-bottom: 16px;
}

.cf-coin {
    width: 180px;
    height: 180px;
    perspective: 1000px;
    cursor: pointer;
}

.cf-coin-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateY(0deg);
}

.cf-face {
    --cf-rim-color: transparent;
    position: absolute;
    inset: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 500;
    font-size: 32px;
    backface-visibility: hidden;
    box-sizing: border-box;
    background-size: cover;
    background-position: center;
    overflow: hidden;
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.25),
        inset 0 3px 3px rgba(255, 255, 255, 0.4),
        inset 0 -3px 3px rgba(0, 0, 0, 0.2),
        inset 0 0 0 6px var(--cf-rim-color);
}

.cf-heads {
    background-color: #ffce44;
    z-index: 2;
}

.cf-tails {
    background-color: #ffce44;
    transform: rotateY(180deg);
    color: #111827;
}

/* Extra motion layers (don’t affect facing) */
.cf-hop {
    animation: cf-hop 1s ease-out;
}

@keyframes cf-hop {
    0% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-160px);
    }

    100% {
        transform: translateY(0);
    }
}

.cf-zoom {
    animation: cf-zoom 1s ease-out;
}

@keyframes cf-zoom {
    0% {
        filter: none;
    }

    50% {
        filter: drop-shadow(0 12px 20px rgba(0, 0, 0, 0.2));
    }

    100% {
        filter: none;
    }
}

.cf-shrink {
    animation: cf-shrink 1s ease-in-out;
}

@keyframes cf-shrink {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(0);
    }

    100% {
        transform: scale(1);
    }
}

.cf-fade {
    animation: cf-fade 1s ease-in-out;
}

@keyframes cf-fade {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

.cf-toss {
    animation: cf-toss 1s ease-out;
}

@keyframes cf-toss {
    0% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(40px, -120px) scale(1.1);
    }

    100% {
        transform: translate(0, 0) scale(1);
    }
}

/* Controls */
.cf-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 16px;
}

.cf-btn {
    background: #2563eb;
    color: #ffffff;
    border: 0;
    padding: 10px 25px;
    border-radius: 10px;
    font-weight: 500;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.1s ease-out;
}

.cf-tool .cf-btn:hover,
.cf-tool .cf-btn:focus,
.cf-tool .cf-btn:active {
    background-color: #2563eb;
    color: #ffffff;
    outline: none;
    box-shadow: none;
}

.cf-tool .cf-btn:not(:disabled):active {
    transform: scale(0.95);
}

.cf-btn.cf-btn-secondary {
    background: #e5e7eb;
    color: #374151;
}

.cf-tool .cf-btn.cf-btn-secondary:hover,
.cf-tool .cf-btn.cf-btn-secondary:focus,
.cf-tool .cf-btn.cf-btn-secondary:active {
    background-color: #e5e7eb;
    color: #374151;
}

.cf-tool .cf-btn:disabled {
    opacity: .6;
    cursor: not-allowed;
}

#cf-mute {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

#cf-mute svg {
    width: 18px;
    height: 18px;
}

.cf-input-num {
    width: 80px;
    padding: 10px;
    border: 2px solid #e5e7eb;
    border-radius: 999px;
    text-align: center;
    font-weight: 500;
}

@media (min-width: 769px) {
    .cf-stats {
        max-width: 450px;
        margin-left: auto;
        margin-right: auto;
    }
}

.cf-stats-table {
    width: 100%;
    max-width: 250px;
    margin: 0 auto;
    border-collapse: collapse;
    font-size: 16px;
}

.cf-stats-table th,
.cf-stats-table td {
    border: 1px solid #d1d5db;
    padding: 10px;
    text-align: center;
}

.cf-stats-table th {
    font-weight: 500;
    color: #374151;
    background-color: #f9fafb;
}

.cf-stats-table td {
    font-weight: 500;
}

#cf-history-log {
    text-align: center;
    font-size: 16px;
    font-weight: normal;
    color: #6b7280;
    word-break: break-all;
    line-height: 1.4;
    min-height: 40px;
}

@keyframes cf-highlight-fade-heads {
    from {
        background-color: #dbeafe;
    }

    /* blue-100 */
    to {
        background-color: transparent;
    }
}

@keyframes cf-highlight-fade-tails {
    from {
        background-color: #dcfce7;
    }

    /* green-100 */
    to {
        background-color: transparent;
    }
}

.cf-highlight-heads {
    animation: cf-highlight-fade-heads 2.5s ease-out;
}

.cf-highlight-tails {
    animation: cf-highlight-fade-tails 2.5s ease-out;
}

/* Settings */
.cf-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.cf-settings-footer {
    margin-top: 10px;
    padding-top: 10px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.cf-field {
    display: grid;
    gap: 6px;
}

.cf-label {
    font-weight: 500;
    font-size: 16px;
    color: #374151;
}

.cf-field-error {
    font-size: 13px;
    color: #dc2626;
    /* red-600 */
    margin-top: -2px;
}

.cf-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-size: 16px;
    color: #374151;
    cursor: pointer;
}

.cf-input,
.cf-select {
    width: 100%;
    padding: 10px;
    border: 2px solid #e5e7eb;
    background-color: #ffffff;
    border-radius: 10px;
    box-sizing: border-box;
    font-size: 16px;
}

.cf-tool .cf-input:hover,
.cf-tool .cf-input:focus,
.cf-tool .cf-input:active,
.cf-tool .cf-select:hover,
.cf-tool .cf-select:focus,
.cf-tool .cf-select:active {
    border-color: #e5e7eb;
    outline: none;
    box-shadow: none;
    background-color: #ffffff;
}

.cf-tool .cf-input:focus,
.cf-tool .cf-select:focus {
    border-color: #e9c9c9;
}

.cf-tool input[type="text"].cf-input:focus,
.cf-tool input[type="number"].cf-input:focus {
    border-color: #e9c9c9;
}

.cf-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23374151' stroke-width='1.5'%3e%3cpath stroke-linecap='round' stroke-linejoin='round' d='M6 9l6 6 6-6' /%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

/* Hide spinners from number input */
.cf-tool .cf-input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.cf-tool input[type="text"].cf-input,
.cf-tool input[type="number"].cf-input {
        background-color: #ffffff;
        border-radius: 10px;
        border: 2px solid #e5e7eb;
}

.cf-tool .cf-input[type="number"]::-webkit-outer-spin-button,
.cf-tool .cf-input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Color Inputs */
.cf-color-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    padding-left: 6px;
    background-color: #fff;
}

.cf-tool .cf-color-input-wrap:hover,
.cf-tool .cf-color-input-wrap:focus-within {
    border-color: #e5e7eb;
    background-color: #ffffff;
}

.cf-tool .cf-color-input-wrap:focus-within {
    border-color: #e9c9c9;
}

.cf-color-picker {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background-color: transparent;
    cursor: pointer;
    flex-shrink: 0;
}

.cf-tool .cf-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.cf-tool .cf-color-picker::-webkit-color-swatch {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

.cf-tool .cf-color-picker::-moz-color-swatch {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

.cf-tool .cf-color-text {
    width: 100%;
    border: none;
    padding: 10px 10px 10px 0;
    background-color: #ffffff;
    font-size: 16px;
}

.cf-tool .cf-color-text:focus,
.cf-tool .cf-color-text:active,
.cf-tool .cf-color-text:hover {
    background-color: #ffffff;
}

.cf-tool .cf-color-picker:focus,
.cf-tool .cf-checkbox-label input[type="checkbox"]:focus {
    outline: none;
    box-shadow: none;
}

.cf-tool .cf-color-text:focus {
    outline: none;
}

/* Drag and Drop Area */
.cf-drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    border: 2px dashed #d1d5db;
    border-radius: 10px;
    background-color: #f3f4f6;
    text-align: center;
    color: #6b7280;
    font-size: 15px;
    transition: background-color .2s ease, border-color .2s ease;
}

.cf-image-upload-area {
    display: grid;
    gap: 10px;
}

.cf-hidden {
    display: none;
}

.cf-tool .cf-drop-zone.cf-drag-over {
    background-color: #e0e7ff;
    border-color: #2563eb;
}

.cf-file-input-hidden {
    display: none;
}

/* Image Preview */
.cf-img-preview-wrap {
    display: none;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    padding: 8px;
    background: #f3f4f6;
    border-radius: 10px;
}

.cf-img-preview-wrap.cf-active {
    display: flex;
}

.cf-img-preview {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-size: cover;
    border: 2px solid #fff;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.cf-img-preview-actions {
    display: flex;
    gap: 8px;
}

.cf-btn-small {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 8px;
    font-weight: 500;
}

.cf-btn-icon {
    background: #e5e7eb;
    color: #374151;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    font-weight: 400;
}

.cf-tool .cf-btn-icon#cf-heads-remove-btn,
.cf-tool .cf-btn-icon#cf-tails-remove-btn {
    color: #dc2626;
    /* red-600 */
}

.cf-tool .cf-btn-icon:hover,
.cf-tool .cf-btn-icon:focus,
.cf-tool .cf-btn-icon:active {
    background-color: #e5e7eb;
    color: #374151;
}

.cf-tool .cf-btn-icon#cf-heads-remove-btn:hover,
.cf-tool .cf-btn-icon#cf-tails-remove-btn:hover {
    color: #dc2626;
    /* red-600 */
}

/* Modal & Cropper */
.cf-modal {
    display: none;
    /* Hidden by default */
    position: fixed;
    /* Stay in place */
    z-index: 1000;
    /* Sit on top */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    /* Black w/ opacity */
    align-items: center;
    justify-content: center;
}

.cf-modal.cf-active {
    display: flex;
}

.cf-modal-content {
    background-color: #ffffff;
    padding: 20px;
    width: 90%;
    max-width: 400px;
    border-radius: 16px;
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
    animation: cf-modal-open 0.4s;
}

@keyframes cf-modal-open {
    from {
        transform: scale(0.8);
        opacity: 0
    }

    to {
        transform: scale(1);
        opacity: 1
    }
}

.cf-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.cf-modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.cf-modal-close {
    border: none;
    background: none;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
    padding: 0;
    line-height: 1;
}

.cf-tool .cf-modal-close:hover,
.cf-tool .cf-modal-close:focus {
    color: #aaa;
    background: none;
    outline: none;
}

.cf-modal-body {
    display: grid;
    gap: 15px;
}

.cf-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid #e5e7eb;
    padding-top: 15px;
    margin-top: 15px;
}

/* Cropper */
.cf-cropper {
    display: grid;
    place-items: center;
}

.cf-cropper-window {
    width: 250px;
    height: 250px;
    position: relative;
    background-color: #e5e7eb;
    touch-action: none;
    /* Prevent page scroll while dragging */
    box-sizing: border-box;
    overflow: hidden;
}

.cf-cropper-overlay {
    position: absolute;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
    /* Large spread to dim outside */
    border: 4px solid white;
    cursor: move;
}

#cf-cropper-img {
    position: absolute;
    transform-origin: center center;
}

.cf-drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.cf-spinner {
    width: 30px;
    height: 30px;
    border: 4px solid #d1d5db;
    /* gray-300 */
    border-top-color: #2563eb;
    /* blue-600 */
    border-radius: 50%;
    animation: cf-spin 1s linear infinite;
}

@keyframes cf-spin {
    to {
        transform: rotate(360deg);
    }
}

.faq-list {
    margin-top: 1rem;
}

.faq-list dt {
    font-weight: 500;
    font-size: 1.1em;
}

.faq-list dd {
    margin-left: 0;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
    padding-left: 1rem;
    padding-bottom: 10px;
    border-bottom: 1px dashed #ddd;
}

@media (max-width:768px) {
    .cf-grid {
        grid-template-columns: 1fr;
    }

}