/* public/styles.css */

:root {
    --purple-dark: #4a148c;
    --purple-medium: #7b1fa2;
    --purple-light: #9c27b0;
    --gold-primary: #ffd700;
    --gold-secondary: #ffab00;
    --gold-light: #ffec8b;
    --white: #ffffff;
    --light-purple: #e1bee7;
    --chat-bg: #ffffff;
    --chat-text: #000000;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, var(--purple-dark), var(--purple-medium));
    color: var(--white);
}

body {
    padding: 15px;
    box-sizing: border-box;
}

.container {
    display: flex;
    flex-direction: column;
    height: calc(100% - 20px);
    max-width: none;
    margin: 0;
    padding: 0;
}

/* =========================
   Language Selector (global)
   ========================= */
#lang-select-container {
    position: fixed;
    /* keep it visible on all screens */
    top: 12px;
    right: 12px;
    z-index: 1300;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 2px 2px;
    border-radius: 999px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

#lang-select-container:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.35);
}

#lang-select-container::after {
    content: "▾";
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gold-light);
    font-size: 0.8rem;
    pointer-events: none;
}

#language-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border: none;
    outline: none;
    color: var(--white);
    font-weight: 700;
    font-size: 0.95rem;
    padding: 8px 28px 8px 10px;
    /* leave room for arrow */
    border-radius: 10px;
    background: transparent;
    /* glass container provides bg */
    cursor: pointer;
    line-height: 1;
}

#language-select:focus {
    outline: none;
}

#language-select option {
    color: #111;
    /* dropdown text color */
    background: #fff;
    /* dropdown background */
}

/* Reduce footprint on small screens */
@media (max-width: 480px) {
    #lang-select-container {
        top: 8px;
        right: 8px;
        padding: 4px 10px;
    }

    #language-select {
        font-size: 0.9rem;
        padding: 6px 26px 6px 8px;
    }

    #lang-select-container::after {
        right: 14px;
        font-size: 0.75rem;
    }
}

/* ========================= */

.purple-gradient {
    background: linear-gradient(135deg, var(--purple-dark), var(--purple-medium));
    border-radius: 16px;
    padding: 1.2rem;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
}

.purple-card {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 1rem;
    backdrop-filter: blur(10px);
}

.text-muted {
    margin-top: 15px !important;
}

.gold-text {
    color: var(--gold-primary);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    font-weight: 700;
    margin: 5px 0;
}

.gold-btn {
    background: linear-gradient(135deg, var(--gold-primary), var(--gold-secondary));
    color: var(--purple-dark);
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin: 8px 0;
    width: 100%;
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
}

.gold-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    filter: brightness(1.1);
}

#show-board-btn {
    background: linear-gradient(135deg, var(--gold-light), var(--gold-primary));
}

.form-group {
    margin-bottom: 12px;
}

#mode-solo-btn,
#mode-multi-btn,
#mode-played-btn {
    margin-top: -10px !important;
}

.start-section {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: -15px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--light-purple);
}

input {
    padding: 12px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.15);
    color: var(--white);
    width: 100%;
    box-sizing: border-box;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
}

input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

#mode-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 20px;
    min-height: 100vh;
    background-image: url('mahalilah.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    border-radius: 20px;
    overflow: hidden;
}

/* Dark overlay to ensure text readability */
#mode-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 0;
    border-radius: 20px;
}

/* Ensure content is above the overlay */
#mode-screen>* {
    position: relative;
    z-index: 1;
}

/* Apply Playwrite IN font to mode screen title */
#mode-screen h1 {
    font-family: 'Playwrite IN', sans-serif;
    font-weight: 800;
    font-size: 3rem;
    letter-spacing: 1px;
}

/* Responsive title size for mobile */
@media (max-width: 768px) {
    #mode-screen h1 {
        font-size: 2.2rem;
    }
}

/* Apply Playwrite IN font to mode screen buttons */
#mode-screen .gold-btn {
    font-weight: 600;
    font-size: 1.3rem;
    border-radius: 16px;
}

#solo-setup,
#multi-setup {
    display: none;
    flex-direction: column;
    height: 100%;
    max-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Make back sections sticky for solo and multi setup */
