:root {
    --bg: #fdfdfd;
    --text: #1a1a1a;
    --accent: #4a7c59;
    --border: #e0e0e0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    display: flex;
    justify-content: center;
    padding: 2rem;
}

#game-container {
    max-width: 800px;
    width: 100%;
    padding: 2rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

#game-container:has(#farm-operations:not([hidden])) { max-width: 1140px; }
#farm-layout:has(#farm-operations:not([hidden])) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(250px, 310px);
    gap: 1.5rem;
    align-items: start;
}
#farm-workspace { grid-column: 1; grid-row: 1; min-width: 0; }
#farm-operations { grid-column: 2; grid-row: 1; }
.operation-card {
    padding: 1rem;
    margin-bottom: 1rem;
    background: #f6f8f3;
    border: 1px solid #cbd9cd;
    border-radius: 8px;
}
.operation-card > summary { cursor: pointer; color: #365641; font-weight: 700; }
.operation-card[open] > summary { margin-bottom: 0.75rem; }
.operation-card label { display: block; margin-bottom: 0.6rem; }
.operation-card input[type="number"] { width: 6em; }
@media (max-width: 820px) {
    #farm-layout:has(#farm-operations:not([hidden])) { display: block; }
    body { padding: 0.5rem; margin: 0; }
    #game-container { box-sizing: border-box; padding: 1rem; }
}

#start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    text-align: center;
    padding: 2rem;
}

.start-content {
    max-width: 400px;
}

.start-content h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--accent);
}

.start-action {
    margin-top: 2rem;
}

.primary-btn {
    background: var(--accent);
    color: white;
    font-size: 1.2rem;
    padding: 1rem 2rem;
}

.subtext {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: #666;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.5rem;
}

#stats-bar span {
    margin-left: 1.5rem;
    font-weight: bold;
}

main section {
    margin-bottom: 1rem;
}

#clock-anchor { height: 1px; }
#clock-bar {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg);
    padding: 0.55rem 0;
}
.clock-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }
.clock-row > span { font-weight: 700; color: #365641; }
#resume-season { flex-shrink: 0; min-height: 44px; background: var(--accent); color: white; }
#clock-bar.compact { border-bottom: 1px solid var(--border); }
#clock-bar.compact #season-track span { font-size: 0; padding: 0; }
#planning-bank-notice { margin: 0.5rem 0 0; font-size: 0.875rem; }
@media (max-width: 600px) {
    #clock-bar.compact #season-track { display: none; }
    #clock-bar.compact { font-size: 0.875rem; }
}
#season-track {
    position: relative;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    margin-top: 0.5rem;
    text-align: center;
    font-size: 0.85rem;
}

#season-track span {
    border-top: 7px solid #abc9d9;
    padding-top: 0.4rem;
}

#season-track span:nth-child(2) { border-color: #9dc589; }
#season-track span:nth-child(3) { border-color: #ebc461; }
#season-track span:nth-child(4) { border-color: #d18e68; }
#season-track .current { font-weight: bold; }
#season-track::after {
    content: '';
    position: absolute;
    top: -3px;
    left: clamp(0%, var(--position, 0%), calc(100% - 3px));
    height: 13px;
    width: 3px;
    background: var(--text);
}

#status-display {
    background: #f0f0f0;
    padding: 1rem;
    border-radius: 4px;
}
#status-display > p, #inventory-display p { margin: 0.35rem 0; }
.ranch-news summary { cursor: pointer; font-weight: 600; }
.ranch-news { margin-top: 0.5rem; }
#news-history { max-height: 12rem; overflow: auto; }
#inventory-display button { max-width: 100%; margin-bottom: 0.3rem; }

.ranch-news { border-top: 1px solid var(--border); padding-top: 0.75rem; }
.ranch-news p { margin: 0.4rem 0; }
.ranch-news li { margin: 0.5rem 0; }

.farm-main-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
}

#actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 250px;
}

#inventory-display {
    background: #f9f9f9;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    min-width: 150px;
}

.inventory-title {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    color: var(--accent);
}

button {
    padding: 0.75rem 1.5rem;
    border: 1px solid var(--accent);
    background: white;
    color: var(--accent);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

button:hover {
    background: var(--accent);
    color: white;
}

button:disabled {
    border-color: #ccc;
    color: #ccc;
    cursor: not-allowed;
}

#herd-details {
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.3rem 1rem;
}
#herd-details h2 { font-size: 1.1rem; }
#herd-details > * { margin: 0; }

h1 {
    margin: 0;
    font-size: 1.5rem;
}

#game-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}
#game-tabs button {
    border: 0;
    border-bottom: 3px solid transparent;
    border-radius: 4px 4px 0 0;
    padding: 0.65rem clamp(0.45rem, 2vw, 1.2rem);
    min-height: 44px;
}
#game-tabs button.active {
    border-bottom-color: var(--accent);
    background: #edf4ed;
    color: #274831;
}

#view-farm {
    display: block;
}

#view-facilities {
    display: none;
}
#research-projects { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 245px), 1fr)); gap: 0.75rem; }
#view-research section { padding: 1rem; border: 1px solid var(--border); border-radius: 8px; }
#view-research h3 { margin-top: 0; }
#view-research progress { accent-color: var(--accent); }

#view-market {
    display: none;
}

/* Herd Management Styles */
.herd-header {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}
#type-sale { display: flex; flex-wrap: wrap; gap: 0.5rem 0.8rem; align-items: center; min-width: 0; border: 1px solid var(--border); border-radius: 6px; }
#type-sale small { flex-basis: 100%; }

#selection-info {
    white-space: pre-line;
    font-style: italic;
    color: #666;
    margin-top: 0.5rem;
}

.herd-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.animal-card {
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.2s;
    background: white;
}

.animal-card:hover {
    color: inherit;
    background: white;
    border-color: var(--accent);
    transform: translateY(-2px);
}

.animal-card.selected {
    border: 2px solid var(--accent);
    box-shadow: 0 0 8px rgba(74, 124, 89, 0.3);
}

.animal-type {
    pointer-events: none;
    font-weight: bold;
    display: block;
    margin-bottom: 0.5rem;
}

.tag-details { width: 100%; padding: 0.25rem; border: 0; }
.tag-actions { display: grid; gap: 0.4rem; margin-top: 0.75rem; }
.tag-actions button { padding: 0.5rem 0.25rem; }

.animal-weight {
    display: block;
    margin-bottom: 0.5rem;
}

.animal-card progress {
    display: block;
    width: 100%;
    height: 12px;
    accent-color: var(--accent);
}

.pregnancy {
    margin-top: 0.6rem;
}

.pregnancy progress {
    accent-color: #86549b;
}

/* Responsive Adjustments */
@media (max-width: 600px) {
    .farm-main-layout {
        flex-direction: column;
    }
}
