html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    font-family: Arial, Helvetica, sans-serif;
    color: #1f1f1f;
    background: #ffffff;
    -webkit-user-select: none;
    user-select: none;
}

button,
input {
    font: inherit;
}

.craft-game,
.craft-game * {
    -webkit-user-drag: none;
    -webkit-user-select: none;
    user-select: none;
}

.search-box,
.target-input,
.settings-field input {
    -webkit-user-select: text;
    user-select: text;
}

.app-shell,
.craft-game {
    width: 100vw;
    height: 100vh;
}

.craft-game {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 6px var(--sidebar-width, 310px);
    background: #ffffff;
}

.app-loading-screen {
    position: relative;
    grid-column: 1 / -1;
    display: grid;
    min-height: 100vh;
    place-content: center;
    justify-items: center;
    gap: 18px;
    overflow: hidden;
    background:
        linear-gradient(#f7f7f7 1px, transparent 1px),
        linear-gradient(90deg, #f7f7f7 1px, transparent 1px),
        #ffffff;
    background-size: 36px 36px;
}

.app-loading-logo {
    color: #161616;
    font-size: 28px;
    font-weight: 800;
}

.app-loading-combo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-width: 0;
    color: #555555;
    font-size: 18px;
    font-weight: 700;
}

.app-loading-token {
    position: static;
    animation: loading-token-pulse 1.4s ease-in-out infinite;
}

.app-loading-result {
    animation-delay: 260ms;
}

.app-loading-dots {
    display: flex;
    gap: 6px;
}

.app-loading-dots span {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: #17498f;
    opacity: 0.32;
    animation: loading-dot 1.2s ease-in-out infinite;
}

.app-loading-dots span:nth-child(2) {
    animation-delay: 140ms;
}

.app-loading-dots span:nth-child(3) {
    animation-delay: 280ms;
}

.pwa-status-strip {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 9px;
    max-width: min(380px, calc(100vw - 28px));
    padding: 8px 10px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    background: rgb(255 255 255 / 94%);
    box-shadow: 0 8px 24px rgb(0 0 0 / 14%);
    color: #333333;
    font-size: 12px;
}

.pwa-status-strip button {
    height: 26px;
    padding: 0 9px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    background: #f5f5f5;
    color: #262626;
    cursor: pointer;
    font-size: 12px;
}

.pwa-status-strip button:hover {
    border-color: #b8b8b8;
    background: #ffffff;
}

.craft-canvas {
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(#f7f7f7 1px, transparent 1px),
        linear-gradient(90deg, #f7f7f7 1px, transparent 1px),
        #ffffff;
    background-size: 36px 36px;
}

.game-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgb(255 255 255 / 20%);
    pointer-events: auto;
}

.brand {
    position: absolute;
    top: 18px;
    left: 22px;
    z-index: 1;
    font-size: 24px;
    font-weight: 700;
    color: #161616;
    letter-spacing: 0;
}

.target-chip {
    position: absolute;
    top: 55px;
    left: 22px;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: min(360px, calc(100vw - 390px));
    min-height: 30px;
    padding: 5px 9px;
    border: 1px solid #d8d8d8;
    border-radius: 5px;
    background: #ffffff;
    box-shadow: 0 1px 4px rgb(0 0 0 / 8%);
    font-size: 14px;
}

.target-chip span {
    color: #777777;
}

.target-chip strong {
    min-width: 0;
    overflow: hidden;
    color: #202020;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toast-message {
    position: absolute;
    top: 92px;
    left: 22px;
    z-index: 4;
    max-width: min(520px, calc(100vw - 360px));
    padding: 8px 11px;
    border: 1px solid #dedede;
    border-radius: 5px;
    background: #ffffff;
    box-shadow: 0 2px 8px rgb(0 0 0 / 8%);
    color: #333333;
    font-size: 14px;
    line-height: 1.3;
    overflow-wrap: anywhere;
    pointer-events: none;
}

.toast-message.is-top {
    top: 55px;
}

.race-scoreboard {
    position: absolute;
    top: 18px;
    right: 18px;
    z-index: 5;
    display: grid;
    --race-columns: minmax(88px, 1fr) 46px minmax(104px, 1.25fr);
    gap: 4px;
    width: min(340px, calc(100vw - 380px));
    padding: 9px;
    border: 1px solid #dedede;
    border-radius: 6px;
    background: rgb(255 255 255 / 92%);
    box-shadow: 0 6px 18px rgb(0 0 0 / 10%);
    color: #2b2b2b;
    font-size: 12px;
    pointer-events: none;
}

.race-scoreboard-title,
.race-row {
    display: grid;
    grid-template-columns: var(--race-columns);
    column-gap: 10px;
    align-items: center;
}

.race-scoreboard-title {
    color: #767676;
    font-weight: 700;
}

.race-scoreboard-title strong {
    grid-column: 2 / 4;
}

.race-scoreboard-title strong,
.race-name,
.race-numbers,
.race-last {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.race-row {
    min-height: 24px;
    padding: 3px 5px;
    border-radius: 4px;
}

.race-row.is-you {
    background: #eef5ff;
}

.race-row.is-finished {
    color: #13572f;
    font-weight: 700;
}

.race-numbers {
    color: #555555;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.game-chat-peek {
    position: absolute;
    bottom: 76px;
    left: 18px;
    z-index: 5;
    display: grid;
    gap: 3px;
    width: min(420px, calc(100vw - var(--sidebar-width, 310px) - 72px));
    pointer-events: none;
}

.game-chat-peek-line {
    overflow: hidden;
    color: rgb(31 31 31 / 78%);
    font-size: 12px;
    line-height: 1.25;
    opacity: 0;
    animation: game-chat-peek-fade var(--game-chat-fade, 8s) ease-out forwards;
    text-shadow: 0 1px 2px #ffffff, 0 0 8px #ffffff;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.game-chat-peek-line strong {
    color: rgb(23 73 143 / 82%);
}

.game-chat-peek-line.is-system {
    color: rgb(90 90 90 / 78%);
    font-style: italic;
}

@keyframes game-chat-peek-fade {
    0%,
    72% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

@keyframes loading-token-pulse {
    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-4px);
    }
}

@keyframes loading-dot {
    0%,
    100% {
        opacity: 0.25;
        transform: scale(0.85);
    }

    50% {
        opacity: 1;
        transform: scale(1);
    }
}

.game-chat-toggle {
    position: absolute;
    right: 18px;
    bottom: 18px;
    z-index: 7;
    min-width: 50px;
    height: 30px;
    padding: 0 11px;
    border: 1px solid #d7d7d7;
    border-radius: 999px;
    background: rgb(255 255 255 / 88%);
    box-shadow: 0 4px 12px rgb(0 0 0 / 10%);
    color: #303030;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
}

.game-chat-toggle.is-open {
    border-color: #bcd3ff;
    background: #eef5ff;
    color: #17498f;
}

.game-chat-badge {
    position: absolute;
    top: -7px;
    right: -7px;
    display: inline-grid;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    place-items: center;
    border-radius: 999px;
    background: #1d5bbf;
    color: #ffffff;
    font-size: 10px;
    line-height: 1;
}

.game-chat-panel {
    position: absolute;
    right: 18px;
    bottom: 56px;
    z-index: 8;
    width: min(360px, calc(100vw - var(--sidebar-width, 310px) - 48px));
    padding: 9px;
    border: 1px solid #d8d8d8;
    border-radius: 6px;
    background: rgb(255 255 255 / 94%);
    box-shadow: 0 12px 32px rgb(0 0 0 / 16%);
}

.game-chat-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    color: #505050;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.game-chat-panel-header button {
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #777777;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.game-chat-messages {
    max-height: 210px;
    min-height: 118px;
    margin-top: 0;
}

.countdown-overlay {
    position: fixed;
    inset: 0;
    z-index: 31;
    display: grid;
    place-content: center;
    gap: 10px;
    background: rgb(255 255 255 / 72%);
    color: #1e1e1e;
    text-align: center;
    pointer-events: auto;
}

.countdown-number {
    font-size: 74px;
    font-weight: 800;
    line-height: 1;
}

.canvas-trash {
    position: absolute;
    bottom: 16px;
    left: 16px;
    z-index: 3;
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;
    border: 1px solid #d6d6d6;
    border-radius: 999px;
    background: rgb(255 255 255 / 92%);
    box-shadow: 0 2px 8px rgb(0 0 0 / 10%);
    color: #6f6f6f;
    font-size: 22px;
    opacity: 0.42;
    pointer-events: none;
    transition: opacity 120ms ease, transform 120ms ease, background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.canvas-trash.is-available {
    opacity: 0.9;
}

.canvas-trash.is-active {
    border-color: #f0a6a6;
    background: #fff0f0;
    box-shadow: 0 0 0 4px rgb(220 58 58 / 12%), 0 8px 22px rgb(0 0 0 / 16%);
    color: #b82424;
    transform: scale(1.08);
}

.merge-wait-dialog {
    position: absolute;
    z-index: 6;
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    width: min(330px, calc(100vw - 390px));
    min-height: 58px;
    padding: 14px 16px;
    border: 1px solid #d8d8d8;
    border-radius: 6px;
    background: #ffffff;
    box-shadow: 0 12px 30px rgb(0 0 0 / 14%);
    color: #2d2d2d;
    font-size: 14px;
    line-height: 1.35;
    pointer-events: none;
}

.merge-wait-dialog.is-hidden {
    visibility: hidden;
    opacity: 0;
}

.merge-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #cfcfcf;
    border-top-color: #4f4f4f;
    border-radius: 999px;
    animation: spin 0.8s linear infinite;
}

.craft-token {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    max-width: 230px;
    padding: 6px 10px;
    border: 1px solid #d8d8d8;
    border-radius: 5px;
    background: #f5f5f5;
    color: #262626;
    box-shadow: 0 1px 2px rgb(0 0 0 / 10%);
    cursor: grab;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    touch-action: none;
}

.craft-token:active {
    cursor: grabbing;
}

.craft-token span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
}

