@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@600;700;800&display=swap');

:root {
  --sky-top: #4EC0CA;
  --sky-bottom: #71D1DB;
  --pipe-green: #5BBF4C;
  --pipe-green-dark: #4AA33E;
  --pipe-green-light: #6FD35E;
  --pipe-highlight: #7FE86E;
  --bird-yellow: #F8C036;
  --bird-orange: #F5A623;
  --bird-white: #FFFFFF;
  --ground-brown: #DEA464;
  --ground-dark: #C4884D;
  --grass-green: #7BC64E;
  --cloud-white: #FFFFFF;
  --brick-brown: #C8703C;
  --brick-dark: #A85A2E;
  --brick-light: #D98A54;
  --score-white: #FFFFFF;
  --score-stroke: #534B47;
  --text-dark: #4A3728;
  --text-medium: #6B5644;
  --text-light: #8A7563;
  --panel-bg: #F7F0E8;
  --panel-border: #E0D5C5;
  --sidebar-bg: #E8F5E1;
  --sidebar-border: #C5E3B0;
  --accent: var(--pipe-green);
  --accent-dark: var(--pipe-green-dark);
  --sidebar-width: 310px;
  --header-height: 68px;
  --panel-gap: 20px;
}

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

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 60%, var(--grass-green) 60%, var(--grass-green) 65%, var(--ground-brown) 65%, var(--ground-dark) 100%);
  color: var(--text-dark);
  height: 100vh;
  overflow: hidden;
}

/* Clouds background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60%;
  background:
    radial-gradient(ellipse 120px 50px at 15% 20%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(ellipse 160px 60px at 18% 22%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(ellipse 100px 45px at 12% 22%, rgba(255,255,255,0.55) 0%, transparent 100%),
    radial-gradient(ellipse 140px 55px at 55% 15%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(ellipse 180px 65px at 58% 17%, rgba(255,255,255,0.45) 0%, transparent 100%),
    radial-gradient(ellipse 110px 48px at 52% 17%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(ellipse 130px 52px at 80% 25%, rgba(255,255,255,0.55) 0%, transparent 100%),
    radial-gradient(ellipse 150px 58px at 83% 27%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(ellipse 100px 42px at 77% 27%, rgba(255,255,255,0.48) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
  animation: drift 40s linear infinite;
}

@keyframes drift {
  0% { background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0; }
  100% { background-position: 200px 0, 200px 0, 200px 0, 200px 0, 200px 0, 200px 0, 200px 0, 200px 0, 200px 0; }
}

/* Background clouds - far layer */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60%;
  background:
    radial-gradient(ellipse 80px 35px at 30% 35%, rgba(255,255,255,0.35) 0%, transparent 100%),
    radial-gradient(ellipse 100px 40px at 33% 37%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(ellipse 70px 30px at 27% 37%, rgba(255,255,255,0.32) 0%, transparent 100%),
    radial-gradient(ellipse 90px 38px at 65% 40%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(ellipse 110px 42px at 68% 42%, rgba(255,255,255,0.28) 0%, transparent 100%),
    radial-gradient(ellipse 75px 32px at 62% 42%, rgba(255,255,255,0.3) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
  animation: drift-slow 70s linear infinite;
}

@keyframes drift-slow {
  0% { background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0; }
  100% { background-position: -180px 0, -180px 0, -180px 0, -180px 0, -180px 0, -180px 0; }
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* Header */
#site-header {
  height: var(--header-height);
  padding: 0 30px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--pipe-green);
  border-bottom: 4px solid var(--pipe-green-dark);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  flex-shrink: 0;
  position: relative;
  z-index: 100;
  pointer-events: auto;
}

#site-header::after {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 0;
  right: 0;
  height: 8px;
  background:
    repeating-linear-gradient(90deg, var(--pipe-highlight) 0px, var(--pipe-highlight) 38px, var(--pipe-green-dark) 38px, var(--pipe-green-dark) 42px);
  opacity: 0.3;
}

#site-header h1 {
  font-family: 'Fredoka One', 'Nunito', sans-serif;
  font-size: 1.5rem;
  color: var(--score-white);
  text-shadow: 2px 2px 0 var(--score-stroke), -1px -1px 0 var(--score-stroke), 1px -1px 0 var(--score-stroke), -1px 1px 0 var(--score-stroke);
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

#site-header h1:hover {
  opacity: 0.8;
}

#site-header h1:active {
  transform: scale(0.97);
}

.clickable {
  cursor: pointer;
}

#site-header .subtitle {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.85);
  font-weight: 700;
  margin-left: auto;
  background: rgba(0,0,0,0.12);
  padding: 4px 14px;
  border-radius: 20px;
}

