/* Game colors inherit from main style.css CSS variables */
/* These are defined in style.css:
   --board-border, --board-surface, --board-point-light, --board-point-dark,
   --board-home, --board-button, --board-button-hover, --board-text
*/


@media (max-width: 768px) {
    .align-form {
        .game-form-group {
        margin-bottom: 0.6rem; /* Add spacing between form elements */
        }
    
        input[type="text"],
        input[type="email"],
        textarea {
            width: 100%; /* Make input fields full-width */
            padding: 0.5rem; /* Add some padding for better touch target size */
            border-radius: 0.25rem; /* Optional: Add rounded corners */
        }
    
        button {
            padding: 0.6rem 0.6rem; /* Add some padding for better touch target size */
            border-radius: 0.25rem; /* Optional: Add rounded corners */
            font-size: 1rem; /* Make the button text size larger for better tap target */
        }
    }
}

.game-home {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    margin-top: 32px;
}
.game-home-image {
    max-width: 120px;
    height: auto;
    border-radius: 8px;
}
.game-home-text {
    display: inline;
    height: auto;
    border-radius: 8px;
}

.align-form  { display: table;      }
.align-p     { display: table-row;  }
.align-label { display: table-cell; }
.align-input { display: table-cell; }

.inline-form { display: inline-block; }

.align-checkboxes label {
    display: inline-block;
    padding-right: 0.7rem;
    white-space: nowrap;
}
.align-checkboxes input {
    vertical-align: middle;
}
.align-checkboxes label span {
    vertical-align: middle;
}

.confirm-button {
    font-weight : bold;
}
.panebtn {
    font-size: inherit;
    padding: 1px;
    background-color: transparent;
    width: auto;
    height: auto;
    border: none;
    cursor: pointer;
    z-index: 25;
    white-space: nowrap;
}

.panebtn:hover /*, .panebtn:focus*/ {
    opacity: 0.7;
}

/* Settle button container and button */
.settlediv {
    display: inline-block;
    margin-left: 0.3em;
}

.settlebtn {
    font-size: 1em;
    padding: 0.1em 0.3em;
    background-color: transparent;
    color: var(--board-text);
    border: none;
    cursor: pointer;
    line-height: 1;
}

.settlebtn:hover {
    opacity: 0.7;
}

.opensettlediv {
    display: inline-block;
    margin-left: 0.3em;
}

.opensettlebtn {
    font-size: 1em;
    padding: 0.1em 0.3em;
    background-color: transparent;
    color: var(--board-text);
    border: none;
    cursor: pointer;
    line-height: 1;
}

.opensettlebtn:hover {
    opacity: 0.7;
}

/* Dropdown Button */
.dropbtn {
    background-color: transparent;
    padding: 0.15em;
    border: none;
    cursor: pointer;
}

.pdropbtn {
    background-color: var(--board-border);
    color: white;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 3px;
}

.expanddown {
    background-image: url( '../img/down.svg' );
    background-size: 2em 1em;
    width: 2em;
    height: 1em;
}

.expandup {
    background-image: url( '../img/up.svg' );
    background-size: 2em 1em;
    width: 2em;
    height: 1em;
}

.expandleft {
    background-image: url( '../img/left.svg' );
    background-size: 1em 2em;
    width: 1em;
    height: 2em;
}

.expandright {
    background-image: url( '../img/right.svg' );
    background-size: 1em 2em;
    width: 1em;
    height: 2em;
}

/* Dropdown button on hover & focus */
.dropbtn:hover /*, .dropbtn:focus*/ {
    opacity: 0.7;
}

/* The container <div> - needed to position the dropdown button */
.dropdown {
    position: absolute;
    display: none;
    z-index: 25;
    width: auto;
    height: auto;
    border: none;
}

/* The container <div> - needed to position the dropdown button */
.pdropdown {
    position: relative;
    display: inline-block;
}

.pdropbtn:hover /*, .dropbtn:focus*/ {
    opacity: 0.7;
}

/* The container <div> - needed to position the dropdown button */
.fdropdown {
    padding-left: 0.2rem;
    position: relative;
    display: inline-block;
}

.fdropbtn:hover /*, .dropbtn:focus*/ {
    opacity: 0.7;
}


/* Dropdown Content (Hidden by Default) */
.dropdown-content {
    display: none;
    position: absolute;
    bottom: 0.75rem;
    overflow: auto;
    left: 0;
    background-color: #f1f1f1;
    /*min-width: 200px;*/
    white-space: nowrap;
    box-shadow: 0rem 0.5rem 1rem 0rem rgba(0,0,0,0.2);
    z-index: 35;
}

