* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    touch-action: none;
    user-select: none;
}

#sf-game-overlay {
    position: fixed;
    inset: 0;
    z-index: 1;
    background: #000;
    overflow: hidden;
}

#sf-game-container {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

#sf-game-container canvas {
    display: block;
}

#sf-game-ui {
    position: absolute;
    inset: 0;
    z-index: 10;
    pointer-events: none;
    font-family: Arial, sans-serif;
}

.sf-boot-loading {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #4fb8c9;
    pointer-events: none;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.sf-boot-loading.sf-boot-loading-hide {
    opacity: 0;
    visibility: hidden;
}

.sf-boot-loading-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.sf-boot-spinner {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.28);
    border-top-color: #fff;
    animation: sf-boot-spin 0.75s linear infinite;
}

.sf-boot-loading-text {
    margin: 0;
    font-family: Arial, sans-serif;
    font-size: 14px;
    letter-spacing: 0.04em;
    color: #f8fafc;
}

@keyframes sf-boot-spin {
    to { transform: rotate(360deg); }
}

#sf-left-chrome {
    position: absolute;
    top: 10px;
    left: 12px;
    z-index: 1000;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.sf-left-row {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 5px;
    height: 30px;
    padding: 0 6px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-sizing: border-box;
}

#player-auth-badge {
    position: static;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 24px;
    box-sizing: border-box;
    flex-shrink: 0;
}

.player-home-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    box-sizing: border-box;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #e8ecf5;
    opacity: 0.9;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.2s ease, background 0.2s ease;
    flex-shrink: 0;
}

.player-home-button:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.12);
}

#player-auth-badge.player-auth-badge--guest {
    padding: 0 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #e8ecf5;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    opacity: 0.9;
    text-decoration: none;
    cursor: pointer;
}

#player-auth-badge.player-auth-badge--guest:hover {
    opacity: 1;
    border-color: rgba(251, 191, 36, 0.75);
    background: rgba(255, 255, 255, 0.12);
}

#player-auth-badge.player-auth-badge--user {
    width: 24px;
    padding: 0;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(15, 23, 42, 0.85);
    text-decoration: none;
    cursor: pointer;
}

#player-auth-badge .player-auth-badge__avatar {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#how-to-play-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 7px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.06);
    color: #e8ecf5;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    opacity: 0.9;
}

#how-to-play-button:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.12);
}

#sf-share-wrap {
    position: relative;
    flex-shrink: 0;
    z-index: 40;
}

#sf-share-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 7px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.06);
    color: #e8ecf5;
    cursor: pointer;
    opacity: 0.9;
}

#sf-share-button:hover,
#sf-share-button[aria-expanded="true"] {
    opacity: 1;
    background: rgba(255, 255, 255, 0.12);
}

.sf-share-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 11.5rem;
    padding: 4px 0;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(12, 14, 22, 0.96);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
    display: none;
}

.sf-share-menu.is-open {
    display: block;
}

.sf-share-menu a,
.sf-share-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 8px 12px;
    border: 0;
    background: transparent;
    color: #e8ecf5;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.sf-share-menu a:hover,
.sf-share-menu button:hover {
    background: rgba(255, 255, 255, 0.08);
}

.sf-share-menu__copy {
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
    margin-top: 2px;
}

#sf-game-brand,
.sf-game-brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 24px;
    padding: 0 8px;
    color: #fde68a;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    text-transform: uppercase;
    cursor: pointer;
}

#sf-game-brand:hover,
.sf-game-brand:hover {
    color: #fef3c7;
}

.how-to-play-modal {
    position: fixed;
    inset: 0;
    z-index: 2147483648;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(3, 6, 15, 0.88);
    pointer-events: auto;
    font-family: 'Segoe UI', Arial, sans-serif;
}