#solo-setup .back-section,
#multi-setup .back-section {
    position: sticky !important;
    bottom: 0;
    left: auto !important;
    transform: none !important;
    width: auto !important;
    z-index: 2000;
    margin: 0 !important;
    padding: 10px 8px calc(10px + env(safe-area-inset-bottom, 0px)) !important;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 12px !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
}

#solo-setup .back-section .gold-btn,
#multi-setup .back-section .gold-btn {
    width: 100%;
    margin: 0;
}

#player-names {
    margin: 12px 0;
}

button {
    padding: 8px;
    margin-top: 5px;
    width: 100%;
    box-sizing: border-box;
}

#chat-container {
    flex: 1 1 auto;
    min-height: 0;
    /* allow it to shrink inside flex container */
    background: var(--chat-bg);
    border-radius: 16px;
    padding: 20px;
    overflow-y: auto;
}

#chat-messages {
    color: var(--chat-text);
    display: flex;
    flex-direction: column;
    gap: 10px;
    /* Space between messages */
}

.message {
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.05);
    position: relative;
}

.message-content {
    margin-bottom: 5px;
    color: var(--chat-text);
}

.timestamp {
    font-size: 0.8em;
    color: #666;
    text-align: right;
    display: block;
}

/* Nice, consistent line formatting for turn content */
.turn-line {
    margin: 8px 0;
    line-height: 1.4;
    color: var(--chat-text);
}

.roll-for {
    margin-top: 10px;
}

.manual-roll {
    display: flex;
    gap: 10px;
    margin-top: 5px;
}

.manual-roll input {
    flex: 1;
    max-width: 100px;
}

.manual-roll button {
    flex: 1;
}

#copy-room-link {
    background: #9b59b6;
}

#copy-room-link:hover {
    background: #8e44ad;
}

.info {
    background: rgba(227, 242, 253, 0.7);
}

.success {
    background: rgba(232, 245, 233, 0.7);
}

.snake {
    background: rgba(255, 235, 238, 0.7);
}

.ladder {
    background: rgba(232, 245, 233, 0.7);
}

.victory {
    background: rgba(255, 249, 196, 0.7);
    font-weight: bold;
    font-size: 1.2em;
}

.house-description {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    margin-top: 8px;
    max-height: 40vh;
    overflow-y: auto;
}

.house-description p {
    margin: 5px 0;
    line-height: 1.5;
    color: var(--chat-text);
}

/* Title should truncate instead of overlapping */
.custom-modal {
    display: none;
    position: fixed;
    inset: 0;
    /* CHANGED from 0.75 to 0.8 to make it less transparent (≈80% opacity) */
    background: rgba(0, 0, 0, 0.8);
    z-index: 1100;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 12000;
}

.custom-modal .modal-inner {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px 20px 30px;
    position: relative;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.close-start-info-modal {
    top: 0px !important;
    margin: 0px 0 !important;
}

.modal-ready-btn-container {
    margin: 0px 0 !important;
}

#start-info-modal .close-start-info-modal,
#game-over-modal .close-game-over-modal,
.close-dice-modal {
    position: absolute;
    top: 12px;
    /* was 10px */
    right: 12px;
    /* was -170px (caused the button to sit incorrectly) */
    left: auto;
    /* ensure no left offset competes */
    transform: none;
    /* neutralize any centering transforms */
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gold-primary);
    cursor: pointer;
    padding: 4px;
    z-index: 2;
    width: auto !important;
}

/* Floating Ready Button in Start Info Modal */
.modal-ready-btn-container {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 16px -20px -30px -20px;
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px)) 20px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.7) 50%, transparent 100%);
    border-radius: 0 0 16px 16px;
}

#show-board-btn-bar,
#copy-room-link-bar {
    margin-top: 0px !important;
    height: 30px !important;
    padding: 5px 16px !important;
}

/* Mobile Action Bar */
.mobile-action-bar {
    display: none;
    gap: 8px;
    /*padding: 8px;*/
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    margin-bottom: 8px;
}

.mobile-action-bar .action-bar-btn {
    flex: 1;
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--gold-primary), var(--gold-secondary));
    color: var(--purple-dark);
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.mobile-action-bar .action-bar-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

/* Show mobile action bar only on mobile */
@media (max-width: 768px) {
    .mobile-action-bar {
        display: flex;
    }
}

