:root {
  --background-color: #1a1a1d;
  --primary-text: #c5c6c7;
  --dm-bubble-bg: #2a2a2e;
  --user-bubble-bg: #0b3954;
  --accent-color: #ff9900;
  --border-color: #464646;
  --font-body: 'Lato', sans-serif;
  --font-title: 'MedievalSharp', cursive;
  --danger-color: #e53935;
  --danger-hover-color: #c62828;
  --sidebar-bg: #202023;
  --sidebar-width: 280px;
  --proficient-color: #4CAF50; /* Green for proficient */
  --not-proficient-color: #9E9E9E; /* Gray for non-proficient */
}

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

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-body);
  background-color: var(--background-color);
  color: var(--primary-text);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

.hidden {
  display: none !important;
}

/* Landing Page Styles */
#landing-page {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  height: 100%;
  width: 100%;
  max-width: 600px;
  position: relative;
}

#landing-page h1 {
  font-family: var(--font-title);
  font-size: 4rem;
  color: var(--accent-color);
  margin-bottom: 2rem;
  text-shadow: 0 0 15px rgba(255, 153, 0, 0.4);
}

.landing-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 300px;
  margin-bottom: 3rem;
}

#landing-page button {
  padding: 1rem 2rem;
  font-family: var(--font-title);
  font-size: 1.5rem;
  color: var(--background-color);
  background: linear-gradient(45deg, var(--accent-color), #ffbf60);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

#landing-page button:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(255, 153, 0, 0.5);
}

.landing-footer {
    position: absolute;
    bottom: 1rem;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    width: 100%;
}

#landing-page .credit {
  position: static;
  font-size: 0.8rem;
  color: #888;
}

.version-info {
  position: absolute;
  top: 1rem;
  left: 1rem;
  font-size: 0.8rem;
  color: #888;
  opacity: 0.7;
}

#legal-btn {
    position: static;
    background: rgba(0,0,0,0.5);
    border: 1px solid var(--border-color);
    color: var(--primary-text);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

#legal-btn:hover {
    background: var(--dm-bubble-bg);
    border-color: var(--accent-color);
}


/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-content {
  background-color: var(--dm-bubble-bg);
  padding: 2rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  max-width: 600px;
  width: 100%;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

.modal-close-btn {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 2rem;
    font-weight: bold;
    color: var(--accent-color);
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
}
.modal-close-btn:hover {
    color: #ffb84d;
}


.modal-content h2 {
  font-family: var(--font-title);
  color: var(--accent-color);
  margin-bottom: 1rem;
}

.modal-content p {
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.modal-content a {
    color: var(--accent-color);
    text-decoration: none;
}
.modal-content a:hover {
    text-decoration: underline;
}

.modal-settings {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  margin-bottom: 1.5rem;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
  flex-shrink: 0; /* Prevent buttons from shrinking */
}

.modal-content button {
  padding: 0.75rem 1.5rem;
  border: none;
  background-color: var(--accent-color);
  color: var(--background-color);
  font-size: 1rem;
  font-weight: bold;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.modal-content button:hover {
  background-color: #ffb84d;
}

.modal-content button.secondary {
    background-color: var(--dm-bubble-bg);
    color: var(--primary-text);
    border: 1px solid var(--border-color);
}
.modal-content button.secondary:hover:not(:disabled) {
    background-color: var(--border-color);
}

.modal-content button.secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#confirm-modal-yes-btn {
    background-color: var(--danger-color);
    color: white;
}
#confirm-modal-yes-btn:hover {
    background-color: var(--danger-hover-color);
}


/* Save Game Modal */
#save-slots-list {
    flex-grow: 1;
    overflow-y: auto;
    margin: 1.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-right: 1rem; /* for scrollbar */
    max-height: 50vh;
}

.save-slot-card {
    background-color: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    gap: 1rem;
}

.save-slot-card:hover {
    border-color: var(--accent-color);
}

