html, body {
  height: 100%;
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #0b0e16;
  overflow: hidden;
  color: white;
}

.header{
  position: fixed;
  left: 0; right: 0; top: 0;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: rgba(20,24,36,0.92);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  z-index: 10;
  backdrop-filter: blur(8px);
}

.reset-button, .upgrades-button, .upgrade-button, .close-button, .stage-button, .menu-toggle-button, .user-profile-button, .view-button{
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: #11182a;
  color: #eaeef6;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
}

.reset-button { background: #2a1111; }
.reset-button:hover { background: #3a1818; }

.view-button { 
  background: #1a2a11; 
  padding: 8px 12px;
}
.view-button:hover { background: #243a18; }

.user-profile-button {
  background: #1a1a3a;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-profile-button:hover { background: #2a2a5a; }
.user-profile-button canvas { flex-shrink: 0; }

.menu-toggle-button { 
  background: #12301a; 
  display: flex;
  align-items: center;
  gap: 6px;
}
.menu-toggle-button:hover { background: #1a4024; }

.upgrade-button { background: #12301a; width: fit-content; }
.upgrade-button:hover { background: #1a4024; }
.upgrade-button.secondary { background: #11182a; }
.upgrade-button.secondary:hover { background: #1a2238; }
.upgrade-button.secondary.active { 
  background: #2a4024; 
  border-color: #4a8040;
  box-shadow: 0 0 8px rgba(74, 128, 64, 0.4);
}

.stage-controls{
  display: flex;
  gap: 10px;
  align-items: center;
  margin-left: 8px;
}

.view-controls{
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: 8px;
  padding-left: 8px;
  border-left: 1px solid rgba(255,255,255,0.1);
}

.stage-label, .zoom-label{
  color: #eaeef6;
  opacity: 0.9;
  font-size: 13px;
  padding: 0 8px;
  min-width: 90px;
  text-align: center;
}

.stage-button:disabled,
.upgrade-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.game-container{
  height: 100%;
  padding-top: 56px;
  position: relative;
  z-index: 1;
}

.island-container{
  height: calc(100vh - 56px);
  width: 100%;
  overflow: hidden;
  cursor: grab;
  position: relative;
  z-index: 1;
}

.island-container.dragging {
  cursor: grabbing;
}

/* Side Panel (Right) */
.improvements-panel {
  position: fixed;
  right: -360px;
  top: 56px;
  width: 360px;
  height: calc(100vh - 56px);
  background: #0e1220;
  border-left: 1px solid rgba(255,255,255,0.10);
  z-index: 20;
  overflow-y: auto;
  transition: right 0.3s ease;
  box-shadow: -4px 0 20px rgba(0,0,0,0.3);
}

.improvements-panel.open {
  right: 0;
}

.panel-header {
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  position: sticky;
  top: 0;
  background: #0e1220;
  z-index: 1;
}

.panel-header h2 {
  margin: 0;
  color: #eaeef6;
  font-size: 18px;
}

.panel-section {
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.panel-section h3 {
  margin: 0 0 12px 0;
  color: #eaeef6;
  font-size: 14px;
  opacity: 0.9;
}

.panel-hint {
  font-size: 11px;
  opacity: 0.7;
  color: #eaeef6;
  margin: 0 0 12px 0;
}

.phase-info {
  font-size: 13px;
  opacity: 0.85;
  color: #eaeef6;
  margin: 0 0 10px 0;
}

.phase-buttons{
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.upgrades-list{
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upgrade-item{
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.10);
  background: #0a0d16;
  transition: background 0.2s;
  justify-content: space-between;
}

.upgrade-item:hover {
  background: #0d1018;
}

.upgrade-item.disabled {
  opacity: 0.5;
}

.upgrade-preview{
  width: 56px;
  height: 56px;
  image-rendering: pixelated;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.10);
  background: #05070d;
}

.upgrade-label{
  font-size: 12px;
  opacity: 0.9;
  color: #eaeef6;
  word-break: break-word;
}

.unavailable-hint {
  font-size: 10px;
  opacity: 0.6;
  color: #ff8080;
  margin-top: 2px;
}

/* Toggle */
.toggle{
  position: relative;
  width: 50px;
  height: 28px;
  display: inline-block;
}
.toggle input{ display:none; }
.slider{
  position:absolute;
  inset:0;
  background:#2a324a;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  transition: .2s;
}
.slider:before{
  content:"";
  position:absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  background: #eaeef6;
  border-radius: 50%;
  transition: .2s;
}
.toggle input:checked + .slider{
  background: #2a6a3e;
}
.toggle input:checked + .slider:before{
  transform: translate(22px, -50%);
}
.toggle input:disabled + .slider {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Scrollbar styling */
.improvements-panel::-webkit-scrollbar {
  width: 8px;
}
.improvements-panel::-webkit-scrollbar-track {
  background: #0b0e16;
}
.improvements-panel::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
}
.improvements-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.25);
}

/* Responsive */
@media (max-width: 768px) {
  .improvements-panel {
    width: 100%;
    right: -100%;
  }
  
  .game-container.panel-open {
    margin-right: 0;
  }
}

/* Tab styles */
.tab-button {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.14);
  background: #11182a;
  color: #eaeef6;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  font-weight: 500;
}

.tab-button:hover {
  background: #1a2238;
  border-color: rgba(255,255,255,0.2);
}

.tab-button.active {
  background: #12301a;
  border-color: #4a8040;
  color: #4CAF50;
  box-shadow: 0 0 8px rgba(74, 128, 64, 0.3);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}
