[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Command-Palette Style Omnibox Search */
.portal-search {
  margin: 0 0 28px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.portal-search form {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.portal-game-label {
  display: flex;
  align-items: center;
  font-size: 0;
  color: transparent;
  margin: 0;
}

.portal-search select,
.portal-query input {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  padding: 0 12px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.portal-search select {
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  min-width: 128px;
}

.portal-search select:focus,
.portal-query input:focus {
  background: var(--card);
  border-color: var(--accent);
}

.portal-query {
  position: relative;
  flex: 1;
  min-width: 0;
}

.portal-query input {
  width: 100%;
  font-size: 0.92rem;
}

.portal-search form > button {
  height: 44px;
  padding: 0 20px;
  background: var(--accent);
  color: #ffffff;
  border: 0;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease;
}

@media (prefers-color-scheme: dark) {
  .portal-search form > button {
    color: #0d1310;
  }
}

.portal-search form > button:hover {
  background: var(--accent-hover);
}

.portal-search-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.76rem;
}

.portal-search-meta p {
  margin: 0;
}

.portal-search-meta kbd {
  padding: 2px 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  white-space: nowrap;
}

.portal-examples {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 0.76rem;
  color: var(--muted);
}

.portal-examples span {
  font-weight: 600;
  margin-right: 2px;
}

.portal-examples button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 3px 10px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.76rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.portal-examples button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

#portal-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 60;
  list-style: none;
  margin: 0;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  max-height: min(440px, 65vh);
  overflow: auto;
}

#portal-results a {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--text);
  padding: 8px 10px;
  text-decoration: none;
  border-radius: var(--radius-sm);
}

#portal-results a:hover,
#portal-results [aria-selected="true"] a {
  background: var(--surface);
}

#portal-results img {
  object-fit: contain;
  flex: none;
  border-radius: 6px;
  background: var(--surface);
}

#portal-results span {
  min-width: 0;
}

#portal-results strong {
  display: block;
  font-size: 0.88rem;
}

#portal-results small {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

#portal-fallback {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.8rem;
  margin-top: 10px;
}

#portal-fallback a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

#portal-fallback a:hover {
  text-decoration: underline;
}

/* Dashboard Game Cards */
.portal-games {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.portal-game {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.portal-game:not(.portal-game--soon):hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}

.portal-game > .status {
  position: absolute;
  top: 16px;
  right: 16px;
}

.portal-game .game-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding-right: 68px;
}

.portal-game .game-title img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex: none;
  border-radius: 8px;
}

.portal-game .game-name {
  margin: 0;
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.2;
}

.portal-game .game-title h3 {
  margin: 2px 0 0;
  font-size: 1.2rem;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.portal-game .game-description {
  margin: 12px 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
  word-break: keep-all;
}

.portal-counts {
  margin: auto 0 12px;
  padding: 9px 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  line-height: 1.45;
}

.portal-counts strong {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
}

.portal-counts small {
  display: block;
  margin-top: 2px;
  font-size: 0.73rem;
  color: var(--muted);
}

.portal-game .primary-link {
  width: 100%;
}

.portal-shortcuts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.portal-shortcuts a {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.portal-shortcuts a:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.portal-game--soon {
  background: var(--surface);
  border-style: dashed;
}

.portal-unavailable {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 9px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
}

.soon-details {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  padding: 5px 0;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.soon-details:hover {
  text-decoration: underline;
}

/* Segmented Filter Tabs */
.portal-tabs {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
  margin: 4px 0 20px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.portal-tabs button {
  padding: 7px 16px;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 7px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.portal-tabs button:hover {
  color: var(--text);
}

.portal-tabs [aria-selected="true"] {
  background: var(--card);
  color: var(--accent);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

/* Dashboard Tool Cards */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.tool-card {
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tool-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.tool-category {
  align-self: flex-start;
  padding: 2px 8px;
  background: var(--surface);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
}

.tool-card h3 {
  margin: 8px 0 4px;
  font-size: 0.98rem;
  letter-spacing: -0.02em;
  word-break: keep-all;
}

.tool-card h3 a {
  color: var(--text);
  text-decoration: none;
}

.tool-card h3 a:hover {
  color: var(--accent);
}

.tool-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
  word-break: keep-all;
}

.tool-card .tool-scope {
  margin-top: auto;
  padding-top: 10px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
}

/* Starter Roadmap Cards */
.starter-games {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.starter-games > section {
  display: flex;
  flex-direction: column;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.starter-games h3 {
  margin: 0 0 12px;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.starter-games .guide-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.starter-games .guide-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.starter-games .guide-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 26px;
  height: 26px;
  margin-top: 1px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 6px;
  font: 700 0.75rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.starter-games .guide-list article {
  min-width: 0;
  flex: 1;
}

.starter-games h4 {
  margin: 0 0 3px;
  font-size: 0.9rem;
  line-height: 1.35;
}

.starter-games h4 a {
  color: var(--text);
  text-decoration: none;
}

.starter-games h4 a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.starter-games .guide-list article p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
  word-break: keep-all;
}

.starter-games .guide-list article > a {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.starter-games .guide-list article > a:hover {
  text-decoration: underline;
}

.starter-games > section > a {
  display: inline-flex;
  align-items: center;
  margin-top: 12px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}

.starter-games > section > a:hover {
  text-decoration: underline;
}

@media (max-width: 960px) {
  .portal-games,
  .tool-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .portal-games,
  .tool-grid,
  .starter-games {
    grid-template-columns: minmax(0, 1fr);
  }
  .portal-search {
    padding: 12px;
  }
  .portal-search form {
    flex-wrap: wrap;
  }
  .portal-game-label {
    width: 100%;
  }
  .portal-search select {
    width: 100%;
    height: 40px;
  }
  .portal-query input {
    height: 42px;
    font-size: 16px;
  }
  .portal-search form > button {
    height: 42px;
    padding: 0 16px;
  }
  .portal-search-meta kbd {
    display: none;
  }
  .portal-tabs {
    display: flex;
    width: 100%;
  }
  .portal-tabs button {
    flex: 1 1 auto;
    padding: 7px 8px;
    font-size: 0.8rem;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
