:root {
    --ink: #10261f;
    --muted: #65736d;
    --paper: #f6f1e6;
    --paper-deep: #e9e0cf;
    --forest: #0d3b2d;
    --forest-dark: #08291f;
    --grass: #2f8f4e;
    --grass-light: #45a85e;
    --red: #d84f3f;
    --gold: #f1bf3b;
    --amber: #cc8a2f;
    --wood: #c7a16f;
    --white: #fffdf8;
    --shadow: 0 24px 70px rgba(12, 38, 29, 0.16);
    --soft-shadow: 0 12px 34px rgba(12, 38, 29, 0.12);
    --radius-lg: 30px;
    --radius-md: 18px;
    --font-display: "Uncial Antiqua", Georgia, serif;
    --font-body: "Manrope", system-ui, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--paper);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 10% 10%, rgba(241, 191, 59, 0.14), transparent 30rem),
        radial-gradient(circle at 90% 8%, rgba(39, 125, 76, 0.12), transparent 34rem),
        var(--paper);
    font-family: var(--font-body);
    line-height: 1.5;
}

button,
input {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    color: inherit;
}

[hidden] {
    display: none !important;
}

.page-grain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.16;
    z-index: 100;
    background-image:
        repeating-radial-gradient(circle at 20% 30%, rgba(39, 62, 51, .15) 0 0.4px, transparent 0.8px 4px),
        repeating-radial-gradient(circle at 75% 65%, rgba(95, 70, 42, .1) 0 0.5px, transparent 1px 6px);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.site-header {
    position: relative;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: min(1420px, calc(100% - 48px));
    margin: 0 auto;
    padding: 22px 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.brand-image-wrap {
    width: 52px;
    height: 52px;
    overflow: hidden;
    border: 3px solid var(--white);
    border-radius: 16px;
    box-shadow: 0 6px 18px rgba(12, 42, 31, 0.17);
    background: #8fd4e3;
}

.brand-image {
    width: 74px;
    height: 56px;
    object-fit: cover;
    object-position: 6% 47%;
}

.brand-copy {
    display: grid;
    line-height: 1;
}

.brand-name {
    font-family: var(--font-display);
    font-size: 20px;
    letter-spacing: 0.02em;
}

.brand-edition {
    margin-top: 7px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.text-button,
.icon-button,
.dialog-close {
    border: 0;
    background: transparent;
    cursor: pointer;
}

.text-button {
    padding: 10px 2px;
    border-bottom: 1px solid rgba(16, 38, 31, 0.28);
    font-size: 13px;
    font-weight: 800;
}

.connection-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 11px;
    border: 1px solid rgba(12, 64, 45, 0.14);
    border-radius: 999px;
    background: rgba(255, 253, 248, 0.74);
    font-size: 11px;
    font-weight: 800;
}

.connection-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #45a85e;
    box-shadow: 0 0 0 4px rgba(69, 168, 94, 0.14);
}

.connection-pill.is-offline .connection-dot {
    background: var(--red);
    box-shadow: 0 0 0 4px rgba(216, 79, 63, 0.12);
}

.lobby-view {
    position: relative;
    display: grid;
    grid-template-columns: minmax(350px, 0.95fr) minmax(430px, 1.2fr) minmax(330px, 0.8fr);
    align-items: center;
    gap: clamp(22px, 3vw, 54px);
    width: min(1420px, calc(100% - 48px));
    min-height: calc(100vh - 104px);
    margin: 0 auto;
    padding: 28px 0 76px;
}

.hero-copy {
    position: relative;
    z-index: 4;
}

.eyebrow {
    margin: 0 0 10px;
    color: #2b7851;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.hero-copy h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(43px, 5.1vw, 78px);
    font-weight: 400;
    line-height: 1.04;
    letter-spacing: -0.035em;
}

.hero-copy h1 span {
    color: var(--red);
}

.hero-lede {
    max-width: 560px;
    margin: 26px 0 0;
    color: #52635c;
    font-size: clamp(15px, 1.3vw, 18px);
    line-height: 1.75;
}

.designer-credit {
    margin: 17px 0 0;
    color: #758079;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.025em;
}

.designer-credit strong {
    color: #355c49;
    font-weight: 800;
}

.hero-facts {
    display: flex;
    gap: 24px;
    margin-top: 34px;
}