.save-slot-info h4 {
    font-family: var(--font-title);
    color: var(--accent-color);
    margin: 0 0 0.25rem;
    font-size: 1.3rem;
}

.save-slot-info p {
    margin: 0;
    font-size: 0.9rem;
    color: #ccc;
    text-transform: capitalize;
}

.save-slot-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.save-slot-actions button {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.delete-btn {
    background-color: var(--danger-color);
    color: white;
}
.delete-btn:hover {
    background-color: var(--danger-hover-color);
}

#save-slots-list .no-saves {
    text-align: center;
    padding: 2rem;
    color: #aaa;
}

/* Character Creation & Settings Form Styles */
#settings-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  text-align: left;
  margin-top: 1.5rem;
}

#character-form {
  display: flex;
  flex-direction: column;
  flex-grow: 1; 
  text-align: left;
  margin-top: 1.5rem;
  overflow: hidden; 
}

.form-scroll-container {
    overflow-y: auto;
    flex-grow: 1;
    padding: 0.5rem 1rem 0.5rem 0.5rem; /* Space for scrollbar and breathing room */
    margin: 0 -1rem 0 -0.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border-color);
  padding-top: 1.25rem;
}

.form-scroll-container > *:first-child {
    border-top: none;
    padding-top: 0;
}


.form-group label {
  font-family: var(--font-title);
  color: var(--primary-text);
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.form-group .form-hint {
    font-size: 0.8rem;
    color: #aaa;
    margin-top: 0.5rem;
    margin-bottom: 0;
    line-height: 1.4;
}

#rag-status {
    background-color: rgba(0,0,0,0.2);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    margin-top: 0.5rem;
    font-style: italic;
    color: #ccc;
}

#character-form input[type="text"],
#character-form textarea,
#character-form select,
#settings-form input,
#settings-form select {
  width: 100%;
  padding: 0.75rem;
  background-color: var(--background-color);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--primary-text);
  font-size: 1rem;
  font-family: var(--font-body);
  transition: border-color 0.3s, box-shadow 0.3s;
}

#character-form input[type="text"]:focus,
#character-form textarea:focus,
#character-form select:focus,
#settings-form input:focus,
#settings-form select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(255, 153, 0, 0.3);
}

#character-form select,
#settings-form select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c5c6c7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1.2em;
}

#character-form select option,
#settings-form select option {
    background-color: var(--dm-bubble-bg);
    color: var(--primary-text);
}

#character-form select:invalid {
    color: #9E9E9E;
}

#character-form textarea {
  resize: vertical;
  min-height: 60px;
}

#settings-form button {
  margin-top: 0.5rem;
  align-self: center;
}

/* --- Point Buy Styles --- */
.point-buy-section {
    border-top: 1px solid #444;
    padding-top: 15px;
}

.point-buy-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.points-display {
    font-size: 1.1em;
    font-weight: bold;
    color: var(--accent-color);
}

.point-buy-grid {
    display: grid;
    grid-template-columns: 1fr; /* Stack on small screens */
    gap: 10px;
}

@media (min-width: 500px) {
    .point-buy-grid {
        grid-template-columns: 1fr 1fr;
    }
}


.stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    background-color: #2a2a2e;
    border-radius: 5px;
}

.stat-row label {
    font-weight: bold;
    flex-basis: 100px;
}

.stat-controls {
    display: flex;
    align-items: center;
}

.stat-score {
    font-size: 1.2em;
    font-weight: bold;
    width: 40px;
    text-align: center;
}

.stat-btn {
    width: 30px;
    height: 30px;
    border: 1px solid #555;
    background-color: #3e3e42;
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2em;
    line-height: 1;
}

.stat-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.stat-cost {
    width: 60px;
    text-align: right;
    color: #999;
}

/* Story Hooks Modal */
#story-hooks-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1.5rem 0;
  text-align: left;
}

.story-hook-card {
  background-color: rgba(0,0,0,0.2);
  border: 1px solid var(--border-color);
  padding: 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.3s, border-color 0.3s;
}

