* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    background: #0d1117;
    color: #c9d1d9;
    min-height: 100vh;
}

/* ── Login ── */

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.login-card h1 {
    font-size: 1.8rem;
    margin-bottom: 0.25rem;
}

.login-card .subtitle {
    color: #8b949e;
    margin-bottom: 1.5rem;
}

.error {
    background: #da363440;
    border: 1px solid #da3634;
    color: #f85149;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.user-select {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1.25rem;
}

.user-option {
    cursor: pointer;
}

.user-option input {
    display: none;
}

.user-option span {
    display: block;
    padding: 0.6rem 1.5rem;
    border-radius: 8px;
    border: 2px solid #30363d;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.15s;
}

.user-option input:checked + span {
    border-color: #58a6ff;
    background: #58a6ff20;
    color: #58a6ff;
}

.login-card input[type="password"] {
    width: 100%;
    padding: 0.7rem 1rem;
    border-radius: 8px;
    border: 1px solid #30363d;
    background: #0d1117;
    color: #c9d1d9;
    font-size: 1rem;
    margin-bottom: 1rem;
    outline: none;
}

.login-card input[type="password"]:focus {
    border-color: #58a6ff;
}

.login-card button {
    width: 100%;
    padding: 0.7rem;
    border: none;
    border-radius: 8px;
    background: #238636;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.login-card button:hover {
    background: #2ea043;
}

.setup-link {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: #8b949e;
}

.setup-link a {
    color: #58a6ff;
    text-decoration: none;
}

.setup-link a:hover {
    text-decoration: underline;
}

.setup-back {
    margin-top: 1.5rem;
    font-size: 0.85rem;
}

.setup-back a {
    color: #8b949e;
    text-decoration: none;
}

.setup-back a:hover {
    color: #c9d1d9;
}

/* ── Header ── */

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    border-bottom: 1px solid #21262d;
}

header h1 {
    font-size: 1.3rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
}

.logged-in-as {
    color: #8b949e;
}

.logout-btn {
    color: #8b949e;
    text-decoration: none;
    padding: 0.3rem 0.8rem;
    border: 1px solid #30363d;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: all 0.15s;
}

.logout-btn:hover {
    color: #c9d1d9;
    border-color: #8b949e;
}

/* ── Combined Grid Section ── */

.grid-section {
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-bottom: 1px solid #21262d;
}

.grid-legend {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: #8b949e;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.legend-box {
    width: 13px;
    height: 13px;
    border-radius: 2px;
    display: inline-block;
}

.legend-box.jon-entry {
    background: #55B080;
}

.legend-box.tora-entry {
    background: #A855F7;
}

.legend-box.both {
    background: linear-gradient(135deg, #55B080 50%, #A855F7 50%);
}



/* ── Contribution grid ── */

.contribution-grid {
    display: grid;
    grid-template-rows: repeat(7, 13px);
    grid-auto-flow: column;
    grid-auto-columns: 13px;
    gap: 3px;
}

.day {
    width: 13px;
    height: 13px;
    border-radius: 2px;
    background: #161b22;
    outline: 1px solid #1b1f2308;
    cursor: pointer;
    position: relative;
    transition: outline-color 0.1s;
}

.day:hover {
    outline-color: #58a6ff80;
}

.day.jon-entry {
    background: #55B080;
}

.day.tora-entry {
    background: #A855F7;
}

.day.both {
    background: linear-gradient(135deg, #55B080 50%, #A855F7 50%);
}

/* Speech bubble for stories — color coded per user */
.day.jon-story::before,
.day.tora-story::before {
    content: '';
    position: absolute;
    inset: 0;
    -webkit-mask-image: url('assets/something-else.svg');
    mask-image: url('assets/something-else.svg');
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
    z-index: 1;
    pointer-events: none;
}

.day.jon-story::before {
    background-color: #55B080;
}

.day.tora-story::before {
    background-color: #A855F7;
}

.day.jon-story.tora-story::before {
    background: linear-gradient(135deg, #55B080 50%, #A855F7 50%);
}

/* Tooltip */
.day:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1b1f23;
    border: 1px solid #30363d;
    color: #c9d1d9;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
}

/* ── Tracker layout (user panels) ── */

.tracker {
    display: flex;
    min-height: 200px;
}

.user-panel {
    flex: 1;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 50%;
}

.user-panel.jon {
    border-right: 1px solid #21262d;
}

.user-panel.jon h2 {
    color: #55B080;
}

.user-panel.tora h2 {
    color: #A855F7;
}

.user-panel.jon .log-btn,
.user-panel.jon .story-btn {
    background: #238636;
}

.user-panel.tora .log-btn,
.user-panel.tora .story-btn {
    background: #7C3AED;
}

.user-panel h2 {
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
}

.other-status {
    color: #484f58;
    font-style: italic;
    font-size: 0.9rem;
}

/* ── Log form ── */

.log-form {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.log-btn {
    padding: 0.65rem 1.3rem;
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
    margin-right: auto;
}

.log-btn:hover {
    filter: brightness(1.15);
}

.log-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.note-input {
    padding: 0.6rem 1rem;
    border-radius: 8px;
    border: 1px solid #30363d;
    background: #0d1117;
    color: #c9d1d9;
    font-size: 0.9rem;
    width: 220px;
    outline: none;
    margin-right: auto;
}

.note-input:focus {
    border-color: #58a6ff;
}

/* ── Story form ── */

.story-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    margin-top: 1rem;
    width: 100%;
    max-width: 402px;
}

.story-btn {
  padding: 0.65rem 1.3rem;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  margin-right: auto;
}

.story-btn:hover {
    filter: brightness(1.15);
}

.story-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.story-input {
    width: 100%;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    border: 1px solid #30363d;
    background: #0d1117;
    color: #c9d1d9;
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
    outline: none;
}

.story-input:focus {
    border-color: #58a6ff;
}

/* ── Modal ── */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: #000000aa;
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 2rem;
    min-width: 300px;
    max-width: 420px;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 1rem;
    background: none;
    border: none;
    color: #8b949e;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: #c9d1d9;
}

.modal h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.modal p {
    color: #8b949e;
    margin-bottom: 0.5rem;
    word-break: break-word;
}

.modal .modal-meta {
    font-size: 0.8rem;
    color: #484f58;
}

.modal .no-entry {
    color: #484f58;
    font-style: italic;
}

.modal-entry {
    padding: 0.75rem 0;
    border-bottom: 1px solid #21262d;
}

.modal-entry:last-child {
    border-bottom: none;
}

.delete-btn {
    margin-top: 0.5rem;
    padding: 0.3rem 0.8rem;
    border: 1px solid #da3634;
    border-radius: 6px;
    background: transparent;
    color: #f85149;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}

.delete-btn:hover {
    background: #da363420;
}

.form {
    border-bottom: 1px solid #30363d;
    padding-bottom: 1rem;
}

.delete-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Games section (Nonogram + Chess side by side) ── */

.games-section {
    display: flex;
    border-top: 1px solid #21262d;
    min-height: 420px;
}

.game-half {
    flex: 1;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-half h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: #c9d1d9;
}

.nonogram-half {
    border-right: 1px solid #21262d;
}

/* ── Chess ── */

#chess-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

#chess-board {
    width: 100%;
    max-width: 400px;
}

/* Scale chess pieces down to fit better on the board */
#chess-board img {
    transform: scale(0.81);
}
#chess-board img[src*="P.png"] {
    transform: scale(0.7);
}

