* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: linear-gradient(to bottom, #e5f4f9 0%, #a7cad7 100%);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

#hp-game-overlay {
    position: fixed;
    inset: 0;
    z-index: 1;
    background: linear-gradient(to bottom, #e5f4f9 0%, #a7cad7 100%);
    overflow: hidden;
}

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

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

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

.hp-end-layer {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(26, 44, 55, 0.46);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

.hp-end-layer.hp-end-layer-show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.hp-end-card {
    width: 420px;
    max-width: calc(100% - 32px);
    min-height: 240px;
    box-sizing: border-box;
    padding: 36px 40px 32px;
    background: #f9f4ea;
    border: 4px solid #c58c53;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.hp-end-title {
    margin: 0;
    font-family: "Microsoft YaHei", "PingFang SC", "Trebuchet MS", sans-serif;
    font-size: 36px;
    font-weight: bold;
    line-height: 1.2;
    color: #223643;
}

.hp-end-message {
    margin: 16px 0 0;
    max-width: 320px;
    font-family: "Microsoft YaHei", "PingFang SC", "Trebuchet MS", sans-serif;
    font-size: 20px;
    line-height: 1.35;
    color: #59717f;
}

.hp-end-replay {
    margin-top: 22px;
    width: 172px;
    height: 56px;
    padding: 0;
    border: 3px solid rgba(255, 212, 178, 0.9);
    background: #b24a2d;
    color: #fff7e8;
    font-family: "Microsoft YaHei", "PingFang SC", "Trebuchet MS", sans-serif;
    font-size: 22px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
}

.hp-end-replay:hover {
    background: #9a3d24;
}

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

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

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

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

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

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

#hp-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;
}

.hp-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(255, 209, 102, 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);
}

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

#hp-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;
}

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

.hp-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;
}

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

.hp-share-menu a,
.hp-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;
}

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

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

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

#hp-game-brand:hover,
.hp-game-brand:hover {
    color: #ffe8a3;
}

.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: #ffd166;
}

.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(255, 209, 102, 0.12);
    border-color: rgba(255, 209, 102, 0.45);
    color: #ffd166;
}

.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;
}
