*, ::before, ::after {
    box-sizing: inherit;
    margin: 0;
    padding: 0;
}

.simuls {
    grid-area: main;
    max-width: 1000px;
    margin: auto;
    width: 100%;
}

/* Override main wrap constraint to allow full width for simul pages */
.simuls #main-wrap,
#pupusachess[data-view="simul"] #main-wrap {
    grid-template-columns: 0 1fr 1fr 1fr 0;
    --main-max-width: 100%;
}

/* For simul pages specifically */
div#main-wrap[data-view="simul"] {
    grid-template-columns: 0 1fr 1fr 1fr 0;
    --main-max-width: 100%;
}

a {
    white-space:unset;
}

.box-pad, .box:not(.box-pad) > h1 {
    padding: 5vh var(--box-padding);
}

.box {
    --box-padding: 15px;
}

@media (min-width: 320px) {
    .box {
        --box-padding: calc( 15px + 45 * ((100vw - 320px) / 880));
    }
}

@media (min-width: 1200px) {
    .box {
        --box-padding: 60px;
    }
}

.box-top {
    display: flex;
    flex-flow: row wrap;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 5vh;
}

h1 {
    font-size: 40px;
}

.actions {
    display: flex;
    flex-flow: row wrap;
}

a.button.icon-plus-square, a.button.calendar {
    color: #fff;
    background: var(--green-switch);
    box-shadow: 0 2px 5px 0 rgba(0,0,0,0.225);
    border-radius: 3px;
    padding: 0.8em 1em;
    border: none;
    text-align: center;
    white-space: nowrap;
    transition: all 150ms;
    margin-left: 4px;
}

.text::before {
    margin-right: 0.4em;
}

th {
    font: inherit;
    vertical-align: middle;
    text-align: inherit;
}

.slist {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    width: 100%;
    border-bottom: 1px solid #d9d9d9;
    margin-bottom: 3em;
    border-collapse: collapse;
}

.slist thead {
    background: var(--bg-color2);
}

.slist th:first-child {
    padding-left: 1.5rem;
}

.slist thead th {
    border-top: 1px solid #d9d9d9;
    border-bottom: 1px solid #d9d9d9;
    padding: 0.5rem 0.8rem;
}

.header a .name, .system, .starts {
    display: block;
}

.header a .name {
    font-size: 1.4em;
}

.by, td .icon {
    color: var(--gold);
}

td .icon {
    text-align: center;
    font-size: 3.5em;
}

.slist tbody tr:nth-child(2n) {
    background-color: var(--bg-color2)
}

.slist td {
    padding: 1rem;
    font: inherit;
}

.slist td:last-child {
    text-align: right;
}

td a {
    display: block;
    color: var(--font-color);
    padding: 1em;
}

td.header {
    padding: 0;
    transition: 150ms all;
}

td.header:hover {
    transform: translateX(3px);
}

.header .name, .header .system {
    letter-spacing: 2px;
}

.name {
    margin-top: 0.5em;
}

.starts {
    opacity: 0.9;
    font-size: 90%;
}

.system {
    margin: 0.5em 0;
}

/* New Simul Form styling */
.form3 {
    margin: 0 auto;
    max-width: 500px;
    background-color: var(--bg-color);
    padding: 2em;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.form3 .form-group {
    margin-bottom: 1em;
}

.form3 .form-label {
    display: block;
    font-weight: bold;
    margin-bottom: 0.5em;
}

.form3 .form-control {
    width: 100%;
    padding: 0.5em;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: var(--bg-color2);
    color: var(--font-color);
}

.form3 .form-split {
    display: flex;
    gap: 1em;
}

.form3 .form-half {
    flex: 1;
}

.form3 .form-actions {
    margin-top: 1.5em;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.form3 .form-actions a {
    margin-right: 1em;
    color: var(--link-color-blue);
    text-decoration: none;
}

.form3 .form-actions a:hover {
    text-decoration: underline;
}

.form3 .form-actions button {
    padding: 0.8em 1.5em;
    border: none;
    background-color: var(--green-switch);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
}

.form3 .form-actions button:hover {
    background-color: var(--green-hover);
}

/* Simul page styling (Lichess-inspired) */
.simul, .simul-new {
    grid-area: main;
}

.simul__app {
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(0, 1fr) minmax(250px, 320px);
    grid-template-areas:
        'main side'
        'main chat';
}

.simul__app__content {
    grid-area: main;
    display: flex;
    flex-flow: column;
    gap: 1rem;
}

.simul__app .chat {
    grid-area: chat;
    min-height: 18rem;
}

.simul__side {
    grid-area: side;
    display: flex;
    flex-flow: column;
    gap: 1rem;
}

.simul__title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.simul__title h1 {
    margin: 0;
    font-size: 2rem;
    line-height: 1.2;
}

.simul-status {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
}

.status-waiting {
    background: rgba(54, 146, 231, 0.2);
    color: var(--link-color-blue);
}

.status-started {
    background: rgba(98, 153, 36, 0.22);
    color: var(--green-hover);
}

.status-finished {
    background: rgba(213, 144, 32, 0.22);
    color: var(--gold);
}

.simul__meta {
    display: flex;
    flex-flow: row wrap;
}

.simul__meta > div {
    flex: 1 1 12rem;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 0.8rem 0.6rem;
    border-right: 1px solid var(--bg-color2);
}

.simul__meta > div:last-child {
    border-right: none;
}

.simul__meta__host,
.simul__meta__text {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--link-color);
    font-size: 0.82rem;
}

.simul__meta__status {
    color: var(--font-color);
    font-weight: 600;
}

.simul__meta__games {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--font-color);
}

