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

html, body {
    height: 100%;
    overflow: hidden;
    background: #111;
    font-family: 'Trebuchet MS', system-ui, sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

#game { display: block; }

#topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 7px 16px;
    background: linear-gradient(180deg, rgba(46, 32, 16, 0.96), rgba(24, 16, 8, 0.94));
    color: #f5e9d0;
    font-size: 15px;
    border-bottom: 1px solid #2a1c0c;
    box-shadow: 0 1px 0 rgba(212, 179, 90, 0.55), 0 3px 0 rgba(212, 179, 90, 0.18), 0 6px 14px rgba(0, 0, 0, 0.45);
}

.res {
    background: rgba(0, 0, 0, 0.32);
    border: 1px solid rgba(138, 106, 58, 0.55);
    border-radius: 8px;
    padding: 3px 11px;
    box-shadow: inset 0 1px 0 rgba(255, 235, 190, 0.08);
}

.res b { font-weight: 700; }

.res.age {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 9px;
    background: linear-gradient(180deg, rgba(64, 44, 18, 0.85), rgba(38, 26, 11, 0.85));
    border-color: rgba(212, 179, 90, 0.65);
}

#ageCoin {
    display: inline-block;
    width: 27px;
    height: 27px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #ffe9a8, #e3b455 55%, #9c7426);
    border: 1px solid #5b3a10;
    box-shadow: 0 0 0 1.5px rgba(212, 179, 90, 0.6), 0 2px 4px rgba(0, 0, 0, 0.5);
    color: #4a2f0c;
    font-family: Georgia, 'Times New Roman', serif;
    font-weight: 700;
    font-size: 13px;
    text-align: center;
    line-height: 27px;
}

.res b.overcap {
    color: #ff8a80;
    animation: overcapPuls 1.2s ease-in-out infinite;
}

@keyframes overcapPuls {
    50% { opacity: 0.55; }
}

#idleBtn {
    cursor: pointer;
    background: rgba(255, 202, 40, 0.12);
    border: 1px solid rgba(255, 202, 40, 0.4);
    border-radius: 6px;
    padding: 0 8px;
    margin-top: -2px;
}

#idleBtn:hover { background: rgba(255, 202, 40, 0.25); }

#message {
    position: fixed;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    color: #ffe082;
    text-shadow: 0 1px 3px #000;
    font-size: 17px;
    pointer-events: none;
    opacity: 0;
}

#panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    gap: 14px;
    padding: 10px 14px;
    background: linear-gradient(180deg, rgba(38, 26, 12, 0.95), rgba(20, 14, 8, 0.96));
    border-top: 1px solid #2a1c0c;
    box-shadow: 0 -1px 0 rgba(212, 179, 90, 0.55), 0 -3px 0 rgba(212, 179, 90, 0.18), 0 -6px 14px rgba(0, 0, 0, 0.45);
    color: #f5e9d0;
    min-height: 132px;
    align-items: flex-start;
}

#minimap {
    border: 2px solid #6b4f2a;
    border-radius: 4px;
    box-shadow: 0 0 0 1px #241a0e, 0 0 0 2.5px rgba(212, 179, 90, 0.45), 0 3px 8px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    flex: none;
    width: 110px;
    height: 110px;
}

#portrait {
    flex: none;
    width: 56px;
    height: 56px;
    border: 2px solid #6b4f2a;
    border-radius: 6px;
    box-shadow: 0 0 0 1px #241a0e, 0 0 0 2.5px rgba(212, 179, 90, 0.45), inset 0 0 10px rgba(0, 0, 0, 0.35);
}

#panelRight { flex: 1; }

#selInfo {
    font-size: 14px;
    margin-bottom: 8px;
    min-height: 18px;
}

#actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

#actions .hint {
    font-size: 13px;
    color: #cdb88f;
}

#actions button {
    background: linear-gradient(180deg, #46351d, #30220f);
    color: #f5e9d0;
    border: 1px solid #8a6a3a;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    box-shadow: inset 0 1px 0 rgba(255, 235, 190, 0.09), 0 1px 3px rgba(0, 0, 0, 0.35);
}

#actions button:hover {
    background: linear-gradient(180deg, #574222, #3d2c14);
    border-color: #b89455;
}

#actions button.disabled {
    opacity: 0.45;
}

#actions button.active {
    border-color: #d4b35a;
    box-shadow: 0 0 0 1px #d4b35a;
    background: #4d3a20;
}

#actions button small {
    display: block;
    color: #cdb88f;
    font-size: 11px;
}

#overlay, #endOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.hidden { display: none !important; }

.box {
    background: #241a0e;
    border: 2px solid #8a6a3a;
    border-radius: 10px;
    padding: 28px 32px;
    max-width: 580px;
    color: #f5e9d0;
}

.box h1 { margin-bottom: 14px; }

.box p, .box ul {
    margin-bottom: 12px;
    line-height: 1.5;
    font-size: 15px;
}

.box ul { padding-left: 20px; }

.box button {
    background: #7a5a2a;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 24px;
    font-size: 16px;
    cursor: pointer;
    font-family: inherit;
}

.box button:hover { background: #94703a; }

#endStats { margin-bottom: 16px; }

.statsLabel {
    font-size: 13px !important;
    color: #cdb88f;
    margin-bottom: 4px !important;
}

#statsCanvas {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 6px;
    margin-bottom: 10px;
    max-width: 100%;
}

#statsTable table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

#statsTable th, #statsTable td {
    text-align: right;
    padding: 3px 8px;
    border-bottom: 1px solid rgba(138, 106, 58, 0.35);
}

#statsTable th:first-child, #statsTable td:first-child { text-align: left; }

#statsTable th { color: #cdb88f; font-weight: 600; }

#diffRow, #sizeRow {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    align-items: center;
}

#seedInput {
    background: #1c130a;
    border: 1px solid #8a6a3a;
    border-radius: 6px;
    color: #f5e9d0;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    width: 190px;
}

#allyRow {
    display: block;
    margin-bottom: 16px;
    font-size: 14px;
    cursor: pointer;
}

#startRow {
    display: flex;
    gap: 10px;
}

#resumeBtn { background: #2d6a4f; }

#resumeBtn:hover { background: #40916c; }

#diffRow .diff, #sizeRow .diff {
    background: #3a2c18;
    border: 1px solid #8a6a3a;
    font-size: 14px;
    padding: 8px 16px;
}

#diffRow .diff.selected, #sizeRow .diff.selected {
    background: #7a5a2a;
    border-color: #d4b35a;
    box-shadow: 0 0 0 1px #d4b35a;
}
