:root {
    --bg: #f4f1ea;
    --card: #fff;
    --text: #1a1a1a;
    --accent: #2d5a3d;
    --accent-hover: #234a31;
    --border: #d4cfc4;
    --error: #a33;
    --muted: #5c5c5c;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
}

header {
    background: var(--accent);
    color: #fff;
    padding: 1rem 1.25rem;
}

.app-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.app-header-text {
    min-width: 0;
}

.fullscreen-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 0.45rem;
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
    cursor: pointer;
}

.fullscreen-btn:hover,
.fullscreen-btn:focus-visible {
    background: rgba(0, 0, 0, 0.35);
    outline: none;
}

.fullscreen-btn svg {
    width: 1.35rem;
    height: 1.35rem;
    display: block;
}

.fullscreen-btn .icon-compress {
    display: none;
}

.fullscreen-btn.is-active .icon-expand {
    display: none;
}

.fullscreen-btn.is-active .icon-compress {
    display: block;
}

.help-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    height: 2.5rem;
    padding: 0 0.65rem;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 0.45rem;
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
    cursor: pointer;
    font-weight: 600;
}

.help-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.help-overlay.hidden {
    display: none !important;
}

.help-dialog {
    width: min(560px, 100%);
    max-height: min(80vh, 640px);
    overflow: auto;
    background: #fff;
    color: #1a1a1a;
    border-radius: 0.75rem;
    padding: 1rem 1.15rem 1.25rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.help-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.help-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.help-body h3 {
    margin: 1rem 0 0.35rem;
    font-size: 1rem;
}

.help-body p,
.help-body li {
    font-size: 0.95rem;
    line-height: 1.45;
}

.help-body ul {
    margin: 0.25rem 0 0.5rem 1.1rem;
    padding: 0;
}

.whist-bid-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 0.75rem 0;
}

.whist-bid-radios {
    border: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.whist-bid-radios legend {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.whist-bid-radios label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.05rem;
    color: inherit;
}

.player-body.felt-mode .whist-bid-actions,
.player-body.felt-mode .whist-bid-radios,
.player-body.felt-mode .whist-bid-radios legend,
.player-body.felt-mode .whist-bid-radios label {
    color: #e8f5e9;
}

.player-body.felt-mode .whist-bid-radios input[type="radio"] {
    accent-color: #e8c547;
    width: 1.15rem;
    height: 1.15rem;
}

.whist-team-board {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin: 0.5rem 0 0.75rem;
}

.whist-team-card {
    background: rgba(10, 10, 10, 0.55);
    border: 1px solid rgba(232, 245, 233, 0.25);
    border-radius: 10px;
    padding: 0.55rem 0.65rem;
    color: #e8f5e9;
}

.whist-team-card.declaring {
    border-color: #e8c547;
    box-shadow: 0 0 0 1px #e8c547;
}

.whist-team-card .team-name {
    font-size: 0.85rem;
    color: #d7ecdb;
    margin: 0 0 0.2rem;
}

.whist-team-card .team-score {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0;
}

.whist-team-card .team-meta {
    font-size: 0.8rem;
    color: #cfe3d3;
    margin: 0.15rem 0 0;
}

.bismarck-contract-actions,
.bismarck-discard-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin: 0.75rem 0;
    align-items: center;
}

