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

html, body {
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Rounded', system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

/* Counter columns */

#app {
  display: flex;
  height: 100%;
  width: 100%;
}

.column {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-width: 0;
}

.tap-zone {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tap-zone:active {
  filter: brightness(1.15);
}

.column-content {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  width: 100%;
  display: flex;
  justify-content: center;
}

.column-meta {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 6px;
  width: 100%;
}

.count-display {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(4.5rem, 20vw, 12rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.02em;
}

.column-symbol {
  width: clamp(28px, 7vw, 52px);
  height: clamp(28px, 7vw, 52px);
  opacity: 0.5;
}

.column-symbol.with-backdrop {
  background: rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  padding: 5px;
  box-sizing: border-box;
  opacity: 0.85;
}

.column-name {
  margin-top: 4px;
  font-size: clamp(0.65rem, 1.4vw, 0.9rem);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
  text-align: center;
  max-width: 100%;
  padding: 0 2px;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: auto;
  line-height: 1.15;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty-state {
  color: #666;
  text-align: center;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.9rem;
}

/* Profiles page */

.profiles-page {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  background: #000;
  flex-direction: column;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
            max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  color: #fff;
}

.profiles-page.open {
  display: flex;
}

body.profiles-open .controls {
  display: none;
}

.profiles-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  flex-shrink: 0;
}

.profiles-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.profiles-done {
  background: none;
  border: none;
  color: #0a84ff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.profiles-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.profile-item {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid #2c2c2e;
}

.profile-item-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  color: #ccc;
  font-size: 1rem;
  cursor: pointer;
  background: #000;
  position: relative;
  z-index: 1;
  transition: transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.profile-item.active .profile-item-content {
  color: #fff;
  background: #1c1c1e;
}

.profile-item-content:active {
  background: #2c2c2e;
}

.profile-item-check {
  color: #0a84ff;
  font-weight: 600;
}

.profile-item-delete {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 70px;
  background: #ff453a;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 0;
}

.profile-item-delete svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

.profiles-add {
  margin: 12px 0;
  padding: 12px;
  background: #1c1c1e;
  border: none;
  border-radius: 10px;
  color: #0a84ff;
  font-size: 1.3rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.profiles-add:active {
  background: #2c2c2e;
}

/* Control buttons */

.controls {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
  z-index: 10;
}

.ctrl-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.ctrl-btn:active {
  background: rgba(0, 0, 0, 0.7);
}

/* Help overlay */

.help-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 20;
  align-items: center;
  justify-content: center;
}

.help-overlay.open {
  display: flex;
}

.help-panel {
  background: #1c1c1e;
  border-radius: 12px;
  padding: 20px 24px;
  max-width: 340px;
  color: #ccc;
  font-size: 0.9rem;
  line-height: 1.5;
}

.help-panel ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.help-panel strong {
  color: #fff;
}

/* Settings overlay */

.settings-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 20;
  align-items: center;
  justify-content: center;
}

.settings-overlay.open {
  display: flex;
}

.settings-panel {
  background: #1c1c1e;
  border-radius: 12px;
  padding: 20px;
  width: 90vw;
  height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #fff;
}

.settings-body {
  display: flex;
  flex: 1;
  gap: 20px;
  min-height: 0;
}

.settings-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.settings-col-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.settings-col-form {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-left: 1px solid #2c2c2e;
  padding-left: 20px;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.settings-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.settings-done {
  background: none;
  border: none;
  color: #0a84ff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #2c2c2e;
}

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

.drag-handle {
  color: #888;
  font-size: 1.3rem;
  line-height: 1;
  cursor: grab;
  padding: 8px 6px;
  flex-shrink: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.settings-row.dragging {
  opacity: 0.6;
  background: #2c2c2e;
  border-radius: 6px;
}

body.dragging-active {
  overflow: hidden;
}

body.dragging-active .settings-col-list {
  overflow: hidden;
}

.color-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.settings-row label {
  flex: 1;
  font-size: 0.95rem;
}

.toggle {
  appearance: none;
  -webkit-appearance: none;
  width: 44px;
  height: 26px;
  background: #39393d;
  border-radius: 13px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle:checked {
  background: #30d158;
}

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle:checked::after {
  transform: translateX(18px);
}

.row-delete {
  background: none;
  border: none;
  color: #ff453a;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 6px;
  flex-shrink: 0;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-form input[type="text"] {
  background: #2c2c2e;
  border: 1px solid #3a3a3c;
  border-radius: 8px;
  padding: 10px;
  color: #fff;
  font-size: 0.95rem;
}

.settings-form input[type="text"]:focus {
  outline: none;
  border-color: #0a84ff;
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.form-row label,
.form-label {
  font-size: 0.9rem;
  color: #ccc;
}

.form-row input[type="color"] {
  width: 44px;
  height: 30px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.symbol-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 32px);
  gap: 6px;
  justify-content: start;
}

.symbol-cell {
  width: 32px;
  height: 32px;
  background: #e8e8e8;
  border: 2px solid transparent;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 4px;
  overflow: hidden;
  box-sizing: border-box;
}

.symbol-cell img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.symbol-cell.selected {
  border-color: #0a84ff;
  box-shadow: 0 0 0 2px rgba(10, 132, 255, 0.4);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.form-save {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  background: #0a84ff;
  color: #fff;
}
