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

html {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(to bottom, #2f77f3 0%, #2f77f3 30%, #e0e0e0 30%, #e0e0e0 100%);
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    margin: 0;
}

.app-wrapper {
    width: 95%;
    max-width: 700px;
    transform-origin: center top;
}

.container {
    width: 100%;
}

/* Header */
.header {
    background: transparent;
    color: white;
    padding: 15px 20px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border-radius: 0;
    margin-bottom: 0;
}

.header-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.header h1 {
    color: white;
    font-size: 36px;
    font-weight: 600;
    margin: 0;
    letter-spacing: 0.7px;
    line-height: 1.2;
}

/* Card */
.card {
    background: #F4F7FF;
    border-radius: 24px;
    padding: 25px 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    text-align: center;
    margin-top: 0;
}

.instruction-text {
    color: #000;
    font-size: 16px;
    margin-bottom: 12px;
    line-height: 1.5;
    font-weight: 400;
}

/* Loading */
.loading {
    padding: 30px 20px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #1976d2;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Code display */
.code-section {
    margin-bottom: 15px;
}

.code-display {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
}

.code-digit {
    background: #FFFFFF;
    border: none;
    border-radius: 12px;
    width: 65px;
    height: 75px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 58px;
    font-weight: 500;
    color: #000000;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1;
    transition: all 0.3s ease;
}

.code-digit:hover {
    opacity: 0.9;
}

.code-label {
    color: #666;
    font-size: 14px;
    margin-top: 6px;
}

/* QR Code */
.qr-section {
    margin: 15px 0;
}

.qr-label {
    color: #000;
    font-size: 16px;
    margin-bottom: 12px;
    font-weight: 400;
}

#qrcode {
    display: inline-block;
    padding: 0;
    background: transparent;
    border-radius: 0;
    margin: 0 auto;
    box-shadow: none;
}

#qrcode canvas {
    display: block;
    margin: 0 auto;
}

/* Google Play Button */
.google-play-section {
    margin-top: 15px;
    margin-bottom: 10px;
}

.google-play-link {
    display: inline-block;
    text-decoration: none;
    transition: opacity 0.2s;
}

.google-play-link:hover {
    opacity: 0.8;
}

.google-play-badge {
    height: 60px;
    width: auto;
    display: block;
    margin: 0 auto;
}

/* Status and Action Holder */
.status-action-holder {
    position: relative;
    min-height: 50px;
    margin-top: 8px;
}

/* Placeholder to maintain card height */
.status-action-placeholder {
    height: 48px;
    visibility: hidden;
}

/* When status or button is visible, hide placeholder */
.status-action-holder .status-message:not(.hidden) ~ .status-action-placeholder {
    display: none;
}

/* Hide placeholder when button is visible */
.status-action-holder:has(.actions .btn:not(.hidden)) .status-action-placeholder {
    display: none;
}

/* Position status message absolutely to overlay placeholder */
.status-action-holder .status-message:not(.hidden) {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
}

/* Position actions container absolutely when it contains visible button */
.status-action-holder .actions:has(.btn:not(.hidden)) {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    margin-top: 0;
}

/* When both status message and button are visible, stack them vertically */
.status-action-holder .status-message:not(.hidden) ~ .actions:has(.btn:not(.hidden)) {
    top: 25px;
}

/* When only button is visible (no status message), position at top */
.status-action-holder .status-message.hidden ~ .actions:has(.btn:not(.hidden)) {
    top: 0;
}

/* Status messages */
.status-message {
    padding: 0;
    border-radius: 0;
    margin: 0;
    font-size: 14px;
    text-align: center;
    background: transparent;
    border: none;
}

.status-message.info {
    color: #1976d2;
}

.status-message.warning {
    color: #f57c00;
}

.status-message.error {
    color: #d32f2f;
}

.status-message.success {
    color: #388e3c;
}

/* Buttons */
.actions {
    margin-top: 6px;
    text-align: center;
    position: relative;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.5);
}

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

.btn-secondary {
    background: transparent;
    color: #666;
    border: 1px solid #ddd;
    padding: 8px 20px;
    font-size: 14px;
    text-transform: none;
    letter-spacing: 0;
}

.btn-secondary:hover {
    background: #f5f5f5;
    border-color: #bbb;
}

/* Error state */
#error-content {
    text-align: center;
}

#error-message {
    color: #d32f2f;
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.5;
}

/* Hidden class */
.hidden {
    display: none !important;
}

/* iPad Pro (1024x1366) - tăng background gradient lên 40% */
@media screen and (min-width: 1020px) and (max-width: 1030px) and (min-height: 1360px) and (max-height: 1370px) {
    body {
        background: linear-gradient(to bottom, #2f77f3 0%, #2f77f3 40%, #e0e0e0 40%, #e0e0e0 100%);
    }
}

/* Surface Pro (912x1368) - tăng background gradient lên 40% */
@media screen and (min-width: 908px) and (max-width: 916px) and (min-height: 1364px) and (max-height: 1372px) {
    body {
        background: linear-gradient(to bottom, #2f77f3 0%, #2f77f3 40%, #e0e0e0 40%, #e0e0e0 100%);
    }
}

/* Responsive - scale toàn bộ theo tỷ lệ như 1 bức ảnh */
@media (max-width: 700px) {
    .app-wrapper {
        width: 100%;
        max-width: 100%;
        transform: scale(calc(100vw / 700));
        transform-origin: center top;
        padding: 0;
    }
}

@media (max-width: 375px) {
    /* iPhone SE, iPhone 6/7/8 - scale để fit */
    .app-wrapper {
        width: 100%;
        max-width: 100%;
        transform: scale(calc(100vw / 700));
        transform-origin: center top;
        padding: 0;
    }
}

@media (max-width: 320px) {
    /* iPhone SE (first generation) - scale nhỏ hơn */
    .app-wrapper {
        width: 100%;
        max-width: 100%;
        transform: scale(calc(100vw / 700));
        transform-origin: center top;
        padding: 0;
    }
}

/* Animation for code change */
.code-text {
    transition: all 0.3s ease;
}

.code-text.updating {
    opacity: 0.5;
    transform: scale(0.95);
}
