/* =============================================
   CSS Custom Properties
   ============================================= */
:root {
    --clr-bg:             #110e14;
    --clr-surface:        #1d1921;
    --clr-surface-header: #251f2b;
    --clr-border:         rgba(255, 255, 255, 0.08);
    --clr-red:            #C0344B;
    --clr-red-dark:       #731527;
    --clr-green:          #2B8603;
    --clr-green-dark:     #0A7D01;
    --clr-text:           #f0edf5;
    --clr-muted:          #9990a8;
    --font-body:          'Open Sans', sans-serif;
    --font-heading:       'Roboto Slab', serif;
    --radius:             8px;
}

/* =============================================
   Reset & Base
   ============================================= */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
html, body {
    height: 100%;
}
body {
    display: flex;
    flex-direction: column;
}
body {
    font-family: var(--font-body);
    font-size: 14px;
    background-color: var(--clr-bg);
    color: var(--clr-text);
    line-height: 1.6;
}
a {
    color: var(--clr-red);
    text-decoration: none;
}
a:hover {
    color: var(--clr-text);
}
ul {
    padding-left: 20px;
}
ul li {
    padding-bottom: 8px;
}
ul li:last-child {
    padding-bottom: 0;
}
img {
    max-width: 100%;
    display: block;
}
strong {
    font-weight: 700;
}
p {
    margin: 0;
}

/* =============================================
   Utilities
   ============================================= */
.text-center { text-align: center; }

/* =============================================
   Container
   ============================================= */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* =============================================
   Page wrap (sticky footer)
   ============================================= */
.page-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.page-wrap > .container {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* =============================================
   Navbar
   ============================================= */
.navbar {
    background: #0a0809;
    display: flex;
    align-items: center;
    padding: 0 20px;
    margin-bottom: 28px;
    border-bottom: 2px solid var(--clr-red);
}
.navbar-brand {
    display: block;
    padding: 16px 0;
}
.navbar-brand img {
    max-height: 44px;
    width: auto;
    max-width: 100%;
}

/* =============================================
   Game layout — 3-column CSS Grid
   (DOM order: game | found-words | rules)
   ============================================= */
.game-layout {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    grid-template-areas: "rules game found-words";
    gap: 20px;
    margin-top: auto;
    margin-bottom: auto;
}
#view-leaderboard {
    width: 100%;
    margin-top: auto;
    margin-bottom: auto;
}
.col-game        { grid-area: game;        display: flex; flex-direction: column; }
.col-found-words { grid-area: found-words; display: flex; flex-direction: column; }
.col-rules       { grid-area: rules;       display: flex; flex-direction: column; }
/* :first-child — skips the hidden #results-leaderboard in col-game */
.col-game > .standard-box:first-child,
.col-found-words > .standard-box,
.col-rules > .standard-box {
    flex: 1;
}
.col-game > .standard-box:first-child {
    display: flex;
    flex-direction: column;
}
.col-game > .standard-box:first-child > .standard-box-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* =============================================
   Card / Standard Box
   ============================================= */
.standard-box {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
    width: 100%;
}
.standard-box-header {
    font-family: var(--font-heading);
    background: var(--clr-surface-header);
    padding: 12px 20px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--clr-text);
    border-left: 3px solid var(--clr-red);
}
.standard-box-content {
    padding: 16px;
    position: relative;
    height: 100%;
}

/* =============================================
   Buttons
   ============================================= */
.btn {
    display: block;
    width: 100%;
    padding: 11px 20px;
    border: none;
    border-radius: 4px;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    cursor: pointer;
    transition: background 0.15s ease;
    text-align: center;
}
.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.btn--success {
    background: var(--clr-green);
    color: #fff;
}
.btn--success:hover:not(:disabled) {
    background: var(--clr-green-dark);
}
.btn--danger {
    background: var(--clr-red);
    color: #fff;
}
.btn--danger:hover:not(:disabled) {
    background: var(--clr-red-dark);
}

/* =============================================
   Forms
   ============================================= */