.manual-dice-modal {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.manual-dice-modal input {
    flex: 1;
    min-width: 0;
    padding: 12px 15px;
    font-size: 1rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
    box-sizing: border-box;
}


.manual-dice-modal input,
.manual-dice-modal button {
    width: 100%;
    box-sizing: border-box;
}

#game-title {
    display: flex;
    align-items: center;
    gap: 8px;
    /* keep existing behavior of the container itself */
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#game-title-base {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 767px) {
    .played-open-btn {
        margin-top: -5px !important;
    }

    /* Force the header to stay as a single row on mobile */
    .game-header {
        flex-direction: row !important;
        align-items: center !important;
        gap: 8px;
    }

    /* Ensure the title (with code tag inside) can shrink and ellipsize */
    #game-title {
        flex: 1 1 auto;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Keep the code tag inline with the title on the same line */
    #game-title .code-tag {
        display: inline-block !important;
        margin-left: 8px !important;
        margin-top: 0 !important;
        vertical-align: middle;
    }

    /* Keep the mobile menu on the same line at the far right */
    .mobile-menu {
        display: flex;
        margin-left: auto;
        flex: 0 0 auto;
    }
}

#game-code-tag {
    display: none;
    /* shown via JS when an ID exists */
    flex: 0 0 auto;
    margin-left: 8px;
    padding: 2px 8px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    /* shrink when space is tight, grow a bit on larger screens */
    font-size: clamp(10px, 2.6vw, 14px);
    line-height: 1;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
}

#game-code-tag.copied {
    outline: 2px solid var(--gold-primary);
    outline-offset: 2px;
}

/* Desktop vs mobile toggle */
.desktop-header-actions {
    display: flex;
    gap: 8px;
    flex: 1;
    justify-content: flex-end;
}

.mobile-menu {
    position: relative;
    display: none;
    /* shown only on mobile */
    margin-left: auto;
}

/* Menu button small, inline with title */
.menu-btn {
    background: none;
    border: none;
    color: var(--gold-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    position: relative;
    display: flex;
    align-items: center;
}

/* Dropdown container */
.menu-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    color: var(--purple-dark);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    padding: 6px;
    min-width: 160px;
    z-index: 1200;
}

/* Show when open */
.menu-dropdown.open {
    display: flex;
}

.menu-item {
    background: transparent;
    border: none;
    text-align: left;
    padding: 10px 14px;
    font-weight: 700;
    cursor: pointer;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    transition: background 0.2s;
}

.menu-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

#game-screen {
    display: none;
    flex-direction: column;
    height: 100%;
    gap: 0;
    min-height: 0;
}

.game-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 20px;
}

.game-controls {
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    margin-top: 8px;
}

/* Diamond in current player display (desktop) */
#current-player .player-diamond {
    display: inline-flex;
    vertical-align: middle;
    width: 18px;
    height: 18px;
    margin: 0 4px;
}

#current-player .player-diamond-initial {
    font-size: 10px;
}

.game-header {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
}

.game-header>div {
    display: flex;
    gap: 8px;
}

/* Header buttons - side by side on larger screens */
@media (min-width: 768px) {
    .game-header>div {
        justify-content: flex-end;
    }

    .gold-btn {
        width: auto;
        min-width: 180px;
    }

    .desktop-header-actions {
        display: none !important;
    }

    .mobile-menu {
        display: flex;
        align-items: center;
    }
}

@media (min-width: 769px) {
    .mobile-menu {
        display: none !important;
    }

    .desktop-header-actions {
        display: flex !important;
    }

    #mobile-current-player {
        display: none !important;
    }
}

.game-info {
    padding: 12px;
    margin-top: 8px;
}

.game-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.load-section {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.back-section {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.house-info {
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 5px;
    padding: 8px;
    margin-top: 5px;
    background: rgba(255, 255, 255, 0.9);
}

.house-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    /* Align to top */
    margin-bottom: 5px;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
}

.house-header>div {
    display: flex;
    flex-direction: column;
}

.house-name {
    font-size: 1.1em;
    font-weight: bold;
    color: var(--purple-dark);
    margin-top: 3px;
}

.house-number {
    color: var(--purple-medium);
}

.house-date {
    color: #666;
    font-size: 0.9em;
}

.info-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.info-date {
    color: #666;
    font-size: 0.9em;
}

.author-card {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    margin: 5px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.author-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 12px;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.05);
    transition: background 0.2s;
}

