:root {
    --bg-color: #0f111a;
    --card-bg: #1a1d2d;
    --text-primary: #e0e6ed;
    --text-secondary: #94a3b8;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --border-radius: 8px;
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

#game-container {
    width: 100%;
    max-width: 600px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #334155;
    padding-bottom: 10px;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--accent-color);
}

h1 {
    font-size: 1.5rem;
    margin: 0;
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: normal;
    margin-left: 10px;
}

.turn-indicator {
    font-family: monospace;
    background: #334155;
    padding: 4px 8px;
    border-radius: 4px;
}

#resources {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.resource-item {
    background: var(--card-bg);
    padding: 10px;
    border-radius: var(--border-radius);
    text-align: center;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    position: relative; /* For tooltip */
    cursor: help;
}

.resource-item .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.resource-item .value {
    font-size: 1.25rem;
    font-weight: bold;
    font-family: monospace;
}

/* Tooltip Logic */
.tooltip {
    position: relative;
}

.tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    border: 1px solid #334155;
    pointer-events: none;
    max-width: 250px;
    white-space: normal;
    text-align: center;
    line-height: 1.4;
}

/* Specific tooltip position for buttons */
#actions .tooltip:hover::after {
    bottom: 110%;
    width: 200px;
}

.card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

#event-card {
    border-left: 4px solid var(--accent-color);
    margin-bottom: 20px;
    min-height: 220px;
    display: flex;
    flex-direction: column;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

#event-title {
    margin: 0;
    font-size: 1.2rem;
    flex: 1;
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    background: #334155;
    color: #94a3b8;
    font-weight: bold;
    letter-spacing: 0.5px;
}

#event-description {
    line-height: 1.6;
    margin-bottom: 20px;
    flex-grow: 1;
}

.hint-box {
    background: rgba(0, 0, 0, 0.2);
    padding: 12px;
    border-radius: 4px;
    border-left: 2px solid var(--warning-color);
    font-style: italic;
    color: var(--text-secondary);
    margin-top: auto;
}

.hint-label {
    font-weight: bold;
    color: var(--warning-color);
    margin-right: 5px;
    font-style: normal;
}

#log-panel {
    height: 150px;
    overflow-y: auto;
    font-size: 0.9rem;
    border: 1px solid #334155;
}

#log-panel h3 {
    margin-top: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-bottom: 1px solid #334155;
    padding-bottom: 8px;
    margin-bottom: 10px;
}

.log-entry {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.action-btn {
    padding: 15px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.action-btn:active {
    transform: scale(0.98);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(100%);
}

.primary {
    background-color: var(--accent-color);
    color: white;
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.2);
}

.primary:hover:not(:disabled) {
    background-color: var(--accent-hover);
    box-shadow: 0 6px 8px rgba(37, 99, 235, 0.3);
    transform: translateY(-1px);
}

.primary.large {
    font-size: 1.2rem;
    padding: 20px 40px;
    width: 100%;
    margin-top: 20px;
}

.secondary {
    background-color: #475569;
    color: white;
}

.secondary:hover:not(:disabled) {
    background-color: #334155;
}

/* Modal */
.hidden {
    display: none !important;
}

#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#modal-content {
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--border-radius);
    max-width: 500px;
    width: 90%;
    text-align: center;
    border: 1px solid var(--accent-color);
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.close-modal:hover {
    color: white;
}

#modal-title {
    color: var(--accent-color);
    margin-top: 0;
    font-size: 2rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.4s ease-out;
}

/* Start Screen */
#start-screen {
    width: 100%;
    max-width: 600px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.intro-card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    border: 1px solid #334155;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
}

.intro-text {
    line-height: 1.8;
    margin: 20px 0;
    color: var(--text-secondary);
    font-family: monospace;
    text-align: left;
    background: rgba(0,0,0,0.2);
    padding: 15px;
    border-radius: 4px;
}

.rules-box {
    text-align: left;
    margin: 30px 0;
}

.rules-box h3 {
    margin-top: 0;
    color: var(--accent-color);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
    margin-bottom: 20px;
    font-family: monospace;
}

.guide-item {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.guide-item .icon {
    font-size: 1.5rem;
    padding-top: 5px;
}

.guide-item strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 5px;
}

.guide-item p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.small-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 20px;
    font-style: italic;
    opacity: 0.7;
}

.input-group {
    margin: 20px 0;
    width: 100%;
}

#player-name-input {
    width: 100%;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #334155;
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 1.1rem;
    text-align: center;
    box-sizing: border-box;
    font-family: monospace;
}

#player-name-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Review Modal */
#review-modal {
    background: var(--card-bg);
    width: 95%;
    max-width: 700px;
    height: 85vh;
    border-radius: var(--border-radius);
    border: 1px solid #334155;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.review-header {
    padding: 15px 20px;
    background: rgba(0,0,0,0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #334155;
}

.review-header h2 {
    margin: 0;
    font-size: 1.2rem;
    font-family: monospace;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.icon-btn:hover {
    color: white;
}

#review-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.review-item {
    background: rgba(0,0,0,0.2);
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 4px;
    border-left: 2px solid #334155;
    transition: background 0.2s;
}

.review-item:hover {
    background: rgba(0,0,0,0.3);
}

.review-item h4 {
    margin: 0 0 10px 0;
    color: var(--accent-color);
    display: flex;
    justify-content: space-between;
    font-size: 1rem;
}

.review-item h4 small {
    color: var(--text-secondary);
    font-weight: normal;
    font-size: 0.8rem;
}

.review-item p {
    margin: 5px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.review-item .truth {
    color: #f59e0b;
    border-top: 1px dashed rgba(255,255,255,0.1);
    padding-top: 8px;
    margin-top: 8px;
    font-style: italic;
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
}

/* Ending Analysis Box */
.analysis-box {
    text-align: left;
    background: rgba(0,0,0,0.2);
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    border: 1px solid #334155;
}

.analysis-box h4 {
    margin-top: 0;
    color: var(--text-secondary);
    border-bottom: 1px solid #334155;
    padding-bottom: 10px;
}

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

.analysis-box li {
    margin-bottom: 8px;
    color: var(--text-primary);
    line-height: 1.5;
}

.final-score {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--success-color);
    margin-top: 20px;
    font-family: monospace;
}

.log-item {
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    line-height: 1.5;
}

.log-arrow {
    color: #64748b;
    margin: 0 5px;
    font-size: 0.8em;
}

.log-world-response {
    font-size: 0.85rem;
    color: #94a3b8;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px 8px;
    border-radius: 4px;
    margin-top: 4px;
    margin-bottom: 8px;
    border-left: 2px solid #334155;
}

.system-prefix {
    color: #3b82f6;
    font-weight: bold;
    margin-right: 5px;
}
