:root {
    --bg-color: #08131d;
    --surface: rgba(12, 24, 36, 0.9);
    --surface-soft: rgba(255, 255, 255, 0.05);
    --primary: #79d2ff;
    --accent: #ffbe63;
    --accent-strong: #ff8359;
    --text-color: #eef8ff;
    --muted-text: #97b0c6;
    --border: rgba(155, 205, 240, 0.18);
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.34);
}

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

body {
    min-height: 100vh;
    font-family: 'Outfit', sans-serif;
    color: var(--text-color);
    overflow: hidden;
    background:
        radial-gradient(circle at top left, rgba(121, 210, 255, 0.18), transparent 30%),
        radial-gradient(circle at 82% 14%, rgba(255, 190, 99, 0.16), transparent 22%),
        linear-gradient(135deg, #061018 0%, #0d2130 52%, #11251d 100%);
}

.app-container {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1440px;
    margin: 0 auto;
    padding: clamp(10px, 1.6vw, 18px);
    gap: 12px;
}

.background-glow {
    position: absolute;
    border-radius: 999px;
    filter: blur(24px);
    opacity: 0.5;
    pointer-events: none;
}

.glow-left {
    width: 260px;
    height: 260px;
    top: 80px;
    left: -100px;
    background: radial-gradient(circle, rgba(121, 210, 255, 0.22), transparent 70%);
}

.glow-right {
    width: 280px;
    height: 280px;
    right: -110px;
    bottom: 110px;
    background: radial-gradient(circle, rgba(255, 131, 89, 0.18), transparent 72%);
}

.top-bar,
.hero-strip,
.sidebar,
.board-stage {
    position: relative;
    z-index: 1;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(11, 24, 37, 0.95), rgba(11, 24, 37, 0.78));
    backdrop-filter: blur(14px);
    box-shadow: var(--shadow);
}

.brand-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.eyebrow,
.hero-kicker,
.panel-kicker,
.mini-label {
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted-text);
}

.logo {
    font-size: clamp(1.7rem, 3vw, 2.5rem);
    font-weight: 800;
    line-height: 1;
}

.top-actions,
.setup-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.room-actions {
    display: flex;
    margin-bottom: 10px;
}

.join-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    margin-bottom: 12px;
}

.glow-btn {
    border: 1px solid rgba(121, 210, 255, 0.38);
    background: linear-gradient(180deg, rgba(16, 42, 61, 0.96), rgba(9, 21, 31, 0.96));
    color: var(--text-color);
    padding: 12px 18px;
    border-radius: 14px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.22);
}

.glow-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: rgba(255, 190, 99, 0.55);
    box-shadow: 0 18px 32px rgba(0, 0, 0, 0.26);
}

.glow-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

.subtle-btn {
    padding: 10px 14px;
    font-size: 0.85rem;
}

.secondary-btn {
    border-color: rgba(255, 190, 99, 0.34);
}

.main-area {
    display: grid;
    grid-template-columns: minmax(220px, 260px) minmax(0, 1fr) minmax(220px, 260px);
    gap: 12px;
    align-items: start;
    flex: 1;
    min-height: 0;
}

.sidebar,
.view-panel,
.board-stage,
.game-messages-card,
.dice-container {
    border: 1px solid var(--border);
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(10, 22, 34, 0.92), rgba(10, 22, 34, 0.76));
    backdrop-filter: blur(14px);
    box-shadow: var(--shadow);
}

.view-panel,
.board-stage {
    padding: 14px;
}

.panel-header {
    margin-bottom: 12px;
}

.panel-header h2,
.board-stage-header h2 {
    margin-top: 6px;
    font-size: 1.15rem;
}

.setup-group {
    margin-bottom: 10px;
}

.input-label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted-text);
    font-size: 0.92rem;
}

.input-control {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    outline: none;
}

select.input-control {
    color-scheme: dark;
}

select.input-control option {
    background: #0d2130;
    color: #eef8ff;
}

.input-control:focus {
    border-color: rgba(121, 210, 255, 0.55);
    box-shadow: 0 0 0 3px rgba(121, 210, 255, 0.12);
}

.player-setup-list {
    display: grid;
    gap: 10px;
    margin-bottom: 12px;
}

.player-input-card {
    display: block;
}

.side-message-card {
    margin-top: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-soft);
}

.room-code-card {
    margin-bottom: 12px;
}

.status-card,
.status-list-wrap {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-soft);
}

.status-card + .status-card,
.status-card + .status-list-wrap {
    margin-top: 10px;
}