.hero-facts span {
    display: grid;
    gap: 2px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.hero-facts strong {
    color: var(--ink);
    font-family: var(--font-display);
    font-size: 21px;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
}

.lobby-art {
    position: relative;
    min-height: 570px;
    align-self: stretch;
    overflow: hidden;
    border-radius: 42% 42% 32px 32px;
    background: linear-gradient(#7fcadd 0 53%, #72ad65 53% 100%);
    box-shadow: var(--shadow);
    isolation: isolate;
}

.sun-disc {
    position: absolute;
    top: 48px;
    right: 54px;
    width: 100px;
    aspect-ratio: 1;
    border-radius: 50%;
    background: rgba(255, 234, 166, 0.78);
    box-shadow: 0 0 60px 18px rgba(255, 235, 173, 0.34);
}

.hero-viking {
    position: absolute;
    inset: 0;
    z-index: 2;
    overflow: hidden;
}

.hero-viking img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 35% center;
    mix-blend-mode: multiply;
}

.hill {
    position: absolute;
    left: -10%;
    width: 120%;
    border-radius: 50% 50% 0 0;
}

.hill-far {
    bottom: 110px;
    z-index: 1;
    height: 180px;
    background: #78b66e;
    transform: rotate(-3deg);
}

.hill-near {
    bottom: -90px;
    z-index: 3;
    height: 250px;
    background: linear-gradient(#4e9a58, #246a41);
    transform: rotate(3deg);
}

.hero-die {
    position: absolute !important;
    right: 40px;
    bottom: 95px;
    z-index: 5;
    transform: rotate(11deg);
    box-shadow: 0 20px 34px rgba(14, 54, 37, 0.34) !important;
}

.hero-kubb {
    position: absolute;
    right: 125px;
    bottom: 28px;
    z-index: 5;
    width: 32px;
    height: 82px;
    transform: rotate(-6deg);
    border: 1px solid #705236;
    border-radius: 4px 4px 6px 6px;
    background: linear-gradient(90deg, #926f4b, #d0ae7d 35%, #b98d59 76%, #785a3c);
    box-shadow: 11px 16px 16px rgba(18, 53, 35, 0.28);
}

.hero-kubb::before {
    content: "";
    position: absolute;
    top: -9px;
    left: -1px;
    width: 32px;
    height: 17px;
    border: 1px solid #705236;
    clip-path: polygon(0 100%, 0 0, 20% 55%, 38% 0, 56% 55%, 75% 0, 100% 55%, 100% 100%);
    background: #caa575;
}

.lobby-card {
    position: relative;
    z-index: 5;
    padding: 11px;
    border: 1px solid rgba(12, 50, 37, 0.11);
    border-radius: var(--radius-lg);
    background: rgba(255, 253, 248, 0.88);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.lobby-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    padding: 5px;
    border-radius: 18px;
    background: #e8e3d8;
}

.lobby-tab {
    min-height: 46px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: #6e7873;
    cursor: pointer;
    font-size: 11px;
    font-weight: 800;
}

.lobby-tab.is-active {
    background: var(--white);
    color: var(--forest);
    box-shadow: 0 5px 14px rgba(29, 53, 44, 0.08);
}

.lobby-form {
    padding: 26px 22px 22px;
}

.form-intro {
    margin-bottom: 25px;
}

.form-intro h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 400;
}

.form-intro p {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.field-label {
    display: block;
    margin: 14px 0 7px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.text-input {
    width: 100%;
    height: 52px;
    padding: 0 15px;
    border: 1px solid #d8d4ca;
    border-radius: 13px;
    outline: none;
    background: #fffefa;
    color: var(--ink);
    transition: border-color 160ms, box-shadow 160ms;
}

.text-input:focus {
    border-color: #2d7e55;
    box-shadow: 0 0 0 4px rgba(45, 126, 85, 0.11);
}

.text-input::placeholder {
    color: #a2aaa6;
}

.code-input {
    font-size: 19px;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.difficulty-fieldset {
    min-width: 0;
    margin: 18px 0 0;
    padding: 0;
    border: 0;
}

.difficulty-fieldset legend {
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.difficulty-list {
    display: grid;
    gap: 7px;
}

.difficulty-option {
    position: relative;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 53px;
    padding: 8px 11px;
    border: 1px solid #dcd7cc;
    border-radius: 12px;
    background: #fffefa;
    cursor: pointer;
    transition: border-color 160ms, background-color 160ms, box-shadow 160ms;
}

.difficulty-option:has(input:checked) {
    border-color: #2d7e55;
    background: #f0f6ed;
    box-shadow: 0 0 0 3px rgba(45, 126, 85, 0.09);
}

.difficulty-option input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--forest);
}

.difficulty-copy {
    display: grid;
    min-width: 0;
}

.difficulty-copy strong {
    font-size: 11px;
}

.difficulty-copy small {
    overflow: hidden;
    color: #7b857f;
    font-size: 8px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.risk-bars {
    display: flex;
    align-items: end;
    gap: 3px;
    height: 17px;
}

.risk-bars i {
    width: 4px;
    border-radius: 4px;
    background: #d3d4ce;
}

.risk-bars i:nth-child(1) { height: 7px; background: #4a9863; }
.risk-bars i:nth-child(2) { height: 12px; }
.risk-bars i:nth-child(3) { height: 17px; }
.risk-bars.level-two i:nth-child(2),
.risk-bars.level-three i { background: #d6a335; }
.risk-bars.level-three i:nth-child(3) { background: #d95743; }

.primary-button,
.secondary-button,
.danger-button,
.resume-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 52px;
    border-radius: 13px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
    transition: transform 160ms, box-shadow 160ms, opacity 160ms;
}

.primary-button {
    width: 100%;
    margin-top: 22px;
    padding: 0 18px;
    border: 1px solid #0b3226;
    background: var(--forest);
    color: white;
    box-shadow: 0 10px 22px rgba(13, 59, 45, 0.18);
}

.primary-button:hover,
.secondary-button:hover,
.resume-button:hover {
    transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    transform: none;
}

.primary-button.compact {
    width: auto;
    min-height: 44px;
    margin: 0;
}

.secondary-button,
.danger-button {
    padding: 0 18px;
    border: 1px solid #d6d1c6;
    background: #fffefa;
}

.danger-button {
    border-color: rgba(181, 67, 53, 0.24);
    color: #a23c31;
}

.full-width {
    width: 100%;
}

.form-error {
    margin: -8px 22px 18px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #fae6e1;
    color: #a43c31;
    font-size: 12px;
    font-weight: 700;
}

.resume-button {
    justify-content: space-between;
    width: calc(100% - 44px);
    margin: 0 22px 20px;
    padding: 0 16px;
    border: 1px dashed #99aa9f;
    background: #f2f3ea;
}

.game-view {
    width: min(1420px, calc(100% - 48px));
    margin: 0 auto;
    padding: 8px 0 56px;
}

.match-bar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 20px;
    margin-bottom: 17px;
}

.room-chip,
.game-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.room-chip strong,
.game-chip strong {
    color: var(--ink);
    font-size: 12px;
    letter-spacing: 0.16em;
}

.game-chip {
    justify-self: end;
}

.game-chip span {
    padding-right: 10px;
    border-right: 1px solid #cbc7bd;
}

.icon-button {
    padding: 6px 9px;
    border-radius: 7px;
    background: rgba(17, 58, 45, 0.07);
    color: #286247;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: none;
}

.scoreboard {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 9px 12px;
    border: 1px solid rgba(16, 38, 31, 0.1);
    border-radius: 999px;
    background: rgba(255, 253, 248, 0.78);
    box-shadow: 0 6px 20px rgba(26, 54, 44, 0.08);
}

.score-player {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 180px;
    font-size: 12px;
    font-weight: 800;
}

.score-player.is-you::after {
    content: "YOU";
    padding: 2px 5px;
    border-radius: 4px;
    background: #dde9df;
    color: #286247;
    font-size: 7px;
    letter-spacing: 0.12em;
}

.score-player.is-ai::after {
    content: "AI";
    padding: 2px 5px;
    border-radius: 4px;
    background: #f1e6bf;
    color: #8a651d;
    font-size: 7px;
    letter-spacing: 0.12em;
}

.team-dot {
    width: 9px;
    height: 9px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--team);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--team) 18%, transparent);
}

.score-points {
    display: flex;
    gap: 5px;
}

.score-points i {
    width: 18px;
    height: 7px;
    border-radius: 999px;
    background: #d8d7cf;
}

.score-points i.is-won {
    background: var(--team);
}

.score-versus {
    color: #9ba39e;
    font-family: var(--font-display);
    font-size: 12px;
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
    gap: 18px;
    align-items: start;
}

.pitch-card,
.action-card {
    border: 1px solid rgba(16, 50, 38, 0.1);
    border-radius: 28px;
    background: rgba(255, 253, 248, 0.85);
    box-shadow: var(--soft-shadow);
    backdrop-filter: blur(10px);
}

.pitch-card {
    padding: clamp(16px, 2vw, 25px);
}

.pitch-topline {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 16px;
}

.pitch-topline h2,
.turn-heading h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(20px, 2vw, 27px);
    font-weight: 400;
}

.pitch-legend {
    display: flex;
    gap: 12px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
}

.pitch-legend span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-mark {
    width: 14px;
    height: 3px;
    border-radius: 4px;
}

.field-mark {
    background: #f8e5b3;
}

.baseline-mark {
    background: #fff;
}

.pitch-wrap {
    position: relative;
    padding: 10px;
    border-radius: 24px;
    background: #d9c8a9;
    box-shadow: inset 0 0 0 1px rgba(65, 45, 27, 0.14), inset 0 0 20px rgba(79, 49, 24, 0.12);
}

.pitch {
    position: relative;
    width: 100%;
    min-height: clamp(500px, 63vh, 690px);
    overflow: hidden;
    border-radius: 17px;
    background:
        radial-gradient(ellipse at 20% 40%, rgba(255,255,255,.09), transparent 38%),
        repeating-linear-gradient(0deg, transparent 0 3px, rgba(10,61,32,.03) 3px 4px),
        linear-gradient(90deg, #237b42, #34924d 24%, #2a8547 50%, #379650 74%, #247d43);
    box-shadow: inset 0 0 50px rgba(8, 49, 28, 0.35);
    isolation: isolate;
}

.pitch::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    opacity: 0.1;
    background-image:
        repeating-linear-gradient(83deg, transparent 0 12px, rgba(255,255,255,.28) 13px 14px, transparent 15px 28px),
        repeating-linear-gradient(97deg, transparent 0 18px, rgba(5,48,26,.2) 19px 20px, transparent 21px 35px);
}

.mown-stripe {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 16.66%;
    background: rgba(151, 210, 118, 0.07);
}

.stripe-one { left: 16.66%; }
.stripe-two { left: 49.98%; }
.stripe-three { left: 83.3%; }

.pitch-line {
    position: absolute;
    z-index: 1;
    left: 5%;
    width: 90%;
    height: 2px;
    background: rgba(247, 239, 211, 0.72);
    box-shadow: 0 1px 2px rgba(11, 55, 31, 0.3);
}

.center-line { top: 50%; }
.far-baseline-line { top: 10%; }
.near-baseline-line { bottom: 10%; }

.center-line::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 12px;
    height: 12px;
    transform: translate(-50%, -50%) rotate(45deg);
    border: 2px solid rgba(247, 239, 211, 0.72);
}

.side-name {
    position: absolute;
    z-index: 2;
    right: 3.2%;
    max-width: 150px;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.8);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.far-side-name { top: 4%; }
.near-side-name { bottom: 3.5%; }

.piece-zone {
    position: absolute;
    z-index: 5;
    left: 8%;
    right: 8%;
    display: flex;
    align-items: end;
    justify-content: center;
    gap: clamp(8px, 2.6vw, 27px);
    min-height: 48px;
}

.far-baseline { top: 5.5%; }
.near-baseline { bottom: 5.2%; }

.far-field,
.near-field {
    display: grid;
    grid-template-columns: repeat(5, minmax(18px, 30px));
    justify-content: center;
    gap: 7px 13px;
    min-height: 84px;
}

.far-field {
    top: 24%;
    align-content: start;
}

.near-field {
    bottom: 23%;
    align-content: end;
}

.kubb {
    --team: var(--red);
    position: relative;
    width: clamp(15px, 2vw, 21px);
    height: clamp(35px, 4.6vw, 48px);
    flex: 0 0 auto;
    transform: perspective(110px) rotateX(-3deg);
    border: 1px solid #6a4d31;
    border-radius: 2px 2px 4px 4px;
    background:
        linear-gradient(82deg, transparent 42%, rgba(91,60,32,.18) 44% 46%, transparent 48%),
        linear-gradient(90deg, #8c6847, #d0ad7b 29%, #c39a65 65%, #79583a);
    box-shadow: 5px 8px 8px rgba(9, 48, 26, 0.28);
    animation: piece-arrive 360ms ease both;
}

.kubb.owner-1 { --team: var(--gold); }

.kubb::before {
    content: "";
    position: absolute;
    top: -5px;
    left: -1px;
    width: calc(100% + 2px);
    height: 10px;
    border: 1px solid #6b4e33;
    border-bottom: 0;
    clip-path: polygon(0 100%, 0 0, 21% 55%, 39% 0, 57% 55%, 76% 0, 100% 55%, 100% 100%);
    background: linear-gradient(90deg, #a57e55, #d3b483 54%, #997149);
}

.kubb::after {
    content: "";
    position: absolute;
    left: -1px;
    right: -1px;
    bottom: 8px;
    height: 5px;
    border-top: 1px solid rgba(68, 43, 23, 0.45);
    border-bottom: 1px solid rgba(68, 43, 23, 0.45);
    background: var(--team);
}

.kubb.is-pending {
    filter: saturate(0.4);
    opacity: 0.43;
    transform: rotate(72deg) translateY(6px);
}

.king-star {
    position: absolute;
    z-index: 2;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 235, 164, 0.82);
    font-size: 68px;
    line-height: 1;
    text-shadow: 0 2px 7px rgba(7, 48, 25, 0.25);
}

.king {
    position: absolute;
    z-index: 7;
    top: 50%;
    left: 50%;
    width: 29px;
    height: 61px;
    transform: translate(-50%, -51%);
    filter: drop-shadow(7px 10px 6px rgba(8, 42, 23, 0.35));
    transition: transform 500ms, opacity 500ms;
}

.king-body {
    position: absolute;
    inset: 12px 0 0;
    border: 1px solid #60452e;
    border-radius: 3px 3px 5px 5px;
    background:
        linear-gradient(90deg, transparent 47%, rgba(83,52,28,.25) 49% 52%, transparent 54%),
        linear-gradient(90deg, #806044, #d0aa75 35%, #b68755 70%, #67482f);
}

.king-body::after {
    content: "ᚲ";
    position: absolute;
    top: 17px;
    left: 50%;
    transform: translateX(-50%);
    color: #4d3726;
    font-size: 15px;
    font-weight: 800;
}

.king-crown {
    position: absolute;
    z-index: 2;
    top: 0;
    width: 100%;
    height: 20px;
    clip-path: polygon(0 100%, 0 5%, 18% 52%, 35% 0, 51% 52%, 68% 0, 84% 52%, 100% 5%, 100% 100%);
    border-bottom: 2px solid #61462f;
    background: linear-gradient(90deg, #a3794f, #d5b17e 48%, #85603e);
}

.king.is-fallen {
    opacity: 0.72;
    transform: translate(-50%, -50%) rotate(79deg) translateY(15px);
}

.throw-line {
    position: absolute;
    z-index: 3;
    left: 50%;
    width: 2px;
    height: 20%;
    transform: translateX(-50%);
    border-left: 2px dashed rgba(248, 229, 179, 0.45);
    opacity: 0;
    transition: opacity 200ms;
}

.throw-line.from-near { bottom: 11%; opacity: 1; }
.throw-line.from-near-field { bottom: 34%; opacity: 1; }
.throw-line.from-far { top: 11%; opacity: 1; }
.throw-line.from-far-field { top: 34%; opacity: 1; }

.last-event {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 48px;
    margin-top: 12px;
    padding: 8px 12px;
    border-radius: 13px;
    background: #edf0e7;
}

.last-event p {
    margin: 0;
    color: #4c5e56;
    font-size: 12px;
    font-weight: 600;
}

.event-icon {
    display: grid;
    width: 29px;
    height: 29px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 50%;
    background: var(--forest);
    color: #f6d675;
    font-family: serif;
}

.action-card {
    position: sticky;
    top: 18px;
    overflow: hidden;
}

.turn-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 95px;
    padding: 21px 22px;
    border-bottom: 1px solid #e2ded3;
}

.turn-avatar {
    display: grid;
    width: 45px;
    height: 45px;
    place-items: center;
    border: 3px solid white;
    border-radius: 50%;
    background: var(--team, #d8d5cc);
    color: #fff;
    box-shadow: 0 4px 12px rgba(18, 50, 39, 0.14);
    font-size: 15px;
    font-weight: 800;
}

.setup-panel,
.turn-panel,
.match-end-panel {
    padding: 22px;
}

.setup-panel {
    text-align: center;
}

.waiting-rune {
    display: grid;
    width: 68px;
    height: 68px;
    margin: 2px auto 17px;
    place-items: center;
    border: 1px solid #d9caa4;
    border-radius: 50%;
    background: #f4ebd3;
    color: #926c28;
    font-family: serif;
    font-size: 31px;
    box-shadow: 0 7px 18px rgba(92, 65, 24, 0.1);
}

.setup-panel h3,
.match-end-panel h3 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 400;
}

.setup-panel > p,
.match-end-panel > p {
    margin: 9px auto 18px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.65;
}

.opening-rolls {
    display: grid;
    gap: 10px;
    margin-top: 15px;
}

.opening-player {
    padding: 10px;
    border-radius: 12px;
    background: #f1efe8;
    text-align: left;
}

.opening-player > span {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 10px;
    font-weight: 800;
}

.opening-dice {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 5px;
}

.turn-meters,
.token-bank,
.hit-bank {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.turn-meters {
    margin-bottom: 16px;
}

.meter-block {
    display: grid;
    gap: 6px;
}

.meter-block > span,
.token-label,
.target-kicker {
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.align-right {
    justify-items: end;
}

.throw-pips,
.void-meter,
.tokens {
    display: flex;
    gap: 6px;
}

.throw-pips i {
    width: 28px;
    height: 8px;
    border-radius: 99px;
    background: #dbddd4;
}

.throw-pips i.is-used {
    background: var(--forest);
}

.void-meter i {
    display: grid;
    width: 20px;
    height: 20px;
    place-items: center;
    border: 1px solid #d6d7cf;
    border-radius: 50%;
    background: #f0f1eb;
}

.void-meter i::after {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #c8cbc3;
}

.void-meter i.is-visible {
    border-color: #191c20;
    background: #272a2d;
    box-shadow: 0 0 0 3px rgba(32, 34, 37, 0.1);
}

.void-meter i.is-visible::after {
    background: #bc5450;
    box-shadow: 0 0 7px #e2605a;
}

.token-bank {
    padding: 13px;
    border: 1px solid #e1d7c0;
    border-radius: 13px;
    background: #f6efde;
}

.token-bank > div:first-child {
    display: grid;
    gap: 2px;
}

.token-bank small {
    color: #8b8170;
    font-size: 8px;
}

.token {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border: 2px solid #8e5a34;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #e2a451, #9b5b31 62%, #6f3d25);
    color: #ffe3a0;
    box-shadow: inset 0 0 0 2px rgba(255, 214, 132, 0.26), 0 3px 5px rgba(83, 49, 24, 0.18);
    font-family: serif;
    font-size: 13px;
}

.token.is-empty {
    border-color: #d5cdbd;
    background: transparent;
    box-shadow: none;
    color: transparent;
}

.target-card {
    position: relative;
    margin-top: 15px;
    padding: 12px 14px;
    overflow: hidden;
    border-radius: 13px;
    background: var(--forest);
    color: white;
}

.target-card::after {
    content: "ᚦ";
    position: absolute;
    right: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(240, 195, 69, 0.18);
    font-family: serif;
    font-size: 54px;
}

.target-kicker {
    display: block;
    color: rgba(255,255,255,.6);
}

.target-card strong {
    position: relative;
    z-index: 1;
    display: block;
    margin-top: 1px;
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 400;
}

.target-card p {
    position: relative;
    z-index: 1;
    margin: 4px 0 0;
    color: rgba(255,255,255,.7);
    font-size: 9px;
}

.dice-tray {
    display: grid;
    min-height: 132px;
    margin: 15px 0 11px;
    place-items: center;
    border: 1px dashed #d5d1c8;
    border-radius: 16px;
    background:
        radial-gradient(circle at 50% 15%, rgba(255,255,255,.82), transparent 58%),
        #ebe8df;
}

.empty-dice {
    display: grid;
    grid-template-columns: auto auto;
    gap: 9px;
    justify-items: center;
}

.empty-die {
    width: 43px;
    height: 43px;
    border: 1px dashed #c4c2bb;
    border-radius: 10px;
}

.empty-dice p {
    grid-column: 1 / -1;
    margin: 1px 0 0;
    color: #8c948f;
    font-size: 9px;
}

.dice-pair {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 17px;
    padding: 14px 0 8px;
}

.die-wrap {
    display: grid;
    justify-items: center;
    gap: 7px;
}

.die {
    position: relative;
    display: grid;
    width: 74px;
    height: 74px;
    place-items: center;
    border: 1px solid #806b4e;
    border-radius: 16px;
    background:
        linear-gradient(135deg, rgba(255,255,255,.65), transparent 30%),
        linear-gradient(145deg, #fff8df, #e8d8b6 72%, #c9b58e);
    box-shadow: inset -5px -7px 11px rgba(102, 77, 40, 0.12), inset 4px 4px 8px rgba(255,255,255,.7), 0 11px 18px rgba(56, 47, 34, 0.2);
}

.die::after {
    content: "";
    position: absolute;
    inset: 5px;
    border: 1px solid rgba(111, 84, 49, 0.12);
    border-radius: 11px;
    pointer-events: none;
}

.die.is-rolling {
    animation: dice-roll 520ms cubic-bezier(.2,.8,.2,1) both;
}

.die.is-hit {
    box-shadow: inset -5px -7px 11px rgba(102, 77, 40, 0.12), 0 0 0 4px rgba(63, 143, 79, 0.16), 0 11px 18px rgba(56, 47, 34, 0.2);
}

.die.is-void {
    border-color: #242429;
    background: linear-gradient(145deg, #45464a, #17181b 72%, #090a0c);
    box-shadow: inset -6px -8px 10px rgba(0,0,0,.34), inset 4px 4px 8px rgba(255,255,255,.08), 0 11px 18px rgba(26, 25, 28, 0.25);
}

.die.is-covered {
    box-shadow: inset -5px -7px 11px rgba(102, 77, 40, 0.12), 0 0 0 4px rgba(200, 126, 43, 0.23), 0 11px 18px rgba(56, 47, 34, 0.2);
}

.die-label {
    min-height: 16px;
    padding: 3px 7px;
    border-radius: 99px;
    background: #dfe2da;
    color: #667069;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.die-label.is-hit {
    background: #d9ead9;
    color: #2e7244;
}

.die-label.is-danger {
    background: #f1d7d3;
    color: #9f3e34;
}

.rune {
    position: relative;
    display: block;
    width: 52px;
    height: 52px;
}

.baton {
    position: absolute;
    top: 5px;
    left: 23px;
    width: 6px;
    height: 43px;
    border: 1px solid rgba(43, 31, 20, 0.46);
    border-radius: 3px;
    background: linear-gradient(90deg, #765737, #ba8e58 45%, #725335);
    box-shadow: 1px 2px 2px rgba(56, 38, 21, 0.2);
}

.baton::before {
    content: "";
    position: absolute;
    top: -2px;
    left: 50%;
    width: 9px;
    height: 5px;
    transform: translateX(-50%);
    clip-path: polygon(0 50%, 45% 0, 100% 50%, 45% 100%);
    background: #5f452d;
}

.rune-one .baton-a {
    transform: rotate(-35deg);
}

.rune-two .baton-a,
.rune-three .baton-a {
    transform: rotate(-43deg);
}

.rune-two .baton-b,
.rune-three .baton-b {
    transform: rotate(43deg);
}

.shield {
    position: absolute;
    z-index: 3;
    top: 13px;
    left: 12px;
    width: 29px;
    height: 30px;
    border: 3px solid #5b432e;
    border-radius: 50% 50% 48% 48%;
    background: radial-gradient(circle, #dbbd7e 0 15%, #8f693f 17% 23%, #d0ae70 25% 64%, #715238 66%);
    box-shadow: 0 3px 4px rgba(55, 37, 22, 0.22);
}

.shield::before,
.shield::after {
    content: "";
    position: absolute;
    background: #715238;
}

.shield::before {
    left: 50%;
    top: 1px;
    bottom: 1px;
    width: 2px;
    transform: translateX(-50%);
}

.shield::after {
    top: 50%;
    left: 1px;
    right: 1px;
    height: 2px;
    transform: translateY(-50%);
}

.rune-void i {
    position: absolute;
    inset: 6px;
    border: 5px solid #08090b;
    border-radius: 50%;
    background: radial-gradient(circle, #bd4e49 0 9%, #2a1518 11% 27%, #060709 30% 53%, #722f32 56% 60%, #111217 63%);
    box-shadow: 0 0 12px rgba(199, 68, 62, 0.45), inset 0 0 5px #000;
}

.rune-void i::before,
.rune-void i::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 2px;
    background: #0a0b0d;
}

.rune-void i::before { transform: translate(-50%, -50%) rotate(45deg); }
.rune-void i::after { transform: translate(-50%, -50%) rotate(-45deg); }

.mini-die {
    display: grid;
    width: 54px;
    height: 54px;
    place-items: center;
    border: 1px solid #b7a27e;
    border-radius: 12px;
    background: linear-gradient(145deg, #fff8df, #e3d0aa);
    transform: scale(.8);
}

.mini-die .rune {
    transform: scale(.72);
}

.opening-dice .die {
    width: 31px;
    height: 31px;
    border-radius: 7px;
    box-shadow: inset -2px -2px 4px rgba(90,70,40,.14), 0 3px 6px rgba(50,40,30,.12);
}

.opening-dice .die::after {
    inset: 2px;
    border-radius: 5px;
}

.opening-dice .rune {
    transform: scale(.42);
}

.opening-dice .die.is-void .rune {
    transform: scale(.39);
}

.hit-bank {
    gap: 8px;
    margin-bottom: 12px;
    padding: 0 4px;
}

.hit-bank span {
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
}

.hit-bank strong {
    color: var(--forest);
    font-size: 14px;
}

.action-stack {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
}

.action-stack .primary-button,
.action-stack .secondary-button,
.action-stack .danger-button {
    min-height: 49px;
    margin: 0;
}

.action-stack .wide {
    grid-column: 1 / -1;
}

.ai-thinking::after {
    content: "";
    width: 14px;
    height: 4px;
    border-radius: 99px;
    background: linear-gradient(90deg, #96a29c 25%, transparent 25% 38%, #96a29c 38% 63%, transparent 63% 75%, #96a29c 75%);
    animation: thinking-pulse 900ms ease-in-out infinite alternate;
}

.choice-copy {
    grid-column: 1 / -1;
    margin: 0 0 2px;
    color: #7b6353;
    font-size: 10px;
    text-align: center;
}

.match-end-panel {
    text-align: center;
}

.winner-crown {
    display: grid;
    width: 72px;
    height: 72px;
    margin: 0 auto 18px;
    place-items: center;
    border-radius: 50%;
    background: #f1e2ad;
    color: #98691f;
    font-size: 35px;
    box-shadow: inset 0 0 0 1px #dfc677, 0 9px 22px rgba(115, 81, 25, 0.13);
}

.ready-list {
    display: grid;
    gap: 7px;
    margin: 17px 0;
}

.ready-player {
    display: flex;
    justify-content: space-between;
    padding: 9px 11px;
    border-radius: 9px;
    background: #efeee7;
    font-size: 10px;
    font-weight: 800;
}

.ready-player span:last-child {
    color: #7c8580;
}

.ready-player.is-ready span:last-child {
    color: #2f8550;
}

.turn-log {
    border-top: 1px solid #e2ded3;
}

.turn-log summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 22px;
    cursor: pointer;
    list-style: none;
    color: #6f7a74;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.turn-log summary::-webkit-details-marker { display: none; }

.turn-log[open] summary span { transform: rotate(45deg); }

.turn-log ol {
    display: grid;
    gap: 9px;
    max-height: 210px;
    margin: 0;
    padding: 0 22px 19px 42px;
    overflow: auto;
}

.turn-log li {
    padding-left: 4px;
    color: #737d78;
    font-size: 9px;
    line-height: 1.5;
}

.rules-dialog {
    width: min(840px, calc(100% - 28px));
    max-height: calc(100vh - 28px);
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 26px;
    background: var(--paper);
    color: var(--ink);
    box-shadow: 0 35px 100px rgba(4, 25, 18, 0.38);
}

.rules-dialog::backdrop {
    background: rgba(5, 27, 20, 0.72);
    backdrop-filter: blur(6px);
}

.rules-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    max-height: calc(100vh - 28px);
}

.rules-header,
.rules-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 20px 25px;
}

.rules-header {
    border-bottom: 1px solid #ded9ce;
}

.rules-header h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 25px;
    font-weight: 400;
}

.dialog-close {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 50%;
    background: #e8e4da;
    font-size: 24px;
}

.rules-body {
    padding: 8px 25px 24px;
    overflow: auto;
}

.rules-body section {
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 16px;
    padding: 18px 0;
    border-bottom: 1px solid #e2ddd2;
}

.rule-number {
    color: #b39b67;
    font-family: var(--font-display);
    font-size: 18px;
}

.rules-body h3 {
    margin: 0;
    font-size: 13px;
}

.rules-body p {
    margin: 5px 0 0;
    color: #657069;
    font-size: 12px;
    line-height: 1.7;
}

.dice-key {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 19px;
}

.dice-key > div {
    display: grid;
    justify-items: center;
    padding: 8px 4px 11px;
    border-radius: 13px;
    background: #ebe7dd;
}

.dice-key strong {
    font-size: 11px;
}

.dice-key span:last-child {
    color: #7f8782;
    font-size: 8px;
}

.rules-footer {
    border-top: 1px solid #ded9ce;
    background: #eee8dc;
}

.rules-footer a {
    color: #266949;
    font-size: 11px;
    font-weight: 800;
}

.toast {
    position: fixed;
    z-index: 120;
    left: 50%;
    bottom: 24px;
    min-width: 240px;
    max-width: calc(100% - 36px);
    padding: 12px 17px;
    transform: translateX(-50%);
    border-radius: 12px;
    background: #112f25;
    color: white;
    box-shadow: 0 12px 36px rgba(7, 31, 23, 0.24);
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    animation: toast-in 180ms ease both;
}

@keyframes dice-roll {
    0% { transform: translateY(-15px) rotate(-12deg) scale(.82); opacity: .2; }
    45% { transform: translateY(5px) rotate(8deg) scale(1.05); opacity: 1; }
    70% { transform: translateY(-3px) rotate(-3deg); }
    100% { transform: translateY(0) rotate(0); }
}

@keyframes piece-arrive {
    from { opacity: 0; transform: translateY(-8px) scale(.8); }
    to { opacity: 1; }
}

@keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, 8px); }
}

@keyframes thinking-pulse {
    to { opacity: .3; transform: translateX(3px); }
}

@media (max-width: 1180px) {
    .lobby-view {
        grid-template-columns: 1fr 1fr;
    }

    .lobby-art {
        grid-column: 2;
        grid-row: 1 / span 2;
    }

    .lobby-card {
        grid-column: 1;
    }

    .game-layout {
        grid-template-columns: minmax(0, 1fr) 350px;
    }
}

@media (max-width: 900px) {
    .lobby-view {
        grid-template-columns: 1fr;
        max-width: 680px;
    }

    .lobby-art {
        grid-column: 1;
        grid-row: auto;
        min-height: 450px;
    }

    .lobby-card {
        grid-column: 1;
    }

    .game-layout {
        grid-template-columns: 1fr;
    }

    .action-card {
        position: static;
    }

    .pitch {
        min-height: 610px;
    }
}

@media (max-width: 680px) {
    .site-header,
    .lobby-view,
    .game-view {
        width: min(100% - 24px, 1420px);
    }

    .site-header {
        padding: 13px 0;
    }

    .brand-image-wrap {
        width: 43px;
        height: 43px;
        border-radius: 13px;
    }

    .brand-image {
        width: 62px;
        height: 47px;
    }

    .brand-name { font-size: 16px; }
    .brand-edition { font-size: 8px; margin-top: 5px; }
    .connection-pill { display: none; }

    .lobby-view {
        gap: 25px;
        padding-top: 30px;
    }

    .hero-copy h1 {
        font-size: clamp(39px, 13vw, 62px);
    }

    .hero-facts {
        gap: 18px;
    }

    .lobby-art {
        min-height: 380px;
        border-radius: 100px 100px 26px 26px;
    }

    .match-bar {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .scoreboard {
        grid-column: 1 / -1;
        grid-row: 1;
        justify-self: center;
        max-width: 100%;
    }

    .room-chip { grid-column: 1; grid-row: 2; }
    .game-chip { grid-column: 2; grid-row: 2; }

    .score-player {
        max-width: 120px;
    }

    .pitch-card {
        padding: 11px;
        border-radius: 22px;
    }

    .pitch-topline {
        align-items: start;
        padding: 4px 4px 0;
    }

    .pitch-legend { display: none; }

    .pitch-wrap {
        padding: 7px;
        border-radius: 18px;
    }

    .pitch {
        min-height: 520px;
        border-radius: 12px;
    }

    .piece-zone {
        gap: 14px;
    }

    .far-field,
    .near-field {
        grid-template-columns: repeat(5, 19px);
        gap: 6px 8px;
    }

    .kubb {
        width: 15px;
        height: 34px;
    }

    .king-star { font-size: 54px; }
    .king { transform: translate(-50%, -51%) scale(.86); }

    .action-card {
        border-radius: 22px;
    }

    .rules-header,
    .rules-footer {
        padding: 16px;
    }

    .rules-header h2 { font-size: 20px; }
    .rules-body { padding: 4px 16px 20px; }
    .rules-body section { grid-template-columns: 36px 1fr; gap: 8px; }
    .dice-key { grid-template-columns: repeat(2, 1fr); }
    .rules-footer { align-items: stretch; flex-direction: column; }
}

@media (max-width: 410px) {
    .hero-facts span { font-size: 8px; }
    .hero-facts strong { font-size: 17px; }
    .lobby-form { padding-inline: 15px; }
    .form-error { margin-inline: 15px; }
    .resume-button { width: calc(100% - 30px); margin-inline: 15px; }
    .scoreboard { gap: 8px; padding-inline: 8px; }
    .score-player { max-width: 105px; font-size: 10px; }
    .score-player.is-you::after { display: none; }
    .score-player.is-ai::after { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
