* {
  box-sizing: border-box;
}
body {
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
  background: #F5F5F5;
  color: #222;
  overflow-x: hidden;
  overflow-y: auto;
}
#heatmap-container {
  position: relative;
  width: 100vw;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  box-sizing: border-box;
}
#heatmap-container.collapsed {
  overflow-y: auto;
}
#heatmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15px, 1fr));
  grid-auto-rows: minmax(20px, 1fr);
  width: 100vw;
  height: calc(100vh - 60px);
  overflow-y: hidden;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
#heatmap-grid.collapsed {
  margin-left: 0;
  padding-left: 0;
  width: 100vw;
  height: auto;
  overflow-y: auto;
  touch-action: pan-y; /* Разрешить прокрутку по оси Y */
  box-sizing: border-box;
}
.heatmap-tile {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: translateX(-20px);
  transition: opacity 0.15s ease, transform 0.15s ease, background-color 0.5s ease;
  box-sizing: border-box;
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: #222;
  text-align: center;
  padding: 0 1px;
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.5);
}
.heatmap-tile.visible {
  opacity: 1;
  transform: translateX(0);
}
.heatmap-tile.highlighted {
  transform: scale(1.4);
  box-shadow: 0 0 16px 4px #00CED1;
  outline: 2px solid #00CED1;
  z-index: 10;
  transition: transform 0.2s ease, box-shadow 0.2s ease, outline 0.2s ease;
}
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}
.heatmap-tile.high-change {
  animation: pulse 1s infinite;
}
.heatmap-tile:hover, .heatmap-tile:active {
  transform: scale(1.4);
  z-index: 10;
  transition: transform 0.2s ease;
}
.heatmap-tile:hover:not(.highlighted), .heatmap-tile:active:not(.highlighted) {
  border: 1px solid rgba(0, 0, 0, 0.1);
}
.heatmap-tile .symbol { font-weight: normal; }
.heatmap-tile .change, .heatmap-tile .price { margin-top: 2px; }
#heatmap-tooltip {
  visibility: hidden;
  background-color: rgba(0, 0, 0, 0.8);
  color: #FFFFFF;
  text-align: left;
  border-radius: 4px;
  padding: 5px 10px;
  position: fixed;
  left: 150px;
  top: 40px;
  z-index: 1011;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  white-space: nowrap;
}
#heatmap-tooltip.visible {
  visibility: visible;
  opacity: 1;
}
#list-container {
  position: relative;
  width: 100vw;
  min-height: 100vh;
  display: none;
  background: #FFFFFF;
  color: #222;
  padding: 10px;
  box-sizing: border-box;
  z-index: 1;
}
.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 2px solid #E0E0E0;
  background: #F5F5F5;
  color: #222;
  font-weight: bold;
  position: sticky;
  top: 0;
  z-index: 1010;
  line-height: 1.2;
}
.list-header span {
  cursor: pointer;
}
.list-header span:hover {
  color: #007AFF;
}
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 14px;
  border-bottom: 1px solid #E0E0E0;
  cursor: pointer;
  background: #FFFFFF;
  color: #222;
  line-height: 1.2;
}
.list-header .symbol, .list-header .price, .list-header .change, .list-header .change-30d, .list-header .volume,
.list-item .symbol, .list-item .price, .list-item .change, .list-item .change-30d, .list-item .volume {
  font-weight: bold;
  flex: 1;
}
.list-header .price, .list-header .change, .list-header .change-30d, .list-header .volume,
.list-item .price, .list-item .change, .list-item .change-30d, .list-item .volume {
  text-align: right;
}
.list-item .volume {
  color: #555;
}
.list-item:hover { background: #F0F3F0; }
.list-item.selected { background: #65B0FF; }
.change-24h.positive { color: #008300; }
.change-24h.negative { color: #FF0000; }
.change-30d.positive { color: #008300; }
.change-30d.negative { color: #FF0000; }
.chart-icon {
  position: relative;
  width: 24px;
  height: 24px;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.chart-icon.visible {
  opacity: 1;
}
.chart-icon .tooltip {
  visibility: hidden;
  background-color: rgba(0, 0, 0, 0.8);
  color: #FFFFFF;
  text-align: center;
  border-radius: 4px;
  padding: 5px 10px;
  position: fixed;
  z-index: 1011;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.list-item:hover .chart-icon .tooltip {
  visibility: visible;
  opacity: 1;
}
#controls {
  position: fixed;
  top: 0;
  left: 100px;
  display: flex;
  gap: 10px;
  z-index: 1005;
  background: #F5F5F5;
  padding: 3px;
}
#toggle-view, #collapse-heatmap {
  padding: 4px 8px;
  background: #007AFF;
  color: #FFFFFF;
  border: none;
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
}
#collapse-heatmap {
  padding: 4px;
  width: 30px;
  font-size: 16px;
  text-align: center;
}
#toggle-view:hover, #collapse-heatmap:hover {
  background: #005BB5;
}
#period-controls {
  position: fixed;
  bottom: 10px;
  right: 10px;
  display: flex;
  gap: 10px;
  z-index: 1005;
}
#period-24h, #period-1h, #period-30d, #period-price, #period-volume-24h {
  padding: 4px 8px;
  background: #007AFF;
  color: #FFFFFF;
  border: none;
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
}
#period-24h:hover, #period-30d:hover, #period-price:hover, #period-volume-24h:hover {
  background: #005BB5;
}
#period-24h.active, #period-30d.active, #period-price.active, #period-volume-24h.active {
  background: #0041A3;
  border: 1px solid #FFFFFF;
}
#symbol-input {
  padding: 4px;
  width: 100px;
  background: #FFFFFF;
  color: #222;
  border: 1px solid #E0E0E0;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
}
#symbol-input:focus {
  outline: none;
  border-color: #007AFF;
}
#symbol-dropdown {
  position: fixed;
  top: 40px;
  left: 210px;
  background: #FFFFFF;
  border: 1px solid #E0E0E0;
  border-radius: 4px;
  max-height: 200px;
  overflow-y: auto;
  display: none;
  z-index: 1006;
  width: 120px;
}
.dropdown-item {
  padding: 8px 12px;
  color: #222;
  cursor: pointer;
  font-size: 12px;
}
.dropdown-item:hover { background: #F0F0F0; }
#error {
  position: fixed;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 4px;
  z-index: 1004;
  display: none;
  background: #FF3B30;
  color: #FFFFFF;
  cursor: pointer;
}
#loading {
  position: fixed;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 4px;
  z-index: 1004;
  display: none;
  background: #007AFF;
  color: #FFFFFF;
}
#progress-bar {
  position: fixed;
  top: 140px;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 20px;
  background: #E0E0E0;
  border-radius: 10px;
  overflow: hidden;
  display: none;
  z-index: 1004;
}
#progress-fill {
  height: 100%;
  background: #007AFF;
  width: 0;
  transition: width 0.3s ease;
}
@media (max-width: 1024px) {
  .heatmap-tile .symbol { font-size: 5.6px; } /* Уменьшено для minTileSizeMobile = 24 */
  .heatmap-tile .change, .heatmap-tile .price { font-size: 6.8px; } /* Уменьшено для minTileSizeMobile = 24 */
  .list-header .symbol, .list-header .price, .list-header .change, .list-header .change-30d, .list-header .volume,
  .list-item .symbol, .list-item .price, .list-item .change, .list-item .change-30d, .list-item .volume { font-size: 10px; }
  #heatmap-container.collapsed {
    margin-left: 0;
    padding-left: 0;
    width: 100vw;
    box-sizing: border-box;
  }
  #heatmap-grid.collapsed {
    margin-left: 0;
    padding-left: 0;
    width: 100vw;
    height: auto;
    overflow-y: auto;
    touch-action: pan-y; /* Разрешить прокрутку по оси Y */
    box-sizing: border-box;
  }
  #heatmap-container:not(.collapsed) {
    width: 100vw;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: hidden;
    box-sizing: border-box;
  }
  #heatmap-grid:not(.collapsed) {
    width: 100vw;
    margin: 0;
    padding: 0;
    height: calc(100vh - 60px);
    overflow-x: hidden;
    overflow-y: hidden;
    box-sizing: border-box;
  }
  #heatmap-tooltip {
    pointer-events: none; /* Тултип не перехватывает события касания */
    font-size: 12px; /* Уменьшено для мобильных */
    left: 10px; /* Ближе к краю */
    top: 50px;
  }
}
@media (min-width: 1025px) {
  .list-header .symbol, .list-header .price, .list-header .change, .list-header .change-30d, .list-header .volume,
  .list-item .symbol, .list-item .price, .list-item .change, .list-item .change-30d, .list-item .volume { font-size: 12px; }
}
@media (max-width: 400px) {
  #controls { left: 5px; }
  #symbol-dropdown { left: 130px; width: 100px; }
  #symbol-input { width: 100px; }
  #collapse-heatmap { width: 30px; padding: 4px; }
  #heatmap-tooltip { left: 5px; top: 40px; }
}
@keyframes glow {
  0% { box-shadow: 0 0 12px 3px #00CED1; }
  50% { box-shadow: 0 0 16px 4px #00CED1; }
  100% { box-shadow: 0 0 12px 3px #00CED1; }
}
.heatmap-tile.highlighted {
  animation: glow 1.5s infinite;
}