.craft-token.is-own-discovery {
    border-color: #d9a51b;
    background:
        linear-gradient(110deg, rgb(255 255 255 / 0%) 0%, rgb(255 255 255 / 0%) 38%, rgb(255 255 255 / 72%) 48%, rgb(255 255 255 / 0%) 58%, rgb(255 255 255 / 0%) 100%),
        linear-gradient(180deg, #fff7cf, #f6dd83);
    background-size: 220% 100%, 100% 100%;
    box-shadow: 0 1px 2px rgb(0 0 0 / 10%), 0 0 0 2px rgb(217 165 27 / 14%);
    animation: own-discovery-shimmer 2.8s ease-in-out infinite;
}

.craft-token.is-own-discovery:hover {
    border-color: #c89110;
    box-shadow: 0 2px 8px rgb(0 0 0 / 13%), 0 0 0 3px rgb(217 165 27 / 18%);
}

.canvas-token {
    position: absolute;
    z-index: 2;
}

.canvas-token.is-dragging {
    box-shadow: 0 8px 20px rgb(0 0 0 / 18%);
    transform: translateY(-1px);
}

.canvas-token.is-merge-target {
    border-color: #4f8cff;
    background: #eef5ff;
    box-shadow: 0 0 0 3px rgb(79 140 255 / 18%), 0 3px 10px rgb(0 0 0 / 12%);
}

.canvas-token.is-merge-target::before {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff;
    border-radius: 999px;
    background: #4f8cff;
    box-shadow: 0 1px 5px rgb(0 0 0 / 20%);
    content: "";
}

.canvas-token.is-loading {
    opacity: 0.66;
}

.canvas-token.is-loading::after {
    content: "";
    width: 8px;
    height: 8px;
    border: 2px solid #a5a5a5;
    border-top-color: transparent;
    border-radius: 999px;
    animation: spin 0.8s linear infinite;
}

.canvas-token.is-merge-rejected {
    border-color: #e08b8b;
    background: #fff5f5;
    box-shadow: 0 0 0 3px rgb(224 139 139 / 18%), 0 3px 10px rgb(0 0 0 / 10%);
    animation: merge-rejected-shake 0.46s ease-in-out;
}

.canvas-token.is-merge-rejected::before {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff;
    border-radius: 999px;
    background: #e06d6d;
    box-shadow: 0 1px 5px rgb(0 0 0 / 18%);
    color: #ffffff;
    content: "x";
    font-size: 12px;
    font-weight: 800;
    line-height: 12px;
    text-align: center;
}

.discovery-burst {
    position: absolute;
    z-index: 4;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.discovery-particle {
    position: absolute;
    width: 7px;
    height: 7px;
    border-radius: 2px;
    background: var(--color);
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6) rotate(0deg);
    animation: discovery-confetti 0.95s cubic-bezier(0.18, 0.8, 0.28, 1) forwards;
    animation-delay: var(--delay);
}

.discovery-particle:nth-child(3n) {
    width: 5px;
    height: 10px;
    border-radius: 999px;
}

.discovery-particle:nth-child(4n) {
    width: 9px;
    height: 5px;
}

.inventory {
    display: flex;
    height: 100%;
    min-height: 0;
    min-width: 0;
    flex-direction: column;
    overflow: hidden;
    border-left: 1px solid #d8d8d8;
    background: #f8f8f8;
}

.sidebar-resizer {
    position: relative;
    width: 6px;
    background: #f8f8f8;
    border-left: 1px solid #d8d8d8;
    cursor: col-resize;
    touch-action: none;
}

.sidebar-resizer:hover,
.sidebar-resizer:active {
    background: #e6e6e6;
}

.inventory-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 14px;
    border-bottom: 1px solid #e4e4e4;
}

