:root {
    --desk: #e7e9dc;
    --paper: #fffef8;
    --ink: #23281d;
    --soft: #6b725e;
    --rule: #c9cdbb;
    --club: #2f6b3a;
    --pencil: #b5452a;
    --gold: #c99a2e;
    --red-suit: #b0281a;
    --type: 'Courier Prime', 'Courier New', monospace;
    --card-width: 52px;
    --card-height: 73px;
    --card-font: 19px;
    --card-back: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2040%2056%22%20preserveAspectRatio%3D%22none%22%3E%3Crect%20width%3D%2240%22%20height%3D%2256%22%20fill%3D%22%232f6b3a%22%2F%3E%3Crect%20x%3D%220%22%20width%3D%225%22%20height%3D%2256%22%20fill%3D%22%233c7f48%22%2F%3E%3Crect%20x%3D%2210%22%20width%3D%225%22%20height%3D%2256%22%20fill%3D%22%233c7f48%22%2F%3E%3Crect%20x%3D%2220%22%20width%3D%225%22%20height%3D%2256%22%20fill%3D%22%233c7f48%22%2F%3E%3Crect%20x%3D%2230%22%20width%3D%225%22%20height%3D%2256%22%20fill%3D%22%233c7f48%22%2F%3E%3Crect%20x%3D%221.5%22%20y%3D%221.5%22%20width%3D%2237%22%20height%3D%2253%22%20rx%3D%221%22%20fill%3D%22none%22%20stroke%3D%22%23f4efdc%22%20stroke-width%3D%22.6%22%2F%3E%3Cellipse%20cx%3D%2212%22%20cy%3D%2245%22%20rx%3D%224%22%20ry%3D%221.3%22%20fill%3D%22%2324502c%22%2F%3E%3Cpath%20d%3D%22M12%2045V20%22%20stroke%3D%22%23f4efdc%22%20stroke-width%3D%221%22%2F%3E%3Cpath%20d%3D%22M12%2020L34%2028%2012%2036Z%22%20fill%3D%22%23f4efdc%22%2F%3E%3Ctext%20x%3D%2220%22%20y%3D%2230.9%22%20text-anchor%3D%22middle%22%20font-family%3D%22Georgia%2Cserif%22%20font-weight%3D%22bold%22%20font-size%3D%228.5%22%20fill%3D%22%232f6b3a%22%3EK%3C%2Ftext%3E%3C%2Fsvg%3E");
}

* {
    box-sizing: border-box;
}

body {
    background: var(--desk);
    color: var(--ink);
    font-family: var(--type);
    margin: 0;
    -webkit-text-size-adjust: 100%;
}

#container {
    margin: 0 auto;
    max-width: 440px;
    padding: 18px 12px 110px;
}

button {
    font-family: inherit;
    color: inherit;
}

.sheet {
    background: var(--paper);
    border: 1px solid var(--rule);
    box-shadow: 0 2px 0 var(--rule);
    padding: 14px 12px 16px;
}

.club-heading {
    text-align: center;
    margin-bottom: 4px;
}

.club-heading .crest {
    color: var(--club);
    font-size: 11px;
    letter-spacing: .2em;
    text-transform: uppercase;
}

.club-heading .title {
    font-size: 24px;
    font-weight: 700;
}

.club-heading .subtitle {
    color: var(--soft);
    font-size: 13px;
    margin-top: 2px;
}

.rule-label {
    color: var(--soft);
    font-size: 11px;
    letter-spacing: .14em;
    margin: 14px 0 5px;
    text-transform: uppercase;
}

.button {
    background: var(--paper);
    border: 1.5px solid var(--ink);
    cursor: pointer;
    display: block;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: .04em;
    padding: 12px 0;
    width: 100%;
}

.button.go {
    background: var(--club);
    border-color: var(--club);
    color: white;
}

.button:disabled {
    cursor: default;
    opacity: .4;
}