.author-header:hover {
    background: rgba(0, 0, 0, 0.08);
}

.author-title {
    font-weight: bold;
    font-size: 0.95rem;
    flex: 1;
}

.author-content {
    display: none;
    padding: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.author-card.expanded .author-content {
    display: block;
}

.author-header .play-audio-btn,
.comment-header .play-audio-btn,
.paths-content .play-audio-btn {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px;
    min-height: 34px;
    flex: 0 0 34px;
    /* prevents grow/shrink in flex rows */
    padding: 0;
    margin-left: 10px;
    align-self: center;
}

.play-audio-btn {
    position: relative;

    /* hard-stop any stretching from global button { width:100% } */
    width: 34px !important;
    height: 34px !important;
    min-width: 34px;
    min-height: 34px;
    flex: 0 0 auto;
    padding: 0;
    aspect-ratio: 1 / 1;

    background: var(--purple-medium);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    /* don't expand to full width */
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s;
}

.play-audio-btn:hover {
    background: var(--purple-dark);
}

.play-audio-btn.playing {
    background: var(--gold-primary);
}

.play-audio-btn.playing:hover {
    background: var(--gold-secondary);
}

.play-audio-btn.loading {
    background: var(--purple-light);
}

.play-icon,
.stop-icon,
.spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.spinner {
    display: none;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

.manual-dice,
.manual-roll {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    flex-wrap: nowrap;
    align-items: center;
}

.manual-dice input,
.manual-roll input {
    flex: 1;
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, 0.3);
    min-width: 120px;
    /* Increased width */
    padding: 12px 15px;
    font-size: 1.1rem;
    height: 46px;
    /* Bigger font */
}

.manual-dice button,
.manual-roll button {
    width: 90%;
    /* override global full-width button */
    flex: 0 0 auto;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--gold-primary), var(--gold-secondary));
    color: var(--purple-dark);
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    height: 46px;
}

/* Style all game control buttons */
#roll-btn,
#roll-for-btn,
#submit-for-dice,
#start-game-btn {
    background: linear-gradient(135deg, var(--gold-primary), var(--gold-secondary));
    color: var(--purple-dark);
    border: none;
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    margin: 5px 0;
}

/* Add to the end of the file */

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
}

.modal-content {
    position: relative;
    margin: auto;
    display: block;
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    top: 50%;
    transform: translateY(-50%);
    animation: zoom 0.3s;
    border-radius: 16px;
    overflow: hidden;
    background: var(--purple-medium);
}

@keyframes zoom {
    from {
        transform: scale(0) translateY(-50%);
    }

    to {
        transform: scale(1) translateY(-50%);
    }
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    color: var(--gold-primary);
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.7);
}

.close:hover,
.close:focus {
    color: var(--gold-secondary);
    text-decoration: none;
}

/*
.board-image {
    width: 100%;
    height: auto;
    max-height: 90vh;
    object-fit: contain;
}*/

#player-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    /* compact 2 columns */
    gap: 6px;
    /* tighter gaps */
    padding: 8px 10px !important;
    /* smaller padding */
    margin-bottom: 10px;
}

/* Smaller cards: less padding, smaller font, no hover lift */
.player {
    padding: 6px 8px;
    /* was 15px */
    font-size: 0.86rem;
    /* smaller text */
    line-height: 1.15;
    /* tighter lines */
    margin: 0;
    /* remove extra margin */
    border-radius: 10px;
    /* slightly smaller corners */
    display: flex;
    /* name on left, status on right */
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.player:hover {
    transform: none;
    /* remove lift to save vertical space */
}

.player.me {
    background: rgba(255, 215, 0, 0.16);
    /* was 0.2 */
    border: 1px solid rgba(255, 215, 0, 0.6);
    /* slightly lighter border */
    font-weight: 700;
    /* a touch smaller than boldest */
}

.player-row {
    margin-bottom: 0 !important
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .desktop-header-actions {
        display: none !important;
    }

    .mobile-menu {
        display: flex;
        align-items: center;
    }

    .menu-item {
        font-size: 1rem;
        /* increase text size */
        padding: 12px 16px;
        /* more tappable area */
    }

    #roll-btn {
        font-size: 1rem;
        /* match menu size */
        padding: 12px 20px;
        /* larger hit‐area */
    }

    body {
        padding: 8px;
    }

    .container {
        height: calc(100% - 16px);
    }

    .purple-gradient,
    .purple-card {
        padding: 1rem;
        padding-top: 1rem !important;
    }

    .game-header {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .player-list {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        padding: 12px;
    }

    .modal-content {
        width: 98%;
    }

    .close {
        top: 8px;
        right: 12px;
        font-size: 25px;
    }

    /* Stack buttons on mobile */
    .game-header>div {
        flex-direction: column;
        gap: 6px;
    }

    /* Chat container larger on mobile */
    #chat-container {
        flex: 1;
    }

    /* Fix for author cards on mobile */
    .house-description {
        grid-template-columns: 1fr !important;
        /* Force single column */
    }

    .game-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 8px 0;
    }

    /* keep the two header buttons in a row instead of stacked */
    .game-header>div {
        flex-direction: row;
        gap: 6px;
        flex-wrap: wrap;
    }

    /* Smaller but still perfectly circular on mobile */
    .comments-section .play-audio-btn,
    .author-header .play-audio-btn,
    .paths-content .play-audio-btn {
        width: 30px !important;
        height: 30px !important;
        min-width: 30px;
        min-height: 30px;
        flex-basis: 30px;
    }
}