.items-count {
    min-width: 0;
    font-size: 20px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-actions {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 4px;
}

.icon-button {
    display: inline-grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border: 0;
    border-radius: 4px;
    background: transparent;
    font-size: 24px;
    line-height: 1;
    color: #6b6b6b;
    cursor: pointer;
}

.restart-button {
    font-size: 20px;
}

.settings-button,
.sound-button {
    font-size: 0;
}

.settings-button svg,
.sound-button svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.settings-button svg {
    fill: none;
    stroke-width: 2.1;
}

.sound-button svg path:first-child {
    fill: currentColor;
    stroke: none;
}

.sound-button.is-muted {
    color: #999999;
    opacity: 0.72;
}

.debug-win-button {
    color: #8a6a0f;
    font-size: 18px;
}

.icon-button:hover {
    background: #ececec;
    color: #1f1f1f;
}

.search-box {
    height: 34px;
    margin: 12px 12px 8px;
    padding: 0 10px;
    border: 1px solid #d6d6d6;
    border-radius: 5px;
    background: #ffffff;
    outline: none;
}

.search-box:focus {
    border-color: #8c8c8c;
}

.sort-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 48px;
    padding: 8px 12px;
    border-top: 1px solid #e0e0e0;
    background: #f8f8f8;
    color: #6a6a6a;
    font-size: 13px;
}

