:root {
    /* ---- Luna 2.0 design tokens (warm & elegant) ---------------------- */
    --cream-bg:    #FAF7F2;
    --cream-light: #FFFDFB;
    --cream-dark:  #F5F0E8;

    --warm-red:    #E85D45;
    --warm-orange: #FF8C42;
    --warm-coral:  #FFA07A;
    --coral-soft:  #FBE9E1;

    --ink:         #2B2724;  /* primary text  */
    --ink-soft:    #6E655C;  /* secondary text */
    --line:        #EAE3D8; /* hairlines / borders */

    --font-main:    'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Caveat Brush', cursive;
    --font-mono:    Inconsolata, "Courier New", monospace;

    --rainbow-gradient: linear-gradient(
        90deg,
        #FF6B6B 0%, #FF8C42 20%, #FFC837 40%,
        #4ECDC4 60%, #5A67D8 80%, #9B5DE5 100%);

    --shadow-sm: 0 1px 2px rgba(40, 30, 20, 0.06);
    --shadow-md: 0 4px 10px rgba(40, 30, 20, 0.08);
    --shadow-lg: 0 12px 28px rgba(40, 30, 20, 0.10);

    --radius:    10px;

    /* ---- Neutral surface palette (warmed toward cream) ---------------- */
    --dark0: #2A2420;  /* darkest tile fill (last played) */
    --dark1: #3D3631;  /* hand-piece tile fill           */
    --dark2: var(--ink);
    --dark3: #6B5F57;  /* placed tile fill               */
    --dark4: #C7BCAE;  /* soft borders + tile strokes    */

    --light4: #D8CFC2;
    --light3: #E5DDD0;
    --light2: var(--cream-dark);
    --light1: var(--cream-bg);
    --light0: var(--cream-light);

    /* ---- Qwirkle piece colors (gameplay — left as-is) ---------------- */
    --yellow: #ff5;
    --orange: #fa5;
    --violet: #c7f;
    --blue: #5cf;
    --green: #5e5;
    --red: #f55;
    --dark-red: #922;
}

body {
    font-family: var(--font-main);
    font-size: 16px;
    color: var(--ink);
    margin: 0 auto;
    padding: 0 20px 24px;
    max-width: 1280px;
    background-color: var(--cream-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---- Luna-style brand header ---------------------------------------- */
div#app_header {
    padding: 18px 0 10px;
}
h1.luna-logo {
    font-family: var(--font-display);
    font-size: 2.6rem;
    font-weight: 400;
    line-height: 1;
    margin: 0;
    letter-spacing: 0.5px;
    background: var(--rainbow-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--warm-red); /* fallback */
}

div.information {
    font-size: 20px;
}

/* ---- The join screen, as a soft Luna card --------------------------- */
div#join {
    max-width: 440px;
    margin: 6vh auto 0;
    padding: 28px 32px;
    background-color: var(--cream-light);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
}
div#join p {
    margin: 0 0 14px;
}

input {
    font-family: var(--font-main);
    font-size: 16px;
    background-color: var(--cream-light);
    border: 1px solid var(--dark4);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-left: 10px;
    color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus {
    outline: none;
    border-color: var(--warm-coral);
    box-shadow: 0 0 0 3px var(--coral-soft);
}

/*  Shows an error if you connect to an invalid room */
div#err_div {
    color: var(--warm-red);
}
span#err_span {
    margin-left: 10px;
}

/*  Make the 'Room:' text unselectable to make copy-pasting easier */
.noselect {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/*  Welcome to... the chat zone */
div#chat_input_div {
    display:flex;
    flex-direction: row;
    margin-top: 10px;
}
input#chat_input {
    min-width: 0px;
    flex: 1;
}
div#chat_name {
    padding-top: 10px;
}
div#chat_msgs {
    height: 100px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background-color: var(--cream-light);
    box-shadow: var(--shadow-sm);
    padding: 10px;
}
div#chat_div {
    display: flex;
    flex-direction: column;
    overflow-x: auto;
}
#chat_msgs span {
    margin-left: 5px;
}
p.msg {
    margin-top: 2px;
    margin-bottom: 2px;
}

/*  Button to join the game */
button {
    color: var(--ink);
    background-color: var(--cream-light);
    border: 1px solid var(--dark4);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: border-radius 0.1s, background-color 0.15s, color 0.15s, box-shadow 0.15s;
}

form button {
    border-radius: var(--radius);
    transition: border-radius 0.1s, background-color 0.15s, box-shadow 0.15s;
    padding: 11px 22px;
    font-family: var(--font-main);
    font-weight: 500;
    font-size: 16px;
}

/*  Primary (enabled) join button gets the warm Luna accent */
form:not(:invalid) button {
    color: #fff;
    background-color: var(--warm-red);
    border-color: var(--warm-red);
    box-shadow: var(--shadow-md);
}

span#revhash {
    font-family: var(--font-mono);
}
span#room_name {
    margin-left: 10px;
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--warm-red);
}

form:invalid button {
    color: var(--ink-soft);
    background-color: var(--cream-dark);
    border-color: var(--dark4);
}

button.disabled {
    color: var(--ink-soft);
    background-color: var(--cream-dark);
    pointer-events: none;
}

/*  Only change button radius on hover for devices that support it
 *  (otherwise, they get hovered on click, which is weird) */
@media (hover: hover) {
    form:not(:invalid) button:hover {
        border-radius: 18px;
        background-color: #d94f38;
    }
    button.gameplay:hover {
        border-radius: 18px;
    }
}