.story-hook-card:hover, .story-hook-card:focus {
  background-color: rgba(255, 153, 0, 0.1);
  border-color: var(--accent-color);
  outline: none;
}

.story-hook-card h4 {
  font-family: var(--font-title);
  color: var(--accent-color);
  margin-bottom: 0.5rem;
}

.story-hook-card p {
  font-size: 0.9rem;
  margin-bottom: 0;
}

#story-hooks-container .spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem;
}

.custom-hook-section {
  margin-top: 2rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
}

.custom-hook-section h3 {
  font-family: var(--font-title);
  margin-bottom: 1rem;
}

#custom-hook-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#custom-hook-form textarea {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--primary-text);
    font-size: 1rem;
    font-family: var(--font-body);
    resize: vertical;
}

#custom-hook-form textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(255, 153, 0, 0.3);
}

/* Legal Modal */
#legal-modal-content {
    overflow-y: auto;
    text-align: center;
}

#legal-modal .modal-content p {
    text-align: center;
    font-size: 0.9rem;
}

#legal-modal .legal-section {
    margin-bottom: 1.5rem;
}


/* Main App Layout */
#app {
  width: 100%;
  max-width: 1200px;
  height: 95vh;
  max-height: 900px;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  background-color: #202023;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-color);
}

#player-stats {
  background-color: var(--sidebar-bg);
  padding: 1.5rem;
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  color: var(--primary-text);
}

.stats-header {
  text-align: center;
  margin-bottom: 1.5rem;
  border-bottom: 1px dashed var(--border-color);
  padding-bottom: 1rem;
}

.stats-header h2 {
  font-family: var(--font-title);
  color: var(--accent-color);
  font-size: 1.8rem;
}

.stats-header p {
  font-size: 0.9rem;
  color: #aaa;
}

/* Existing stats-section for general stats */
.stats-section {
  margin-bottom: 1.5rem;
}

.stats-section > h3 {
  font-family: var(--font-title);
  color: var(--accent-color);
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.25rem;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.stat-item label {
  font-weight: bold;
}

#player-stats ul {
  list-style: none;
  padding-left: 0;
}

#player-stats li {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.9rem;
}

#player-stats li:nth-child(odd) {
  background-color: rgba(0,0,0,0.2);
}

#player-stats li strong {
  color: #ccc;
}

/* NEW TTRPG STATS STYLING & ACCORDION */
.accordion-section {
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}
.accordion-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.accordion-header {
    font-family: var(--font-title);
    color: var(--accent-color);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}
.accordion-header:hover {
    color: #ffb84d;
}

.accordion-header::after {
    content: '▸';
    transition: transform 0.3s ease;
}

.accordion-header.active::after {
    transform: rotate(90deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.accordion-content.expanded {
    max-height: 1500px; /* Adjust if content is larger */
    transition: max-height 0.5s ease-in;
    padding-bottom: 1rem;
}

#player-stats h4 { /* For sub-headers within an accordion */
    font-family: var(--font-title);
    color: var(--primary-text);
    font-size: 1.1rem;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px dotted var(--border-color);
    padding-bottom: 0.2rem;
}
#player-stats .accordion-content h4:first-child {
    margin-top: 0;
}

.accordion-content p {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    display: flex;
    justify-content: space-between;
}

.accordion-content p span {
    font-weight: bold;
    color: white;
}

#stats-ability-scores li {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0.5rem;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    margin-bottom: 0.2rem;
    font-size: 0.95rem;
}

#stats-skills li.proficient,
#stats-saving-throws li.proficient {
    color: var(--proficient-color);
    font-weight: bold;
}

#stats-skills li.not-proficient,
#stats-saving-throws li.not-proficient {
    color: var(--not-proficient-color);
}
/* END ACCORDION STYLING */


#main-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

header {
  padding: 1rem 1.5rem;
  background-color: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  flex-shrink: 0;
}

