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

body {
    font-family: 'Segoe UI', sans-serif;
    background: #1a5c2a;
    color: #fff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#app {
    width: 100%;
    max-width: 1100px;
    padding: 16px;
}

h1 {
    text-align: center;
    font-size: 1.6rem;
    margin-bottom: 12px;
    letter-spacing: 1px;
    text-shadow: 1px 2px 4px #000a;
}

/* --- Scores --- */
#scoreboard {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 14px;
}
.score-box {
    background: #ffffff22;
    border-radius: 8px;
    padding: 6px 14px;
    text-align: center;
    min-width: 90px;
}
.score-box.active-player {
    background: #ffe06688;
    color: #000;
    font-weight: bold;
}
.score-box .label { font-size: 0.75rem; opacity: 0.8; }
.score-box .pts   { font-size: 1.2rem; font-weight: bold; }

/* --- Status bar --- */
#status-bar {
    text-align: center;
    font-size: 0.95rem;
    margin-bottom: 10px;
    min-height: 24px;
    color: #ffe066;
    font-weight: bold;
}

/* --- Board (trains) --- */
#board {
    background: #14481f;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 14px;
}

.train-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}
.train-label {
    font-size: 0.78rem;
    width: 90px;
    flex-shrink: 0;
    opacity: 0.85;
}
.train-tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    flex: 1;
}
/* Train row state classes */
.train-row.has-marker {
    border-left: 3px solid #e74c3c;
    padding-left: 6px;
}
.train-row.has-marker .train-label {
    color: #ff7675;
}
.marker-badge {
    display: inline-block;
    background: #e74c3c;
    color: #fff;
    font-size: 0.65rem;
    font-weight: bold;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 6px;
    vertical-align: middle;
    letter-spacing: 0.05em;
}
.train-row.double-open {
    border-left: 3px solid #e67e22;
    padding-left: 6px;
}
.train-row.double-open .train-label {
    color: #fdcb6e;
}
.open-end {
    font-size: 0.75rem;
    background: #ffffff33;
    border-radius: 4px;
    padding: 2px 6px;
    margin-left: 4px;
    flex-shrink: 0;
}

/* --- Domino tiles --- */
.domino {
    display: inline-block;
    background: #f5f0e0;
    border-radius: 5px;
    border: 2px solid #bbb;
    cursor: default;
    user-select: none;
    line-height: 0;
    overflow: hidden;
    transition: transform 0.1s, box-shadow 0.1s;
    vertical-align: middle;
}
.domino svg { display: block; }
.domino.double { border-color: #c0392b; background: #ffeaea; }
.domino.engine { border-color: #2980b9; background: #eaf4ff; }

/* Arrows between chained tiles */
.chain-arrow {
    color: rgba(255,255,255,0.5);
    font-size: 1rem;
    align-self: center;
    flex-shrink: 0;
}

/* Gap between chain tiles and leftover tiles in hand */
.hand-gap {
    width: 3px;
    min-height: 38px;
    background: rgba(255,255,255,0.35);
    border-radius: 2px;
    margin: 0 8px;
    align-self: stretch;
    flex-shrink: 0;
}

/* Hand dominoes — playable / selected */
.domino.playable {
    border-color: #ffe066;
    border-width: 3px;
    background: #eafaf1;
    cursor: pointer;
    box-shadow: 0 0 6px #ffe06699;
}
.domino.playable:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 12px #ffe066cc;
}
.domino.selected {
    border-color: #e67e22;
    background: #fff3e0;
    box-shadow: 0 0 10px #e67e22cc;
    transform: translateY(-4px);
}

/* --- Hand area --- */
#hand-area {
    background: #14481f;
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 12px;
}
#hand-area h3 {
    font-size: 0.85rem;
    margin-bottom: 8px;
    opacity: 0.85;
}
#hand-tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

/* --- Train selection highlight --- */
.train-row.valid-target {
    background: #1e6b30;
    border-radius: 6px;
    outline: 2px solid #27ae60;
    cursor: pointer;
}
.train-row.valid-target .train-label { color: #ffe066; font-weight: bold; }

/* --- Controls --- */
#controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
button {
    padding: 8px 20px;
    border-radius: 8px;
    border: none;
    font-size: 0.95rem;
    cursor: pointer;
    font-weight: bold;
    transition: opacity 0.15s;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }
#btn-draw  { background: #e67e22; color: #fff; }
#btn-pass  { background: #7f8c8d; color: #fff; }
#btn-new   { background: #2980b9; color: #fff; }
button:not(:disabled):hover { opacity: 0.85; }

/* --- Info row --- */
#info-row {
    text-align: center;
    font-size: 0.8rem;
    opacity: 0.75;
    margin-bottom: 6px;
}

/* --- Modal overlay --- */
#modal {
    display: none;
    position: fixed;
    inset: 0;
    background: #000000aa;
    justify-content: center;
    align-items: center;
    z-index: 100;
}
#modal.show { display: flex; }
#modal-box {
    background: #1a5c2a;
    border-radius: 14px;
    padding: 30px 40px;
    text-align: center;
    max-width: 420px;
    border: 2px solid #ffe066;
}
#modal-box h2 { margin-bottom: 16px; }
#modal-box p  { margin-bottom: 18px; opacity: 0.85; }

/* --- Score table inside modal --- */
.score-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
}
.score-table th {
    font-size: 0.78rem;
    opacity: 0.7;
    padding: 4px 10px;
    text-align: left;
    border-bottom: 1px solid #ffffff33;
}
.score-table th:last-child,
.score-table td:last-child { text-align: right; }
.score-row td {
    padding: 7px 10px;
    font-size: 1rem;
    border-bottom: 1px solid #ffffff18;
}
.score-row.score-highlight td {
    color: #ffe066;
    font-weight: bold;
}
.score-note {
    font-size: 0.72rem;
    opacity: 0.55;
    margin-bottom: 18px;
}