/* Main layout */
#main-container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
#sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 3px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
}

#sidebar::after {
  content: '';
  position: absolute;
  top: 0;
  right: -16px;
  width: 16px;
  height: 100%;
  background: linear-gradient(90deg, var(--pipe-green), var(--pipe-green-light));
  border-left: 3px solid var(--pipe-green-dark);
  border-right: 3px solid var(--pipe-green-dark);
  border-radius: 0 8px 8px 0;
}

#sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 2px dashed var(--sidebar-border);
  background: linear-gradient(180deg, rgba(91,191,76,0.12) 0%, transparent 100%);
}

#sidebar-header .label {
  font-family: 'Fredoka One', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 2px;
  color: var(--text-medium);
}

.badge {
  font-family: 'Fredoka One', sans-serif;
  background: var(--bird-yellow);
  color: var(--score-stroke);
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 14px;
  border: 2px solid var(--score-stroke);
  box-shadow: 0 2px 0 var(--score-stroke);
}

#model-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

#model-list::-webkit-scrollbar {
  width: 8px;
}

#model-list::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.04);
}

#model-list::-webkit-scrollbar-thumb {
  background: var(--pipe-green);
  border-radius: 4px;
  border: 2px solid var(--sidebar-bg);
}

.model-item {
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.12s ease;
  margin-bottom: 6px;
  border: 2px solid transparent;
  background: rgba(255,255,255,0.6);
}

.model-item:hover {
  background: rgba(255,255,255,0.9);
  border-color: var(--pipe-green-light);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0,0,0,0.08);
}

.model-item.active {
  background: var(--bird-yellow);
  border-color: var(--bird-orange);
  box-shadow: 0 3px 0 var(--bird-orange), 0 6px 12px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}

.model-item .model-title {
  font-size: 0.88rem;
  font-weight: 800;
  margin-bottom: 5px;
  color: var(--text-dark);
}

.model-item .model-meta {
  font-size: 0.7rem;
  color: var(--text-light);
  font-weight: 700;
}

.model-item .model-meta span {
  display: inline-block;
  background: rgba(91,191,76,0.15);
  color: var(--pipe-green-dark);
  padding: 1px 8px;
  border-radius: 6px;
  margin-right: 3px;
  font-size: 0.65rem;
}

/* Content area */
#content-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
}

#content-area::-webkit-scrollbar {
  width: 10px;
}

#content-area::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.05);
}

#content-area::-webkit-scrollbar-thumb {
  background: var(--brick-brown);
  border-radius: 5px;
  border: 2px solid var(--panel-bg);
}

.hidden {
  display: none !important;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  height: 100%;
  text-align: center;
  color: var(--text-light);
  padding: 50px 40px 40px 40px;
}

.empty-state p {
  font-size: 0.88rem;
  max-width: 340px;
  line-height: 1.6;
  color: var(--text-light);
}

.empty-state .home-intro {
  font-family: 'Fredoka One', sans-serif;
  font-size: 2.2rem;
  line-height: 1.3;
  color: var(--text-dark);
  text-align: center;
  margin: 0 auto 32px auto;
  text-shadow: 2px 2px 0 rgba(255,255,255,0.5);
  letter-spacing: 0.5px;
  max-width: 950px;
}

.empty-state .home-intro br {
  display: block;
  content: '';
  margin-bottom: 8px;
}

.home-content {
  max-width: 520px;
  margin: 0 auto;
  text-align: left;
}

.home-section {
  margin-bottom: 20px;
  padding: 16px 20px;
  background: rgba(255,255,255,0.85);
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.6);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.home-section h3 {
  font-family: 'Fredoka One', sans-serif;
  font-size: 0.95rem;
  color: var(--pipe-green-dark);
  margin-bottom: 8px;
}

.home-section p {
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--text-medium);
}

/* Model view */
.model-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#model-header {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 3px dashed var(--panel-border);
}

#model-name {
  font-family: 'Fredoka One', sans-serif;
  font-size: 1.5rem;
  color: var(--text-dark);
  margin-bottom: 10px;
}

/* Version tabs - styled like game bricks */
#version-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.version-tab {
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.12s ease;
  background: linear-gradient(180deg, var(--brick-light) 0%, var(--brick-brown) 100%);
  color: var(--score-white);
  border: 2px solid var(--brick-dark);
  box-shadow: 0 3px 0 var(--brick-dark), inset 0 1px 0 rgba(255,255,255,0.2);
  user-select: none;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.2);
}

.version-tab:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 var(--brick-dark), inset 0 1px 0 rgba(255,255,255,0.2);
}