.form-field {
    position: relative;
    margin-bottom: 16px;
}
.form-control {
    display: block;
    width: 100%;
    padding: 9px 12px;
    background: #120f16;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    color: var(--clr-text);
    font-family: var(--font-body);
    font-size: 14px;
    appearance: none;
    -webkit-appearance: none;
}
.form-control:focus {
    outline: none;
    border-color: var(--clr-red);
    box-shadow: 0 0 0 2px rgba(210, 1, 7, 0.2);
}
select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239990a8'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 30px;
}
label.error {
    color: #ff7070;
    font-size: 12px;
    font-weight: 300;
    line-height: 1.3;
    margin: 5px 0 0;
    display: block;
}

/* =============================================
   Start-screen overlay
   ============================================= */
.btn-choice-container {
    position: absolute;
    top: 50%;
    left: 0;
    z-index: 11;
    width: 100%;
    padding: 0 20px;
    transform: translateY(-50%);
}
.btn-choice-container h2 {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 20px;
}
.btn-choice-container .form-field {
    margin-bottom: 0;
}
.btn-choice-container .form-control {
    width: 80%;
    margin: 0 auto;
}
#dict-select {
    margin-top: 10px;
}
.btn-choice-container .btn {
    width: 80%;
    margin: 0 auto;
}
#btn-play {
    margin-top: 20px;
}
#btn-leaderboard {
    margin-top: 8px;
}

/* =============================================
   Nick error
   ============================================= */
.nick-error {
    font-size: 12px;
    margin-top: 5px;
    color: #ff7070;
    width: 80%;
    margin-left: auto;
    margin-right: auto;
}

/* =============================================
   Game elements
   ============================================= */
.map {
    display: block;
    margin: 0 auto;
    width: 260px;
    min-height: 260px;
    cursor: pointer;
}
.map-results {
    margin: 40px auto 0 auto;
    opacity: 0.65;
}
.loader-bar {
    position: absolute;
    top: 50%;
    left: 30px;
    right: 30px;
    height: 3px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
    transform: translateY(-50%);
    z-index: 9;
}
.loader-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--clr-red) 50%,
        transparent 100%
    );
    transform: translateX(-100%);
    animation: loader-wave 1.6s ease-in-out infinite;
}
@keyframes loader-wave {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(200%); }
}
.loader-desc {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--clr-muted);
    position: absolute;
    top: calc(50% + 14px);
    left: 0;
    width: 100%;
}
.score,
.timer {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    position: absolute;
    top: 15px;
    z-index: 11;
    text-transform: uppercase;
    color: var(--clr-text);
}
.score { left: 15px; }
.timer { right: 15px; }
.current-word {
    position: absolute;
    top: 40px;
    width: 100%;
    text-align: center;
    left: 0;
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
    color: var(--clr-red);
    letter-spacing: 0.12em;
}

/* =============================================
   Results
   ============================================= */
.results {
    margin-top: 20px;
}
.results-first {
    max-width: 300px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}
.results h3 {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 600;
    text-transform: uppercase;
    margin: 60px 0 20px;
}
.results .percent-result {
    font-size: 44px;
    font-weight: 700;
    color: var(--clr-red);
    margin: 0 0 20px;
}
.all-words {
    padding: 0 16px;
    text-align: center;
}
.all-words h4 {
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--clr-muted);
    margin: 32px 0 16px;
}

/* =============================================
   Word tiles
   ============================================= */
.word {
    display: inline-block;
    padding: 4px 8px 3px;
    border-radius: 3px;
    background: var(--clr-red);
    border: 2px solid var(--clr-red);
    color: #fff;
    margin: 0 4px 4px 0;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.word.active {
    background: var(--clr-red-dark);
    border-color: var(--clr-red-dark);
}
.word.checking {
    border-color: rgba(255, 255, 255, 0.4);
}
.word.checking.active {
    border-color: rgba(255, 255, 255, 0.4);
}

/* =============================================
   Alerts (class names set dynamically by main.js)
   ============================================= */
.alert {
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    border-left: 3px solid transparent;
    margin-bottom: 10px;
}
.alert-danger {
    background: rgba(210, 1, 7, 0.15);
    border-color: var(--clr-red);
    color: #ff8080;
}
.alert-success {
    background: rgba(43, 134, 3, 0.15);
    border-color: var(--clr-green);
    color: #8cd97e;
}
.alert-info {
    background: rgba(100, 130, 200, 0.12);
    border-color: #6484c8;
    color: #aabce8;
}
#save-score-status {
    font-size: 13px;
    text-align: center;
    margin-bottom: 10px;
}

