* {
    box-sizing: border-box;
}

:root {
    --bg: #0f172a;
    --card: rgba(30, 41, 59, 0.92);
    --border: rgba(255,255,255,0.08);
    --green: #22c55e;
    --orange: #f59e0b;
    --red: #ef4444;
    --text: #f8fafc;
    --muted: #cbd5e1;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, Arial, sans-serif;
    background:
        radial-gradient(circle at top left, #1e293b 0%, transparent 30%),
        radial-gradient(circle at bottom right, #14532d 0%, transparent 25%),
        linear-gradient(135deg, #020617, #0f172a);
    color: var(--text);
}

a {
    color: #22c55e;
    text-decoration: none;
    transition: color 0.2s ease, transform 0.2s ease;
}

a:hover {
    color: #4ade80;
}

.home-page {
    display: flex;
    justify-content: center;
    align-items: center;
}

.home-container {
    text-align: center;
    padding: 50px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 28px;
    backdrop-filter: blur(12px);
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.home-container h1 {
    font-size: 54px;
    margin-bottom: 10px;
}

.home-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 40px;
    flex-wrap: wrap;
}

.home-btn {
    text-decoration: none;
    color: white;
    padding: 18px 36px;
    border-radius: 18px;
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(135deg, #22c55e, #15803d);
    transition: all 0.2s ease;
    box-shadow: 0 10px 30px rgba(34,197,94,0.25);
}

.home-btn:hover {
    transform: translateY(-4px) scale(1.02);
}

.game-container {
    width: 96%;
    max-width: 1600px;
    margin: auto;
    padding: 30px 10px 60px;
}

.game-container h2 {
    text-align: center;
}

.page-title {
    text-align: center;
    font-size: 52px;
    margin-bottom: 30px;
}

.page-title a {
    color: white;
    text-decoration: none;
    transition: 0.2s;
}

.page-title a:hover {
    color: #4ade80;
}

.search-wrapper {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: auto;

    /* allow horizontal growth */
    display: inline-block;
}

#searchInput {
    width: 100%;
    padding: 20px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: rgba(15,23,42,0.95);
    color: white;
    font-size: 20px;
    outline: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

#searchResults {
    margin-top: 14px;
    border-radius: 22px;
    overflow: hidden;
    backdrop-filter: blur(16px);
}

#searchHeader {
    display: grid;
    grid-template-columns: 80px repeat(var(--field-count), minmax(140px, 1fr));
    
    gap: 8px;
    margin-top: 10px;
    padding: 10px;

    font-weight: 800;
    color: var(--muted);

    background: rgba(255,255,255,0.03);
    border-radius: 14px;

    align-items: center;

    overflow-x: auto;
}

#searchHeader { /* Hide normally */
    display: none;
}

#searchHeader div {
  text-align: center;
}

#searchHeader,
.result-item {
    width: 100%;
    box-sizing: border-box;
}

.result-item {
    display: grid;
    grid-template-columns: 80px repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    align-items: center;

    background: rgba(30,41,59,0.96);
    border: 1px solid rgba(255,255,255,0.05);
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 20px;
    cursor: pointer;
    transition: 0.15s ease;

    overflow-x: auto;
}

.result-item > * {
    flex-shrink: 0;
}

.result-item:hover {
    transform: scale(1.01);
    border-color: rgba(255,255,255,0.2);
}
.result-item.ambiguous-disabled {
    position: relative;

    filter: grayscale(100%);
    opacity: 0.55;

    cursor: not-allowed;
    pointer-events: none;

    overflow: hidden;
}

/* Red line */
.result-item.ambiguous-disabled::before {
    content: "";

    position: absolute;

    left: -10%;
    top: 50%;

    width: 120%;
    height: 6px;

    background: #ff2b2b;

    transform: rotate(-3deg);

    z-index: 5;
}

/* Ambiguous label */
.result-item.ambiguous-disabled::after {
    content: "AMBIGUOUS";

    position: absolute;

    top: 50%;
    left: 50%;

    transform: translate(-50%, -50%);

    background: rgba(0, 0, 0, 0.85);

    color: #ff4d4d;

    font-weight: 900;
    font-size: 1.2rem;
    letter-spacing: 2px;

    padding: 6px 14px;
    border-radius: 12px;

    border: 2px solid #ff2b2b;

    text-transform: uppercase;

    z-index: 10;

    pointer-events: none;
}

.result-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
}

.result-main img {
    width: 46px;
    height: 46px;
    object-fit: contain;
}

.preview-cell {
    background: rgba(255,255,255,0.05);
    border-radius: 14px;
    padding: 10px;
    height: 95%;

    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 14px;

    min-width: 120px;
}

.table-wrapper {
    overflow-x: auto;
    margin-top: 35px;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 10px;
    table-layout: fixed;
    min-width: 1200px;
}

th {
    padding: 14px;
    color: #e2e8f0;
}

td {
    min-width: 120px;
    padding: 18px 14px;
    text-align: center;
    border-radius: 18px;
    font-weight: 700;
}

.guess-cell {
    background: rgba(255,255,255,0.05);
}

.guess-image {
    width: 52px;
    height: 52px;
    object-fit: contain;
}

.correct {
    background: rgba(34,197,94,0.85);
}

.partial {
    background: rgba(245,158,11,0.85);
}

.wrong {
    background: rgba(239,68,68,0.85);
}

.arrow-up::after {
    content: ' ↑';
}

.arrow-down::after {
    content: ' ↓';
}

.finished {
    margin-top: 25px;
    text-align: center;
    font-size: 28px;
    font-weight: 800;
    color: #4ade80;
}

@media (max-width: 1000px) {
    .result-item {
        grid-template-columns: 1fr;
    }

    td, th {
        min-width: 100px;
        font-size: 12px;
    }

    .page-title {
        font-size: 34px;
    }
}