body {
    font-family: 'Segoe UI', Georgia, serif;
    background: #061018;
    color: #e8f0f8;
    margin: 0;
    min-height: 100vh;
}

.sea-bg {
    position: fixed;
    inset: 0;
    background-size: 115%;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    z-index: -1;
}

.sea-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        rgba(4, 16, 28, 0.45) 0%,
        rgba(4, 16, 28, 0.7) 50%,
        rgba(4, 16, 28, 0.8) 100%
    );
    pointer-events: none;
    transition: background 0.35s ease;
}

/* Assemble Crew — let the beach show through */
.sea-bg.sea-bg--crew {
    background-size: cover;
    background-position: center 40%;
}

.sea-bg.sea-bg--crew::after {
    background: linear-gradient(
        180deg,
        rgba(4, 16, 28, 0.12) 0%,
        rgba(4, 16, 28, 0.22) 45%,
        rgba(4, 16, 28, 0.38) 100%
    );
}

/* ── Lobby ── */
.page-lobby {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.lobby-wrap {
    width: 100%;
    max-width: 920px;
}

.lobby-hero {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.hero-cards {
    display: flex;
    gap: 0;
}

.hero-cards-left .hero-card:first-child { transform: rotate(-12deg); }
.hero-cards-left .hero-card.offset { transform: rotate(-4deg) translateX(-28px); margin-top: 12px; }
.hero-cards-right .hero-card.offset { transform: rotate(4deg) translateX(28px); margin-top: 12px; }
.hero-cards-right .hero-card:last-child { transform: rotate(12deg); }

.hero-card {
    width: 88px;
    height: 124px;
    border-radius: 8px;
    border: 2px solid rgba(255, 211, 107, 0.45);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    object-fit: cover;
}

.hero-text {
    text-align: center;
    min-width: 260px;
}

.hero-text h1 {
    font-size: 2.8rem;
    margin: 0 0 8px;
    color: #ffd36b;
    text-shadow: 0 2px 12px rgba(255, 180, 50, 0.35);
    letter-spacing: 0.04em;
}

.tagline {
    color: #9ec5e8;
    margin: 0 0 6px;
    font-size: 1.05rem;
}

.deck-info {
    color: #6a8fa8;
    font-size: 0.85rem;
    margin: 0;
}

.lobby-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 680px) {
    .lobby-grid { grid-template-columns: 1fr; }
    .hero-cards { display: none; }
}

.lobby-panel {
    background: rgba(10, 28, 48, 0.92);
    border: 1px solid rgba(255, 211, 107, 0.2);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.panel-icon img {
    width: 56px;
    height: 78px;
    border-radius: 6px;
    border: 2px solid #2f6aa8;
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.lobby-panel h2 {
    margin: 0 0 6px;
    color: #ffd36b;
    font-size: 1.35rem;
}

.panel-desc {
    color: #8ab0cc;
    font-size: 0.9rem;
    margin: 0 0 16px;
}

.field-label {
    display: block;
    font-size: 0.8rem;
    color: #9ec5e8;
    margin: 10px 0 4px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.field-hint {
    text-transform: none;
    letter-spacing: 0;
    color: #7a9eb8;
    font-weight: 500;
}

.crew-count {
    margin-left: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #9ec4dc;
    letter-spacing: 0.04em;
}

input[type="text"], select {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid #2a4a68;
    background: rgba(6, 16, 28, 0.9);
    color: #fff;
    font-size: 1rem;
}

.input-code {
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-weight: bold;
}

button {
    padding: 10px 18px;
    margin-top: 14px;
    border: 1px solid rgba(255, 255, 255, 0.88);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    display: inline-block;
    width: 100%;
    box-sizing: border-box;
    transition: background 0.2s, border-color 0.2s;
}

button:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: #ffffff;
    color: #ffffff;
}

.btn-primary,
.btn-gold,
.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.88);
    color: #ffffff;
    box-shadow: none;
}

.btn-primary:hover,
.btn-gold:hover,
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: #ffffff;
    color: #ffffff;
    filter: none;
}

