body {
    font-family: 'Roboto', sans-serif;
    background-color: #2a2a2a;
    background-image: url('track_texture.png');
    background-repeat: repeat;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

#main-container {
    background-color: rgba(0, 20, 40, 0.8);
    padding: 30px 40px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 900px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.hidden {
    display: none !important;
}

/* --- Title --- */
.title-header {
    text-align: center;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.title-header h1 {
    font-family: 'Teko', sans-serif;
    font-size: 4em;
    margin: 0;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 69, 0, 0.7), 0 0 20px rgba(255, 69, 0, 0.5);
    letter-spacing: 2px;
}

.title-header .subtitle {
    font-size: 1.2em;
    color: #cccccc;
    margin: 0;
}

.title-graphic {
    width: 60px;
    height: 60px;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.5));
    display: none; /* Hidden as requested to not be in the setup box */
}

/* --- Setup Screen --- */
#setup-screen {
    display: grid;
    grid-template-columns: 55% 45%;
    gap: 30px;
    align-items: flex-start;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
}

.input-group.full-width {
    grid-column: 1 / -1;
}

.input-group label {
    margin-bottom: 8px;
    font-size: 0.9em;
    font-weight: 700;
    opacity: 0.9;
}

.input-group input, .input-group select {
    width: 100%;
    padding: 12px;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    color: #ffffff;
    font-size: 1em;
    box-sizing: border-box;
    transition: background-color 0.3s, border-color 0.3s;
}

.input-group input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.input-group input:focus, .input-group select:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 0.2);
    border-color: #ff4500;
}

.input-group select option {
    background-color: #003366;
    color: #ffffff;
}

/* --- Preview Panel --- */
.preview-panel {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    height: 100%;
}

.preview-panel h3 {
    margin-top: 0;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

#preview-content p {
    margin: 0 0 12px;
    font-size: 1.1em;
}
#preview-content span {
    font-weight: bold;
    color: #f0f8ff;
}

/* --- Start Button --- */
#start-simulation {
    width: auto;
    display: block;
    margin: 30px auto 0;
    padding: 15px 40px;
    background: linear-gradient(45deg, #ff4500, #ff6500);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 1.4em;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#start-simulation:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 20px rgba(255, 69, 0, 0.5);
}

/* --- Playstyle Screen --- */
#playstyle-selection-screen {
    width: 100%;
    max-width: 900px;
}

.main-container-playstyle {
    background-color: rgba(0, 20, 40, 0.8);
    padding: 30px 40px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    width: 100%;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.playstyle-title {
    font-family: 'Teko', sans-serif;
    font-size: 3em;
    margin: 0 0 20px 0;
    color: #fff;
    text-shadow: 0 0 10px rgba(0, 170, 255, 0.7);
}

.playstyle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    width: 100%;
    margin-bottom: 20px;
}

@media (min-width: 900px) {
    .playstyle-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.playstyle-card {
    background: rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 20px;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, background-color 0.2s;
}

.playstyle-card:hover {
    transform: translateY(-5px);
    border-color: rgba(0, 170, 255, 0.7);
}

.playstyle-card.selected {
    border-color: #00aaff;
    background-color: rgba(0, 170, 255, 0.1);
}

.playstyle-card h3 {
    margin-top: 0;
    color: #f0f8ff;
    font-size: 1.3em;
}

.playstyle-card p {
    margin-bottom: 0;
    font-size: 0.9em;
    color: #ccc;
    line-height: 1.5;
}

.playstyle-card p strong {
    color: #00aaff;
    font-weight: 700;
}

.playstyle-effect-notice {
    background-color: rgba(0, 170, 255, 0.1);
    border: 1px solid rgba(0, 170, 255, 0.4);
    color: #cceeff;
    padding: 10px 15px;
    border-radius: 8px;
    text-align: center;
    font-weight: normal;
    font-style: italic;
    margin-bottom: 20px;
}

#playstyle-warning {
    background-color: rgba(255, 165, 0, 0.1);
    border: 1px solid orange;
    color: orange;
    padding: 10px 15px;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
    margin-bottom: 20px;
}

#confirm-playstyle-button {
    width: auto;
    display: block;
    padding: 15px 40px;
    background: linear-gradient(45deg, #007bff, #00aaff);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 1.4em;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#confirm-playstyle-button:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 5px 20px rgba(0, 170, 255, 0.5);
}

#confirm-playstyle-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #555;
}

/* --- Driving Style Screen --- */
#drivingstyle-selection-screen {
    width: 100%;
    max-width: 900px;
}

.main-container-drivingstyle {
    background-color: rgba(0, 20, 40, 0.8);
    padding: 30px 40px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    width: 100%;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.drivingstyle-title {
    font-family: 'Teko', sans-serif;
    font-size: 3em;
    margin: 0 0 20px 0;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 69, 0, 0.7);
}

.drivingstyle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    width: 100%;
    margin-bottom: 20px;
}

@media (min-width: 900px) {
    .drivingstyle-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.drivingstyle-card {
    background: rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 20px;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, background-color 0.2s;
}

.drivingstyle-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 69, 0, 0.7);
}

.drivingstyle-card.selected {
    border-color: #ff4500;
    background-color: rgba(255, 69, 0, 0.1);
}

.drivingstyle-card h3 {
    margin-top: 0;
    color: #f0f8ff;
    font-size: 1.3em;
}

.drivingstyle-card p {
    margin-bottom: 0;
    font-size: 0.9em;
    color: #ccc;
    line-height: 1.5;
}

.drivingstyle-card p strong {
    color: #ff4500;
    font-weight: 700;
}

