:root {
  --bg: #060a12;
  --bg-2: #0b1220;
  --panel: rgba(10, 16, 28, 0.9);
  --panel-2: rgba(14, 22, 36, 0.95);
  --border: rgba(125, 211, 252, 0.15);
  --accent: #7dd3fc;
  --accent-2: #38bdf8;
  --text: #e2f1ff;
  --muted: #8aa0b7;
  --shadow: 0 24px 60px rgba(2, 6, 23, 0.6);
  --success: #a7f3d0;
  --glow: rgba(56, 189, 248, 0.35);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Courier New', monospace;
  background: radial-gradient(circle at top, #0c2038 0%, var(--bg) 60%);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.page-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 72px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin-bottom: 2rem;
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand__icon {
  font-size: 2rem;
  line-height: 1;
}

.brand h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Chips */
.chip {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chip:hover {
  background: var(--panel-2);
  border-color: var(--text);
}

.chip--ghost.active {
  background: var(--panel-2);
  border-color: var(--text);
  color: var(--text);
}

.chip--accent {
  background: var(--accent);
  color: #03101c;
  border-color: var(--accent);
  font-weight: 600;
}

.chip--accent:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
}

/* Hero Section */
.hero {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 2rem;
  margin-bottom: 3rem;
}

.hero__copy h2 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #b8ecff, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.lead {
  font-size: 1.125rem;
  color: var(--muted);
  margin-bottom: 2rem;
  line-height: 1.7;
}

/* Controls */
.hero__controls {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.preset-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.preset-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.preset-chip {
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.7);
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.preset-chip:hover,
.preset-chip.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--accent);
  color: var(--accent);
}

.hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.primary-btn,
.ghost-btn,
.action-btn {
  padding: 0.65rem 1.1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(8, 15, 30, 0.8);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  font-weight: 600;
}

.primary-btn {
  background: var(--accent);
  color: #03101c;
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(56, 189, 248, 0.35);
}

.primary-btn:hover {
  filter: brightness(1.05);
}

.ghost-btn:hover,
.action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.control {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.control span:first-child {
  min-width: 120px;
  font-weight: 500;
  color: var(--text);
}

.control input[type="range"] {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--panel-2);
  outline: none;
  accent-color: var(--accent);
  cursor: pointer;
}

.control .value {
  min-width: 50px;
  text-align: right;
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.value--editable {
  cursor: pointer;
}

.value-editor {
  width: 60px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: rgba(7, 15, 25, 0.9);
  color: var(--text);
  padding: 0.15rem 0.3rem;
}

/* Features */
.features {
  margin-top: 2rem;
}

.features h3 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: var(--text);
}

.feature-list {
  list-style: none;
  display: grid;
  gap: 0.75rem;
}

.feature-list li {
  padding: 0.75rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
}