@media (max-width: 480px) {
    .menu-item {
        font-size: 1.1rem;
    }

    #roll-btn {
        font-size: 1.1rem;
    }

    .manual-dice-modal {
        flex-direction: column;
    }

    .manual-dice-modal input {
        width: 100%;
    }

    .game-header .gold-btn {
        width: auto;
        flex: 1 1 auto;
        min-width: 100px;
    }

    .manual-dice,
    .manual-roll {
        flex-direction: column;
        gap: 8px;
    }

    .gold-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .house-description {
        grid-template-columns: 1fr;
    }

    /* Full width buttons on mobile */
    .game-header .gold-btn {
        width: 100%;
    }

    .manual-dice input,
    .manual-roll input {
        min-width: 70px;
        /* Smaller width */
        font-size: 0.95rem;
        /* Slightly smaller font */
        padding: 8px 10px;
        /* Reduced padding */
    }

    /* Fix scroll for mobile */
    #chat-container {
        -webkit-overflow-scrolling: touch;
        /* Enable smooth scrolling on iOS */
        overflow-y: auto;
    }

    #chat-messages {
        overflow-anchor: none;
        /* Prevent scroll anchoring issues */
    }

    /* Ensure chat messages don't grow too large */
    .message {
        max-width: 100%;
        word-wrap: break-word;
    }
}

/* Scrollbar styling for better UX */
#chat-container::-webkit-scrollbar {
    width: 8px;
}

#chat-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

#chat-container::-webkit-scrollbar-thumb {
    background: var(--purple-medium);
    border-radius: 4px;
}

#chat-container::-webkit-scrollbar-thumb:hover {
    background: var(--purple-dark);
}

/* Fix for scroll anchoring */
#chat-messages {
    overflow-anchor: auto;
    flex: 1;
}

/* Main description and comments */
.main-card {
    margin: 5px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.8);
}

.main-card .author-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.05);
    transition: background 0.2s;
}

.main-card .author-content {
    display: block;
    padding: 12px;
}

.comments-section {
    margin-top: 10px;
}

.comment-card {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    padding: 8px;
}

.comment-card:first-child {
    border-top: none;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    /* spacing between title and button */
}

.comment-header .comment-house {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
    /* allow wrap on small screens */
}

.comment-body {
    display: block;
    margin-top: 4px;
    font-size: 0.9rem;
    color: var(--chat-text);
}

/* Paths card (origins/destinations) */
.paths-card {
    margin: 5px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.8);
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.paths-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 12px;
    background: rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: background 0.2s;
    height: 51px;
}

.paths-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--purple-dark);
}

.paths-content {
    padding: 10px;
    font-size: 0.9rem;
    color: var(--chat-text);
}

.paths-content ul {
    list-style: none;
    padding-left: 0;
}