.bismarck-trump-pick {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.hand-fan .card.selected {
    outline: 3px solid #f5d76e;
    transform: translateY(-10px);
}

.whist-score {
    margin: 0.5rem 0;
    font-weight: 600;
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.subtitle {
    margin: 0.25rem 0 0;
    opacity: 0.9;
    font-size: 0.9rem;
}

.panel {
    max-width: 720px;
    margin: 1rem auto;
    padding: 1.25rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.hidden {
    display: none !important;
}

.field {
    display: block;
    margin-bottom: 1rem;
}

.field select,
.player-names input {
    display: block;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.5rem 0.6rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.player-names label {
    display: block;
    margin-bottom: 0.75rem;
}

fieldset {
    border: 1px solid var(--border);
    border-radius: 6px;
    margin: 1rem 0;
    padding: 0.75rem 1rem;
}

fieldset label {
    display: block;
    margin: 0.35rem 0;
}

.hint {
    color: var(--muted);
    font-size: 0.95rem;
}

button {
    font-size: 1rem;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
}

button.primary {
    background: var(--accent);
    color: #fff;
}

button.primary:hover {
    background: var(--accent-hover);
}

button.secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    margin-top: 1rem;
}

button.outcome {
    margin-right: 0.35rem;
    margin-top: 0.25rem;
    padding: 0.4rem 0.65rem;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    background: #fafafa;
}

button.outcome.active-plump {
    background: #fde8e8;
    border-color: #c44;
}

button.outcome.active-success {
    background: #e8f5e9;
    border-color: var(--accent);
}

.plump-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0.25rem 0;
}

.plump-toggle-meta {
    font-size: 0.9rem;
}

.round-edit-section {
    margin: 1rem 0;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.protocol-row-editable {
    cursor: pointer;
}

.protocol-row-editable:hover {
    background: #f3f7f4;
}

.round-header h2 {
    margin: 0 0 0.25rem;
}

.phase {
    color: var(--muted);
    margin: 0 0 1rem;
}

.players-table {
    width: 100%;
    border-collapse: collapse;
}

.players-table th,
.players-table td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.6rem;
    text-align: left;
}

.players-table th {
    background: #f0ebe3;
}

.bid-input {
    width: 4rem;
    padding: 0.35rem;
    font-size: 1rem;
}

.zero-blocked {
    display: block;
    font-size: 0.8rem;
    color: var(--error);
}

.actions {
    margin-top: 1rem;
}

.protocol {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.table-wrap {
    overflow-x: auto;
}

#protocolTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

#protocolTable th,
#protocolTable td {
    border: 1px solid var(--border);
    padding: 0.35rem 0.5rem;
    text-align: center;
}

#protocolTable th {
    background: #f0ebe3;
}

.error {
    color: var(--error);
    margin-top: 0.75rem;
}

.qr-section {
    text-align: center;
    margin: 1rem 0;
}

.tab-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.55rem 0.75rem;
}

.tab-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.tab-panel h2 {
    margin-top: 0;
}

.session-actions {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.lobby-list {
    list-style: none;
    padding: 0;
    margin: 1rem 0;
}

.lobby-list li {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.lobby-player-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.bot-badge {
    font-size: 0.75rem;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.05rem 0.35rem;
}

.bot-section {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #faf8f4;
}

.bot-section h3 {
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
}

.bot-section.hidden,
.bot-section .hidden {
    display: none !important;
}

button.linkish {
    background: none;
    border: none;
    color: var(--error);
    cursor: pointer;
    padding: 0;
    font-size: 0.85rem;
    text-decoration: underline;
}

.trick-board,
.trick-section {
    margin: 1rem 0;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #faf8f4;
}

.trick-cards,
.card-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.trick-play,
.completed-trick {
    margin: 0.35rem 0;
}

.playing-card {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.6rem;
    padding: 0.45rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
    font-size: 0.95rem;
    font-weight: 600;
}

button.playing-card {
    cursor: default;
}

button.playing-card.playable {
    cursor: pointer;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(45, 90, 61, 0.15);
}

button.playing-card.playable:active {
    transform: translateY(1px);
}

.playing-card.red {
    color: #b22;
}

.playing-card.black {
    color: #1a1a1a;
}

.hand-by-suit .suit-group {
    margin-bottom: 0.75rem;
}

.hand-by-suit h4 {
    margin: 0 0 0.35rem;
    font-size: 0.95rem;
    color: var(--muted);
}

.bid-section {
    margin: 1rem 0;
}

.bid-input-wide {
    width: 100%;
    max-width: 8rem;
    padding: 0.5rem;
    font-size: 1rem;
}

.player-body .panel {
    max-width: 480px;
}

.mode-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.mode-button {
    display: block;
    text-align: center;
    text-decoration: none;
    padding: 0.85rem 1rem;
    border-radius: 6px;
    font-size: 1.05rem;
}

a.mode-button.primary {
    background: var(--accent);
    color: #fff;
}

a.mode-button.secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.header-link {
    color: inherit;
    opacity: 0.9;
}

.qr-section img {
    display: block;
    margin: 0 auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
}