/* Player dropdown Content (Hidden by Default) */
.pdropdown-content {
    display: none;
    position: absolute;
    top: 1.2rem;
    overflow: auto;
    left: 0;
    background-color: #f1f1f1;
    /*min-width: 200px;*/
    white-space: nowrap;
    box-shadow: 0rem 0.5rem 1rem 0rem rgba(0,0,0,0.2);
    z-index: 15;
}


/* Download filter dropdown Content (Hidden by Default) */
.fdropdown-content {
    display: none;
    position: absolute;
    top: 1.2rem;
    overflow: auto;
    left: 0;
    background-color: #f1f1f1;
    /*min-width: 200px;*/
    white-space: nowrap;
    box-shadow: 0rem 0.5rem 1rem 0rem rgba(0,0,0,0.2);
    z-index: 15;
}

/* Links inside the dropdown */
.fdropdown-content a {
    color: black;
    padding: 0.15rem 0.5rem;
    text-decoration: none;
    display: block;
}

/* Links inside the dropdown */
.pdropdown-content a {
    color: black;
    padding: 0.15rem 0.5rem;
    text-decoration: none;
    display: block;
}

.dropdown-img {
    height: 1em;
    width: auto;
}

/* Links inside the dropdown */
.dropdown-content a {
    color: black;
    padding: 0.35rem 0.5rem;
    text-decoration: none;
    display: block;
}

