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

html,
body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #050607;
  color: #f5f5f5;
}

#app-root {
  height: 100%;
  width: 100%;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.screen {
  position: relative;
  height: 100%;
  width: 100%;
  display: none;
}

.screen.active {
  display: block;
}

/* Home Screen */

#home-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}

.home-panel {
  width: 100%;
  max-width: 420px;
  padding: 24px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: stretch;
}

.home-logo {
  text-align: center;
}

.home-title-main {
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #f2b705;
  text-shadow: 0 0 18px rgba(252, 173, 18, 0.7);
}

.home-title-sub {
  font-size: 18px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #ffd57e;
  margin-top: 6px;
}

.home-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.home-footer {
  margin-top: auto;
  display: flex;
  justify-content: center;
}

.footer-pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Buttons & UI Elements */

button {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.08);
  color: #f5f5f5;
  cursor: pointer;
}

button.primary {
  background: linear-gradient(135deg, #f2b705, #f76b1c);
  color: #050607;
  box-shadow: 0 0 12px rgba(247, 130, 39, 0.7);
}

button.secondary {
  background: rgba(255, 255, 255, 0.05);
}

button.tiny {
  padding: 6px 10px;
  font-size: 11px;
  text-transform: uppercase;
}

button.block {
  width: 100%;
}

button:active {
  transform: translateY(1px);
  opacity: 0.9;
}

/* Game Layout */

#game-layout {
  height: 100%;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at top, #12151d 0, #050607 55%);
}

/* Top bar */

#top-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  background: rgba(0, 0, 0, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#top-left,
#top-center,
#top-right {
  flex: 1;
  text-align: center;
  color: #e2e2e2;
}

#top-left {
  text-align: left;
}

#top-right {
  text-align: right;
}

/* Content */

#content-area {
  flex: 1 1 auto;
  padding: 6px 10px 4px;
  display: flex;
  flex-direction: column;
}

.view {
  display: none;
  height: 100%;
}

.view.active {
  display: block;
}

.panel-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
}

/* Cards */

.card {
  background: rgba(10, 11, 15, 0.96);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-header {
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: linear-gradient(90deg, rgba(242, 183, 5, 0.18), transparent);
}

.card-body {
  padding: 8px 10px 10px;
  font-size: 13px;
  line-height: 1.3;
}

.card-footer {
  padding: 6px 8px 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 6px;
  row-gap: 4px;
}

/* Pills, tags */

.pill {
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10px;
  background: rgba(255, 255, 255, 0.1);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Lists & text */

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.stat-row span:first-child {
  color: #cccccc;
}

.stat-row span:last-child {
  font-weight: 600;
  color: #f8d25a;
}

/* Life actions */

.life-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Logs */

.flex-log {
  /* Keep flexible layout but constrain overall visual height so logs can't push navigation offscreen */
  flex: 1 1 auto;
  min-height: 0;
  max-height: 40vh; /* prevent very tall logs from growing too far */
  display: flex;
  flex-direction: column;
  overflow: hidden; /* contain inner scroll instead of expanding the card */
}

/* Limit the scrolling area inside flex-log cards so content scrolls internally */
.flex-log .card-body.scroll {
  max-height: calc(40vh - 46px); /* subtract header/footer approximate height so content fits inside the card */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 8px; /* give space for scrollbar on some platforms */
}

.scroll {
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.log-entry {
  margin-bottom: 6px;
}

.log-entry strong {
  color: #f2b705;
}

/* Chat footer */

.chat-footer {
  display: flex;
  gap: 4px;
  align-items: center;
}

.chat-footer input {
  flex: 1;
  border-radius: 999px;
  border: none;
  padding: 6px 10px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.07);
  color: #f5f5f5;
}

/* Relationships */

.relationship-item {
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  margin-bottom: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.relationship-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.relationship-meta {
  font-size: 11px;
  opacity: 0.8;
}

/* Fields */

.field {
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
}

.field label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.8;
}

.field input,
.field textarea,
.field select {
  border-radius: 10px;
  border: none;
  padding: 7px 9px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.07);
  color: #f5f5f5;
}

.field textarea {
  resize: vertical;
}

/* Bottom bar */

#bottom-bar {
  flex: 0 0 auto;
  padding: 6px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(0, 0, 0, 0.9);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

#time-controls {
  display: flex;
  gap: 4px;
  justify-content: space-between;
}

#nav-tabs {
  display: flex;
  justify-content: space-between;
  gap: 3px;
}

.nav-btn {
  flex: 1;
  padding: 6px 4px;
  font-size: 11px;
  text-transform: uppercase;
}

.nav-btn.active {
  background: linear-gradient(135deg, #f2b705, #f76b1c);
  color: #050607;
}

/* Modals */

.modal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.modal-panel {
  position: relative;
  width: 92%;
  max-width: 420px;
  max-height: 88%;
  background: #080a0f;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
}

.modal-header,
.modal-footer {
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.modal-body {
  padding: 4px 10px 8px;
  font-size: 13px;
}

/* Save slots */

.settings-section h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 6px 0;
  opacity: 0.9;
}

.save-slots {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.save-slot {
  border-radius: 10px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.04);
}

.slot-header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 2px;
}

.slot-body {
  font-size: 11px;
  opacity: 0.9;
}

.slot-actions {
  margin-top: 4px;
  display: flex;
  gap: 4px;
}

/* Toggle */

.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

/* Time modal */

#time-warning-body {
  font-size: 13px;
}

/* Status */

#status-character-summary {
  font-size: 13px;
}

/* Global loading */

#global-loading {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.9));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

#global-loading.hidden {
  display: none;
}

.loader-ring {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: #f2b705;
  animation: spin 1s linear infinite;
}

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

/* Utility */

@media (min-width: 500px) {
  #game-layout {
    border-radius: 18px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
    margin: 8px auto;
  }
}