:root {
  --page-bg: #f8f8f8;
  --card-bg: #ffffff;
  --border-color: #d8d8d8;
  --border-strong: #444444;
  --text-color: #111111;
  --link-color: #184b9b;
  --button-bg: #f3f3f3;
  --button-primary-bg: #f8f085;
  --tab-active-bg: #cfdcff;
  --row-highlight: #fff4bf;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  --radius: 0;
}

html {
  overflow-y: scroll;
}

body {
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  background: var(--page-bg);
  color: var(--text-color);
}

a {
  color: var(--link-color);
}

.page-shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 0;
}

.center-panel {
  text-align: center;
}

.home-panel,
.launch-page,
.board-page {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.site-home,
.site-leaderboard-index {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  text-align: center;
}

.site-home h1,
.site-home h2,
.site-leaderboard-index h1,
.site-leaderboard-index h2,
.page-header h1 {
  margin: 0;
}

.site-home p,
.site-leaderboard-index p {
  margin: 0.8rem 0;
}

.leaderboard-card-simple {
  border: none;
  margin-top: 16px;
  box-shadow: none;
}

.mascot img,
.blinkie-link img {
  image-rendering: pixelated;
}

.leaderboard-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 24px auto;
  padding: 16px;
  border: 1px dashed #bcbcbc;
  max-width: 640px;
  text-align: left;
}

.leaderboard-entry-page {
  display: grid;
  gap: 16px;
  min-height: 180px;
}

.blinkie-grid {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.blinkie-grid .game-blinkie {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.blinkie-grid img {
  image-rendering: pixelated;
}

.page-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.page-nav-center {
  justify-content: center;
}

.page-nav-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.page-nav-group:last-child:not(:first-child) {
  margin-left: auto;
}

.page-header {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  height: 93px;
  overflow: hidden;
}

.page-header-center {
  text-align: center;
}

.page-header p {
  margin: 0;
}

.launch-form {
  max-width: 520px;
  margin: 24px auto 0;
  display: grid;
  gap: 12px;
  text-align: left;
  justify-items: center;
}

.launch-form input[type="text"],
.picker-form select {
  padding: 10px 12px;
  font-size: 1rem;
  min-height: 42px;
  box-sizing: border-box;
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: #fff;
}

.launch-form input[type="text"] {
  width: 18ch;
  max-width: 18ch;
}

.launch-field-row {
  display: grid;
  grid-template-columns: max-content max-content;
  gap: 12px;
  align-items: center;
}

.launch-field-label {
  display: grid;
  gap: 2px;
}

.launch-form label,
.picker-form label {
  font-size: 0.95rem;
  font-weight: bold;
}

.field-hint {
  color: #555;
  font-weight: normal;
  font-size: 0.9rem;
}

.launch-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  width: 100%;
}

button,
.primary-button,
.secondary-button,
.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--button-bg);
  color: var(--text-color);
  padding: 10px 14px;
  text-decoration: none;
  cursor: pointer;
  min-height: 42px;
  box-sizing: border-box;
  font: inherit;
  font-size: 1rem;
  line-height: 1.2;
  text-align: center;
}

button:hover,
.primary-button:hover,
.secondary-button:hover,
.tab:hover {
  filter: brightness(0.98);
}

.primary-button,
.play-button {
  background: var(--button-primary-bg);
  font-weight: bold;
}

.disabled-button {
  background: #e6e6e6;
  color: #666;
  border-color: #999;
  cursor: not-allowed;
  pointer-events: none;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
  align-items: center;
}

.tab-align-right {
}

.tab-active {
  background: var(--tab-active-bg);
  font-weight: bold;
}

.tabs-group-right {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-left: auto;
  justify-content: flex-end;
  min-height: 42px;
}

.picker-form {
  display: inline-flex;
  align-items: center;
  gap: 0;
  margin: 16px 0;
  flex-wrap: nowrap;
  max-width: 100%;
}

.picker-placeholder {
  width: 220px;
  max-width: 220px;
  flex: 0 0 220px;
  min-height: 42px;
}

.tabs-picker {
  margin: 0;
}

.picker-form select {
  height: 42px;
  min-height: 42px;
  width: 220px;
  max-width: 220px;
  min-width: 0;
  flex: 0 1 220px;
  line-height: 1.2;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-color) 50%),
    linear-gradient(135deg, var(--text-color) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.sort-link {
  color: inherit;
  text-decoration: none;
}

.sort-link:hover,
.sort-link-active {
  text-decoration: underline;
}

.score-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}

.score-table th,
.score-table td {
  border: 1px solid var(--border-color);
  padding: 10px;
  text-align: left;
  vertical-align: middle;
}

.score-table th {
  background: #efefef;
}

.suspicious-row {
  background: var(--row-highlight);
}

.suspicious-row.creator-row {
  background:
    repeating-linear-gradient(
      135deg,
      #e6ffe6 0 12px,
      #fff4bf 12px 24px
    );
}

.creator-row {
  background: #e6ffe6;
  font-weight: bold;
}

.challenge-code code {
  font-size: 0.95rem;
}

.grid-code {
  font-size: 0.95rem;
}

.grid-code span {
  display: block;
  line-height: 1;
}

.compact-button {
  min-height: 0;
  padding: 2px 8px;
  font-size: 0.92rem;
  line-height: 1.1;
}

.score-table td:has(.compact-button) {
  padding: 0;
  border: none;
  position: relative;
}

.score-table td:has(.compact-button) .compact-button {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 8px;
  margin: 0;
  box-sizing: border-box;
  border: 1px solid var(--border-strong);
  text-align: center;
  font-size: 0.92rem;
  line-height: 1.4;
}

.error-message {
  color: #a60000;
  font-weight: bold;
}

.game-page {
  background: #f8f8f8;
}

.game-page-shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

.game-frame {
  background: #fff;
  border: 1px solid #ddd;
  padding: 16px;
  text-align: center;
}

#canvas {
  visibility: hidden;
}

.game-footer {
  text-align: center;
  padding: 16px;
}

@media (max-width: 700px) {
  .page-header {
    height: 190px;
  }

  .page-nav-group,
  .launch-actions {
    justify-content: stretch;
  }

  .leaderboard-card {
    flex-direction: column;
    text-align: center;
  }

  .picker-form select {
    width: 100%;
    max-width: 100%;
    flex-basis: 100%;
  }

  .picker-form {
    width: 100%;
  }

  .tabs-group-right {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }

  .picker-placeholder {
    display: none;
  }

  .tabs-picker {
    flex: 1 1 220px;
    width: auto;
  }

  .tabs-picker select {
    width: 100%;
    max-width: 100%;
    flex-basis: auto;
  }

  .launch-form input[type="text"] {
    width: 100%;
    max-width: 100%;
  }

  .launch-field-row {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .launch-field-row {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .tab-align-right {
    position: static;
    margin-left: auto;
  }

  .score-table {
    font-size: 0.92rem;
  }
}