.paths-content li {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

.paths-content li .path-house {
    font-weight: bold;
    color: var(--purple-dark);
    margin-right: 6px;
}

.paths-content li .play-audio-btn {
    margin-left: 6px;
}

/* =========================
   Floating 3D Gold Dice (FAB)
   ========================= */
:root {
    --dice-size: 92px;
    --dice-radius: 18px;
    --gold-1: #f7d774;
    --gold-2: #caa445;
    --gold-3: #8f6a17;
    --gold-4: #fff3b0;
    --pip: #3a2a06;

    /* inner panel inset so faces remain square (seals seams) */
    --face-inset: 4px;
}

@media (max-width: 600px) {
    :root {
        --dice-size: 48px;
    }
}

#board-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    /* larger than whatever the dice uses */
}

/* === Board modal === */
.board-modal {
    display: none;
    /* must be higher than dice FAB */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background: rgba(0, 0, 0, 0.75);
}

.board-modal-content {
    background: #111827;
    margin: 40px auto;
    padding: 12px 12px 16px;
    border-radius: 10px;
    width: min(95vw, 960px);
    position: relative;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7);
}

.board-wrapper {
    position: relative;
    width: 100%;
    max-height: calc(100vh - 120px);
    overflow: auto;
}

.board-image {
    display: block;
    max-width: 100%;
    height: auto;
}

.board-overlay {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    /* markers don't block clicking the image if needed */
}

/* Close button inside board modal */
.board-close {
    position: absolute;
    top: 6px;
    right: 10px;
    font-size: 22px;
    cursor: pointer;
    color: #e5e7eb;
}

/* === Diamond marker used in list and board overlay === */
.player-diamond {
    position: relative;
    width: 18px;
    height: 18px;
    transform: rotate(45deg);
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
}

/* background: left half colored, right half dark/transparent */
.player-diamond-inner {
    position: absolute;
    inset: 0;
    background: linear-gradient(to right, var(--diamond-color, #6b7280) 0 50%, rgba(17, 24, 39, 0.95) 50% 100%);
    border-radius: 3px;
}

/* Initial in the center (unrotated) */
.player-diamond-initial {
    position: relative;
    transform: rotate(-45deg);
    font-size: 10px;
    font-weight: 700;
    color: #f9fafb;
    z-index: 1;
}

/* Diamond as a "marker on the board" */
.board-marker {
    position: absolute;
    transform-origin: center center;
}

/* Optionally: tweak size for board marker */
.board-marker .player-diamond {
    width: 16px;
    height: 16px;
}

#floating-dice {
    z-index: 8000;
    /* lower than .board-modal (9000) */
}

/* FAB container */
#floating-dice.lilah-dice-fab {
    position: fixed;
    left: 50%;
    bottom: 55px;
    transform: translateX(-50%);
    z-index: 9999;
    width: var(--dice-size);
    height: var(--dice-size);
    display: grid;
    place-items: center;
    border-radius: 999px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

#floating-dice.hidden {
    display: none;
}

/* Subtle base shadow and hover lift */
#floating-dice.lilah-dice-fab::after {
    content: "";
    position: absolute;
    inset: 6px;
    pointer-events: none;
}

/* Active/disabled states */
#floating-dice.lilah-dice--active {
    cursor: pointer;
}

#floating-dice.lilah-dice--active:hover {
    transform: translateX(-50%) translateY(-2px);
}

#floating-dice.lilah-dice--disabled {
    opacity: .5;
    filter: grayscale(.2);
    pointer-events: none;
}

/* =========================
   Solo cooldown badge next to the dice (5s circular progress)
   ========================= */
#floating-dice .dice-cooldown {
    position: absolute;
    top: 50%;
    right: -39px;
    /* float slightly to the right of the dice */
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    display: none;
    /* hidden by default */
    pointer-events: none;
    /* purely informational */
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .35));
}

#floating-dice .dice-cooldown.show {
    display: block;
}

#floating-dice .dice-cooldown svg {
    width: 28px;
    height: 28px;
    transform: rotate(-90deg);
    /* start progress from the top (12 o'clock) */
}

/* circumference ≈ 2πr = 2 * π * 17 ≈ 106.8 */
#floating-dice .dice-cooldown .progress {
    stroke-dasharray: 106.8;
    stroke-dashoffset: 106.8;
    /* start empty */
}

/* when .animating is set on the container, run the 5s fill */
#floating-dice .dice-cooldown.animating .progress {
    animation: lilahCooldown 3s linear forwards;
}

@keyframes lilahCooldown {
    to {
        stroke-dashoffset: 0;
    }
}