/*  Main game div */
div#game {
    display: grid;
    column-gap: 20px;
}

/* List of players */
table#score_table {
    table-layout: fixed;
    width: 100%;
    border-collapse: collapse;
}
th {
    border-bottom: 1px solid var(--line);
    padding-bottom: 4px;
    font-weight: 600;
}
tr.player-row td {
    padding: 6px 4px;
}
tr.player-row i {
    visibility: hidden;
    color: var(--warm-red);
}
tr.player-row.active {
    color: var(--warm-red);
    font-weight: 600;
}
tr.player-row.active i {
    visibility: visible;
}
tr.disconnected {
    color: var(--ink-soft);
}

/*  Tiles on the board */
g.placed rect.tile {
    fill: var(--dark3);
    stroke-width: 0.5;
    stroke: var(--dark4);
}
/* Last played tile */
g.played rect.tile {
    fill: var(--dark0);
    stroke: var(--light4);
}
div#svg_div.nyt g.piece rect.tile {
    fill: var(--dark3);
}
g.piece rect.tile {
    fill: var(--dark1);
    stroke-width: 0.5;
    stroke: var(--dark4);
}
g.invalid rect.tile {
    fill: var(--dark-red);
    stroke: var(--red);
}
g.piece {
    pointer-events: auto;
}
rect.shadow {
    fill: var(--light1);
    stroke-width: 0.5;
    stroke: var(--light2);
}
rect#pan_rect {
    fill: none;
    pointer-events: all;
}
g.shape-orange .color {
    fill: var(--orange);
}
.shape-yellow .color {
    fill: var(--yellow);
}
g.shape-green .color {
    fill: var(--green);
}
g.shape-red .color {
    fill: var(--red);
}
g.shape-blue .color {
    fill: var(--blue);
}
g.shape-purple .color {
    fill: var(--violet);
}

.corner {
    visibility: hidden;
}
div.colorblind .corner {
    visibility: visible;
}

/*  Buttons to submit your play */
button.gameplay {
    color: var(--ink);
    position: absolute;
    height: 10%;
    width: 10%;
    font-size: 4vw;
}
button#accept_button:not(:disabled) {
    color: #2f9e5e;
}
button#reject_button:not(:disabled) {
    color: var(--warm-red);
}
button.gameplay:disabled {
    color: var(--ink-soft);
    background-color: var(--cream-dark);
    pointer-events: none;
}
button#reject_button {
    left: 100%;
    top: 100%;
    transform: translateY(-100%) translateX(-100%);
}
button#accept_button {
    left: 100%;
    top: 100%;
    transform: translateY(-100%) translateX(-210%);
}

div#exchange_div {
    position: absolute;
    border: 1px solid var(--dark4);
    border-radius: var(--radius);
    background-color: var(--cream-light);
    height: 10%;
    width: 27.5%;
    top: calc(100%);
    left: 0%;
    transform: translateY(-100%) translateX(178%);

    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
div#exchange_div.disabled {
    color: var(--ink-soft);
    background-color: var(--cream-dark);
}
div#svg_div.nyt div#exchange_div {
    color: var(--ink-soft);
    background-color: var(--cream-dark);
}

div#exchange_div p {
    text-align: center;
    margin: 0;
    position: relative;
    top: 50%;
    transform: translateY(-50%);
}
div#count_div {
    padding-top: 4px;
    padding-bottom: 20px;
}
div#count_div p {
    color: var(--ink-soft);
    text-align: center;
    border-top: 1px solid var(--line);
    margin: 0px;
    padding-top: 5px;
}

/*  This is only used for layout things */
svg#dummy {
    width: 100%;
    pointer-events: none;
}

/*  Main game board */
svg#game_svg {
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0px;
    top: 0px;
    pointer-events: none;
}

/*  Background divs to create nice sharp rectangles */
div.background {
    position: absolute;
    border: 1px solid var(--dark4);
    border-radius: var(--radius);
    background-color: var(--cream-light);
}
div#hand {
    left: 0px;
    top: calc(100%);
    transform: translateY(-100%);
    width: calc(47.5%);
    height: 10%;
}
div#board {
    left: 0px;
    top: 0px;
    width: calc(100%);
    height: calc(87.5%);
}

div#svg_div {
    margin-bottom: 10px;
    position: relative;
    touch-action: none;
}

/* Two-column layout */
@media only screen and (min-width: 750px) {
    div#game {
        grid-template-columns: 2fr 1fr;
    }
    div#chat_div {
        grid-column: 1 / span 2;
    }
    button.gameplay {
        font-size: 3vw;
    }
}

/* Three-column layout */
@media only screen and (min-width: 1200px) {
    div#svg_div {
        margin-bottom: 0px;
    }
    button.gameplay {
        font-size: 2vw;
    }
    div#game {
        grid-template-columns: 2fr 1fr 1fr;
    }
    div#chat_msgs {
        display:flex;
        flex-direction: column;
        flex: 1 0 auto;
    }
    div#chat_div {
        grid-column: 3;
    }
}

div#footer p {
    margin-bottom: 0;
    margin-top: 0.5em;
    color: var(--ink-soft);
}

div#footer a.padded {
    margin-right: 20px;
}

a {
    color: var(--ink-soft);
    transition: color 0.15s;
}
a:hover {
    color: var(--warm-red);
}

/******************************************************************************/

svg.example {
    width: 75%;
    height: 250px;
    border: 1px solid var(--dark4);
    border-radius: var(--radius);
    background-color: var(--cream-light);
}
