
:game {
    --a: #1d2731;
    --b: #235789;
    --c: #ffcb05;
    --d: #1d2731;
    --e: #f2f2f2;
}

:nomad {
    --a: #f4f1ea;
    --b: #c9b6a2;
    --c: #903b3b;
    --d: #39693c;
    --e: #293622;
}

:gamer {
    --a: #331f49ff;
    --b: #000000ff;
    --c: #ff962cff;
    --d: #ec6b00ff;
    --e: #ab0000ff;
}

:cold-evening {
    --a: #fbfae6ff;
    --b: #d9e0e7ff;
    --c: #a99b92ff;
    --d: #c2c0dbff;
    --e: #65585eff;
}

:branding-colours {
    --a: #f9f9f9ff;
    --b: #e5dae4ff;
    --c: #c8c5ccff;
    --d: #cad4d1ff;
    --e: #6d6876ff;
}

:dmakDent {
    --a: #f49b45ff;
    --b: #0d3c5cff;
    --c: #96939cff;
    --d: #d0ba9aff;
    --e: #a89a88ff;
}

:root {
    --gamer-a: #331f49ff;
    --gamer-b: #000000ff;
    --gamer-c: #ff962cff;
    --gamer-d: #ec6b00ff;
    --gamer-e: #ab0000ff;

    --domino-height: 120px;
    --domino-width: 60px;
    --domino-jugado-height: 60px;
    --domino-jugado-width: 30px;

    /* Bright Sky Blue theme - headers and active player */
    --player-name-color: #2E5CB8;
    --header-color: #2E5CB8;
    --player-name-border: #4A90E2;
    --player-name-canPlay-background: #4A90E2;

    /* Light blue backgrounds */
    --header-background: #E3F2FD;
    --player-name-background: #F0F8FF;
    --player-name-canPlay-color: #FFFFFF;
    --player-name-canPlay-border: #2196F3;

    /* Warm peach/cream for chat */
    --chat-background: #FFF8F0;
    --lobby-border: #FFE4CC;

    /* Chat text colors */
    --chat-color: #5D4E37;
    --chat-h1-color: #D2691E;
    --chat-border: #FFA07A;
    --chat-message-border: #FFB84D;

    /* Bright green for game status - lighter felt look */
    --juegoStatus-color: #E8F5E9;
    --fichasEnJuegoName-color: #FFFFFF;

    /* Lighter, brighter game table */
    --fichasEnJuego-background: #66BB6A;
    --fichasEnJuego-border: #4CAF50;

    --users-table-border: #BDBDBD;

    /* Bright selection colors */
    --domino-selected-border: #FF6F00;
    --domino-fichaGanadora-border: #FF9800;
}

html {
    height: 100%;
}

body {
    min-height: 100%;

    font-family: 'Jura', sans-serif;
    margin: 0;
    padding: 0;
}

h1 {
    font-family: 'Jura', sans-serif;
}

h2 {
    font-family: 'Jura', sans-serif;
}

h3 {
    font-family: 'Jura', sans-serif;
}

h4 {
    font-family: 'Jura', sans-serif;
}

.lobbyActions {
    display: flex;
}

.lobbyActions button {
    height: 7em;
    width: 10em;
}

.innerContent {
    position: absolute;
    height: 100%;
    width: 100%;
    display: grid;
    grid-template-columns: 4fr minmax(200px, 1fr);
    grid-template-rows: auto 1fr;
}