.drivingstyle-effect-notice {
    background-color: rgba(255, 69, 0, 0.1);
    border: 1px solid rgba(255, 69, 0, 0.4);
    color: #ffd4c4;
    padding: 10px 15px;
    border-radius: 8px;
    text-align: center;
    font-weight: normal;
    font-style: italic;
    margin-bottom: 20px;
}

#confirm-drivingstyle-button {
    width: auto;
    display: block;
    padding: 15px 40px;
    background: linear-gradient(45deg, #ff4500, #ff6500);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 1.4em;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#confirm-drivingstyle-button:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 5px 20px rgba(255, 69, 0, 0.5);
}

#confirm-drivingstyle-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #555;
}

/* --- Simulation Screen --- */
#setup-wrapper.hidden {
    display: none;
}

#simulation-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow: hidden; /* Keep the pseudo-element contained */
}

/* New pseudo-element for the blurred racetrack background */
#simulation-screen::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    background-image: url('racetrack_background.png');
    background-size: cover;
    background-position: center;
    filter: blur(4px) brightness(0.2);
    z-index: -1;
}

#simulation-content {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    max-height: 80vh; /* Set a max height for the content area */
    background-color: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    padding: 20px;
    min-height: 400px;
    position: relative; /* For positioning controls inside */
}

#simulation-header {
    width: 100%;
    max-width: 800px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px 10px 10px;
    box-sizing: border-box;
    position: absolute;
    top: calc(50% - 40vh - 54px); /* Position above content box */
    height: 54px; /* Explicit height */
    left: 50%;
    transform: translateX(-50%);
}

.header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

#sound-toggle {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

#sound-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

#simulation-screen h2 {
    text-align: center;
    font-size: 2em;
    margin-top: 0;
    margin-bottom: 0; /* Changed */
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
    flex-grow: 1; /* Allow it to take space */
    padding-left: 100px; /* Offset for controls */
    line-height: 54px; /* Vertically center with controls */
}

#simulation-output {
    background-color: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    min-height: 0;
    flex-grow: 1; /* Allow it to grow */
    overflow-y: auto;
    font-size: 1.1em;
    line-height: 1.6;
}

#simulation-output::-webkit-scrollbar {
  width: 10px;
}
#simulation-output::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 5px;
}
#simulation-output::-webkit-scrollbar-thumb {
  background-color: rgba(255, 69, 0, 0.7);
  border-radius: 5px;
}
#simulation-output::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 69, 0, 1);
}

#simulation-output p {
    margin: 0 0 10px 0;
    opacity: 0;
    animation: fadeIn 0.5s forwards;
    transition: opacity 1s ease-in-out;
}

#simulation-output.fade-out {
    opacity: 0;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

.typing-cursor {
  display: inline-block;
  width: 10px;
  height: 1.1em;
  background-color: white;
  animation: blink 1s step-end infinite;
  vertical-align: bottom;
}

@keyframes blink {
  from, to { background-color: transparent }
  50% { background-color: white; }
}

/* --- New Summary Styles --- */
#summary-output {
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    height: 100%;
}

.trophy-summary-title {
    font-family: 'Teko', sans-serif;
    font-size: 2.5em;
    font-weight: 700;
    text-align: center;
    color: #0099ff; /* Blue */
    margin-bottom: 25px;
    text-shadow: 0 0 10px rgba(0, 153, 255, 0.6);
}

.highlight-title {
    font-size: 1.4em;
    font-weight: 700;
    color: #fff;
    margin-top: 25px;
    margin-bottom: 10px;
}

.highlight-text {
    color: #00aaff;
    text-shadow: 0 0 8px rgba(0, 170, 255, 0.7);
    font-size: 1.2em;
    font-style: italic;
    max-width: 85%;
    line-height: 1.5;
    margin: 0;
}

.trophy-line {
    margin: 8px 0;
    font-size: 1.25em;
    text-align: center;
    animation: fadeIn 0.5s forwards;
    opacity: 0;
}

.trophy-name {
    color: #0099ff; /* Blue */
}

.trophy-count {
    color: #ffd700; /* Gold */
    font-weight: bold;
}

.ending-message {
    margin-top: 25px;
    font-style: italic;
    text-align: center;
    color: #ffffff;
    font-size: 1.3em;
    font-weight: bold;
    max-width: 90%;
}

.simulation-complete {
    color: #00ff00;
    font-weight: bold;
    font-size: 1.1em;
    margin: 0; /* Changed from margin-top: 30px */
    animation: fadeIn 2s forwards;
    opacity: 0;
}

.achievement { color: #ff4500; text-shadow: 0 0 8px rgba(255, 69, 0, 0.7); } /* Orange */
.crash { color: #ff4d4d; font-weight: bold; } /* Red */
.comeback { color: #50c878; font-weight: bold; } /* Green */
.championship { color: #ffd700; font-weight: bold; text-shadow: 0 0 8px rgba(255, 215, 0, 0.7); } /* Gold */
.team { font-weight: bold; }
.nickname { color: #ff4500; font-style: italic; } /* Orange */
.rival { color: #d881ff; }
.legend { color: #ffd700; font-style: italic; } /* Yellow */

#simulation-controls {
    margin-top: 20px;
    display: flex;
    flex-direction: column; /* Stack items vertically */
    gap: 15px;
    justify-content: center;
    align-items: center;
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
}

#timeline-toggle-button {
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
}

#timeline-toggle-button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

#restart-button {
    margin-top: 0;
    width: auto;
    padding: 12px 30px;
    align-self: center;
    background: linear-gradient(45deg, #ffd700, #ffc400);
    color: #002142;
    font-size: 1.1em;
    border-radius: 8px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    transition: transform 0.2s, box-shadow 0.2s;
}

#restart-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 215, 0, 0.4);
}