.sort-toggle {
    display: flex;
    flex-shrink: 0;
    gap: 7px;
}

.toolbar-button {
    height: 26px;
    padding: 0 9px;
    border: 1px solid #d6d6d6;
    border-radius: 4px;
    background: #ffffff;
    color: #565656;
    cursor: pointer;
}

.toolbar-button.active {
    background: #e9e9e9;
    color: #202020;
}

.inventory-list {
    display: flex;
    align-content: flex-start;
    align-items: flex-start;
    flex: 1;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px 12px 14px;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}

.inventory-token {
    max-width: 132px;
    touch-action: none;
}

.inventory-drag-preview {
    position: fixed;
    z-index: 40;
    max-width: 230px;
    pointer-events: none;
    box-shadow: 0 10px 22px rgb(0 0 0 / 18%);
    opacity: 0.96;
    transform: translateY(-1px);
}

.confirm-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 31;
    width: min(320px, 90vw);
    max-height: calc(100dvh - 28px);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translate(-50%, -50%);
    padding: 18px;
    border: 1px solid #d4d4d4;
    border-radius: 6px;
    background: #ffffff;
    box-shadow: 0 12px 32px rgb(0 0 0 / 14%);
    text-align: center;
}

.restart-dialog,
.player-dialog,
.settings-dialog,
.room-lobby-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 31;
    width: min(540px, 94vw);
    max-height: calc(100dvh - 28px);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translate(-50%, -50%);
    padding: 26px;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 18px 52px rgb(0 0 0 / 18%), 0 1px 2px rgb(0 0 0 / 8%);
    text-align: center;
}

.player-dialog {
    width: min(420px, 92vw);
}

.settings-dialog {
    width: min(440px, 92vw);
}

.room-lobby-dialog {
    width: min(560px, 94vw);
}

.target-complete-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 31;
    width: min(480px, 92vw);
    max-height: calc(100dvh - 28px);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translate(-50%, -50%);
    padding: 28px 26px 24px;
    border: 1px solid #d7d7d7;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 18px 54px rgb(0 0 0 / 18%), 0 1px 2px rgb(0 0 0 / 8%);
    text-align: center;
}

.room-results-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 31;
    width: min(620px, 94vw);
    max-height: calc(100dvh - 28px);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translate(-50%, -50%);
    padding: 28px 26px 24px;
    border: 1px solid #d7d7d7;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 18px 54px rgb(0 0 0 / 18%), 0 1px 2px rgb(0 0 0 / 8%);
    text-align: center;
}

.target-complete-icon {
    display: inline-grid;
    width: 48px;
    height: 48px;
    margin-bottom: 13px;
    place-items: center;
    border: 1px solid #d7e4ff;
    border-radius: 999px;
    background: #eef5ff;
    color: #1d5bbf;
    font-size: 24px;
    line-height: 1;
}

.room-results-crown {
    display: inline-grid;
    width: 50px;
    height: 50px;
    margin-bottom: 13px;
    place-items: center;
    border: 1px solid #ecd082;
    border-radius: 999px;
    background: linear-gradient(180deg, #fff7d4, #fffdf2);
    color: #9b6d00;
    font-size: 27px;
    line-height: 1;
    box-shadow: 0 8px 22px rgb(201 151 30 / 16%);
}

.room-results-table {
    margin-top: 18px;
    overflow: hidden;
    border: 1px solid #e4e4e4;
    border-radius: 6px;
    text-align: left;
}

.room-results-row {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) repeat(3, minmax(78px, 0.65fr));
    gap: 8px;
    align-items: center;
    min-height: 38px;
    padding: 8px 10px;
    border-bottom: 1px solid #eeeeee;
    color: #303030;
    font-size: 13px;
    line-height: 1.2;
}

.room-results-row:last-child {
    border-bottom: 0;
}