/* Change color of dropdown links on hover */
.dropdown-content a:hover {background-color: #ddd;}

/* Change color of dropdown links on hover */
.pdropdown-content a:hover {background-color: #ddd;}

/* Change color of dropdown links on hover */
.fdropdown-content a:hover {background-color: #ddd;}

/* Show the dropdown menu (use JS to add this class to the .dropdown-content container when the user clicks on the dropdown button) */
.show {
    display:block;
}

#offline {
    position: fixed;
    box-sizing: border-box;
    display: block;
    background-color: yellow;
    top: 1.2rem;
    left: 1.2rem;
    z-index: 40;
}

#chatPopup {
    position: fixed;
    box-sizing: border-box;
    display: block;
    z-index: 40;
    top: 3rem;
    pointer-events: none;
    background: rgba(175, 166, 46, 0.5)
}

.canvas {
    cursor: pointer;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.board {
    box-sizing: border-box;
    position: absolute;
    display: block;
    top: 0px;
    left: 0px;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.games {
    box-sizing: border-box;
    position: absolute;
    z-index: 19;
    background-color: var(--secondary-bg);
    color: var(--text-primary);
    display: none;
    overflow: hidden;
    top: 0px;
    border-left: 1px solid #e0e0e0;
    flex-direction: column;
}

.games-scrollwrapper {
    display: inline;
    border-top: 1px solid #e0e0e0;
    overflow: hidden;
    flex-grow: 1;
}

.games-inner {
    display: block;
    width: 100%;
    height: 100%;
    overflow: auto;
    table, td, th {
        border-collapse: collapse;
        white-space: nowrap;
    }
    th {
        border-bottom: 1px solid #e0e0e0;
    }
}

.tallies {
    th:nth-child(4) {
        text-align: right;
        min-width: 2.5rem;
        padding-right: 0.5rem;
    }
    th:nth-child(5) {
        text-align: right;
        min-width: 2.5rem;
        padding-right: 0.5rem;
    }
    td:nth-child(4) {
        text-align: right;
        padding-right: 0.5rem;
    }
    td:nth-child(5) {
        text-align: right;
        padding-right: 0.5rem;
    }
}
.match-tallies {
    th {
        padding: 3px 5px;
    }
    td {
        padding: 0px 5px;
    }

    th:nth-child(4) {
        text-align: right;
        min-width: 2.5rem;
        padding-right: 0.5rem;
    }
    td:nth-child(4) {
        text-align: right;
        padding-right: 0.5rem;
    }
}
.game-log {
    width: 100%;
    td, th {
        border-left: 1px solid #e0e0e0;
        border-right: 1px solid #e0e0e0;
        border-collapse: collapse;
    }
    th:first-child {
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }
    th,td:first-child {
        border-left: none
    }
    th,td:last-child {
        border-right: none
    }
    td:nth-child(2) {
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }
    th:nth-child(2) {
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }
    td:nth-child(4) {
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }
}

.highlight {
    background: lightgray !important;
}

.selected {
    background: darkgrey !important;
}

.blunder {
    background-color: red;
}
.error {
    background-color: yellow;
}

.acting {
    color: red;
    border: red 2px solid;
}
.admit {
    background-color: rgb(86, 188, 86);
}
.reject {
    background-color: rgb(234, 57, 57);
}
.unmute {
    background-color: rgb(165, 234, 156);
}
.mute {
    background-color: rgb(220, 129, 11);
}

.sheet {
    box-sizing: border-box;
    position: absolute;
    z-index: 21;
    background-color: var(--secondary-bg);
    color: var(--text-primary);
    display: none;
    overflow: auto;
    top: 0px;
    left: 0px;
    border-bottom: 1px solid #e0e0e0;
}

.bottom-container {
    box-sizing: border-box;
    position: absolute;
    z-index: 19;
    background-color: var(--secondary-bg);
    color: var(--text-primary);
    display: none;
    left: 0px;
    border-right: 1px solid #e0e0e0;
    overflow: hidden;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

.chat {
    display: inline;
    flex-grow: 1;
    overflow: auto;
    border-top: 1px solid #e0e0e0;
}

.chat-input {
    display: flex;
    flex-direction: row;
}

.chat-input-field {
    flex: 1;
    min-width: 0;
}

.chat-input-field-control {
    width: 100%;
    box-sizing: border-box;
    font-size: 16px;
}

.chat-input-button {
    padding-left: 0.3rem;
    flex-shrink: 0;
}

.standings {
    box-sizing: border-box;
    border-top: 1px solid #e0e0e0;
    display: none;
    overflow: hidden;
    position: absolute;
    z-index: 20;
    background-color: var(--secondary-bg);
    table, td, th {
        white-space: nowrap;
    }
}

.move-table {
    width:100%;
    border-collapse: collapse;
    th:first-child,td:first-child {
        border-left: none;
    }
    th:last-child, td:last-child {
        border-left: none;
        border-right: none;
    }
    td:nth-child(3), th:nth-child(3) {
        border-right: none;
    }
    tr:nth-child(odd) {
        border-bottom: 1px solid black;
    }
    tr:last-child {
        border-bottom: none !important;
    }
    th, td {
        border-left: 1px solid black;
        border-right: 1px solid black;
        border-collapse: collapse;
    }
    th {
        border-bottom: 1px solid black;
    }     
}

.standings-table {
    border-collapse: collapse;
    height: 100%;
    th:nth-child(even), td:nth-child(even) {
        background: #f7ede6;
    }
    th:first-child,td:first-child {
        padding-left: 0.25rem;
        padding-right: 0.25rem;
        border-left: none;
    }
    th:last-child, td:last-child {
        padding-left: 0.25rem;
        padding-right: 0.25rem;
        border-right: none;
    }
    th, td {
        border-left: 1px solid black;
        border-right: 1px solid black;
        border-collapse: collapse;
    }
    th {
        border-bottom: 1px solid black;
    }  
    tr:last-child {
        vertical-align: top;
        height: 100%;
    }     
}

[data-theme="dark"] .standings-content {
    color: white;
}

[data-theme="dark"] .standings .game-tabcontent,
[data-theme="dark"] .standings .game-tabcontent-inner {
    color: white;
}

[data-theme="dark"] .standings-table {
    th, td {
        color: white;
    }
    th:nth-child(even), td:nth-child(even) {
        background: #3a3a3a;
    }
}

[data-theme="dark"] .dropbtn,
[data-theme="dark"] .pdropbtn,
[data-theme="dark"] .fdropbtn {
    color: white;
}

[data-theme="dark"] .expanddown {
    filter: invert(1);
}

[data-theme="dark"] .expandup {
    filter: invert(1);
}

[data-theme="dark"] .expandleft {
    filter: invert(1);
}

[data-theme="dark"] .expandright {
    filter: invert(1);
}

[data-theme="dark"] .standings-img-no-invert {
    filter: none;
}

[data-theme="dark"] .error {
    color: black;
}

[data-theme="dark"] .highlight {
    background: #555555 !important;
}

[data-theme="dark"] .selected {
    background: #777777 !important;
}

.standings-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

.game-tab {
    display: inline;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--secondary-bg);
}

/* Style the buttons that are used to open the tab content */
.game-tab button {
    display: inline;
    background-color: inherit;
    color: var(--text-primary);
    border-top: none;
    border-bottom: none;
    border-left: none;
    border-right: 1px solid var(--border-color);
    outline: none;
    cursor: pointer;
    padding: 0.35rem 1rem;
    transition: 0.3s;
}

/* Change background color of buttons on hover */
.game-tab button:hover {
    background-color: var(--board-border);
}

/* Create an active/current tablink class */
.game-tab button.active {
    background-color: var(--board-border);
}

/* Style the tab content */
.game-tabcontent {
    border-top: none;
    display: inline;
    flex-grow: 1;
    overflow: hidden;
}

.game-tabcontent-inner {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

.standings-scroll {
    display: block;
    overflow: auto;
    width: 100%;
    height: 100%;
}

.arrows {
    display: inline;
    width: 100%;
    background-color: var(--board-border);
    color: var(--board-text);
}

.moves {
    display: inline;
    overflow: auto;
    width: 100%;
    flex-grow: 1;
}

.cube-analysis {
    display: block;
    overflow: auto;
    width: 100%;
    height: 100%;
}

.standings-img {
    height: 1em;
    width: auto;
}

th {
    text-align: left;
}
  
/*
.table {
    display: inline;
}*/

.popup {
    display: none;
    z-index: 30;
    position: absolute;
    box-sizing: border-box;
    background-color: #EBEBEB;
    border: 1px solid black;
}

.cubedialog .popup-header {
    display: flex;
    height: 1.2rem;
    cursor: move;
    z-index: 10;
    background-color: #bfc0bf;
    border: 1px solid black;
}

.minimized {
    height: auto;
    overflow: visible;
}

.minimized .popup-content {
    display: none;
}

.popup-header-button {
    font-weight: bold;
    background: none;
    cursor: pointer;
    font-size: 0.5rem;
    height: 100%;
    aspect-ratio: 1 / 1;
    margin: 0rem;
    padding: 0rem;
}

.popup-content {
    padding: 0.3rem;
    background-color: #EBEBEB;
}

.button {
    z-index: 5;
    position: absolute;
    box-sizing: border-box;
    display: none;
    cursor: pointer;
    overflow: hidden;
    color: var(--text-primary);
}

.semi-transparent {
    opacity: 0.4;
}

/* Dialog styling to match React Modal components */
.dialog-body {
    padding: 20px 0;
}

.dialog-message {
    color: var(--text-primary);
    font-size: 14px;
    margin: 0;
}

.dialog-checkbox-item {
    margin-bottom: 12px;
}

.dialog-checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.dialog-checkbox-label input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.dialog-checkbox-label span {
    color: var(--text-primary);
}

.dialog-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    overflow-x: auto;
    flex-wrap: nowrap;
    flex-shrink: 0;
    min-width: min-content;
}

/* Game dialog buttons - inherit from main lobby button styles */
.popup .btn {
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    padding: 8px 16px;
    font-size: 14px;
    width: auto;
    margin: 0;
    flex-shrink: 0;
    white-space: nowrap;
}

/* Compact styling for game board buttons */
.button .btn {
    display: block;
    padding: 4px 10px;
    font-size: 13px;
}

.popup .btn-primary {
    background: linear-gradient(135deg, var(--primary-start) 0%, var(--primary-end) 100%);
    color: white;
}

.popup .btn-primary:hover:not(:disabled) {
    box-shadow: 0 5px 15px var(--shadow-hover);
}

.popup .btn-primary:disabled {
    background: var(--border-color);
    color: var(--text-light);
    cursor: not-allowed;
    opacity: 0.6;
}

.popup .btn-secondary {
    background: var(--secondary-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.popup .btn-secondary:hover:not(:disabled) {
    background: var(--border-color);
}

.popup .btn-secondary:disabled {
    background: #f5f5f5;
    color: #bbb;
    cursor: not-allowed;
    opacity: 0.5;
}

/* Modal dialog structure */
.popup-container {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: visible;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Compact dialog for confirmations */
.compact-dialog {
    max-width: 400px;
    width: auto;
    min-width: 300px;
}

.popup-header {
    background-color: var(--bg-white);
    padding: 16px 24px;
    padding-bottom: 12px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.popup-header h2 {
    margin: 0;
    font-size: 18px;
    color: var(--text-primary);
}

.popup-header-button {
    margin-left: auto;
    margin-right: 8px;
}

.popup-content {
    padding: 20px 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: visible;
    background: var(--bg-white);
}

/* Responsive height adjustments - progressively reduce whitespace */
@media (max-height: 700px) {
    .popup-header {
        padding: 12px 24px;
    }
    
    .popup-header h2 {
        font-size: 16px;
    }
    
    .popup-content {
        padding: 16px 24px;
    }
    
    .dialog-body {
        padding: 16px 0;
    }
    
    .dialog-checkbox-item {
        margin-bottom: 10px;
    }
    
    .dialog-footer {
        padding-top: 12px;
    }
    
    .popup .btn {
        padding: 6px 14px;
        font-size: 13px;
    }
}

@media (max-height: 600px) {
    .popup-header {
        padding: 10px 20px;
    }
    
    .popup-header h2 {
        font-size: 15px;
    }
    
    .popup-content {
        padding: 12px 20px;
    }
    
    .dialog-body {
        padding: 12px 0;
    }
    
    .dialog-checkbox-item {
        margin-bottom: 8px;
    }
    
    .dialog-footer {
        padding-top: 10px;
        gap: 8px;
    }
    
    .popup .btn {
        padding: 5px 12px;
        font-size: 13px;
    }
}

@media (max-height: 500px) {
    .popup-header {
        padding: 8px 16px;
    }
    
    .popup-header h2 {
        font-size: 14px;
    }
    
    .popup-content {
        padding: 8px 16px;
    }
    
    .dialog-body {
        padding: 8px 0;
    }
    
    .dialog-checkbox-item {
        margin-bottom: 6px;
    }
    
    .dialog-checkbox-label input[type="checkbox"] {
        margin-right: 6px;
    }
    
    .dialog-footer {
        padding-top: 8px;
        gap: 6px;
    }
    
    .popup .btn {
        padding: 4px 10px;
        font-size: 12px;
    }
}

@media (max-width: 500px) {
    .popup .btn {
        padding: 4px 8px;
        font-size: 12px;
    }
    
    .dialog-footer {
        gap: 6px;
    }
}

@media (max-height: 400px) {
    .popup-container {
        border-radius: 8px;
    }
    
    .popup-header {
        padding: 6px 12px;
    }
    
    .popup-header h2 {
        font-size: 13px;
    }
    
    .popup-content {
        padding: 6px 12px;
    }
    
    .dialog-body {
        padding: 4px 0;
    }
    
    .dialog-checkbox-item {
        margin-bottom: 4px;
    }
    
    .dialog-checkbox-label input[type="checkbox"] {
        margin-right: 4px;
    }
    
    .dialog-footer {
        padding-top: 6px;
        gap: 4px;
    }
    
    .popup .btn {
        padding: 3px 8px;
        font-size: 11px;
        border-radius: 4px;
    }
}
.board-notice {
    z-index: 4;
    position: absolute;
    box-sizing: border-box;
    display: none;
    overflow: hidden;
    color: var(--text-primary);
    pointer-events: none;
}

/* Fullscreen portrait: pad chat input away from rounded display corners at bottom.
   :fullscreen matches when the Fullscreen API is active (document.documentElement).
   :-webkit-full-screen is needed for Safari/iOS. */
@media (orientation: portrait) {
  :fullscreen .chat-input,
  :-webkit-full-screen .chat-input {
    padding-left: max(env(safe-area-inset-left, 40px), 40px);
    padding-right: max(env(safe-area-inset-right, 40px), 40px);
    padding-bottom: 4px;
  }
  :fullscreen .chat-input-field-control,
  :-webkit-full-screen .chat-input-field-control {
    font-size: 18px;
    padding: 8px;
  }
  :fullscreen .chat-input-button input,
  :-webkit-full-screen .chat-input-button input {
    font-size: 18px;
    padding: 8px 16px;
  }
}

/* Standalone PWA portrait: same treatment */
@media (display-mode: standalone) and (orientation: portrait) {
  .chat-input {
    padding-left: max(env(safe-area-inset-left, 40px), 40px);
    padding-right: max(env(safe-area-inset-right, 40px), 40px);
    padding-bottom: 4px;
  }
  .chat-input-field-control {
    font-size: 18px;
    padding: 8px;
  }
  .chat-input-button input {
    font-size: 18px;
    padding: 8px 16px;
  }
}

/* Mobile/touch devices: bigger chat input and send button for touch targets */
@media (pointer: coarse) {
  .chat-input-field-control {
    font-size: 18px;
    padding: 6px;
  }
  .chat-input-button input {
    font-size: 16px;
    padding: 6px 12px;
  }
}