header .header-main {
  text-align: left;
  display: flex;
  align-items: center;
}

header h1 {
  font-family: var(--font-title);
  color: var(--accent-color);
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

header p {
  font-size: 0.9rem;
  color: var(--primary-text);
}

/* Settings Toggle Switch */
.settings {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.settings-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--primary-text);
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.settings-btn:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
  background-color: rgba(255, 153, 0, 0.1);
}

.settings-btn svg {
  width: 20px;
  height: 20px;
}

.toggle-label {
  font-size: 0.9rem;
  font-weight: bold;
}

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #464646;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
}

input:checked + .slider {
  background-color: var(--accent-color);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--accent-color);
}

input:checked + .slider:before {
  transform: translateX(22px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

#chat-container {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: relative;
}

#chat-log {
  flex-grow: 1;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.message {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  max-width: 80%;
  line-height: 1.5;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(20px);
  animation: a-fade-in 0.5s forwards;
}

@keyframes a-fade-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dm-message {
  background-color: var(--dm-bubble-bg);
  color: var(--primary-text);
  align-self: flex-start;
  border: 1px solid var(--border-color);
  border-top-left-radius: 0;
}

.user-message {
  background-color: var(--user-bubble-bg);
  color: white;
  align-self: flex-end;
  border-top-right-radius: 0;
}

.error-message {
    background-color: #5c1a1a;
    color: #ffc0c0;
    align-self: center;
    text-align: center;
    border: 1px solid #a82c2c;
}

.dice-roll-message {
  background-color: transparent;
  border: 1px dashed var(--accent-color);
  color: var(--primary-text);
  align-self: center;
  text-align: center;
  padding: 1rem;
  max-width: 70%;
  font-size: 0.9rem;
}

.dice-roll-message .dice-title {
  font-family: var(--font-title);
  color: var(--accent-color);
  font-size: 1.2rem;
  display: block;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.dice-roll-message .dice-result {
  font-size: 1.8rem;
  font-weight: bold;
  color: white;
}

.dice-roll-message .dice-breakdown {
  display: block;
  font-size: 0.8rem;
  color: #aaa;
  margin-top: 0.25rem;
}

.attack-roll-message {
    background-color: transparent;
    border: 1px solid var(--danger-color);
    color: var(--primary-text);
    align-self: center;
    text-align: center;
    padding: 1rem;
    max-width: 80%;
    font-size: 0.9rem;
    position: relative;
    border-radius: 12px;
}

.attack-roll-message .attack-title {
    font-family: var(--font-title);
    color: var(--danger-color);
    font-size: 1.2rem;
    display: block;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.attack-roll-message .attack-results {
    display: flex;
    justify-content: space-around;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.attack-roll-message .result-box {
    display: flex;
    flex-direction: column;
}

.attack-roll-message .result-label {
    font-size: 0.8rem;
    color: #aaa;
    text-transform: uppercase;
}

.attack-roll-message .result-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: white;
}

.attack-roll-message .result-breakdown {
    display: block;
    font-size: 0.8rem;
    color: #aaa;
    margin-top: 0.25rem;
}

.attack-roll-message .critical-hit {
    font-family: var(--font-title);
    color: var(--accent-color);
    font-weight: bold;
    font-size: 1.1rem;
    margin-top: 0.5rem;
    animation: a-pulse 1.5s infinite;
}

/* Event Notification Message */
.event-message {
  align-self: center;
  text-align: center;
  padding: 0.75rem 1.5rem;
  border-radius: 25px;
  background-color: var(--dm-bubble-bg);
  border: 1px solid var(--accent-color);
  color: var(--accent-color);
  font-family: var(--font-title);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 0 15px rgba(255, 153, 0, 0.2);
  font-size: 1.1rem;
}

.event-icon {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.event-message.item {
  color: #81c784; /* A soft green */
  border-color: #81c784;
  box-shadow: 0 0 15px rgba(129, 199, 132, 0.2);
}

.event-message.xp {
  color: #64b5f6; /* A soft blue */
  border-color: #64b5f6;
  box-shadow: 0 0 15px rgba(100, 181, 246, 0.2);
}

/* --- Action Choice Button Styles --- */
/* This container is used for the new multi-choice buttons */
.roll-request-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 10px 20px;
    padding: 15px;
    border: 1px dashed var(--accent-color);
    border-radius: 8px;
    background-color: #2a2a2e;
    align-self: center;
    width: 100%;
    max-width: 500px;
}

.roll-choice-title {
  text-align: center;
  font-family: var(--font-title);
  color: var(--primary-text);
  margin-bottom: 0.25rem;
  font-size: 1rem;
}

.roll-request-btn {
  width: 100%;
  padding: 0.8rem;
  font-family: var(--font-title);
  font-size: 1.2rem;
  line-height: 1.4;
  text-align: center;
  color: var(--background-color);
  background: linear-gradient(45deg, var(--accent-color), #ffbf60);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.roll-request-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 153, 0, 0.4);
}

/* The individual choice buttons */
.action-choice-btn {
    width: 100%;
    padding: 12px;
    background-color: #3e3e42;
    border: 1px solid #555;
    color: #eee;
    font-family: var(--font-body);
    font-size: 1em;
    font-weight: bold;
    border-radius: 5px;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.2s, color 0.2s;
}

.action-choice-btn:hover {
    background-color: var(--accent-color);
    color: #1a1a1d;
}


.roll-request-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--border-color);
  box-shadow: none;
}

/* Action buttons (Reroll/Regenerate) */
.action-btn-container {
  display: flex;
  justify-content: flex-start;
  padding-left: 0; /* Aligns with dm-message which has its own padding */
  margin-top: 0.5rem;
  margin-bottom: -0.25rem; /* Reduce gap to next message */
  position: relative;
  z-index: 2; /* Ensure it's clickable */
  align-self: flex-start;
}

.action-btn {
  background: var(--dm-bubble-bg);
  border: 1px solid var(--border-color);
  color: #aaa;
  padding: 0.2rem 0.8rem;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: var(--font-body);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.action-btn:hover:not(:disabled) {
  border-color: var(--accent-color);
  color: var(--accent-color);
  background-color: rgba(255, 153, 0, 0.1);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-btn svg {
    width: 1em;
    height: 1em;
}


#loading {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background-color: rgba(0, 0, 0, 0.7);
  border-radius: 20px;
  z-index: 10;
  color: var(--primary-text);
  font-size: 0.9rem;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background-color: rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

#chat-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

#chat-input {
  flex-grow: 1;
  padding: 0.65rem 1rem;
  background-color: var(--dm-bubble-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  color: var(--primary-text);
  font-size: 1rem;
  transition: border-color 0.3s, box-shadow 0.3s;
  resize: none;
  font-family: var(--font-body);
  line-height: 1.4;
  min-height: 50px;
  max-height: 150px; /* Limit growth */
  overflow-y: auto; /* Show scrollbar if max-height is exceeded */
}

#chat-input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(255, 153, 0, 0.3);
}

#mic-btn {
  flex-shrink: 0;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background-color: var(--dm-bubble-bg);
  color: var(--primary-text);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.3s, border-color 0.3s, box-shadow 0.3s;
}

#mic-btn.listening {
  background-color: var(--danger-color);
  border-color: var(--danger-color);
  box-shadow: 0 0 12px 2px rgba(229, 57, 53, 0.7);
  animation: a-pulse 1.5s infinite;
}

@keyframes a-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.7);
  }
  70% {
    box-shadow: 0 0 12px 2px rgba(229, 57, 53, 0.1);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.1);
  }
}