.version-tab:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--brick-dark), inset 0 1px 0 rgba(255,255,255,0.2);
}

.version-tab.active {
  background: linear-gradient(180deg, var(--bird-yellow) 0%, var(--bird-orange) 100%);
  border-color: var(--score-stroke);
  box-shadow: 0 3px 0 var(--score-stroke), inset 0 1px 0 rgba(255,255,255,0.3);
}

/* Model body - game + writeup */
#model-body {
  display: flex;
  gap: var(--panel-gap);
  flex: 1;
  min-height: 0;
}

/* Game container - styled like a pipe frame */
#game-container {
  flex: 1;
  background: var(--panel-bg);
  border-radius: 16px;
  border: 4px solid var(--pipe-green);
  box-shadow: 0 6px 0 var(--pipe-green-dark), 0 10px 24px rgba(0,0,0,0.12);
  overflow: hidden;
  position: relative;
  min-width: 0;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-frame {
  border: none;
  display: block;
  background: #4EC0CA;
}

#loading-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--score-white);
  font-size: 0.9rem;
  font-weight: 700;
  z-index: 10;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.2);
}

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255,255,255,0.3);
  border-top-color: var(--bird-yellow);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* Writeup panel - styled like a scroll/parchment */
#writeup-panel {
  width: 340px;
  flex-shrink: 0;
  background: var(--panel-bg);
  border-radius: 14px;
  border: 3px solid var(--panel-border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.8);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  padding: 12px 18px;
  border-bottom: 2px dashed var(--panel-border);
  background: linear-gradient(180deg, rgba(91,191,76,0.1) 0%, transparent 100%);
}

.panel-header .label {
  font-family: 'Fredoka One', sans-serif;
  font-size: 0.68rem;
  letter-spacing: 2px;
  color: var(--text-medium);
}

#writeup-content {
  padding: 18px;
  font-size: 0.85rem;
  line-height: 1.75;
  color: var(--text-medium);
  flex: 1;
  overflow-y: auto;
}

#writeup-content:empty::before {
  content: "No notes yet — start writing!";
  font-style: italic;
  color: var(--text-light);
}

#writeup-content p {
  margin-bottom: 10px;
}

#writeup-content p:last-child {
  margin-bottom: 0;
}

#writeup-content li {
  margin-left: 18px;
  margin-bottom: 4px;
  list-style-type: '-> ';
}

.version-notes {
  border-top: 2px dashed var(--panel-border);
}

/* Version notes content - rich data display */
#version-notes-content {
  padding: 16px 18px;
  font-size: 0.8rem;
  max-height: 500px;
  overflow-y: auto;
}

#version-notes-content:empty::before {
  content: "No version-specific notes.";
  font-style: italic;
  color: var(--text-light);
}

.empty-note {
  font-style: italic;
  color: var(--text-light);
  font-size: 0.8rem;
}

/* Note rows: simple label/value pairs */
.note-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.note-row:last-child {
  border-bottom: none;
}

.note-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-light);
  flex-shrink: 0;
}

.note-value {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-dark);
  text-align: right;
}

/* Adjustment note spans full width */
.note-adjustment {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  background: rgba(248, 192, 54, 0.1);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 6px 0;
  border-bottom: none;
}

.note-adjustment .note-value {
  font-size: 0.75rem;
  font-style: italic;
  color: var(--text-medium);
  line-height: 1.5;
  text-align: left;
}

/* Badge for prompt type */
.badge-type {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(91,191,76,0.18);
  color: var(--pipe-green-dark);
}

/* Note sections: grouped stat/param grids */
.note-section {
  margin: 8px 0;
  background: rgba(255,255,255,0.55);
  border-radius: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(0,0,0,0.06);
}

.note-section-label {
  display: block;
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-light);
  margin-bottom: 6px;
}

/* Stat rows in sections */
.stat-row, .param-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 3px 0;
}

.stat-row span, .param-row span {
  font-size: 0.7rem;
  color: var(--text-light);
  font-weight: 600;
}

.stat-row strong, .param-row strong {
  font-size: 0.75rem;
  color: var(--text-dark);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* Responsive */
@media (max-width: 900px) {
  #main-container {
    flex-direction: column;
  }

  #sidebar {
    width: 100%;
    max-height: 180px;
    border-right: none;
    border-bottom: 3px solid var(--sidebar-border);
  }

  #sidebar::after {
    display: none;
  }

  #model-body {
    flex-direction: column;
  }

  #writeup-panel {
    width: 100%;
    max-height: 220px;
  }

  #site-header .subtitle {
    display: none;
  }
}