.side-dice-card {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.status-card strong {
    display: block;
    margin-top: 6px;
    font-size: 0.98rem;
}

.player-status-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.status-player {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
}

.status-player.active {
    border: 1px solid rgba(121, 210, 255, 0.34);
    background: rgba(121, 210, 255, 0.08);
}

.player-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.player-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    display: inline-block;
}

.status-square {
    color: var(--muted-text);
    font-size: 0.82rem;
}

.board-column {
    min-width: 0;
}

.board-stage-header {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.board-legend {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    color: var(--muted-text);
    font-size: 0.82rem;
}

.board-legend span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    display: inline-block;
}

.ladder-dot {
    background: #d8ab51;
}

.snake-dot {
    background: #69d87f;
}

.game-board-wrapper {
    position: relative;
    width: min(100%, min(60vh, 520px));
    aspect-ratio: 1;
    margin: 0 auto;
}

.board {
    position: relative;
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 24px;
    border: 2px solid rgba(255, 255, 255, 0.08);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0)),
        linear-gradient(135deg, #10293c 0%, #0b1722 52%, #14291d 100%);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03), 0 22px 40px rgba(0, 0, 0, 0.28);
}

.square {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    padding: clamp(4px, 0.8vw, 8px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    font-size: clamp(0.58rem, 1vw, 0.82rem);
    font-weight: 700;
    color: rgba(255, 255, 255, 0.66);
}

.square:nth-child(4n + 1) {
    background: rgba(121, 210, 255, 0.08);
}

.square:nth-child(4n + 2) {
    background: rgba(255, 190, 99, 0.08);
}

.square:nth-child(4n + 3) {
    background: rgba(255, 131, 89, 0.08);
}

.square:nth-child(4n) {
    background: rgba(105, 216, 127, 0.08);
}

.token-layer {
    position: absolute;
    inset: 0;
    z-index: 20;
    pointer-events: none;
}

.player-token {
    position: absolute;
    width: clamp(20px, 4vw, 30px);
    height: clamp(20px, 4vw, 30px);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    z-index: 21;
    transform: translate(-50%, -50%);
    transition: left 0.45s ease-in-out, top 0.45s ease-in-out;
}

.token-label {
    font-size: clamp(0.55rem, 1vw, 0.72rem);
    font-weight: 800;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.dice-container {
    padding: 12px 14px;
}

.game-messages {
    margin-top: 8px;
    min-height: 22px;
    line-height: 1.45;
    font-size: 0.92rem;
}

.dice-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dice-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.dice {
    width: clamp(52px, 6vw, 64px);
    height: clamp(52px, 6vw, 64px);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transform-style: preserve-3d;
    border: 2px solid rgba(255, 190, 99, 0.42);
    border-radius: 18px;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.16), transparent 44%),
        linear-gradient(180deg, rgba(21, 48, 70, 0.98), rgba(8, 19, 29, 0.98));
    box-shadow: 0 0 20px rgba(255, 190, 99, 0.14);
    transition: transform 1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.pip {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.pip.top-left {
    top: 14px;
    left: 14px;
}

.pip.top-right {
    top: 14px;
    right: 14px;
}

.pip.middle-left {
    top: 50%;
    left: 14px;
    transform: translateY(-50%);
}

.pip.middle-right {
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
}

.pip.center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.pip.bottom-left {
    bottom: 14px;
    left: 14px;
}

.pip.bottom-right {
    right: 14px;
    bottom: 14px;
}

.spinning {
    transform: rotateX(720deg) rotateY(720deg) rotateZ(360deg) scale(1.15);
}

.roll-effect-flip {
    animation: diceFlip 1.1s cubic-bezier(0.22, 1, 0.36, 1);
}

.roll-effect-shake {
    animation: diceShake 1.1s ease-in-out;
}

.roll-effect-slam {
    animation: diceSlam 1.1s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.roll-effect-wobble {
    animation: diceWobble 1.1s ease-in-out;
}

.dice-btn {
    padding: 12px 18px;
    font-size: 0.92rem;
}

.app-credit {
    position: relative;
    z-index: 1;
    text-align: center;
    font-size: 0.82rem;
    color: var(--muted-text);
    padding-bottom: 2px;
}

.app-credit span {
    color: var(--accent-strong);
}

.board-label {
    position: absolute;
    z-index: 5;
    pointer-events: none;
    font-size: 10px;
    color: #fff;
    background: rgba(0, 0, 0, 0.6);
    padding: 2px;
    border-radius: 4px;
}

.snake-group {
    transform-box: fill-box;
    transform-origin: center;
}

.snake-active .snake-main {
    filter: drop-shadow(0 0 8px rgba(156, 241, 125, 0.7));
    animation: snakePulse 0.45s ease-in-out infinite alternate;
}

.snake-active .snake-marks {
    animation: snakeFlash 0.28s linear infinite;
}

.snake-active .snake-head {
    animation: snakeHeadWiggle 0.3s ease-in-out infinite alternate;
}

@keyframes diceFlip {
    0% {
        transform: rotateX(0deg) rotateY(0deg) scale(1);
    }

    40% {
        transform: rotateX(540deg) rotateY(360deg) scale(1.18);
    }

    75% {
        transform: rotateX(760deg) rotateY(620deg) scale(1.05);
    }

    100% {
        transform: rotateX(720deg) rotateY(720deg) scale(1);
    }
}

@keyframes diceShake {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(1);
    }

    15% {
        transform: translate(-8px, -4px) rotate(-14deg) scale(1.08);
    }

    30% {
        transform: translate(8px, 3px) rotate(14deg) scale(1.12);
    }

    45% {
        transform: translate(-6px, 5px) rotate(-10deg) scale(1.08);
    }

    60% {
        transform: translate(6px, -3px) rotate(10deg) scale(1.05);
    }

    100% {
        transform: translate(0, 0) rotate(0deg) scale(1);
    }
}

@keyframes diceSlam {
    0% {
        transform: translateY(-14px) scale(0.92) rotate(-8deg);
    }

    35% {
        transform: translateY(8px) scale(1.18) rotate(12deg);
    }

    55% {
        transform: translateY(-4px) scale(1.04) rotate(-8deg);
    }

    75% {
        transform: translateY(2px) scale(1.01) rotate(4deg);
    }

    100% {
        transform: translateY(0) scale(1) rotate(0deg);
    }
}

@keyframes diceWobble {
    0% {
        transform: rotate(0deg) scale(1);
    }

    20% {
        transform: rotate(-18deg) scale(1.1);
    }

    40% {
        transform: rotate(18deg) scale(1.12);
    }

    60% {
        transform: rotate(-10deg) scale(1.06);
    }

    80% {
        transform: rotate(6deg) scale(1.02);
    }

    100% {
        transform: rotate(0deg) scale(1);
    }
}

@keyframes snakePulse {
    from {
        stroke-width: 14;
        opacity: 0.92;
    }

    to {
        stroke-width: 16.5;
        opacity: 1;
    }
}

@keyframes snakeFlash {
    from {
        opacity: 0.45;
    }

    to {
        opacity: 1;
    }
}

@keyframes snakeHeadWiggle {
    from {
        transform: rotate(-6deg);
    }

    to {
        transform: rotate(6deg);
    }
}

@media (max-width: 1180px) {
    .main-area,
    .bottom-area {
        grid-template-columns: 1fr;
    }

    body {
        overflow-y: auto;
    }

    .app-container {
        height: auto;
        min-height: 100vh;
    }
}

@media (max-width: 760px) {
    .app-container {
        padding: 14px;
        gap: 14px;
    }

    .top-bar,
    .top-actions,
    .setup-actions,
    .room-actions,
    .board-stage-header,
    .dice-container {
        flex-direction: column;
        align-items: stretch;
    }

    .view-panel {
        display: flex;
        flex-direction: column;
    }

    .side-dice-card {
        order: 1;
    }

    .status-card,
    .status-list-wrap {
        order: 2;
    }

    .join-row {
        grid-template-columns: 1fr;
    }

    .top-bar,
    .view-panel,
    .board-stage,
    .game-messages-card,
    .dice-container {
        padding: 14px;
        border-radius: 20px;
    }

    .glow-btn,
    .dice-btn,
    .input-control {
        width: 100%;
    }

    .dice-meta {
        align-self: center;
    }

    .status-player {
        flex-direction: column;
        align-items: flex-start;
    }
    .pip {
        width: 8px;
        height: 8px;
    }

    .pip.top-left,
    .pip.top-right {
        top: 12px;
    }

    .pip.top-left,
    .pip.middle-left,
    .pip.bottom-left {
        left: 12px;
    }

    .pip.top-right,
    .pip.middle-right,
    .pip.bottom-right {
        right: 12px;
    }

    .pip.bottom-left,
    .pip.bottom-right {
        bottom: 12px;
    }
}