.room-results-head {
    min-height: 32px;
    background: #fafafa;
    color: #777777;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.room-results-row span:not(.room-results-player) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.room-results-player {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    min-width: 0;
    overflow: hidden;
    color: #242424;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.room-results-row.is-winner {
    background: linear-gradient(180deg, #fff8dc, #fffdf2);
    box-shadow: inset 3px 0 0 #d9a51b;
}

.room-results-row.is-winner .room-results-player {
    color: #7a5600;
}

.room-results-row.is-you:not(.is-winner) {
    background: #f4f8ff;
}

.target-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 20px;
}

.target-stats div {
    display: grid;
    gap: 4px;
    min-height: 74px;
    align-content: center;
    padding: 12px 10px;
    border: 1px solid #e4e4e4;
    border-radius: 6px;
    background: #fafafa;
}

.target-stats span {
    color: #202020;
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
}

.target-stats strong {
    color: #6a6a6a;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.25;
}

.target-complete-actions {
    margin-top: 20px;
}

.dialog-title {
    color: #202020;
    font-size: 21px;
    font-weight: 700;
    letter-spacing: 0;
}

.compact-title {
    font-size: 19px;
}

.confirm-copy {
    margin: 9px auto 0;
    max-width: 390px;
    color: #666666;
    font-size: 13px;
    line-height: 1.45;
}

.mode-picker {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-top: 22px;
    padding: 5px;
    border: 1px solid #eeeeee;
    border-radius: 8px;
    background: #f7f7f7;
}

.mode-button {
    display: grid;
    grid-template-rows: 38px minmax(42px, auto);
    min-height: 82px;
    align-items: center;
    justify-items: center;
    justify-content: stretch;
    gap: 7px;
    padding: 10px 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: #333333;
    cursor: pointer;
    line-height: 1.2;
    transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.mode-button > span:last-child {
    display: grid;
    min-height: 42px;
    place-items: center;
    text-align: center;
}

.mode-button:hover {
    background: #ffffff;
}

.mode-button.active {
    border-color: #c9d9ff;
    background: #ffffff;
    box-shadow: 0 1px 4px rgb(0 0 0 / 8%);
    color: #163b77;
    font-weight: 700;
}

.mode-icon {
    display: inline-grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid #dddddd;
    border-radius: 999px;
    background: #ffffff;
    color: #3a3a3a;
    font-size: 20px;
    line-height: 1;
}

.mode-button.active .mode-icon {
    border-color: #b8cffd;
    background: #eef5ff;
    color: #17498f;
}

.target-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    margin-top: 14px;
    padding: 8px 8px 8px 12px;
    border: 1px solid #dfdfdf;
    border-radius: 5px;
    background: #fafafa;
}

.language-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
    padding: 9px 11px;
    border: 1px solid #e1e1e1;
    border-radius: 5px;
    background: #fafafa;
    color: #555555;
    font-size: 13px;
    text-align: left;
}

.language-field.compact {
    margin-top: 14px;
}

.language-field span {
    font-weight: 700;
}

.language-field select {
    min-width: 150px;
    height: 30px;
    padding: 0 8px;
    border: 1px solid #d2d2d2;
    border-radius: 4px;
    background: #ffffff;
    color: #262626;
}

.settings-field {
    display: grid;
    gap: 6px;
    margin-top: 14px;
    color: #555555;
    font-size: 13px;
    text-align: left;
}

.settings-field span {
    font-weight: 700;
}

.settings-field input,
.settings-field select {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #d4d4d4;
    border-radius: 5px;
    background: #ffffff;
    color: #262626;
    outline: none;
}

.settings-field input:focus,
.settings-field select:focus {
    border-color: #8c8c8c;
}

.settings-field.is-disabled {
    opacity: 0.64;
}

.settings-note {
    margin-top: 8px;
    color: #777777;
    font-size: 12px;
    line-height: 1.35;
    text-align: left;
}

.room-language-field {
    margin: 14px auto 0;
}

.target-preview-text {
    display: grid;
    min-width: 0;
    justify-items: start;
    gap: 2px;
}

.target-preview-text span {
    color: #777777;
    font-size: 13px;
}

.target-preview-text strong {
    max-width: 100%;
    overflow: hidden;
    color: #202020;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.target-reroll-button {
    display: inline-grid;
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid #d4d4d4;
    border-radius: 5px;
    background: #ffffff;
    color: #333333;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.multiplayer-start {
    display: grid;
    gap: 12px;
    margin-top: 14px;
    text-align: left;
}

.multiplayer-hint,
.multiplayer-start span {
    color: #6a6a6a;
    font-size: 13px;
}

.multiplayer-choice-list {
    display: grid;
    margin-top: 4px;
}

.multiplayer-choice {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, auto);
    align-items: center;
    gap: 16px;
    padding: 14px 0;
}

