:root {
    --bg-color: #f2f2f2;
    --card-bg: #ffffff;
    --text-primary: #333333;
    --text-secondary: #64748b;
    --accent-color: #e68a00;
    --accent-hover: #cc7a00;
    --border-color: #cbd5e1;
    --error-color: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 3.5rem;
}

header {
    text-align: center;
    animation: fadeIn 0.8s ease-out;
}

.logo {
    max-width: 100px;
    height: auto;
    margin-bottom: 1rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.signature-container {
    background-color: var(--card-bg);
    border-radius: 24px;
    padding: 4px;
    /* Space for border effect if needed */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    position: relative;
    overflow: hidden;
    animation: slideUp 0.8s ease-out 0.2s both;
}

canvas {
    background-color: #ffffff;
    /* Contrast for signature */
    border-radius: 20px;
    width: 100%;
    height: 300px;
    /* Fixed height for signature area */
    display: block;
    cursor: crosshair;
    touch-action: none;
    /* Prevent scrolling while signing */
}

.text-btn {
    position: absolute;
    bottom: 15px;
    right: 15px;
    background: rgba(230, 138, 0, 0.1);
    border: 1px solid rgba(230, 138, 0, 0.2);
    padding: 6px 16px;
    border-radius: 8px;
    color: var(--accent-color);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
}

.text-btn:hover {
    background: rgba(230, 138, 0, 0.2);
    transform: translateY(-1px);
}

.terms-container {
    animation: slideUp 0.8s ease-out 0.4s both;
}

.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 35px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-secondary);
    user-select: none;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    height: 22px;
    width: 22px;
    background-color: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    transition: all 0.2s;
}

.checkbox-container:hover input~.checkmark {
    border-color: var(--accent-color);
}

.checkbox-container input:checked~.checkmark {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked~.checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-container a {
    color: var(--accent-color);
    text-decoration: none;
    transition: color 0.2s;
}

.checkbox-container a:hover {
    color: var(--accent-hover);
}

.primary-btn {
    width: 100%;
    background-color: var(--accent-color);
    color: #fff;
    border: none;
    padding: 16px;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: slideUp 0.8s ease-out 0.6s both;
}

.primary-btn:hover:not(:disabled) {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(56, 189, 248, 0.4);
}

.primary-btn:active:not(:disabled) {
    transform: translateY(0);
}

.primary-btn:disabled {
    background-color: var(--border-color);
    cursor: not-allowed;
    opacity: 0.7;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.captcha-container {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-top: 1rem;
    animation: slideUp 0.8s ease-out 0.5s both;
}

.terms-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.view-terms-link {
    color: var(--accent-color);
    text-decoration: none;
    font-size: 0.95rem;
    cursor: pointer;
    transition: color 0.2s;
}

.view-terms-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgb(0, 0, 0);
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
    animation: fadeIn 0.3s;
}

.modal-content {
    background-color: var(--card-bg);
    margin: auto;
    padding: 2rem;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 600px;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    position: relative;
    display: flex;
    flex-direction: column;
    max-height: 85vh;
}

.close-modal {
    color: var(--text-secondary);
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close-modal:hover,
.close-modal:focus {
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
}

.terms-body {
    margin-top: 1rem;
    margin-bottom: 2rem;
    overflow-y: auto;
    max-height: 60vh;
    padding-right: 10px;
    line-height: 1.6;
    color: var(--text-secondary);
    white-space: pre-wrap;
    /* Preserve newlines from API */
    text-align: left;
}

.terms-body::-webkit-scrollbar {
    width: 8px;
}

.terms-body::-webkit-scrollbar-track {
    background: transparent;
}

.terms-body::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 10px;
}