/* Gentle pulse to hint it's your turn */
@keyframes lilahDicePulse {

    0%,
    100% {
        transform: translateX(-50%) scale(1);
    }

    50% {
        transform: translateX(-50%) scale(1.04);
    }
}

#floating-dice.lilah-dice--active {
    animation: lilahDicePulse 1.6s ease-in-out infinite;
}

/* Throw/land bounce */
@keyframes lilahDiceThrow {
    0% {
        transform: translateX(-50%) translateY(0);
    }

    30% {
        transform: translateX(-50%) translateY(-14px);
    }

    100% {
        transform: translateX(-50%) translateY(0);
    }
}

#floating-dice.throwing {
    animation: lilahDiceThrow .9s cubic-bezier(.18, .6, .24, 1);
}

/* 3D dice scene */
#floating-dice .dice-scene {
    width: var(--dice-size);
    height: var(--dice-size);
    perspective: 800px;
    filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .4));
    isolation: isolate;
}

/* Cube */
#floating-dice .dice {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    transform: translateZ(calc(-1 * var(--dice-size) / 2));
    transition: transform 1s;
    will-change: transform;
}

/* Faces: keep them SQUARE to seal edges (no real border-radius here) */
#floating-dice .dice__face {
    position: absolute;
    width: var(--dice-size);
    height: var(--dice-size);
    display: flex;

    /* seal seams & avoid hairlines during rotation */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    outline: 1px solid transparent;
    /* AA hack */
    background: var(--gold-2);
    /* body/edge tone under inner panel */
    box-shadow: none;
    border: 0;
    background-clip: padding-box;
}

/* Inner rounded panel (visual roundness) — sits INSET so outer face stays square */
#floating-dice .dice__face::after {
    content: "";
    position: absolute;
    inset: var(--face-inset);
    border-radius: var(--dice-radius);
    background: radial-gradient(120% 120% at 30% 25%,
            var(--gold-4) 0%,
            var(--gold-1) 28%,
            var(--gold-2) 62%,
            var(--gold-3) 100%);
    box-shadow:
        0 10px 18px rgba(0, 0, 0, .35),
        0 2px 0 rgba(255, 255, 255, .18) inset,
        0 -2px 0 rgba(0, 0, 0, .35) inset;
    z-index: 0;
}

/* Pips above the inner panel */
#floating-dice .dot {
    position: relative;
    z-index: 1;
    background: var(--pip);
    width: calc(var(--dice-size) / 5.2);
    height: calc(var(--dice-size) / 5.2);
    border-radius: 50%;
    margin: auto;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, .25) inset,
        0 -1px 0 rgba(0, 0, 0, .5) inset;
}

#floating-dice .dot-1 {
    background: var(--pip);
}

#floating-dice .dot-5-m {
    grid-column: 2;
    grid-row: 2;
}

#floating-dice .dot-5-t1 {
    grid-column: 1;
    grid-row: 1;
}

#floating-dice .dot-5-t2 {
    grid-column: 1;
    grid-row: 3;
}

#floating-dice .dot-5-b1 {
    grid-column: 3;
    grid-row: 1;
}

#floating-dice .dot-5-b2 {
    grid-column: 3;
    grid-row: 3;
}

/* Face transforms (size/2 = translateZ) */
#floating-dice .front {
    transform: rotateY(0deg) translateZ(calc(var(--dice-size) / 2));
}

#floating-dice .back {
    transform: rotateY(180deg) translateZ(calc(var(--dice-size) / 2));
}

#floating-dice .left {
    transform: rotateY(-90deg) translateZ(calc(var(--dice-size) / 2));
    display: grid;
}

#floating-dice .right {
    transform: rotateY(90deg) translateZ(calc(var(--dice-size) / 2));
    display: grid;
    grid-template-columns: 1fr 1fr;
}

#floating-dice .top {
    transform: rotateX(90deg) translateZ(calc(var(--dice-size) / 2));
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
}

#floating-dice .bottom {
    transform: rotateX(-90deg) translateZ(calc(var(--dice-size) / 2));
    display: grid;
    grid-template-columns: 1fr 1fr;
}

/* Reduce motion preference */
@media (prefers-reduced-motion: reduce) {
    #floating-dice.lilah-dice--active {
        animation: none;
    }

    #floating-dice.throwing {
        animation: none;
    }

    #floating-dice .dice {
        transition: transform .3s;
    }
}