.btn-gold {
    margin-top: 8px;
}

.btn-secondary {
    width: auto;
}

.result-msg {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #ff8080;
    min-height: 1.2em;
}

/* ── Game room ── */
.page-game {
    padding: 16px;
    max-width: 1280px;
    margin: 0 auto;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 211, 107, 0.15);
}

.game-header h1 {
    margin: 0;
    color: #ffd36b;
    font-size: 1.6rem;
}

.room-meta {
    color: #9ec5e8;
    font-size: 0.9rem;
}

.room-meta #rank_label {
    color: #ffd36b;
}

section, .panel {
    background: rgba(10, 28, 48, 0.88);
    padding: 16px;
    margin-bottom: 14px;
    border-radius: 10px;
    border: 1px solid rgba(46, 90, 130, 0.5);
}

h2, h3 {
    margin: 0 0 10px;
    color: #ffd36b;
}

/* Table centre — deck & discard */
.table-centre {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 40px;
    padding: 20px;
    margin-bottom: 14px;
    background: rgba(6, 20, 36, 0.7);
    border-radius: 12px;
    border: 1px solid rgba(46, 90, 130, 0.4);
    min-height: 140px;
}

.pile-wrap {
    text-align: center;
}

.pile-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #7a9eb8;
    margin-bottom: 8px;
}

.card-pile {
    position: relative;
    width: 100px;
    height: 140px;
    margin: 0 auto;
}

.card-pile img {
    position: absolute;
    width: 100px;
    height: 140px;
    border-radius: 7px;
    border: 2px solid #2f6aa8;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0,0,0,0.45);
}

.card-pile img:nth-child(1) { top: 0; left: 0; }
.card-pile img:nth-child(2) { top: -3px; left: 2px; transform: rotate(1.5deg); }
.card-pile img:nth-child(3) { top: -6px; left: 4px; transform: rotate(3deg); }

.pile-count {
    position: absolute;
    bottom: -8px;
    right: -8px;
    background: #ffd36b;
    color: #1a1000;
    font-weight: bold;
    font-size: 0.85rem;
    min-width: 26px;
    height: 26px;
    line-height: 26px;
    border-radius: 50%;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
    z-index: 5;
}

.turn-indicator {
    text-align: center;
    padding: 8px 20px;
    background: rgba(255, 211, 107, 0.12);
    border: 1px solid rgba(255, 211, 107, 0.35);
    border-radius: 8px;
    color: #ffd36b;
    font-weight: 600;
}

.turn-indicator.cpu-turn {
    border-color: rgba(100, 180, 255, 0.4);
    color: #7ec8ff;
    background: rgba(50, 120, 200, 0.12);
}

/* Players */
.player-row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-start;
    padding: 12px;
    margin-bottom: 10px;
    background: rgba(6, 18, 32, 0.85);
    border-radius: 8px;
    border: 1px solid #1a3550;
}

.player-row.active {
    border-color: #ffd36b;
    box-shadow: 0 0 14px rgba(255, 211, 107, 0.2);
}