.multiplayer-choice + .multiplayer-choice {
    border-top: 1px solid #e7e7e7;
}

.multiplayer-choice > div:first-child {
    display: grid;
    gap: 4px;
}

.multiplayer-choice strong {
    color: #262626;
    font-size: 15px;
}

.multiplayer-choice span {
    line-height: 1.3;
}

.multiplayer-actions,
.room-target-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.room-target-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px;
}

.multiplayer-choice > .multiplayer-actions {
    width: 100%;
    justify-content: flex-end;
}

.text-button {
    justify-self: start;
    padding: 0;
    border: 0;
    background: transparent;
    color: #1d5bbf;
    cursor: pointer;
    font-size: 13px;
}

.anonymous-button {
    margin-top: 10px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #777777;
    cursor: pointer;
    font-size: 13px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.anonymous-button:hover {
    color: #303030;
}

.multiplayer-actions .join-code-input,
.room-target-row input {
    min-width: 0;
    flex: 1;
}

.multiplayer-choice > .multiplayer-actions > button:only-child {
    min-width: 180px;
}

.multiplayer-actions .join-code-input,
.room-target-row .target-input {
    box-sizing: border-box;
    height: 38px;
    margin-top: 0;
    padding: 0 10px;
    border: 1px solid #d4d4d4;
    border-radius: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #fbfbfb;
    color: #262626;
    font-size: 16px;
    font-weight: 400;
    line-height: 38px;
    outline: none;
    box-shadow: none;
}

.multiplayer-actions .join-code-input:focus {
    border-color: #8c8c8c;
    background: #ffffff;
}

.multiplayer-actions .join-code-input:disabled {
    opacity: 0.48;
    cursor: default;
}

.room-target-row .target-reroll-button {
    width: 38px;
    height: 38px;
}

.room-code-box {
    display: inline-grid;
    min-width: 116px;
    margin-top: 16px;
    padding: 9px 16px;
    place-items: center;
    border: 1px solid #d7e4ff;
    border-radius: 6px;
    background: #eef5ff;
    color: #163b77;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 3px;
}

.room-target-row {
    margin-top: 18px;
}

.lobby-player-list {
    display: grid;
    gap: 6px;
    margin-top: 18px;
    text-align: left;
}

.lobby-player-row {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) 24px;
    align-items: center;
    gap: 9px;
    min-height: 34px;
    padding: 6px 9px;
    border: 1px solid #e5e5e5;
    border-radius: 5px;
    background: #fafafa;
}

.lobby-player-row.is-you {
    border-color: #d7e4ff;
    background: #f4f8ff;
}

.lobby-player-avatar {
    display: inline-grid;
    width: 26px;
    height: 26px;
    place-items: center;
    border: 1px solid #dddddd;
    border-radius: 999px;
    background: #ffffff;
    color: #4e4e4e;
    font-size: 12px;
    font-weight: 700;
}

.lobby-player-name {
    overflow: hidden;
    color: #262626;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lobby-host-icon {
    justify-self: end;
    color: #17498f;
    font-size: 15px;
    line-height: 1;
}

.lobby-chat {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid #e5e5e5;
    text-align: left;
}

.lobby-chat-header {
    color: #505050;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.lobby-chat-messages {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    overflow: hidden;
    max-height: 190px;
    min-height: 104px;
    margin-top: 6px;
    padding: 5px 6px 6px;
    gap: 0;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    background: #fbfbfb;
    overscroll-behavior: contain;
}

.lobby-chat-log {
    display: block;
    overflow-y: auto;
    min-height: 66px;
    overscroll-behavior: contain;
}

.lobby-chat-message {
    display: flex;
    flex: none;
    gap: 4px;
    align-items: start;
    min-height: 0;
    margin-bottom: 2px;
    padding: 1px 0;
    color: #303030;
    font-size: 12px;
    line-height: 1.35;
}

.lobby-chat-message.is-you .lobby-chat-author {
    color: #17498f;
}

.lobby-chat-message.is-system {
    color: #767676;
}

.lobby-chat-time {
    flex: 0 0 42px;
    color: #969696;
    font-variant-numeric: tabular-nums;
    line-height: 1.35;
}

.lobby-chat-author {
    flex: 0 0 auto;
    margin-right: 5px;
    overflow: hidden;
    max-width: 132px;
    color: #555555;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lobby-chat-author::after {
    content: ":";
}

.lobby-chat-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
    color: #303030;
    font-size: 12px;
    line-height: 1.35;
    white-space: normal;
}

.lobby-chat-system-text {
    color: #777777;
    font-style: italic;
}

.lobby-chat-compose {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px solid #eeeeee;
}

.lobby-chat-compose input {
    min-width: 0;
    height: 28px;
    padding: 0 8px;
    border: 1px solid #d4d4d4;
    border-radius: 4px;
    outline: none;
    font-size: 12px;
}