/* Hero Panel */
.hero__panel {
  background: linear-gradient(135deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  height: fit-content;
  position: sticky;
  top: 180px;
}

.how-to {
  margin-bottom: 3rem;
  padding: 1.5rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(8, 16, 30, 0.85);
  box-shadow: var(--shadow);
}

.how-to__steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.how-to__step {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: rgba(12, 20, 34, 0.8);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.step-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.panel-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

/* Stats Grid */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.stat__label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat__value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat__value--success {
  color: var(--success);
}

/* Panel Sections */
.panel-section h4 {
  font-size: 0.875rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

/* Tier Pills */
.tier-pills {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pill {
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.pill:hover {
  background: var(--panel-2);
  color: var(--text);
}

.pill--accent {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}

/* Mode Display */
.mode-display {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.mode-icon {
  font-size: 2rem;
  line-height: 1;
}

.mode-info {
  flex: 1;
}

.mode-title {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.25rem;
  color: var(--text);
}

.mode-desc {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.5;
}

/* Species List */
.species-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.species-chip {
  padding: 0.375rem 0.75rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.875rem;
  color: var(--text);
}

/* Info Section */
.info-section {
  margin-bottom: 3rem;
}

.info-section h3 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text);
}

/* Mode Cards */
.mode-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}

.mode-card {
  padding: 1.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: all 0.3s;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.mode-card:hover {
  background: var(--panel-2);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.mode-card__icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  line-height: 1;
}

.mode-card h4 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.mode-card p {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 1rem;
  line-height: 1.6;
}

.mode-card__specs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.mode-card__specs span {
  padding: 0.25rem 0.625rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.75rem;
  color: var(--muted);
}

/* Responsive */
@media (max-width: 968px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .hero__panel {
    position: static;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .actions {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .hero__copy h2 {
    font-size: 2rem;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .mode-cards {
    grid-template-columns: 1fr;
  }
}

/* Studio Styles */
.studio-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: var(--bg);
  overflow: hidden;
}

.studio-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: rgba(6, 12, 24, 0.75);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.studio-title {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.studio-stats {
  display: flex;
  gap: 1.5rem;
  font-size: 0.875rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.studio-stats span {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.studio-stats .label {
  color: var(--muted);
}

.studio-stats .value {
  color: var(--accent);
  font-weight: 600;
}

#canvas-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#tank-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  background: linear-gradient(180deg, #001a33 0%, #000810 100%);
  border-radius: 8px;
  box-shadow: 0 0 60px rgba(125, 211, 252, 0.2);
}

/* Control Panel */
.control-panel {
  position: absolute;
  right: 1rem;
  top: 80px;
  bottom: 1rem;
  width: 280px;
  background: rgba(8, 10, 18, 0.95);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  z-index: 50;
  box-shadow: var(--shadow);
}

.control-panel__handle {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.sheet-toggle {
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(12, 20, 34, 0.9);
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
}

.sheet-status {
  font-size: 0.75rem;
  color: var(--muted);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.reset-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.7rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
}

.reset-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.control-panel h3 {
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.control-panel .control {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.control-panel .control span:first-child {
  min-width: auto;
  font-size: 0.875rem;
}

.control-panel .control input[type="range"] {
  width: 100%;
}

.button-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.button-group button {
  padding: 0.75rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.button-group button:hover {
  background: var(--panel-2);
  border-color: var(--accent);
}

.button-group button.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}

/* Studio Controls */
.studio-controls {
  display: flex;
  gap: 0.5rem;
  margin-right: 1rem;
}

.studio-btn {
  padding: 0.5rem 0.75rem;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 4px;
  line-height: 1;
}

.studio-btn:hover {
  background: var(--panel-2);
  border-color: var(--accent);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.toggle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.toggle input {
  accent-color: var(--accent);
}

.tier-pills--panel {
  justify-content: flex-start;
}

.preset-chips--stacked {
  margin-bottom: 0.75rem;
}

.watch-hud {
  position: absolute;
  top: 90px;
  left: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.6rem;
  border-radius: 999px;
  background: rgba(6, 12, 24, 0.7);
  border: 1px solid rgba(125, 211, 252, 0.2);
  color: var(--text);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.watch-hud.visible {
  opacity: 1;
  pointer-events: auto;
}

.watch-hud__pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.watch-hud__mode {
  color: var(--accent);
  font-weight: 600;
}

.watch-hud__button {
  border: 1px solid var(--border);
  background: rgba(8, 16, 30, 0.8);
  color: var(--text);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
}

/* Fullscreen mode */
.studio-container.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  background: #000;
}

.studio-container.fullscreen .studio-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s;
}

.studio-container.fullscreen:hover .studio-header {
  opacity: 1;
}

.studio-container.fullscreen .control-panel {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.studio-container.fullscreen:hover .control-panel {
  opacity: 1;
  pointer-events: all;
}

.studio-container.watch-mode .control-panel {
  opacity: 0;
  pointer-events: none;
}

.studio-container.watch-mode .studio-header {
  opacity: 0;
  pointer-events: none;
}

.studio-container.watch-mode #canvas-container {
  cursor: none;
}

.studio-container.fullscreen #canvas-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
}

.studio-container.fullscreen #tank-canvas {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
}

/* Controls hidden */
.control-panel.hidden {
  transform: translateX(calc(100% + 1rem));
  transition: transform 0.3s;
}

.control-panel:not(.hidden) {
  transform: translateX(0);
  transition: transform 0.3s;
}

@media (max-width: 900px) {
  .control-panel {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: auto;
    border-radius: 20px 20px 0 0;
    max-height: 75vh;
    padding: 1rem 1.25rem 1.5rem;
  }

  .control-panel__handle {
    display: flex;
  }

  .control-panel.collapsed {
    max-height: 70px;
    overflow: hidden;
  }

  .control-panel.collapsed section {
    display: none;
  }

  .control-panel.collapsed .control-panel__handle {
    padding-bottom: 0;
  }

  .studio-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .studio-stats {
    flex-wrap: wrap;
    gap: 0.75rem;
  }
}

@media (max-width: 640px) {
  .hero__cta {
    flex-direction: column;
  }

  .topbar {
    top: 60px;
  }
}