.header {
    grid-area: header;
    grid-column-start: 1;
    grid-column-end: span 2;
    grid-row-start: 1;
    grid-row-end: span 1;
    color: var(--header-color);
    background-color: var(--header-background);
    margin: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.header .headerMenu {
    grid-column-start: 1;
    text-align: left;
}

.header .user {
    grid-column-start: 2;
    align-self: center;
    justify-self: right;
    margin-right: 30px;
}

.ui.menu .ui.dropdown .menu > .item {
    background-color: var(--header-background);
    color: var(--header-color);
}

.menuBurger i.dropdown.icon {
    display: none;
}

.ui.text.menu .item {
    background-color: var(--header-background);
    color: var(--header-color);
}

.ui.menu .ui.dropdown .menu>.item {
    background-color: var(--header-background);
    color: var(--header-color);
}

.ui.menu .item {
    background-color: var(--header-background);
    color: var(--header-color);
}

.ui.menu {
    background-color: var(--header-background);
}

.chat h1 {
    color: var(--chat-h1-color);
}

.chat {
    color: var(--chat-color);
    background-color: var(--chat-background);
    border: 5px solid var(--chat-border);
    border-radius: 20px;
    grid-column-start: 2;
    grid-column-end: span 1;
    grid-row-start: 2;
    grid-row-end: span 1;
    margin: 4px;
    text-align: center;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(2em, auto) 1fr minmax(8em, auto);
}

.chat .title {
    grid-row-start: 1;
    grid-row-end: span 1;
    padding: 5px;
    margin: 5px;
}

.chat .messages {
    border: 1px solid var(--chat-message-border);
    grid-row-start: 2;
    grid-row-end: span 1;
    padding: 0;
    margin: 4px;
    overflow-y: scroll;
    max-height: calc(100vh - 250px);
}

.chat .sendMessage {
    grid-row-start: 3;
    grid-row-end: span 1;
    padding: 5px;
    margin: 5px;
}

.chat .sendMessage textArea {
    width: 100%;
    padding: 0;
    margin: 0;
}

.chat .receivedMessage {
    margin-bottom: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr auto;
    text-align: left;
    padding: 4px;
}

.chat .receivedMessage .sentBy {
    font-weight: bold;
    font-size: larger;
}

.chat .receivedMessage .sentAt {
    text-align: right;
}

.chat .receivedMessage .messageText {
    grid-column-end: span 2;
    font-size: smaller;
}

.lobby {
    grid-column-start: 1;
    grid-column-end: span 1;
    grid-row-start: 2;
    grid-row-end: span 1;
    padding: 5px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
}

.lobbyCol1 {
    border-right-color: var(--lobby-border);
    border-right-width: 2px;
    border-right-style: solid;
    grid-column-start: 1;
    grid-column-end: span 1;
    padding-right: 10px;
    padding-left: 10px;
}

.lobbyCol2 {
    grid-column-start: 2;
    grid-column-end: span 1;
    padding-right: 10px;
    padding-left: 10px;
}

.playersTable table {
    border: 1px solid var(--users-table-border);
}

.playersTable td {
    padding: 4px;
    border: 1px solid var(--users-table-border);
}

.ui.menu .item > i.icon {
    display: none;
}

.gameTable {
    display: grid;
    grid-template-columns: 2fr 2fr 2fr;
    grid-template-rows: minmax(calc(var(--domino-height) + 2em), auto) calc(var(--domino-width) * 7) minmax(calc(var(--domino-height) + 2em), auto);
}

.jugador0 {
    grid-column-start: 2;
    grid-column-end: span 2;
    grid-row-start: 3;
    grid-row-end: span 1;
    display: grid;
    grid-template-rows: calc(1em + 30px) minmax(2em, 3em) auto;
    grid-template-columns: minmax(calc(calc(var(--domino-width) + 4) * 7), 1fr) 1fr;
}

.jugador1 {
    grid-column-start: 3;
    grid-column-end: span 1;
    grid-row-start: 2;
    grid-row-end: span 1;

    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
}

.statusBar0 {
    grid-column-end: span 2;

    height: calc(1em + 30px);
    display: inline-block;
    width: 100%;
}


.playerName {
    color: var(--player-name-color);
    background-color: var(--player-name-background);
    border: 3px solid var(--player-name-border);
    border-radius: 10px;
    padding: 10px;
    display: inline-block;
}

.playerName.canPlay {
    color: var(--player-name-canPlay-color);
    background-color: var(--player-name-canPlay-background);
    border: 3px solid var(--player-name-canPlay-border);
    border-radius: 10px;
    padding: 10px;
}

.userStatus {
    font-style: italic;
    display: inline-block;
    margin: 1em;
}

.statusBar1 {
    width: calc(1em + 30px);
    height: 100%;
    display: inline-block;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    margin-right: 10px;
}

.jugadorActionBar {
    grid-column-end: span 2;
    margin: 5px;
}

.fichasEnJuego {
    grid-column-start: 2;
    grid-column-end: span 1;
    grid-row-start: 2;
    grid-row-end: span 1;

    display: grid;
    grid-template-rows: 2em auto auto;
    grid-template-columns: 1fr 1fr 1fr 1fr;

    margin: 10px;
    border: 10px solid var(--fichasEnJuego-border);
    border-radius: 20px;
    background-color: var(--fichasEnJuego-background);
    min-width: calc(var(--domino-width) * 6);
    min-height: calc(var(--domino-height) + 10em);

    align-self: center;
    justify-self: center;
}

.juegoStatus {
    grid-column-end: span 4;
    color: var(--juegoStatus-color);
    font-style: italic;
    display: grid;
    grid-template-columns: 1fr 4fr;
}

.triunfan {
    display: block;
    padding: 3px;
    text-align: center;
}

.juegoStatusString {
    padding: 3px;
    display: block;
    justify-self: center;
    align-self: center;
}

.fichasEnJuegoName {
    align-self: end;
    text-align: center;
    color: var(--fichasEnJuegoName-color);
    padding: 2px;
    grid-row-start: 2;
}

.dominoEnJuego {
    height: var(--domino-height);
    align-self: start;
    justify-self: center;
    padding: 4px;
    grid-row-start: 3;
}

/* Slide animations from each player position */
.slideFromPlayer0 {
    animation: slideFromBottom 800ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.slideFromPlayer1 {
    animation: slideFromRight 800ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.slideFromPlayer2 {
    animation: slideFromTop 800ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.slideFromPlayer3 {
    animation: slideFromLeft 800ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideFromBottom {
    0% {
        transform: translateY(250px) scale(0.7) rotate(5deg);
        opacity: 0;
    }
    70% {
        transform: translateY(-15px) scale(1.15) rotate(-2deg);
    }
    100% {
        transform: translateY(0) scale(1) rotate(0);
        opacity: 1;
    }
}

@keyframes slideFromTop {
    0% {
        transform: translateY(-250px) scale(0.7) rotate(-5deg);
        opacity: 0;
    }
    70% {
        transform: translateY(15px) scale(1.15) rotate(2deg);
    }
    100% {
        transform: translateY(0) scale(1) rotate(0);
        opacity: 1;
    }
}

@keyframes slideFromLeft {
    0% {
        transform: translateX(-250px) scale(0.7) rotate(-5deg);
        opacity: 0;
    }
    70% {
        transform: translateX(15px) scale(1.15) rotate(2deg);
    }
    100% {
        transform: translateX(0) scale(1) rotate(0);
        opacity: 1;
    }
}

@keyframes slideFromRight {
    0% {
        transform: translateX(250px) scale(0.7) rotate(5deg);
        opacity: 0;
    }
    70% {
        transform: translateX(-15px) scale(1.15) rotate(-2deg);
    }
    100% {
        transform: translateX(0) scale(1) rotate(0);
        opacity: 1;
    }
}

/* Animations for collecting tricks to winner's hand */
.collectToPlayer0 {
    animation: collectToBottom 1200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.collectToPlayer1 {
    animation: collectToRight 1200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.collectToPlayer2 {
    animation: collectToTop 1200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.collectToPlayer3 {
    animation: collectToLeft 1200ms cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes collectToBottom {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    50% {
        transform: translateY(30px) scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: translateY(200px) scale(0.6);
        opacity: 0;
    }
}

@keyframes collectToTop {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    50% {
        transform: translateY(-30px) scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: translateY(-200px) scale(0.6);
        opacity: 0;
    }
}

@keyframes collectToLeft {
    0% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
    50% {
        transform: translateX(-30px) scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: translateX(-200px) scale(0.6);
        opacity: 0;
    }
}

@keyframes collectToRight {
    0% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
    50% {
        transform: translateX(30px) scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: translateX(200px) scale(0.6);
        opacity: 0;
    }
}

.domino0Container {
    display: inline-grid;
    height: var(--domino-height);
    width: var(--domino-width);
    padding: 2px;
    grid-template-columns: auto;
    grid-template-rows: auto;
}

.domino0 {
    vertical-align: middle;
    text-align: center;
    height: var(--domino-height);
    width: var(--domino-width);
    padding: 3px;
    margin: 0;
    grid-row-start: 1;
    grid-column-start: 1;
}

.domino0Container .domino0FlipAction {
    grid-row-start: 1;
    grid-column-start: 1;
    padding: 0;
    margin: 0;
    opacity: 0;
    align-self: end;
    justify-self: center;
    cursor: pointer;
    z-index: 1;
}

.domino0Container:hover .domino0FlipAction {
    opacity: 1;
}

.domino0Container .domino0MoveRightAction {
    grid-row-start: 1;
    grid-column-start: 1;
    padding: 0;
    margin: 0;
    opacity: 0;
    align-self: end;
    justify-self: end;
    cursor: pointer;
    z-index: 1;
}

.domino0Container:hover .domino0MoveRightAction {
    opacity: 1;
}

.domino0Container .domino0MoveLeftAction {
    grid-row-start: 1;
    grid-column-start: 1;
    padding: 0;
    margin: 0;
    opacity: 0;
    align-self: end;
    justify-self: start;
    cursor: pointer;
    z-index: 1;
}

.domino0Container:hover .domino0MoveLeftAction {
    opacity: 1;
}

.domino0.selected {
    border: 3px solid var(--domino-selected-border);
    padding: 0;
    border-radius: 10px;
}

.domino0 img {
    height: var(--domino-height);
    width: var(--domino-width);
}

.dominoJugado0Container {
    display: inline-block;
    margin: 1px;
    height: var(--domino-jugado-height);
    width: var(--domino-jugado-width);
}

.dominoJugado0 {
    vertical-align: middle;
    text-align: center;
    height: var(--domino-jugado-height);
    width: var(--domino-jugado-width);
    padding: 1px;
}

.fichas0 {
    padding: 2px;
    display: inline-flex;
    grid-column-start: 1;
}

/* Animate tiles appearing in hand after dealing (only when just-dealt class is present) */
.fichas0.just-dealt .domino0Container {
    animation: dealToHand 300ms ease-out backwards;
}

.fichas0.just-dealt .domino0Container:nth-child(1) { animation-delay: 0ms; }
.fichas0.just-dealt .domino0Container:nth-child(2) { animation-delay: 50ms; }
.fichas0.just-dealt .domino0Container:nth-child(3) { animation-delay: 100ms; }
.fichas0.just-dealt .domino0Container:nth-child(4) { animation-delay: 150ms; }
.fichas0.just-dealt .domino0Container:nth-child(5) { animation-delay: 200ms; }
.fichas0.just-dealt .domino0Container:nth-child(6) { animation-delay: 250ms; }
.fichas0.just-dealt .domino0Container:nth-child(7) { animation-delay: 300ms; }

@keyframes dealToHand {
    from {
        transform: translateY(-50px) scale(0.5);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.filas0 {
    padding: 2px;
    grid-column-start: 2;

    display: inline-grid;
    grid-template-columns: 1fr 1fr;
}

.filaFichas0 {
    white-space: nowrap;
    padding: 1px;
}

.filaFichas0 .dominoJugado0Container:last-child {
    animation: trickCollect 500ms ease-in-out;
}

@keyframes trickCollect {
    0% {
        transform: scale(1.5) translateY(-20px);
        opacity: 0.5;
    }
    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.domino1Container {
    padding: 2px;
    height: var(--domino-width);
    width: var(--domino-height);
}

.domino1 {
    transform: translateX(var(--domino-height)) rotate(90deg);
    transform-origin: top left;
    vertical-align: middle;
    text-align: center;
    height: var(--domino-height);
    width: var(--domino-width);
    padding: 3px;
    margin: 0;
}

.dominoJugado1Container {
    padding: 2px;
    height: var(--domino-jugado-width);
    width: var(--domino-jugado-height);
}

.dominoJugado1 {
    transform: translateX(var(--domino-jugado-height)) rotate(90deg);
    transform-origin: top left;
    vertical-align: middle;
    text-align: center;
    height: var(--domino-jugado-height);
    width: var(--domino-jugado-width);
    padding: 1px;
}

.fichas1 {
    padding: 2px;
}

.fichas1.just-dealt .domino1Container {
    animation: dealToHand 300ms ease-out backwards;
}

.fichas1.just-dealt .domino1Container:nth-child(1) { animation-delay: 0ms; }
.fichas1.just-dealt .domino1Container:nth-child(2) { animation-delay: 50ms; }
.fichas1.just-dealt .domino1Container:nth-child(3) { animation-delay: 100ms; }
.fichas1.just-dealt .domino1Container:nth-child(4) { animation-delay: 150ms; }
.fichas1.just-dealt .domino1Container:nth-child(5) { animation-delay: 200ms; }
.fichas1.just-dealt .domino1Container:nth-child(6) { animation-delay: 250ms; }
.fichas1.just-dealt .domino1Container:nth-child(7) { animation-delay: 300ms; }

.filas1 {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
}

.filaFichas1 {
    padding: 5px;
    white-space: nowrap;
}

.filaFichas1 .dominoJugado1Container:last-child {
    animation: trickCollect 500ms ease-in-out;
}

.domino2Container {
    display: inline-block;
    height: var(--domino-height);
    width: var(--domino-width);
    padding: 2px;
}

.domino2 {
    vertical-align: middle;
    text-align: center;
    height: var(--domino-height);
    width: var(--domino-width);
    padding: 3px;
    margin: 0;
}

.domino2 img {
    height: var(--domino-height);
    width: var(--domino-width);
}

.dominoJugado2Container {
    display: inline-block;
    height: var(--domino-jugado-height);
    width: var(--domino-jugado-width);
}

.dominoJugado2 {
    vertical-align: middle;
    text-align: center;
    height: var(--domino-jugado-height);
    width: var(--domino-jugado-width);
    padding: 1px;
}

.jugador2 {
    grid-column-start: 1;
    grid-column-end: span 2;
    grid-row-start: 1;
    grid-row-end: span 1;
    display: grid;
    grid-template-rows: auto calc(1em + 30px);
    grid-template-columns: 1fr minmax(calc(calc(var(--domino-width) + 4) * 7), 1fr);
    margin-top: 10px;
}

.statusBar2 {
    grid-row-start: 2;
    grid-column-start: 1;
    grid-column-end: span 2;

    height: calc(1em + 30px);
    display: inline-flex;
    flex-flow: row-reverse;
    align-items: center;
    justify-content: end;
    width: 100%;
    margin-top: 10px;
}

.fichas2 {
    padding: 2px;
    display: inline-flex;
    grid-column-start: 2;
    grid-column-end: span 1;
    grid-row-start: 1;
    justify-self: end;
}

.fichas2.just-dealt .domino2Container {
    animation: dealToHand 300ms ease-out backwards;
}

.fichas2.just-dealt .domino2Container:nth-child(1) { animation-delay: 0ms; }
.fichas2.just-dealt .domino2Container:nth-child(2) { animation-delay: 50ms; }
.fichas2.just-dealt .domino2Container:nth-child(3) { animation-delay: 100ms; }
.fichas2.just-dealt .domino2Container:nth-child(4) { animation-delay: 150ms; }
.fichas2.just-dealt .domino2Container:nth-child(5) { animation-delay: 200ms; }
.fichas2.just-dealt .domino2Container:nth-child(6) { animation-delay: 250ms; }
.fichas2.just-dealt .domino2Container:nth-child(7) { animation-delay: 300ms; }

.filas2 {
    padding: 2px;
    grid-column-start: 1;
    grid-column-end: span 1;
    grid-row-start: 1;

    display: inline-grid;
    grid-template-columns: 1fr 1fr;
    justify-self: end;
}

.filaFichas2 {
    white-space: nowrap;
    padding: 1px 10px;
}

.filaFichas2 .dominoJugado2Container:last-child {
    animation: trickCollect 500ms ease-in-out;
}

.jugador3 {
    grid-column-start: 1;
    grid-column-end: span 1;
    grid-row-start: 2;
    grid-row-end: span 1;

    display: grid;
    grid-template-columns: auto auto calc(1em + 30px);
    grid-template-rows: auto;
}

.statusBar3 {
    grid-column-start: 3;
    grid-column-end: span 1;
    width: calc(1em + 30px);
    height: 100%;
    display: inline-block;
    writing-mode: vertical-rl;
    margin-left: 10px;
}

.domino3Container {
    padding: 2px;
    height: var(--domino-width);
    width: var(--domino-height);
}

.domino3 {
    transform: translateX(var(--domino-height)) rotate(90deg);
    transform-origin: top left;
    vertical-align: middle;
    text-align: center;
    height: var(--domino-height);
    width: var(--domino-width);
    padding: 3px;
    margin: 0;
}

.dominoJugado3Container {
    padding: 2px;
    height: var(--domino-jugado-width);
    width: var(--domino-jugado-height);
}

.fichaGanadora {
    border: 1px solid var(--domino-fichaGanadora-border);
}

.dominoJugado3 {
    transform: translateX(var(--domino-jugado-height)) rotate(90deg);
    transform-origin: top left;
    vertical-align: middle;
    text-align: center;
    height: var(--domino-jugado-height);
    width: var(--domino-jugado-width);
    padding: 1px;
}

.fichas3 {
    padding: 2px;
    grid-column-start: 2;
    grid-column-end: span 1;
    grid-row-start: 1;
    justify-self: end;
}

.fichas3.just-dealt .domino3Container {
    animation: dealToHand 300ms ease-out backwards;
}

.fichas3.just-dealt .domino3Container:nth-child(1) { animation-delay: 0ms; }
.fichas3.just-dealt .domino3Container:nth-child(2) { animation-delay: 50ms; }
.fichas3.just-dealt .domino3Container:nth-child(3) { animation-delay: 100ms; }
.fichas3.just-dealt .domino3Container:nth-child(4) { animation-delay: 150ms; }
.fichas3.just-dealt .domino3Container:nth-child(5) { animation-delay: 200ms; }
.fichas3.just-dealt .domino3Container:nth-child(6) { animation-delay: 250ms; }
.fichas3.just-dealt .domino3Container:nth-child(7) { animation-delay: 300ms; }

.filas3 {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    justify-self: end;
    grid-column-start: 1;
    grid-column-end: span 1;
    grid-row-start: 1;
}

.filaFichas3 {
    padding: 5px;
    white-space: nowrap;
}

.filaFichas3 .dominoJugado3Container:last-child {
    animation: trickCollect 500ms ease-in-out;
}

.hoyo {
    border-radius: 100px;
    border: 2px solid red;
    background: white;
    color: black;
    padding: 1px 5px;
    margin: 1px;
    display: inline-block;
}

.triunfoNum {
    display: inline-block;
    margin-left: 5px;
    vertical-align: middle;
}

.triunfoDropdown {
    padding-right: 20px;
}

.ui.dropdown.triunfoDropdown>.text {
    display: none;
}

tr.cuentasSelf {
    background-color: #f7cbbd;
}

b {
    color: brown;
}

/* ========================================
   Phase 1: Tile Movement Animations
   ======================================== */

/* Animation for tiles moving from hand to center when played */
@keyframes slideToCenter {
    from {
        transform: translate(0, 0);
        opacity: 1;
    }
    to {
        transform: translate(var(--target-x, 0), var(--target-y, 0));
        opacity: 0.3;
    }
}

/* Animation for collecting won tricks */
@keyframes collectTrick {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: translate(var(--winner-x, 0), var(--winner-y, 0)) scale(0.5);
        opacity: 0;
    }
}

/* Animation for dealing tiles at game start */
@keyframes dealCard {
    from {
        transform: translate(var(--dealer-x, 0), var(--dealer-y, 0)) scale(0);
        opacity: 0;
    }
    to {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
}

/* Classes to apply animations */
.domino-animating {
    animation: slideToCenter 400ms cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, opacity;
}

.trick-collecting {
    animation: collectTrick 500ms ease-in-out;
    will-change: transform, opacity;
}

.domino-dealing {
    animation: dealCard 300ms ease-out;
    animation-delay: calc(var(--card-index, 0) * 50ms);
    will-change: transform, opacity;
}

/* ========================================
   Phase 2: Bot Indicators
   ======================================== */

/* Bot thinking animation */
@keyframes botThinking {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.bot-thinking {
    animation: botThinking 1s ease-in-out infinite;
}

.bot-indicator {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(89, 34, 140, 0.9);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    z-index: 10;
}

.bot-badge {
    display: inline-block;
    margin-left: 5px;
    font-size: 0.9em;
}

.bot-rationale-icon {
    display: inline-block;
    margin-left: 5px;
    cursor: help;
    color: #59228C;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.bot-rationale-icon:hover {
    opacity: 1;
}

.playerName.bot-player {
    background-color: rgba(89, 34, 140, 0.8);
}

/* ========================================
   Phase 3: Celebration Animations
   ======================================== */

/* Score reveal animation */
@keyframes scoreReveal {
    0% {
        transform: scale(0) rotate(-10deg);
        opacity: 0;
    }
    60% {
        transform: scale(1.2) rotate(5deg);
    }
    100% {
        transform: scale(1) rotate(0);
        opacity: 1;
    }
}

.score-popup {
    animation: scoreReveal 600ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Confetti animation */
@keyframes confetti {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.confetti-piece {
    position: fixed;
    width: 10px;
    height: 10px;
    background: var(--confetti-color);
    animation: confetti 3s linear;
    animation-delay: calc(var(--piece-index, 0) * 50ms);
    pointer-events: none;
    z-index: 1000;
}

.celebration-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.celebration-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 500px;
}

.celebration-winner {
    font-size: 1.6em;
    font-weight: bold;
    color: #59228C;
    line-height: 1.6;
    margin-bottom: 20px;
}

.celebration-trophy {
    font-size: 4em;
    margin: 20px 0;
}

/* Red flash for hoyo */
@keyframes hoyoFlash {
    0%, 100% { background-color: transparent; }
    50% { background-color: rgba(255, 0, 0, 0.3); }
}

.hoyo-flash {
    animation: hoyoFlash 500ms ease-in-out;
}

/* ========================================
   Phase 4: Chat System Messages
   ======================================== */

.system-message {
    background: rgba(89, 34, 140, 0.1);
    border-left: 3px solid #59228C;
    padding: 8px 12px;
    margin: 8px 0;
    font-style: italic;
}

.special-event-message {
    background: rgba(255, 203, 5, 0.2);
    border-left: 3px solid #FFCB05;
    padding: 8px 12px;
    margin: 8px 0;
    font-weight: bold;
}

/* ========================================
   Phase 5: Micro-animations and Polish
   ======================================== */

/* Tile hover and selection improvements */
.domino0 {
    transition: transform 150ms ease, border-color 150ms ease;
}

.domino0:hover {
    transform: translateY(-10px);
    cursor: pointer;
}

.domino0.selected {
    transform: translateY(-15px) scale(1.05);
}

/* Button press feedback */
button {
    transition: transform 100ms ease, box-shadow 100ms ease;
}

button:active {
    transform: scale(0.95);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

/* Score change animations */
@keyframes scoreIncrement {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); color: #00AA00; }
}

@keyframes scoreDecrement {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); color: #CC0000; }
}

.score-changed-up {
    animation: scoreIncrement 400ms ease;
}

.score-changed-down {
    animation: scoreDecrement 400ms ease;
}

/* Active player turn glow */
@keyframes turnGlow {
    0%, 100% { box-shadow: 0 0 0 rgba(89, 34, 140, 0); }
    50% { box-shadow: 0 0 20px rgba(89, 34, 140, 0.8); }
}

.playerName.active-turn {
    animation: turnGlow 2s ease-in-out infinite;
}

/* Trump declaration flip animation */
@keyframes trumpReveal {
    0% {
        transform: scale(0) rotateY(180deg);
        opacity: 0;
    }
    100% {
        transform: scale(1) rotateY(0);
        opacity: 1;
    }
}

.triunfan img {
    animation: trumpReveal 500ms cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

/* Accessibility: Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    .domino-animating,
    .trick-collecting,
    .domino-dealing,
    .bot-thinking,
    .score-popup,
    .confetti-piece,
    .score-changed-up,
    .score-changed-down,
    .playerName.active-turn,
    .triunfan img,
    .dominoEnJuego,
    .domino0Container,
    .domino1Container,
    .domino2Container,
    .domino3Container,
    .dominoJugado0Container,
    .dominoJugado1Container,
    .dominoJugado2Container,
    .dominoJugado3Container {
        animation: none !important;
        transition: none;
    }

    .domino0:hover {
        transform: none;
    }

    button:active {
        transform: none;
    }
}

/* ========================================
   Mobile Responsiveness
   ======================================== */

/* Chat toggle button - hidden on desktop */
.chatToggle {
    display: none;
}

/* =========================================
   Tablet + Phone (max-width: 768px)
   ========================================= */
@media (max-width: 768px) {

    /* Show the chat toggle button */
    .chatToggle {
        display: inline-block;
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
    }

    .header {
        position: relative;
    }

    /* Switch from CSS grid to flex column so Sidebar.Pushable
       can fill remaining height and overlay correctly */
    .innerContent.mobile {
        display: flex;
        flex-direction: column;
    }

    /* Header takes its natural height */
    .innerContent.mobile > .header {
        flex: 0 0 auto;
    }

    /* Sidebar.Pushable fills all remaining height */
    .innerContent.mobile > .ui.pushable {
        flex: 1;
        min-height: 0;
        overflow: hidden;
        position: relative;
    }

    /* Sidebar.Pusher scrolls independently */
    .innerContent.mobile .ui.pusher {
        height: 100%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Chat in sidebar: fill sidebar height */
    .ui.sidebar .chat {
        border: none;
        border-radius: 0;
        height: 100%;
        margin: 0;
    }

    .ui.sidebar .chat .messages {
        max-height: calc(100vh - 150px);
    }

    /* Lobby: single column */
    .lobby {
        grid-template-columns: 1fr;
    }

    .lobbyCol1 {
        border-right: none;
        border-bottom: 2px solid var(--lobby-border);
        padding-bottom: 10px;
        margin-bottom: 10px;
    }

    .lobbyCol2 {
        grid-column-start: 1;
    }

    .lobbyActions button {
        height: 5em;
        width: 7em;
        font-size: 0.85em;
    }

    /* Scale dominos for tablet */
    :root {
        --domino-height: 80px;
        --domino-width: 40px;
        --domino-jugado-height: 40px;
        --domino-jugado-width: 20px;
    }

    /* === Game table: stack vertically === */
    .gameTable {
        display: flex;
        flex-direction: column;
        width: 100%;
        overflow-x: hidden;
    }

    /* Visual order: top-opponent, left, center, right, self */
    .jugador2     { order: 1; }
    .jugador3     { order: 2; }
    .fichasEnJuego { order: 3; }
    .jugador1     { order: 4; }
    .jugador0     { order: 5; }

    /* Jugador 2 (top/opponent): override internal grid to flex */
    .jugador2 {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    .jugador2 .fichas2 {
        justify-self: unset;
    }

    /* Jugador 3 (left → horizontal row) */
    .jugador3 {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        width: 100%;
    }

    .jugador3 .statusBar3 {
        writing-mode: horizontal-tb;
        transform: none;
        width: auto;
        height: auto;
        margin-left: 0;
        margin-right: 5px;
    }

    /* Remove rotation on jugador3 tiles */
    .domino3 {
        transform: none;
        height: var(--domino-height);
        width: var(--domino-width);
    }

    .domino3Container {
        height: var(--domino-height);
        width: var(--domino-width);
    }

    .dominoJugado3 {
        transform: none;
        height: var(--domino-jugado-height);
        width: var(--domino-jugado-width);
    }

    .dominoJugado3Container {
        height: var(--domino-jugado-height);
        width: var(--domino-jugado-width);
    }

    /* fichasEnJuego (center): full width, no overflow */
    .fichasEnJuego {
        width: auto;
        max-width: 100%;
        min-width: 0;
        min-height: auto;
        margin: 5px 0;
        align-self: unset;
        justify-self: unset;
    }

    /* Jugador 1 (right → horizontal row) */
    .jugador1 {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        width: 100%;
    }

    .jugador1 .statusBar1 {
        writing-mode: horizontal-tb;
        transform: none;
        width: auto;
        height: auto;
        margin-right: 5px;
    }

    /* Remove rotation on jugador1 tiles */
    .domino1 {
        transform: none;
        height: var(--domino-height);
        width: var(--domino-width);
    }

    .domino1Container {
        height: var(--domino-height);
        width: var(--domino-width);
    }

    .dominoJugado1 {
        transform: none;
        height: var(--domino-jugado-height);
        width: var(--domino-jugado-width);
    }

    .dominoJugado1Container {
        height: var(--domino-jugado-height);
        width: var(--domino-jugado-width);
    }

    /* Jugador 0 (self/bottom): flex column */
    .jugador0 {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    .statusBar0 {
        width: 100%;
    }

    /* Player 0 hand wraps */
    .fichas0 {
        flex-wrap: wrap;
    }

    /* Smaller action buttons */
    .jugadorActionBar button {
        font-size: 0.85em;
        padding: 5px 8px;
    }

    /* Smaller text */
    .playerName {
        padding: 5px;
        font-size: 0.85em;
    }

    .statusBar0, .statusBar1, .statusBar2, .statusBar3 {
        font-size: 0.85em;
    }

    .header .user {
        font-size: 0.85em;
        margin-right: 50px;
    }

    /* Disable hover-based tile lift on touch screens */
    .domino0:hover {
        transform: none;
    }

    .domino0.selected {
        transform: translateY(-8px) scale(1.05);
    }

    /* Celebration overlay responsive */
    .celebration-content {
        max-width: 90vw;
        padding: 20px;
    }

    .celebration-trophy {
        font-size: 2.5em;
    }

    .celebration-winner {
        font-size: 1.2em;
    }
}

/* =========================================
   Phone only (max-width: 480px)
   ========================================= */
@media (max-width: 480px) {
    :root {
        --domino-height: 65px;
        --domino-width: 33px;
        --domino-jugado-height: 33px;
        --domino-jugado-width: 17px;
    }

    .celebration-content {
        max-width: 95vw;
        padding: 15px;
    }
}