.simul__section-title {
    margin: 0 0 0.85rem;
    font-size: 1.2rem;
}

.simul__waiting-note,
.simul__empty {
    color: var(--link-color);
}

.simul__side__host {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.2rem;
}

.simul__side__host__text {
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--green-switch);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.simul__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
}

.simul__actions .button {
    border: 1px solid var(--bg-color2);
    background: var(--bg-color2);
    color: var(--font-color);
    border-radius: 3px;
    padding: 0.45rem 0.8rem;
    cursor: pointer;
}

.simul__actions .button:hover {
    filter: brightness(1.08);
}

.simul__actions__start {
    background: var(--green-switch) !important;
    border-color: var(--green-switch) !important;
    color: #fff !important;
}

.simul__actions__join {
    background: var(--link-color-blue) !important;
    border-color: var(--link-color-blue) !important;
    color: #fff !important;
}

.simul__actions__note {
    color: var(--link-color);
    font-size: 0.95rem;
}

.simul__players-group h3 {
    margin: 0.75rem 0 0.35rem;
    font-size: 0.95rem;
    text-transform: uppercase;
    color: var(--link-color);
}

.simul__player {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--bg-color2);
}

.simul__player:last-child {
    border-bottom: none;
}

.simul__player__identity {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.simul__player__rating {
    color: var(--link-color);
    font-size: 0.9rem;
}

.simul__player__actions {
    display: flex;
    gap: 0.35rem;
}

.simul__player .button {
    padding: 0.3rem 0.55rem;
    border-radius: 3px;
    border: 1px solid var(--bg-color2);
    background: var(--bg-color2);
    color: var(--font-color);
    cursor: pointer;
}

.simul__player .btn-approve {
    background: rgba(98, 153, 36, 0.16);
    border-color: var(--green-switch);
    color: var(--green-hover);
}

.simul__player .btn-deny {
    background: rgba(192, 58, 65, 0.14);
    border-color: #b94e56;
    color: #b94e56;
}

.simul__games {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
    gap: 0.95rem;
}

.simul__games a {
    display: flex;
    flex-flow: column;
    color: var(--font-color);
    text-decoration: none;
    gap: 0.3rem;
}

.simul__games .mini-game {
    box-shadow: inset 0 0 0 1px var(--bg-color2);
    border-radius: 3px;
    overflow: hidden;
}

.simul__games a:hover .mini-game {
    box-shadow: inset 0 0 0 2px var(--link-color-blue);
}

.simul__games .mini-game.finished {
    opacity: 0.6;
}

.simul__games .mini-game .cg-wrap {
    width: 100%;
    aspect-ratio: 1 / 1;
}

.simul__games .host,
.simul__games .opp {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.simul__games .host {
    color: var(--link-color);
}

.simul__games .vstext {
    color: var(--link-color);
    font-size: 0.78rem;
    text-transform: uppercase;
}

.simul__games .result-wrap {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.simul__games .result-wrap .result {
    font-weight: 700;
}

.simul__games .result-wrap .status {
    color: var(--link-color);
    font-size: 0.78rem;
    text-transform: uppercase;
}

.simul__games.finished {
    grid-template-columns: 1fr;
    gap: 0.35rem;
}

.simul__games.finished a {
    display: flex;
    flex-flow: row;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-color2);
    border-radius: 3px;
    padding: 0.6rem 0.75rem;
}

.simul__games.finished .mini-game {
    display: none;
}

.simul__games.finished .game-header {
    display: flex;
    flex-flow: column;
    gap: 0.1rem;
}

.simul__games.finished .result-wrap {
    display: block;
    text-align: right;
}

@media (max-width: 1260px) {
    .simul__app {
        grid-template-columns: 1fr;
        grid-template-areas:
            'main'
            'side'
            'chat';
    }
}

@media (max-width: 799px) {
    .simul__title {
        align-items: flex-start;
        flex-flow: column;
    }

    .simul__title h1 {
        font-size: 1.6rem;
    }
}