/* Chess.com-style board colors */
#chess-board .white-1e1d7 {
    background-color: #ebecd0 !important;
    color: #739552 !important;
}
#chess-board .black-3c85d {
    background-color: #739552 !important;
    color: #ebecd0 !important;
}

#chess-status {
    font-size: 0.95rem;
    min-height: 1.5em;
    text-align: center;
}

.chess-turn {
    font-weight: 600;
}

.chess-turn.jon {
    color: #55B080;
}

.chess-turn.tora {
    color: #A855F7;
}

.chess-check {
    color: #f85149;
    font-weight: 600;
}

.chess-result {
    font-weight: 700;
    font-size: 1.05rem;
    color: #e3b341;
}

#chess-controls {
    display: flex;
    gap: 0.75rem;
}

.chess-btn {
    padding: 0.5rem 1.2rem;
    border: none;
    border-radius: 8px;
    background: #238636;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.chess-btn:hover {
    filter: brightness(1.15);
}

.chess-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chess-btn-danger {
    background: #6e2a2a;
}

.chess-btn-danger:hover {
    background: #8b3a3a;
}

#chess-info {
    font-size: 0.85rem;
    color: #8b949e;
    text-align: center;
}

.chess-players {
    font-weight: 600;
}

.nonogram-grid {
    border-collapse: collapse;
    user-select: none;
}

.nonogram-grid th,
.nonogram-grid td {
    text-align: center;
    font-size: 0.75rem;
    color: #8b949e;
}

.nono-corner {
    width: 30px;
}

.nono-col-hint {
    width: 28px;
    height: 20px;
    font-weight: 600;
}

.nono-row-hint {
    text-align: right !important;
    padding-right: 6px;
    white-space: nowrap;
    font-weight: 600;
}

.nono-cell {
    width: 28px;
    height: 28px;
    border: 1px solid #30363d;
    background: #161b22;
    cursor: pointer;
    transition: background 0.1s;
}

.nono-cell:hover {
    background: #21262d;
}

.nono-cell.filled-jon {
    background: #55B080;
}

.nono-cell.filled-tora {
    background: #A855F7;
}

.nono-cell.crossed {
    position: relative;
}

.nono-cell.crossed-jon::before {
    content: '✕';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #55B080;
    font-size: 0.85rem;
    pointer-events: none;
}

.nono-cell.crossed-tora::after {
    content: '✕';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #A855F7;
    font-size: 0.85rem;
    pointer-events: none;
}

.nono-hint-jon {
    color: #55B080;
    font-weight: 700;
}

.nono-hint-tora {
    color: #A855F7;
    font-weight: 700;
}

/* ── Responsive ── */

@media (max-width: 768px) {
    .tracker { 
        flex-direction: column;
    }   

    .user-panel.jon {
        border-right: none;
        border-bottom: 1px solid #21262d;
    }

    .user-panel {
        padding: 1.5rem 1rem;
        width: 100%;
    }

    header {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .grid-section {
        padding: 1rem;
    }

    .contribution-grid {
        grid-template-rows: repeat(7, 11px);
        grid-auto-columns: 11px;
        gap: 2px;
    }

    .day {
        width: 11px;
        height: 11px;
    }

    .games-section {
        flex-direction: column;
    }

    .nonogram-half {
        border-right: none;
        border-bottom: 1px solid #21262d;
    }

    .game-half {
        padding: 1.5rem 1rem;
    }
}