.player-row.me { border-color: #3a90d4; }
.player-row.cpu { border-color: #3a5080; }

.player-name {
    min-width: 130px;
    font-weight: bold;
    font-size: 1rem;
}

.player-tags {
    font-size: 0.82rem;
    color: #9ec5e8;
    margin-top: 4px;
}

.hand-backs {
    display: flex;
    gap: 0;
    margin-top: 6px;
}

.hand-backs img {
    width: 52px;
    height: 73px;
    border-radius: 5px;
    border: 1px solid #2f6aa8;
    object-fit: cover;
    margin-left: -20px;
    box-shadow: -2px 2px 6px rgba(0,0,0,0.35);
}

.hand-backs img:first-child { margin-left: 0; }

.card-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.card {
    width: 100px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
}

.card:hover:not(.unplayable) {
    transform: translateY(-10px);
    z-index: 2;
}

.card img {
    width: 100px;
    height: 140px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #2f6aa8;
    display: block;
    background: #081018;
    box-shadow: 0 6px 18px rgba(0,0,0,0.5);
}

/* Player hand — large cards */
.card.hand-card {
    width: 160px;
}

.card.hand-card img {
    width: 160px;
    height: 224px;
    border-width: 3px;
}

.card.hand-card .card-label {
    font-size: 0.78rem;
    margin-top: 6px;
}

.card.hand-card.highlight-sail img {
    border-color: #ffd36b;
    box-shadow: 0 0 20px rgba(255, 211, 107, 0.55);
    animation: pulse-sail 1.8s ease-in-out infinite;
}

@keyframes pulse-sail {
    0%, 100% { box-shadow: 0 0 16px rgba(255, 211, 107, 0.4); }
    50% { box-shadow: 0 0 28px rgba(255, 211, 107, 0.75); }
}

.card.medium { width: 88px; }
.card.medium img {
    width: 88px;
    height: 123px;
}

.card.small { width: 64px; }
.card.small img {
    width: 64px;
    height: 90px;
}

.card.back img {
    border-color: #4a7090;
}

.card.unplayable {
    opacity: 0.5;
    cursor: not-allowed;
}

.card-label {
    font-size: 0.72rem;
    margin-top: 4px;
    color: #b8d4ef;
    line-height: 1.2;
}

#hand {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    min-height: 260px;
    padding: 20px;
    background: rgba(4, 14, 26, 0.6);
    border-radius: 10px;
    border: 1px dashed rgba(255, 211, 107, 0.25);
    justify-content: center;
    align-items: flex-start;
}

.hand-panel {
    border-color: rgba(255, 211, 107, 0.25);
}

.actions { margin-top: 12px; text-align: center; }

#draw_btn {
    width: auto;
    padding: 12px 28px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.88);
    color: #ffffff;
}

#log {
    max-height: 160px;
    overflow-y: auto;
    font-size: 0.88rem;
    line-height: 1.5;
    color: #b8cfe0;
}

#log div { padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,0.04); }

.hidden { display: none !important; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    margin-right: 5px;
    font-weight: 600;
}

