body { margin: 20px auto; max-width: 450px; line-height: 1.6; font-size: 18px; color: #444; padding: 0 10px; }
h1, h2, h3 {line-height: 1.2;}
textarea {width: 100%;min-height: 150px;}
a, input, textarea, button { touch-action: manipulation; }
button {
  border: solid 1px #ccc;
  padding: 6px 14px;
  border-radius: 6px;
  background: linear-gradient(to bottom, #fafafa, #ededed);
  color: #444;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
button:hover {
  background: linear-gradient(to bottom, #f0f0f0, #e2e2e2);
  border-color: #b8b8b8;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
button:active {
  background: linear-gradient(to bottom, #e4e4e4, #d8d8d8);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
  transform: translateY(0.5px);
}
.help { font-style: italic; padding-left: 5px; padding-right: 5px; white-space: pre-line; }
.menu { position: fixed; top: 0; right: 10px; background: transparent; padding: 5px; z-index: 100; }
.menu button + button { margin-left: 5px; }
.menu button {
  background: linear-gradient(to bottom, #4a90d9, #3a7bc8);
  color: #fff;
  border: 1px solid #2e6ab4;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(58,123,200,0.3);
}
.menu button:hover {
  background: linear-gradient(to bottom, #5a9ee6, #4a8bd6);
  border-color: #2e6ab4;
  box-shadow: 0 3px 8px rgba(58,123,200,0.4);
}
.menu button:active {
  background: linear-gradient(to bottom, #3578be, #2c6aab);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
  transform: translateY(0.5px);
}
.summary, .help {font-size: 0.875rem;}
.input-row, textarea {min-width: 200px;}
.input-row {display: flex; flex-direction: row; align-items: stretch;}
.input-row label, .input-row button {flex: 0 0 auto;}
.input-row label {display: flex; align-items: center;}
.input-row * + input, .input-row * + button {margin-left: 5px;}
.input-row button {
  background: linear-gradient(to bottom, #5b9f5b, #4a8e4a);
  color: #fff;
  border: 1px solid #3d7a3d;
  font-weight: 600;
  border-radius: 6px;
  padding: 6px 14px;
  box-shadow: 0 1px 3px rgba(74,142,74,0.25);
}
.input-row button:hover {
  background: linear-gradient(to bottom, #69ad69, #559a55);
  border-color: #3d7a3d;
  box-shadow: 0 2px 5px rgba(74,142,74,0.35);
}
.input-row button:active {
  background: linear-gradient(to bottom, #448a44, #3a7a3a);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
  transform: translateY(0.5px);
}
.input-row input {flex: 1 1 auto;min-width: 0;}
.hidden {display: none;visibility: hidden;}
.result, .game { padding: 5px; border-radius: 4px; }
.game { border: dotted 2px transparent; }
.game.count-winner { border-color: green; }
.game.count-winner.competitive { border-style: solid; }
.result-wrapper, .leaderboard-wrapper { position: relative; padding: 5px; border-radius: 4px; overflow: hidden; }
.result, .leaderboard { display: flex; flex-flow: column; }
.result div { margin-right: auto; }
.result.copyable div { cursor: pointer; }
.results-area { display: flex; flex-direction: column; gap: 5px; }
.results { display: flex; flex-flow: row wrap; align-items: flex-start; }
.leaderboard { width: 100px; }
.leaderboard-container {
  background-color: #e0e0e0; padding: 5px; border-radius: 4px;
  display: flex; flex-direction: column; align-items: center; width: 170px; margin: auto;
  position: relative;
}
.leaderboard-container.hidden {
  display: none;
  margin: 0;
}
.leaderboard-container.hidden-preserve-space {
  visibility: hidden;
}
.leaderboard-comments { position: absolute; top: 1px; right: 3px; }
.leaderboard-list { display: flex; flex-direction: row; }
.leaderboard-list .crown { padding: 5px; }
.leaderboard-wrapper, .game-header > div { display: flex; flex-direction: row; justify-content: space-between; }
.results-dialog { display: flex; flex-direction: column; }
.results-dialog > div:first-child { flex: 0 0 auto; }
.results-dialog > pre { flex: 1 1 auto; padding: 5px; border: solid 1px #444; border-radius: 4px; }

.dialog-overlay { position: fixed; top: 0; left: 0; background: #0006; height: 100vh; width: 100vw; display: flex; align-items: center; justify-content: flex-start; flex-direction: column; padding-top: 5vh; z-index: 200; }
.dialog { width: 425px; max-width: 90vw; height: 600px; max-height: 70vh; background: white; border-radius: 4px; display: flex; flex-direction: column; pointer-events: initial; }
.dialog h4 { margin: 0; }
.dialog-header, .dialog-footer, .dialog-body { margin: 5px; padding: 5px; }
.dialog-header { flex: 0 0 auto; display: flex; flex-direction: row; justify-content: space-between; border-bottom: 1px solid #444; }
.dialog-footer { flex: 0 0 auto; border-top: 1px solid #444; display: flex; justify-content: flex-end; }
.dialog-footer > * + * { margin-left: 10px; }
.dialog-body { flex: 1 1 100%; overflow-y: auto; }

.winner-border {
  position: absolute; display: block; overflow: hidden;
  top: -150%; left: -100%; z-index: -9; height: 400%; width: 300%;
  background: linear-gradient(to right, #fff 20%, #fff 40%, #ECD08C 50%, #ECD08C 55%, #fff 70%, #fff 100%);
  transform: rotate(-45deg); background-size: 200% auto; animation: shine 3s linear infinite;
}

.group-info-area { display: flex; justify-content: space-between; gap: 4px; }

.settings-summary { display: flex; align-items: center; font-size: 0.875rem; flex: 1; justify-content: space-between; }
.settings-summary-spacer { width: 28px; } /* Matches gear button width for centering */
.settings-summary-content { display: flex; align-items: center; gap: 8px; justify-content: center; }
.setting-summary-item { white-space: nowrap; }
.setting-separator { opacity: 0.5; }
.settings-toggle { border: none; background: transparent; padding: 2px 5px; cursor: pointer; font-size: 0.875rem; width: 28px; }
.settings-toggle:hover { background-color: #0001; border-radius: 4px; }

.settings-card { 
  background-color: #e0e0e0; 
  padding: 10px; 
  border-radius: 4px; 
  margin: 10px auto; 
  width: 215px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}
.settings-card.expanded { max-height: 500px; }
.settings-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #444; padding-bottom: 5px; margin-bottom: 10px; }
.settings-header h4 { margin: 0; font-size: 0.875rem; }
.settings-header button { border: none; background: transparent; cursor: pointer; font-size: 0.875rem; padding: 0 5px; }
.settings-header button:hover { background-color: #0001; border-radius: 4px; }
.settings-body { display: flex; flex-direction: column; gap: 10px; }
.setting-row { display: flex; flex-direction: column; gap: 5px; }
.setting-label { font-weight: bold; font-size: 0.875rem; }
.setting-controls { display: flex; flex-direction: column; gap: 3px; font-size: 0.875rem; }
.setting-controls label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.setting-controls input[type="radio"] { cursor: pointer; }
.count-input { width: 30px; padding: 2px; border: 1px solid #999; border-radius: 2px; }
.sub-option { padding-left: 20px; font-size: 0.8rem; }
.sub-option.disabled { opacity: 0.4; pointer-events: none; }

/* Info button and tooltip */
.info-btn {
  all: unset;
  display: inline;
  color: #888;
  font-size: 0.8rem;
  cursor: pointer;
  margin-left: 2px;
  padding: 8px 6px;
  margin-top: -8px;
  margin-bottom: -8px;
  margin-right: -6px;
  vertical-align: baseline;
  -webkit-tap-highlight-color: transparent;
}
.info-btn:hover {
  color: #555;
}

.info-tooltip {
  position: fixed;
  background: #333;
  color: #fff;
  font-size: 0.75rem;
  font-style: normal;
  font-weight: normal;
  line-height: 1.4;
  padding: 8px 11px;
  border-radius: 6px;
  white-space: normal;
  width: 200px;
  z-index: 400;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
  pointer-events: none;
  animation: tooltip-fade-in 0.15s ease;
}
.info-tooltip::before {
  content: '';
  position: absolute;
  top: -6px;
  left: var(--arrow-left, 14px);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid #333;
}

@keyframes tooltip-fade-in {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Game selection mode */
.game-selectable {
  cursor: pointer;
  transition: opacity 0.2s ease, background-color 0.2s ease;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: #d4edda;
  border-color: #8bc49a !important;
  border-style: solid !important;
}
.game-selectable.game-deselected {
  opacity: 0.5;
  background-color: transparent;
  border-color: transparent !important;
  border-style: dotted !important;
}
.game-selectable a { pointer-events: none; color: inherit; text-decoration: none; }
.game-checkbox {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 1.1rem;
  line-height: 1;
  pointer-events: none;
}

/* Selection info box */
.selection-info {
  font-size: 0.8rem;
  font-style: italic;
  color: #555;
  text-align: center;
  padding: 6px 10px;
  background: #eef6ff;
  border: 1px solid #b8d4f0;
  border-radius: 4px;
}
.selection-info.hidden { display: none; }


.group-tabs {
  border-bottom: 2px solid #d0d0d0;
  margin-bottom: 18px;
  margin-top: 18px;
  padding-left: 4px;
  padding-right: 4px;
  display: flex;
  flex-flow: row;
  gap: 4px;
  position: relative;
}
.group-tabs.hidden { display: none; margin: 0; }
.group-tabs button {
  border-top-right-radius: 8px;
  border-top-left-radius: 8px;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border: 1px solid #d0d0d0;
  border-bottom: 2px solid #d0d0d0;
  background: linear-gradient(to bottom, #f8f8f8, #efefef);
  color: #777;
  padding: 8px 16px;
  font-weight: 500;
  box-shadow: none;
  position: relative;
  bottom: -2px;
  transition: all 0.15s ease;
}
.group-tabs button:hover {
  background: linear-gradient(to bottom, #fff, #f5f5f5);
  color: #444;
  border-color: #bbb;
  border-bottom-color: #d0d0d0;
  box-shadow: 0 -2px 4px rgba(0,0,0,0.05);
}
.group-tabs button:active {
  transform: none;
  box-shadow: none;
}
.group-tabs button.selected {
  background: #fff;
  color: #333;
  font-weight: 600;
  border-color: #d0d0d0;
  border-bottom-color: #fff;
  box-shadow: 0 -2px 6px rgba(0,0,0,0.06);
  position: relative;
  bottom: -2px;
}

.error { color: red; }

/* Infrastructure notice banner */
.notice-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  margin: 10px 0;
  background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
  border: 1px solid #ffc107;
  border-left: 4px solid #ff9800;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.notice-banner.hidden { display: none; }
.notice-icon { font-size: 1.25rem; flex-shrink: 0; }
.notice-text { flex: 1; font-size: 0.875rem; line-height: 1.4; color: #856404; }
.notice-text strong { color: #664d03; }
.notice-dismiss {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: #856404;
  cursor: pointer;
  padding: 2px 6px;
  font-size: 1rem;
  border-radius: 4px;
  min-height: auto;
}
.notice-dismiss:hover { background: rgba(0,0,0,0.1); }

@keyframes shine { to { background-position: 200% center; } }

/* Loading states */
.loading-text {
  display: inline-block;
  background: linear-gradient(90deg, #444 25%, #888 50%, #444 75%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: loading-shimmer 1.5s infinite;
}

.results-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  color: #666;
  font-style: italic;
}

.results-loading.hidden {
  display: none;
}

.loading-hidden {
  display: none !important;
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e0e0e0;
  border-top-color: #666;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

@keyframes loading-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Mobile-specific touch improvements */
@media (max-width: 768px) {
  button { padding: 8px 14px; min-height: 44px; }
  .info-btn { padding: 10px 8px; margin-top: -10px; margin-bottom: -10px; min-height: unset; }
  .group-tabs button { padding: 10px 18px; min-height: 44px; }
  .menu { top: calc(100dvh - 60px); right: 10px; }
  .menu button { padding: 10px 18px; border-radius: 10px; }
}
