/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: #1a1a2e;
  color: #eee;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* === Header === */
#app-header {
  text-align: center;
  padding: 2rem 1rem 1rem;
}

#app-header h1 {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

#app-header h1 a {
  color: inherit;
  text-decoration: none;
}

#app-header .subtitle {
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.25rem;
  letter-spacing: 0.06em;
}

/* === Home Screen === */
#home {
  max-width: 420px;
  margin: 0 auto;
  padding: 0.5rem 1rem 1rem;
}

.home-card {
  display: block;
  position: relative;
  background: #1e2d4a;
  border-radius: 10px;
  padding: 1.25rem 1.25rem 1.25rem 1.5rem;
  margin-bottom: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  color: #eee;
  border-left: 4px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.home-card--lookup  { border-left-color: #4ea8de; }
.home-card--challenge { border-left-color: #4ecca3; }

.home-card:hover {
  transform: scale(1.02);
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.08);
}

.home-card h2 {
  font-size: 1.2rem;
  margin-bottom: 0.3rem;
}

.home-card p {
  font-size: 0.85rem;
  color: #aaa;
}

.home-card-date {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  font-size: 0.7rem;
  color: #aaa;
}

.home-credit {
  text-align: center;
  font-size: 0.7rem;
  color: #555;
  margin-top: 1.5rem;
}

.home-credit a {
  color: #888;
  text-decoration: none;
}

.home-credit a:hover {
  color: #4ea8de;
  text-decoration: underline;
}

.install-btn {
  display: block;
  margin: 1rem auto 0;
  padding: 0.6rem 1.5rem;
  font-size: 0.85rem;
  font-family: inherit;
  color: #eee;
  background: transparent;
  border: 1.5px solid #4ea8de;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.install-btn:hover {
  background: rgba(78, 168, 222, 0.15);
}

.home-version {
  text-align: center;
  font-size: 0.6rem;
  color: #444;
  margin-top: 1rem;
}

/* === Character Select Grid === */
#character-select {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  padding: 0.75rem;
  max-width: 400px;
  margin: 0 auto;
}

@media (min-width: 600px) {
  #character-select {
    grid-template-columns: repeat(7, 1fr);
    max-width: 500px;
  }
}

@media (min-width: 900px) {
  #character-select {
    grid-template-columns: repeat(10, 1fr);
    max-width: 700px;
  }
}

/* Desktop move card refinements */
@media (min-width: 769px) {
  .move-card {
    padding: 0.75rem 1rem;
  }

  .mc-stats {
    gap: 0.5rem;
  }

  .mc-stat {
    flex-direction: row;
    gap: 0.35rem;
    justify-content: center;
  }

  .mc-stat-label {
    margin-bottom: 0;
  }
}

/* === Avatar Card === */
.avatar-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  min-width: 44px;
  min-height: 44px;
  padding: 0.2rem;
  border-radius: 10px;
}

.avatar-card:active {
  background: rgba(255, 255, 255, 0.06);
}

.avatar-card img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.avatar-card:hover img,
.avatar-card:focus img {
  transform: scale(1.06);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.15);
}

.avatar-card .name {
  margin-top: 0.3rem;
  font-size: 0.65rem;
  text-align: center;
  color: #ccc;
  line-height: 1.2;
}

/* === Move List Screen === */
#move-list {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

.ml-loading {
  text-align: center;
  color: #888;
  padding: 2rem 0;
}

/* Header */
.ml-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0 0.75rem;
  position: sticky;
  top: 0;
  background: #1a1a2e;
  z-index: 10;
}

.ml-back {
  color: #eee;
  text-decoration: none;
  font-size: 1.4rem;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  flex-shrink: 0;
}

.ml-back:hover,
.ml-back:active {
  color: #4ecca3;
  background: rgba(255, 255, 255, 0.06);
}

.ml-portrait {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.ml-char-name {
  font-size: 1.1rem;
  font-weight: 700;
}

/* Search input */
.ml-search-wrap {
  position: sticky;
  top: 52px;
  background: #1a1a2e;
  z-index: 9;
  padding: 0.25rem 0 0.5rem;
}

#search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 16px; /* Minimum 16px prevents iOS auto-zoom on focus */
  background: #0f1525;
  color: #eee;
  border: 1px solid #333;
  border-radius: 8px;
  outline: none;
}

#search-input:focus {
  border-color: #4ea8de;
}

#search-input::placeholder {
  color: #555;
}

/* Category sections */
.ml-category {
  margin-top: 1.25rem;
}

.ml-cat-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid #ffffff12;
}

/* Move Card */
.move-card {
  position: relative;
  background: #1e2d4a;
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.5rem;
}