.lobby-chat-compose input:focus {
    border-color: #8c8c8c;
}

.lobby-chat-compose button {
    height: 28px;
    padding: 0 10px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    background: #f5f5f5;
    color: #262626;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.lobby-chat-compose button:hover:not(:disabled) {
    border-color: #b8b8b8;
    background: #ffffff;
    box-shadow: 0 1px 4px rgb(0 0 0 / 8%);
}

.lobby-chat-compose button:disabled {
    opacity: 0.48;
    cursor: default;
}

.room-lobby-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    margin-top: 16px;
}

.room-lobby-actions button:not(.quiet-button) {
    grid-column: 2;
    min-width: 96px;
    height: 32px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    background: #f5f5f5;
    color: #262626;
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.room-lobby-actions .quiet-button {
    justify-self: start;
}

.quiet-button {
    border: 0;
    background: transparent;
    color: #777777;
    cursor: pointer;
    font-size: 13px;
}

.quiet-button:hover {
    color: #303030;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.room-lobby-actions button:not(.quiet-button):hover:not(:disabled) {
    border-color: #b8b8b8;
    background: #ffffff;
    box-shadow: 0 1px 4px rgb(0 0 0 / 8%);
}

.room-lobby-actions button:not(.quiet-button):disabled {
    opacity: 0.48;
    cursor: default;
}

.target-reroll-button:hover {
    border-color: #b8b8b8;
    background: #f6f6f6;
}

.target-input {
    width: 100%;
    height: 36px;
    margin-top: 14px;
    padding: 0 10px;
    border: 1px solid #d4d4d4;
    border-radius: 5px;
    outline: none;
}

.target-input:focus {
    border-color: #8c8c8c;
}

.confirm-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 14px;
}

.confirm-actions.compact {
    margin-top: 9px;
}

.confirm-actions button {
    min-width: 64px;
    height: 32px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    background: #f5f5f5;
    color: #262626;
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.confirm-actions button:hover:not(:disabled),
.multiplayer-actions button:hover:not(:disabled),
.room-target-row button:hover:not(:disabled) {
    border-color: #b8b8b8;
    background: #ffffff;
    box-shadow: 0 1px 4px rgb(0 0 0 / 8%);
}

.confirm-actions button:disabled,
.multiplayer-actions button:disabled,
.room-target-row button:disabled {
    opacity: 0.48;
    cursor: default;
}

.multiplayer-actions button,
.room-target-row button:not(.target-reroll-button) {
    height: 32px;
    padding: 0 12px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    background: #f5f5f5;
    color: #262626;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    right: 12px;
    bottom: 12px;
    z-index: 1000;
    padding: 10px 14px;
    border-radius: 5px;
    background: #fff0c2;
    box-shadow: 0 2px 12px rgb(0 0 0 / 18%);
}

#blazor-error-ui .dismiss {
    margin-left: 12px;
    cursor: pointer;
}

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

@keyframes discovery-confetti {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.45) rotate(0deg);
    }

    16% {
        opacity: 0.95;
    }

    100% {
        opacity: 0;
        transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1) rotate(220deg);
    }
}

@keyframes own-discovery-shimmer {
    0%,
    58% {
        background-position: 160% 0, 0 0;
    }

    100% {
        background-position: -80% 0, 0 0;
    }
}