#chat-form button {
  flex-shrink: 0;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  background-color: var(--accent-color);
  color: var(--background-color);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.3s, opacity 0.3s;
}

#chat-form button:hover:not(:disabled) {
  background-color: #ffb84d;
}

#chat-form button[type="submit"]:disabled,
#mic-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#chat-form button svg {
  margin-left: 2px;
}

.dice-roll-message .disadvantage-notice,
.dice-roll-message .advantage-notice,
.attack-roll-message .disadvantage-notice,
.attack-roll-message .advantage-notice {
    display: block;
    font-size: 0.8rem;
    margin-top: 0.5rem;
    font-style: italic;
}

.dice-roll-message .disadvantage-notice,
.attack-roll-message .disadvantage-notice {
    color: #ffc0c0;
}

.dice-roll-message .advantage-notice,
.attack-roll-message .advantage-notice {
    color: var(--proficient-color);
}

#player-stats .penalty {
    color: var(--danger-color);
    font-size: 0.9em;
    margin-left: 0.5em;
    font-weight: normal;
    font-style: italic;
}

/* --- Master Skill Section Styles --- */
.skill-section {
    margin-top: 20px;
}
.skill-section-header {
    font-family: var(--font-title);
    border-bottom: 1px solid #555;
    padding-bottom: 5px;
    margin-bottom: 15px;
}
.skill-choice-block {
    margin-bottom: 20px;
}
.skill-choice-block h5 {
    font-family: var(--font-title);
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--accent-color);
}
.skill-choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
}
.skill-checkbox {
    display: flex;
    align-items: center;
}
.skill-checkbox input {
    margin-right: 8px;
}
.skill-checkbox input:disabled + label {
    color: #888;
    text-decoration: line-through;
}