/* ===== Mobile floating current player badge (icon + name only) ===== */
#mobile-current-player {
    display: none;
}

@media (max-width: 768px) {

    /* Hide the desktop current-player line on mobile */
    #current-player {
        display: none !important;
    }

    #floating-dice.lilah-dice-fab {
        bottom: 62px;
    }

    #mobile-current-player {
        position: fixed;
        left: 50%;
        transform: translateX(-50%);
        bottom: 12px;
        /* placed BELOW the dice (dice bottom = 22px) */
        z-index: 9998;
        /* dice FAB is 9999 */
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 14px;
        border-radius: 999px;
        /* rounded edge box */
        background: rgba(255, 255, 255, 0.92);
        color: var(--purple-dark);
        font-weight: 800;
        box-shadow: 0 10px 25px rgba(0, 0, 0, .25), 0 1px 0 rgba(255, 255, 255, .5) inset;
    }

    #mobile-current-player .player-icon {
        font-size: 1.1rem;
        line-height: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Diamond inside mobile current player badge */
    #mobile-current-player .player-icon .player-diamond {
        width: 20px;
        height: 20px;
        margin: 0;
    }

    #mobile-current-player .player-icon .player-diamond-initial {
        font-size: 11px;
    }

    #mobile-current-player .player-name {
        white-space: nowrap;
        max-width: 70vw;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Floating Feedback Button (?) */
.feedback-fab {
    position: fixed;
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
    z-index: 1200;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--gold-primary), var(--gold-secondary));
    color: var(--purple-dark);
    font-weight: 900;
    font-size: 24px;
    line-height: 1;
    display: grid;
    place-items: center;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .35);
    cursor: pointer;
}

.feedback-fab:hover {
    transform: translateY(-50%) translateX(-1px);
    filter: brightness(1.05);
}

@media (max-width: 480px) {
    .feedback-fab {
        right: 8px;
        width: 44px;
        height: 44px;
        font-size: 22px;
    }
}

/* Close button for Feedback modal (same style as Submit Dice modal) */
.close-feedback-modal {
    position: absolute;
    top: 10px;
    right: -170px;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gold-primary);
    cursor: pointer;
    padding: 4px;
}

/* Feedback form styles (match inputs look) */
.feedback-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.feedback-form textarea {
    padding: 12px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.15);
    color: var(--white);
    width: 100%;
    box-sizing: border-box;
    font-size: 0.95rem;
    resize: vertical;
}

/* Bigger Start Info modal (House 68) */
#start-info-modal .modal-inner {
    max-width: 900px;
    /* wider than the default 400px */
    width: min(95vw, 1000px);
    /* responsive cap */
}

/* Inside the Start Info modal: ensure the description area can grow vertically
     and stack as a single column (JS also enforces this inline for robustness). */
#start-info-modal .house-description {
    grid-template-columns: 1fr !important;
    max-height: none !important;
}

/* Give the modal body comfortable scrolling room if content gets long */
#start-info-modal #start-info-modal-body {
    max-height: 75vh;
    overflow-y: auto;
}

/* Center the intro modal's inline audio button between the intro note and the main text */
#start-info-modal .intro-audio-inline {
    display: flex;
    justify-content: center;
    margin: 8px 0 10px;
}

/* Fix: make the Played Games screen scrollable on mobile and desktop */
#played-games-screen,
#intro-screen {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    /* contain scroll inside the body area */
}

#played-games-screen .back-section,
#intro-screen .back-section {
    position: sticky !important;
    bottom: 0;
    left: auto !important;
    transform: none !important;
    width: auto !important;
    z-index: 2000;

    margin: 0 !important;
    padding: 10px 8px calc(10px + env(safe-area-inset-bottom, 0px)) !important;

    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);

    /* ✅ make all corners rounded and the border consistent */
    border-radius: 12px !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
}

#played-games-screen .back-section .gold-btn,
#intro-screen .back-section .gold-btn {
    width: 100%;
    margin: 0;
}

/* Keep list itself unconstrained; let the container scroll */
#played-games-list,
#intro-body {
    flex: 1 1 auto;
    min-height: 0;
    /* allow flex child to shrink */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 12px;
    /* small breathing room above footer */
}

.end-message {
    font-size: 0.98rem;
    line-height: 1.5;
    color: #000;
}