.button-row {
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr 1fr;
    margin-top: 14px;
}

.link {
    background: none;
    border: 0;
    cursor: pointer;
    font-size: inherit;
    padding: 0;
    text-decoration: underline;
}

.name-2 { font-size: .86em; }
.name-3 { font-size: .74em; }
.name-4 { font-size: .64em; }
.number-3 { font-size: .8em; }
.number-4 { font-size: .66em; }

.tag,
.away-tag {
    font-size: 10px;
    font-weight: 400;
    margin-left: 5px;
}

.tag {
    color: var(--club);
}

.away-tag {
    color: var(--gold);
}

/* Clubhouse */

.seats {
    border-collapse: collapse;
    font-size: 13px;
    table-layout: fixed;
    width: 100%;
}

.seats th,
.seats td {
    border: 1px solid var(--rule);
    height: 34px;
    padding: 0;
    text-align: center;
}

.seats th {
    background: #f3f4ec;
    font-size: 12px;
    height: 24px;
}

.seats .seat {
    color: var(--soft);
    width: 24px;
}

.seats .hole,
.seats .gap {
    width: 32px;
}

.seats .gap {
    color: var(--rule);
}

.seats .name {
    font-weight: 700;
    overflow: hidden;
    padding-left: 8px;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.seats .name.open {
    color: #a8ad99;
    font-size: 12px;
    font-style: italic;
    font-weight: 400;
}

.name-line {
    color: var(--soft);
    font-size: 13px;
    margin-top: 12px;
    text-align: center;
}

.name-line b {
    color: var(--ink);
}

.name-line .link {
    color: var(--ink);
}

.rules-card-button {
    background: var(--paper);
    border: 1px solid var(--rule);
    box-shadow: 0 2px 0 var(--rule);
    cursor: pointer;
    display: block;
    font-size: 17px;
    font-weight: 700;
    margin: 18px auto 0;
    padding: 10px 0;
    width: 70%;
}

.rules-card-button small {
    color: var(--club);
    display: block;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: .18em;
    text-transform: uppercase;
}

/* Table */

.mats {
    display: grid;
    gap: 8px;
    padding-top: 18px;
}

.mats.one {
    grid-template-columns: 1fr;
    justify-items: center;
}

.mats.one .player-mat.medium {
    width: 64%;
}

.mats.own {
    padding-top: 20px;
}

.mats.one .player-mat.large {
    width: 100%;
}

.mats.two {
    grid-template-columns: 1fr 1fr;
}

.player-mat {
    background: var(--paper);
    border: 1px solid var(--rule);
    padding: 6px 6px 9px;
    position: relative;
}

.player-mat.away {
    opacity: .55;
}

.player-mat.turn-holder {
    border-color: var(--club);
    box-shadow: 0 0 0 1.5px var(--club);
}

.player-mat.turn-holder::before {
    background: var(--club);
    border-radius: 4px 4px 0 0;
    color: white;
    content: attr(data-tab);
    font: 700 10px/16px var(--type);
    left: 6px;
    letter-spacing: .06em;
    padding: 0 8px;
    position: absolute;
    top: -17px;
    white-space: nowrap;
}

.player-info {
    align-items: center;
    display: flex;
    gap: 5px;
    height: 20px;
    margin-bottom: 5px;
}

.player-name {
    flex: 1;
    font-size: 15px;
    font-weight: 700;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dealer-badge {
    border: 1.5px solid var(--gold);
    border-radius: 50%;
    color: var(--gold);
    flex: none;
    font: 700 10px/14px var(--type);
    height: 17px;
    text-align: center;
    width: 17px;
}

.out-badge {
    border: 1px solid var(--pencil);
    border-radius: 8px;
    color: var(--pencil);
    flex: none;
    font: 700 9px var(--type);
    padding: 0 5px;
}

.hand {
    display: grid;
    gap: 5px;
    grid-template-columns: repeat(3, var(--card-width));
    justify-content: center;
}

.large .hand {
    gap: 9px;
}

.medium {
    --card-width: 40px;
    --card-height: 56px;
    --card-font: 15px;
}

.card {
    align-items: center;
    background: white;
    border: 1px solid #8f957f;
    border-radius: 4px;
    display: flex;
    font: 700 var(--card-font)/1 var(--type);
    height: var(--card-height);
    justify-content: center;
    letter-spacing: -.04em;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    width: var(--card-width);
}

.card i {
    font-style: normal;
}

.card.red {
    color: var(--red-suit);
}

.card.face-down {
    background: var(--card-back) center / 100% 100%;
    border-color: #24502c;
}

.card.slot {
    background: transparent;
    border: 1.5px dashed var(--rule);
}

.card.playable {
    cursor: pointer;
}

.card.land {
    animation: card-land .32s ease-out;
}

.card.flip {
    animation: card-flip .28s ease-out;
}

@keyframes card-land {
    from { opacity: .2; scale: 1.12; translate: 0 -18px; }
    to { opacity: 1; scale: 1; translate: 0 0; }
}

@keyframes card-flip {
    from { transform: rotateY(90deg); }
    to { transform: rotateY(0); }
}

.piles {
    align-items: flex-start;
    display: flex;
    gap: 28px;
    height: 92px;
    justify-content: center;
    margin-top: 18px;
}

.pile {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: calc(var(--card-height) + 14px);
    justify-content: flex-end;
    position: relative;
    width: var(--card-width);
}

.pile.discard {
    touch-action: none;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
}

.discard-stack {
    height: var(--card-height);
    position: relative;
    width: var(--card-width);
    -webkit-touch-callout: none;
}

.discard-stack .card {
    left: 0;
    position: absolute;
    top: 0;
    transition: transform .35s ease;
}

.held-card {
    box-shadow: 0 6px 12px rgba(0, 0, 0, .28);
    position: absolute;
    right: 30px;
    top: -20px;
    transform: rotate(5deg);
    z-index: 20;
}

.action-float {
    bottom: 26px;
    left: 50%;
    position: fixed;
    transform: translateX(-50%);
    z-index: 30;
}

.action-float .button {
    border-radius: 28px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, .28), 0 2px 4px rgba(0, 0, 0, .2);
    padding: 13px 36px;
    white-space: nowrap;
    width: auto;
    animation: action-in .25s ease-out;
}

@keyframes action-in {
    from { opacity: 0; translate: 0 14px; }
    to { opacity: 1; translate: 0 0; }
}

.table-scorecard {
    margin-top: 16px;
}

.footer {
    display: flex;
    font-size: 13px;
    justify-content: space-between;
    margin-top: 14px;
}

/* Scorecard */

.scorecard {
    background: var(--paper);
    border: 1px solid var(--rule);
    display: flex;
    font-size: 14px;
}

.scorecard table {
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}

.scorecard th,
.scorecard td {
    border-bottom: 1px solid var(--rule);
    height: 34px;
    overflow: hidden;
    padding: 0;
    position: relative;
    text-align: center;
    white-space: nowrap;
}

.scorecard tr:last-child td {
    border-bottom: 0;
}

.scorecard th {
    background: #f3f4ec;
    font-size: 12px;
    height: 24px;
}

.scorecard .names {
    border-right: 1.5px solid var(--ink);
    flex: none;
    width: 84px;
}

.scorecard .names td {
    font-weight: 700;
    max-width: 84px;
    padding-left: 7px;
    text-align: left;
    text-overflow: ellipsis;
}

.scorecard .holes {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-x: none;
    scrollbar-width: none;
}

.scorecard .holes::-webkit-scrollbar {
    display: none;
}

.scorecard .holes td,
.scorecard .holes th {
    border-right: 1px solid var(--rule);
    width: 34px;
}

.scorecard .holes td:last-child,
.scorecard .holes th:last-child {
    border-right: 0;
}

.scorecard .totals {
    border-left: 1.5px solid var(--ink);
    flex: none;
    width: 46px;
}

.scorecard .totals td {
    font-weight: 700;
}

.scorecard .current {
    background: #fff6dd;
}

.busted,
.four-of-a-kind {
    align-items: center;
    border: 1.5px solid var(--pencil);
    display: inline-flex;
    height: 24px;
    justify-content: center;
    min-width: 24px;
}

.busted {
    border-radius: 50%;
    padding: 0 2px;
}

.four-of-a-kind {
    padding: 1px;
}

.four-of-a-kind .busted {
    height: 20px;
    min-width: 20px;
}

.went-out::after {
    background: var(--pencil);
    border-radius: 50%;
    content: '';
    height: 5px;
    position: absolute;
    right: 3px;
    top: 3px;
    width: 5px;
}

.final-card .scorecard,
.overlay-panel .scorecard {
    margin-top: 12px;
}

.winner {
    font-size: 18px;
    font-weight: 700;
    margin: 16px 0 2px;
    text-align: center;
}

/* Overlays */

.overlay {
    align-items: flex-end;
    background: rgba(35, 40, 29, .35);
    display: flex;
    inset: 0;
    justify-content: center;
    position: fixed;
    z-index: 40;
}

.overlay-panel {
    background: var(--paper);
    border-top: 2px solid var(--ink);
    max-height: 88vh;
    max-width: 440px;
    overflow-y: auto;
    padding: 16px 14px 28px;
    position: relative;
    width: 100%;
}

.overlay-close {
    background: none;
    border: 0;
    color: var(--soft);
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    position: absolute;
    right: 10px;
    top: 10px;
}

.rules {
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 10px;
    width: 100%;
}

.rules td {
    border-bottom: 1px solid var(--rule);
    padding: 8px 4px;
    vertical-align: top;
}

.rules .rule-name {
    color: var(--club);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    padding-top: 10px;
    text-transform: uppercase;
    width: 92px;
}

.card-values {
    display: grid;
    gap: 6px;
    --card-width: 28px;
    --card-height: 39px;
    --card-font: 12px;
}

.card-value {
    align-items: center;
    display: flex;
    gap: 8px;
}

.card-value .cards {
    display: flex;
    gap: 3px;
    width: 62px;
}

.card-value .points {
    font-weight: 700;
}

.card-value small {
    color: var(--soft);
    font-size: 12px;
    font-weight: 400;
}

.marks {
    display: grid;
    gap: 5px;
}

.mark {
    align-items: center;
    display: flex;
    gap: 8px;
}

.mark-cell {
    align-items: center;
    background: white;
    border: 1px solid var(--rule);
    display: inline-flex;
    font-size: 13px;
    height: 30px;
    justify-content: center;
    position: relative;
    width: 32px;
}

/* Connection and messages */

#connection-status {
    display: none;
}

#connection-status.reconnecting,
#connection-status.replaced {
    background: var(--paper);
    border: 1.5px solid var(--ink);
    bottom: 90px;
    display: block;
    font: 700 13px var(--type);
    left: 50%;
    padding: 6px 12px;
    position: fixed;
    transform: translateX(-50%);
    white-space: nowrap;
    z-index: 50;
}

#connection-status.replaced {
    cursor: pointer;
}

#message {
    background: var(--paper);
    border: 1.5px solid var(--pencil);
    color: var(--pencil);
    font: 700 13px var(--type);
    left: 50%;
    max-width: calc(100% - 24px);
    opacity: 0;
    padding: 8px 12px;
    pointer-events: none;
    position: fixed;
    top: 12px;
    transform: translateX(-50%);
    transition: opacity .2s;
    z-index: 50;
}

#message.visible {
    opacity: 1;
}