/* Sidebar Toggle Button (Mobile only) */
.sidebar-toggle {
    display: none; /* Hidden by default */
    background: none;
    border: none;
    color: var(--primary-text);
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 0.5rem;
}

.sidebar-toggle svg {
    width: 28px;
    height: 28px;
}

/* Main content overlay for mobile sidebar */
#app-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 998; /* Below sidebar, above content */
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    pointer-events: none;
}

#app.sidebar-open #app-overlay {
    opacity: 1;
    pointer-events: auto;
}

/* Responsive sidebar for mobile */
@media (max-width: 768px) {
    #app {
        grid-template-columns: 1fr;
    }

    .sidebar-toggle {
        display: block;
    }

    #player-stats {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        z-index: 999;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        width: var(--sidebar-width);
        max-width: 80vw;
        box-shadow: 5px 0 15px rgba(0,0,0,0.4);
    }
    
    #app.sidebar-open #player-stats {
        transform: translateX(0);
    }
}

/* Debugger Panel Styles */
#debugger-panel {
  background-color: rgba(0,0,0,0.4);
  border-top: 1px solid var(--border-color);
  padding: 1rem 1.5rem;
  flex-shrink: 0;
  max-height: 25vh;
  overflow-y: auto;
}

#debugger-panel h3 {
  font-family: var(--font-title);
  color: var(--accent-color);
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
  font-size: 1.2rem;
}

.debugger-section {
  margin-bottom: 1rem;
}
.debugger-section:last-child {
    margin-bottom: 0;
}

.debugger-section h4 {
  font-family: var(--font-body);
  font-weight: bold;
  color: var(--primary-text);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

#debugger-panel pre {
  background-color: var(--background-color);
  padding: 0.75rem;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: monospace;
  font-size: 0.85rem;
  color: #ddd;
}

/* Update Notification Banner */
#update-notification {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(45deg, var(--accent-color), #ffbf60);
    color: var(--background-color);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    z-index: 2000;
    font-family: var(--font-body);
    font-weight: bold;
    animation: a-fade-in 0.5s forwards;
}
#update-notification p {
    margin-bottom: 0;
}
#update-notification button {
    padding: 0.5rem 1rem;
    background-color: var(--background-color);
    color: var(--accent-color);
    border: none;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
    font-family: var(--font-title);
    font-size: 1rem;
}

#update-notification button:hover {
    background-color: #3a3a3d;
}