@keyframes merge-rejected-shake {
    0%,
    100% {
        transform: translateX(0);
    }

    18% {
        transform: translateX(-5px);
    }

    36% {
        transform: translateX(5px);
    }

    54% {
        transform: translateX(-3px);
    }

    72% {
        transform: translateX(3px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .discovery-particle {
        animation-duration: 0.3s;
    }

    .craft-token.is-own-discovery {
        animation: none;
    }

    .canvas-token.is-merge-rejected {
        animation: none;
    }

    .app-loading-token,
    .app-loading-dots span {
        animation: none;
    }
}

@media (max-width: 760px) {
    .craft-game {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr) 10px var(--inventory-height, 42vh);
    }

    .sidebar-resizer {
        width: 100%;
        height: 10px;
        border-top: 1px solid #eeeeee;
        border-left: 0;
        background: #fafafa;
        cursor: row-resize;
    }

    .sidebar-resizer::before {
        position: absolute;
        top: 4px;
        left: 50%;
        width: 32px;
        height: 2px;
        border-radius: 999px;
        background: #d6d6d6;
        content: "";
        opacity: 0.72;
        transform: translateX(-50%);
    }

    .sidebar-resizer:active::before {
        background: #bdbdbd;
        opacity: 0.9;
    }

    .inventory {
        border-top: 0;
        border-left: 0;
    }

    .brand {
        display: none;
    }

    .app-loading-screen {
        gap: 14px;
        padding: 20px;
    }

    .app-loading-logo {
        font-size: 25px;
    }

    .app-loading-combo {
        flex-wrap: wrap;
        gap: 7px;
        font-size: 16px;
    }

    .pwa-status-strip {
        right: 10px;
        bottom: 10px;
        left: 10px;
        justify-content: center;
        max-width: none;
        padding: 7px 9px;
        font-size: 11px;
    }

    .target-chip {
        top: 12px;
        left: 12px;
        max-width: min(180px, calc(46vw - 28px));
        min-height: 26px;
        padding: 4px 7px;
        gap: 6px;
        font-size: 12px;
    }

    .canvas-trash {
        bottom: 10px;
        left: 10px;
        width: 44px;
        height: 44px;
    }

    .toast-message {
        top: 48px;
        left: 12px;
        right: auto;
        display: -webkit-box;
        width: min(238px, calc(46vw - 28px));
        max-width: calc(100vw - 24px);
        padding: 6px 8px;
        overflow: hidden;
        font-size: 12px;
        line-height: 1.25;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    .toast-message.is-top {
        top: 12px;
    }

    .merge-wait-dialog {
        width: min(320px, calc(100vw - 36px));
    }

    .race-scoreboard {
        top: 10px;
        right: 10px;
        left: auto;
        width: min(228px, 54vw);
        --race-columns: minmax(48px, 0.9fr) 34px minmax(0, 1.1fr);
        max-height: 118px;
        overflow: hidden;
        gap: 2px;
        padding: 6px;
        font-size: 10px;
    }

    .race-scoreboard-title,
    .race-row {
        gap: 5px;
    }

    .race-scoreboard-title strong {
        display: none;
    }

    .race-last {
        display: block;
        min-width: 0;
    }

    .race-row {
        min-height: 18px;
        padding: 2px 3px;
    }

    .game-chat-peek {
        bottom: 58px;
        left: 12px;
        width: min(240px, calc(100vw - 92px));
        gap: 2px;
    }

    .game-chat-peek-line {
        display: -webkit-box;
        overflow: hidden;
        font-size: 10px;
        line-height: 1.2;
        white-space: normal;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    .game-chat-toggle {
        right: 10px;
        bottom: 10px;
        min-width: 44px;
        height: 28px;
        padding: 0 9px;
        font-size: 11px;
    }

    .game-chat-panel {
        right: 10px;
        bottom: 46px;
        left: 10px;
        width: auto;
        padding: 7px;
    }

    .game-chat-panel-header {
        margin-bottom: 4px;
        font-size: 11px;
    }

    .game-chat-messages {
        max-height: min(210px, 42vh);
        min-height: 106px;
    }

    .game-chat-messages .lobby-chat-message,
    .game-chat-messages .lobby-chat-compose button {
        font-size: 11px;
    }

    .lobby-chat-compose input,
    .game-chat-messages .lobby-chat-compose input {
        height: 26px;
        padding: 0 7px;
        font-size: 16px;
        line-height: 26px;
    }

    .lobby-chat-compose button,
    .game-chat-messages .lobby-chat-compose button {
        height: 26px;
        padding: 0 8px;
        font-size: 12px;
    }

    .restart-dialog,
    .player-dialog,
    .settings-dialog,
    .room-lobby-dialog {
        width: min(540px, calc(100vw - 22px));
        max-height: calc(100dvh - 22px);
        padding: 18px;
        -webkit-overflow-scrolling: touch;
    }

    .confirm-dialog,
    .target-complete-dialog,
    .room-results-dialog {
        max-height: calc(100dvh - 22px);
        -webkit-overflow-scrolling: touch;
    }

    .dialog-title {
        font-size: 19px;
    }

    .confirm-copy {
        font-size: 12px;
    }

    .multiplayer-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .multiplayer-actions .join-code-input {
        width: 100%;
        flex: 0 0 auto;
    }

    .room-target-row {
        grid-template-columns: minmax(0, 1fr) 38px;
        align-items: center;
    }

    .multiplayer-choice {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .target-complete-dialog,
    .room-results-dialog {
        width: min(620px, calc(100vw - 22px));
        padding: 22px 18px 20px;
    }

    .room-results-row {
        grid-template-columns: minmax(0, 1.25fr) repeat(3, minmax(54px, 0.55fr));
        gap: 6px;
        padding: 7px 8px;
        font-size: 12px;
    }

    .target-stats {
        grid-template-columns: 1fr;
    }

    .mode-picker {
        grid-template-columns: 1fr;
    }

    .mode-button {
        min-height: 58px;
        flex-direction: row;
    }

    .language-field {
        align-items: stretch;
        flex-direction: column;
        gap: 6px;
    }

    .language-field select {
        width: 100%;
    }
}