.mc-share-btn {
  position: absolute;
  bottom: 0.4rem;
  right: 0.5rem;
  border: none;
  background: none;
  color: #555;
  font-size: 0.7rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.mc-share-btn:hover {
  color: #4ea8de;
}

.mc-category-tag {
  font-size: 0.65rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.mc-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.mc-command {
  font-family: "Courier New", Consolas, monospace;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

.mc-level {
  font-size: 0.7rem;
  font-weight: 700;
  color: #ccc;
  white-space: nowrap;
  flex-shrink: 0;
}

.mc-name {
  font-size: 0.75rem;
  color: #aaa;
  margin-top: 0.15rem;
}

/* Stats row */
.mc-stats {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.5rem;
}

.mc-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.mc-stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: #999;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.mc-stat-value {
  font-family: "Courier New", Consolas, monospace;
  font-size: 1.05rem;
  font-weight: 700;
  color: #ccc;
  line-height: 1;
}

.mc-stats-optional {
  margin-top: 0.25rem;
  padding-top: 0.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.mc-stats-optional .mc-stat-value {
  font-size: 0.9rem;
  font-weight: 600;
}

.mc-stats-optional .mc-stat-label {
  font-size: 0.6rem;
  text-transform: none;
}

/* Multi-hit sub-rows */
.mc-hit-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mc-hit-marker {
  font-size: 0.85rem;
  color: #666;
  flex-shrink: 0;
  width: 1.2em;
  text-align: center;
}

/* Notes */
.mc-notes {
  font-size: 0.7rem;
  color: #888;
  margin-top: 0.4rem;
  padding-top: 0.3rem;
  border-top: 1px solid #ffffff0d;
}

/* === Challenge Quiz === */
#challenge {
  max-width: 500px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

.cq-difficulty {
  display: flex;
  justify-content: center;
  gap: 0;
  margin-bottom: 0.5rem;
}

.cq-diff-btn {
  padding: 0.4rem 1.2rem;
  font-size: 0.8rem;
  font-family: inherit;
  color: #888;
  background: transparent;
  border: 1px solid #333;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.cq-diff-btn:first-child {
  border-radius: 6px 0 0 6px;
}

.cq-diff-btn:last-child {
  border-radius: 0 6px 6px 0;
  border-left: none;
}

.cq-diff-active {
  background: #4ea8de;
  color: #fff;
  border-color: #4ea8de;
}

.cq-diff-btn:last-child.cq-diff-active {
  border-left: 1px solid #4ea8de;
}

.cq-container {
  padding: 1rem 0;
}

.cq-progress {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 1rem;
  text-align: center;
}

.cq-char-name {
  font-size: 1rem;
  color: #ccc;
  text-align: center;
  margin-bottom: 0.5rem;
}

.cq-char-name strong {
  color: #eee;
}

.cq-command {
  font-family: "Courier New", Consolas, monospace;
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
  text-align: center;
  background: #1e2d4a;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.35rem;
}

.cq-move-name {
  font-size: 0.85rem;
  color: #aaa;
  text-align: center;
  margin-bottom: 0.75rem;
}

.cq-property {
  position: relative;
  font-size: 1.1rem;
  font-weight: 600;
  color: #4ea8de;
  text-align: center;
  margin-bottom: 1rem;
  min-height: 1.6em;
}

.cq-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cq-btn {
  display: block;
  position: relative;
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  color: #eee;
  border: 1.5px solid;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
  text-align: left;
}

.cq-btn-hint {
  font-size: 0.75rem;
  color: #999;
  margin-left: 0.4rem;
}

.cq-marker {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.2rem;
  font-weight: 700;
}

.cq-marker-correct {
  color: #4ecca3;
}

.cq-marker-wrong {
  color: #e84545;
}

.cq-btn:hover:not(:disabled) {
  transform: scale(1.02);
}

.cq-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.cq-actual-value {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-family: "Courier New", Consolas, monospace;
  font-size: 1.3rem;
  font-weight: 700;
  visibility: hidden;
}

.cq-actual-value:not(:empty) {
  visibility: visible;
}

/* Question Navigation */
.cq-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 0.75rem;
}

.cq-nav-btn {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-family: inherit;
  color: #aaa;
  background: transparent;
  border: 1px solid #333;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.cq-nav-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #eee;
}

.cq-nav-results {
  color: #4ecca3;
  border-color: #4ecca3;
}

.cq-nav-results:hover {
  background: rgba(78, 204, 163, 0.15);
}

/* Results */
.cq-score {
  font-size: 3rem;
  font-weight: 700;
  text-align: center;
  margin-top: 1rem;
  line-height: 1.1;
}

.cq-result-date {
  text-align: center;
  font-size: 0.85rem;
  color: #aaa;
  margin-bottom: 0.5rem;
}

.cq-score-label {
  text-align: center;
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 0.75rem;
}

.cq-share-result-btn {
  display: block;
  margin: 0 auto 1.5rem;
  padding: 0.5rem 1.5rem;
  font-size: 0.85rem;
  font-family: inherit;
  color: #4ea8de;
  background: transparent;
  border: 1px solid #4ea8de;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.cq-share-result-btn:hover {
  background: rgba(78, 168, 222, 0.15);
}

.cq-review-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.cq-review-item {
  background: #1e2d4a;
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
}

.cq-review-top {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.cq-review-num {
  color: #666;
  font-size: 0.8rem;
  min-width: 1.5em;
}

.cq-review-char {
  color: #ccc;
  font-weight: 600;
}

.cq-review-detail {
  font-family: "Courier New", Consolas, monospace;
  font-size: 0.75rem;
  color: #888;
  margin-top: 0.2rem;
  padding-left: 1.9em;
}

.cq-review-answer {
  font-size: 0.8rem;
  margin-top: 0.15rem;
  padding-left: 1.9em;
}

.cq-review-correct {
  color: #4ecca3;
  font-weight: 600;
}

.cq-review-wrong {
  color: #e84545;
  font-weight: 600;
}

.cq-back-btn {
  display: block;
  text-align: center;
  background: #1e2d4a;
  color: #eee;
  text-decoration: none;
  padding: 0.85rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  transition: background 0.15s ease;
}

.cq-back-btn:hover {
  background: #1a2744;
}

/* === Guide Page === */
.guide-content {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

.guide-content h3 {
  font-size: 1rem;
  color: #4ea8de;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.guide-content p {
  color: #ccc;
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.guide-content p strong {
  color: #eee;
}

.guide-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

.guide-table td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid #2a3a5c;
  color: #ccc;
}

.guide-table td:first-child {
  color: #eee;
  font-weight: 600;
  white-space: nowrap;
}

.guide-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  border-radius: 4px;
  padding: 2px 6px;
  white-space: nowrap;
}

.guide-frame {
  font-family: "Courier New", Consolas, monospace;
  font-weight: 700;
}

.guide-table .table-section td {
  color: #888;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 0.75rem;
  border-bottom: 1px solid #3a4a6c;
}

/* Guide link in move list header */
.ml-guide-link {
  font-size: 0.8rem;
  color: #666;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #444;
  border-radius: 50%;
  margin-left: 0.4rem;
}

.ml-guide-link:hover {
  color: #4ea8de;
  border-color: #4ea8de;
}

/* Guide link in challenge quiz */
.cq-guide-link {
  font-size: 0.75rem;
  color: #555;
  text-decoration: none;
  margin-left: 0.25rem;
}

.cq-guide-link:hover {
  color: #4ea8de;
}

/* === View Transitions === */
#home,
#character-select,
#move-list,
#challenge,
#legend {
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* === Back Navigation === */
.back-nav {
  padding: 0.5rem 0.75rem;
  grid-column: 1 / -1;
}

.back-nav a {
  color: #ccc;
  text-decoration: none;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 44px;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
}

.back-nav a:hover,
.back-nav a:active {
  color: #4ecca3;
  background: rgba(255, 255, 255, 0.06);
}

/* === Command Notation Sprites === */
/* P/K/G button sprites (from cmd-icons.png) */
.cmd-sprite {
  display: inline-block;
  width: 16px;
  height: 16px;
  background-image: url('../img/cmd-icons.png');
  background-repeat: no-repeat;
  vertical-align: middle;
}

.cmd-s-P { background-position: -119px 0px; }
.cmd-s-K { background-position: -136px 0px; }
.cmd-s-G { background-position: -102px 0px; }

/* Direction arrow images (official cursor icons) */
.cmd-img {
  display: inline-block;
  width: 18px;
  height: 18px;
  vertical-align: middle;
}

/* Plus sign */
.cmd-plus {
  display: inline-block;
  font-size: 0.75em;
  font-weight: 700;
  color: #eee;
  margin: 0 1px;
  vertical-align: middle;
}

.cmd-text {
  color: #aaa;
  font-size: 0.85em;
}

/* === Official Page Link === */
.ml-official-link {
  margin-left: auto;
  font-size: 0.7rem;
  color: #666;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.ml-official-link:hover {
  color: #4ea8de;
}

/* === Hidden Utility === */
.hidden {
  display: none !important;
}