.how-to-play-modal__panel {
    width: min(480px, 100%);
    max-height: min(80vh, 640px);
    overflow-y: auto;
    background: rgba(13, 19, 33, 0.97);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 20px 18px 18px 22px;
    color: #d7dbff;
}

.how-to-play-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.how-to-play-modal__header h2 {
    margin: 0;
    font-size: 22px;
    color: #fde68a;
}

.how-to-play-modal__tabs {
    display: flex;
    gap: 8px;
    margin: 0 0 16px;
    padding: 0 0 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.how-to-play-modal__tab {
    flex: 1 1 0;
    min-height: 36px;
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: #b8c3ff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}

.how-to-play-modal__tab--active {
    background: rgba(253, 230, 138, 0.12);
    border-color: rgba(253, 230, 138, 0.45);
    color: #fde68a;
}

.how-to-play-modal__pane {
    display: none;
}

.how-to-play-modal__pane--active {
    display: block;
}

.how-to-play-modal__close {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}

.how-to-play-modal__section {
    margin: 0 0 14px;
}

.how-to-play-modal__section h3 {
    margin: 0 0 6px;
    font-size: 14px;
    color: #ffffff;
}

.how-to-play-modal__section p {
    margin: 0;
    font-size: 13px;
    line-height: 1.55;
    color: #b8c3ff;
}

.sf-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: rgba(2, 6, 23, 0.82);
    z-index: 2147483646;
    padding: 20px;
    text-align: center;
    pointer-events: auto;
}

.sf-overlay-show {
    display: flex;
}

.sf-card {
    width: min(92vw, 420px);
    padding: 28px 24px;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(2, 6, 23, 0.96));
    border: 1px solid rgba(148, 163, 184, 0.28);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
    color: #e2e8f0;
    font-family: Arial, sans-serif;
}

.sf-card h3 {
    margin: 0 0 10px;
    font-size: 28px;
    color: #f8fafc;
}

.sf-card p {
    margin: 0 0 18px;
    color: #94a3b8;
    font-size: 16px;
}

.sf-card-sub {
    margin: -8px 0 18px !important;
    font-size: 14px !important;
    color: #64748b !important;
}

.sf-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.sf-btn {
    border: none;
    border-radius: 10px;
    padding: 10px 18px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    background: #334155;
    color: #f8fafc;
}

.sf-btn-primary {
    background: linear-gradient(180deg, #fbbf24, #d97706);
    color: #1c1917;
}

.sf-btn:hover {
    filter: brightness(1.08);
}

#sfHsSubmit {
    margin: 0 auto 16px;
    width: 100%;
    box-sizing: border-box;
    text-align: left;
    padding: 14px 14px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

#sfHsSubmit .sf-hs-heading {
    margin: 0 0 10px !important;
    font-size: 12px !important;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-align: center;
    color: rgba(255, 255, 255, 0.7) !important;
}

#sfHsSubmit .sf-hs-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

#sfHsSubmit .sf-hs-row[hidden] {
    display: none !important;
}

#sfHsSubmit input {
    flex: 1;
    min-width: 0;
    width: auto;
    margin: 0;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 10px;
    padding: 11px 12px;
    font: inherit;
    font-size: 15px;
    text-align: left;
    color: #fff;
    background: rgba(0, 0, 0, 0.35);
    outline: none;
}

#sfHsSubmit input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

#sfHsSubmit input:focus {
    border-color: #8ea0f0;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.28);
}

#sfHsSubmit button {
    flex: 0 0 auto;
    color: #fff;
    cursor: pointer;
    border: 0;
    border-radius: 10px;
    padding: 11px 16px;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

#sfHsSubmit button:hover {
    filter: brightness(1.08);
}

#sfHsSubmit button:disabled {
    cursor: default;
    filter: saturate(0.7) brightness(0.85);
}

#sfHsSubmit .sf-hs-status {
    margin: 10px 0 0 !important;
    text-align: center;
    font-size: 13px !important;
    font-weight: 700;
    color: #9dff9d !important;
}