/* =============================================
   Leaderboard table
   ============================================= */
.leaderboard-loading {
    color: var(--clr-muted);
    padding: 16px 0;
}
.leaderboard-table {
    width: 100%;
    font-size: 13px;
    border-collapse: collapse;
    margin-bottom: 0;
}
.leaderboard-table th,
.leaderboard-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--clr-border);
}
.leaderboard-table thead th {
    background: var(--clr-surface-header);
    color: var(--clr-text);
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.leaderboard-table tbody tr:nth-child(odd) td {
    background: rgba(255, 255, 255, 0.02);
}
.leaderboard-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.05);
}
.leaderboard-table tbody tr:nth-child(1) td { background-color: #C98910; font-weight: bold; }
.leaderboard-table tbody tr:nth-child(2) td { background-color: #B0B0B0; font-weight: bold; }
.leaderboard-table tbody tr:nth-child(3) td { background-color: #965A38; font-weight: bold; }
.leaderboard-table tbody tr.lb-highlight td { background-color: #c0344b !important; }
.btn-back {
    margin-top: 12px;
}

/* =============================================
   Blockquote (score formula)
   ============================================= */
blockquote {
    background: rgba(210, 1, 7, 0.08);
    border-left: 3px solid var(--clr-red);
    padding: 10px 16px;
    border-radius: 0 4px 4px 0;
    font-size: 13px;
    color: var(--clr-muted);
    margin: 0;
}

/* =============================================
   Footer
   ============================================= */
.footer {
    background: #0a0809;
    color: var(--clr-muted);
    padding: 20px;
    text-align: center;
    font-size: 13px;
    border-top: 1px solid var(--clr-border);
}
.footer a {
    color: var(--clr-text);
}
.footer a:hover {
    color: var(--clr-red);
}
.recaptcha-disclaimer {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.25);
    margin-top: 4px;
}
.recaptcha-disclaimer a {
    color: rgba(255, 255, 255, 0.45);
    text-decoration: underline;
}

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 991px) {
    #results-leaderboard {
        margin-top: 20px;    
    }
    .game-layout {
        grid-template-columns: 1fr;
        grid-template-areas:
            "game"
            "found-words"
            "rules";
    }
    /* gap handles spacing — kill double margin from .standard-box */
    .col-game > .standard-box,
    .col-found-words > .standard-box,
    .col-rules > .standard-box {
        margin-bottom: 0;
    }
    .navbar {
        margin-bottom: 16px;
    }
    .map {
        margin: 80px auto 40px;
    }
    .map-results {
        margin: 40px auto 0;
    }
    .current-word {
        top: 44px;
    }
    /* push start screen below score/timer (top: 15px + ~22px height = ~37px) */
    .btn-choice-container {
        top: 52px;
        transform: none;
    }
    .btn-choice-container h2 {
        font-size: 17px;
        margin: 36px 0 12px 0;
    }
    #btn-play {
        margin-top: 14px;
    }
    .btn-choice-container .btn,
    .btn-choice-container .form-control {
        width: 100%;
    }
    .loader-desc {
        top: 58%;
    }
    .leaderboard-table th,
    .leaderboard-table td {
        padding: 6px 2px;
        font-size: 11px;
    }
    .leaderboard-table thead th {
        font-size: 10px;
        letter-spacing: 0;
    }
    /* fixed layout on mobile so bold medal rows / long nicks can't wrap or overflow */
    .leaderboard-table {
        table-layout: fixed;
    }
    .leaderboard-table th,
    .leaderboard-table td {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .leaderboard-table th:nth-child(1), .leaderboard-table td:nth-child(1) { width: 24px; }
    .leaderboard-table th:nth-child(3), .leaderboard-table td:nth-child(3) { width: 56px; }
    .leaderboard-table th:nth-child(4), .leaderboard-table td:nth-child(4) { width: 76px; }
    .leaderboard-table th:nth-child(5), .leaderboard-table td:nth-child(5) { width: 68px; }
}
@media (min-width: 1200px) {
    .standard-box {
        min-height: 528px;
    }
}