.badge-sailed { background: #1a6b4a; color: #c8ffe8; }
.badge-port { background: #6b4a1a; color: #ffe8c8; }
.badge-docked { background: #3a4a5a; color: #c8d8e8; }
.badge-danger { background: #6b1a1a; color: #ffc8c8; }
.badge-cpu { background: #2a4060; color: #a8c8ff; border: 1px solid #4a6898; }

.winner-banner {
    background: linear-gradient(90deg, #3a2a00, #5c4600);
    border: 1px solid #ffd36b;
    padding: 14px;
    border-radius: 8px;
    margin-bottom: 14px;
    text-align: center;
    font-size: 1.1rem;
    color: #ffe8a0;
}

.waiting-panel {
    text-align: center;
    padding: 28px;
}

.crew-list {
    list-style: none;
    padding: 0;
    margin: 16px 0;
}

.crew-list li {
    padding: 8px 16px;
    margin: 6px 0;
    background: rgba(6, 18, 32, 0.8);
    border-radius: 6px;
    border: 1px solid #2a4060;
}

.lobby-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 16px;
}

.lan-hint {
    margin-top: 14px;
    font-size: 0.82rem;
    line-height: 1.45;
    color: #a8c4e0;
    text-align: left;
}

.lan-hint strong {
    color: #ffe8a0;
    word-break: break-all;
}

.join-lan-box {
    margin: 14px auto 6px;
    max-width: 420px;
    padding: 12px 14px;
    background: rgba(6, 18, 32, 0.85);
    border: 1px solid #3a6088;
    border-radius: 8px;
    text-align: left;
}

.join-lan-title {
    margin: 0 0 6px;
    font-size: 0.9rem;
    color: #ffe8a0;
}

.join-lan-url {
    margin: 0 0 6px;
    font-size: 0.95rem;
}

.join-lan-url a {
    color: #7ec8ff;
    word-break: break-all;
}

.join-lan-note {
    margin: 0;
    font-size: 0.78rem;
    color: #8aa8c8;
    line-height: 1.4;
}

.lobby-actions button { width: auto; min-width: 160px; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    background: rgba(10, 28, 48, 0.98);
    border: 1px solid rgba(255, 211, 107, 0.3);
    border-radius: 12px;
    padding: 24px;
    max-width: 620px;
    width: 92%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.modal.tutorial-modal {
    max-width: 680px;
}

.modal h3 { margin-top: 0; }

.modal button {
    width: auto;
    margin: 6px;
}

.tutorial-body h4 {
    color: #ffd36b;
    margin: 18px 0 6px;
    font-size: 1.05rem;
}

.tutorial-body h4:first-child {
    margin-top: 0;
}

.tutorial-body p, .tutorial-body li {
    color: #b8cfe0;
    font-size: 0.92rem;
    line-height: 1.55;
}

.tutorial-body ul {
    margin: 6px 0 12px;
    padding-left: 20px;
}

.tutorial-body .rule-highlight {
    background: rgba(255, 211, 107, 0.12);
    border: 1px solid rgba(255, 211, 107, 0.35);
    border-radius: 8px;
    padding: 12px 14px;
    margin: 12px 0;
    color: #ffe8a0;
}

.tutorial-steps {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 16px;
}

.tutorial-steps span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #2a4060;
}

.tutorial-steps span.active {
    background: #ffd36b;
}

.tutorial-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.tutorial-slide-num {
    color: #8ab0cc;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    min-width: 3.5rem;
    text-align: center;
}

.tutorial-skip-label {
    color: #8ab0cc;
    font-size: 0.85rem;
    flex: 1;
    text-align: center;
}

.tutorial-close {
    display: block;
    margin: 16px auto 0 !important;
}

/* Options modal */
.modal.options-modal {
    max-width: 420px;
    width: 100%;
    text-align: left;
}

.modal.options-modal h3 {
    text-align: center;
    color: #ffd36b;
    margin-bottom: 18px;
}

.options-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.options-section:last-of-type {
    border-bottom: none;
}

.options-section h4 {
    margin: 0 0 12px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #8ab0cc;
}

.options-hint {
    margin: 0 0 10px;
    font-size: 0.82rem;
    line-height: 1.45;
    color: #a8c4e0;
}

.options-speed-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.options-speed-btn {
    flex: 1 1 0;
    min-width: 90px;
    margin: 0 !important;
    width: auto !important;
    padding: 10px 8px !important;
    font-size: 0.88rem !important;
}

.options-speed-btn--active {
    border-color: #ffffff;
    background: rgba(255, 255, 255, 0.22);
    font-weight: 700;
}

.options-audio-row {
    margin-bottom: 12px;
}

.options-volume-label {
    display: flex;
    justify-content: space-between;
    color: #c8dce8;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.options-volume-label span {
    color: #ffd36b;
    font-variant-numeric: tabular-nums;
}

.options-slider {
    width: 100%;
    accent-color: #ffd36b;
}

.options-btn {
    display: block;
    width: 100% !important;
    margin: 8px 0 0 !important;
}

.options-close {
    display: block;
    margin: 8px auto 0 !important;
    width: auto !important;
}

.voyage-banner {
    text-align: center;
    padding: 10px 16px;
    margin-bottom: 14px;
    border-radius: 8px;
    font-weight: 600;
}

.voyage-banner.in-port {
    background: rgba(100, 80, 20, 0.25);
    border: 1px solid rgba(255, 211, 107, 0.45);
    color: #ffd36b;
}

.voyage-banner.at-sea {
    background: rgba(26, 107, 74, 0.25);
    border: 1px solid rgba(100, 220, 160, 0.35);
    color: #98ffd0;
}

.voyage-banner.returned {
    background: rgba(107, 74, 26, 0.25);
    border: 1px solid rgba(255, 200, 100, 0.35);
    color: #ffe0a0;
}

.btn-rules {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.88);
    color: #ffffff;
    width: auto;
    padding: 8px 16px;
    margin: 0;
}

#scores {
    text-align: center;
    font-size: 1rem;
    color: #ffd36b;
}

.strip-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6a8fa8;
    width: 100%;
    margin-top: 4px;
}
