:root {
  --costco-red: #e31837;
  --costco-blue: #0060a9;
  --bg: gainsboro;
  --panel: rgb(173, 173, 173);
  --tile: gray;
  --ink: #111;
  --line: rgba(0, 0, 0, 0.22);
  --win: rgb(1, 154, 1);
  --near: rgb(255, 196, 37);
  --far: rgb(255, 37, 37);
}

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

html,
body {
  min-height: 100%;
  font-family: "VT323", "Courier New", monospace;
  color: var(--ink);
  background: var(--bg);
}

button,
input {
  font: inherit;
}

.costcodle-app {
  width: min(100%, 344px);
  margin: 0 auto;
  min-height: 100vh;
  padding: 12px 10px 16px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid gray;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-title {
  font-size: 52px;
  line-height: 1;
  color: rgb(227, 42, 54);
}

.brand-title span {
  color: rgb(0, 96, 169);
}

.mode-switch {
  display: inline-flex;
  border: 2px solid gray;
  border-radius: 8px;
  overflow: hidden;
}

.mode-switch.single-badge {
  border-color: rgb(0, 96, 169);
}

.help-button,
.close-help-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid gray;
  background: transparent;
}

.help-button {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  color: rgb(0, 96, 169);
}

.help-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.help-button .help-dot {
  fill: currentColor;
  stroke: none;
}

.mode-button,
.submit-button,
.ghost-button {
  border: 0;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.mode-button {
  min-width: 76px;
  padding: 5px 10px;
  font-size: 24px;
  color: #000;
  background: transparent;
}

.mode-button.active {
  color: #fff;
  background: rgb(0, 96, 169);
}

.hidden {
  display: none !important;
}

.game-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 12px;
}

.mode-line,
.status-row,
.action-row {
  width: 100%;
}

.mode-line {
  font-size: 26px;
  text-align: center;
}

.product-card {
  display: flex;
  align-items: center;
  flex-direction: column;
  margin-top: 16px;
  margin-bottom: 12px;
  padding: 12px;
  border-radius: 8px;
  background-color: var(--panel);
  box-shadow: 0 3px 10px;
}

.product-image-shell {
  display: flex;
  overflow: hidden;
  justify-content: center;
  width: 220px;
  height: 220px;
  margin-bottom: 10px;
  border-radius: 8px;
  background-color: white;
}

.product-image-shell img {
  height: 100%;
  object-fit: contain;
}

.product-mode-label {
  font-size: 22px;
}

#productName {
  width: 220px;
  font-size: 24px;
  font-weight: normal;
  line-height: 1;
  text-align: center;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 22px;
  line-height: 1;
  white-space: nowrap;
}

#gameStatus,
#statsSummary {
  white-space: nowrap;
}

#statsSummary {
  flex: 0 0 auto;
}

.guess-board {
  display: grid;
  gap: 5px;
  width: 100%;
}

.guess-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px;
  gap: 5px;
}

.guess-value,
.guess-feedback,
.guess-placeholder {
  min-height: 42px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--tile);
  box-shadow: inset 0 0 5px;
}

.guess-value {
  justify-content: start;
  padding: 0 12px;
  font-size: 28px;
}

.guess-feedback {
  font-size: 28px;
  font-weight: bold;
  color: rgba(0, 0, 0, 0.65);
}

.guess-placeholder {
  background-color: var(--tile);
  opacity: 0.45;
}

.guess-feedback.win {
  background: var(--win);
}

.guess-feedback.near {
  background: var(--near);
}

.guess-feedback.far {
  background: var(--far);
}

.guess-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 5px;
  width: 100%;
  margin-top: 5px;
}

.guess-input-wrap {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  min-height: 42px;
  overflow: hidden;
  border: 1px solid black;
  border-radius: 8px;
  background-color: var(--tile);
  box-shadow: inset 0 0 5px;
}

.guess-input-wrap span {
  align-items: center;
  justify-content: center;
  display: flex;
  font-size: 28px;
  color: rgb(0, 96, 169);
  border-right: 2px solid black;
  background-color: var(--panel);
}

.guess-input-wrap input {
  min-width: 0;
  border: 0;
  padding: 0 8px;
  font-size: 28px;
  color: gainsboro;
  background-color: rgb(94, 94, 94);
  outline: none;
}

.guess-input-wrap input::placeholder {
  color: gainsboro;
}

.submit-button {
  font-size: 28px;
  color: rgb(227, 42, 54);
  border-radius: 8px;
  background-color: var(--panel);
  box-shadow: inset 0 0 5px;
}

.action-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 10px;
}

.share-actions {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}

.share-result-text {
  margin-top: 10px;
  padding: 10px;
  border: 2px solid gray;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(255, 255, 255, 0.45);
}

.scoreboard-panel {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.history-chart {
  margin-top: 10px;
  padding: 8px;
  border: 2px solid gray;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.35);
}

.history-chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.history-axis {
  stroke: gray;
  stroke-width: 1.5;
}

.history-line {
  fill: none;
  stroke: rgb(0, 96, 169);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.history-chart circle {
  fill: rgb(227, 42, 54);
}

.history-chart text {
  font-family: "VT323", "Courier New", monospace;
  font-size: 11px;
  fill: #333;
}

.history-empty {
  font-size: 20px;
  text-align: center;
}

.scoreboard-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 2px solid gray;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.35);
  font-size: 20px;
  line-height: 1;
}

.scoreboard-name {
  text-align: left;
}

.scoreboard-status {
  color: rgb(0, 96, 169);
}

.scoreboard-points {
  color: rgb(227, 42, 54);
}

.ghost-button {
  min-width: 130px;
  padding: 7px 12px;
  font-size: 24px;
  color: black;
  border: 2px solid gray;
  border-radius: 8px;
  background: transparent;
}

.share-ghost-button {
  color: white;
  border-color: rgb(0, 96, 169);
  background: rgb(0, 96, 169);
}

.share-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.share-ghost-button,
.share-actions .ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.toast {
  width: 100%;
  margin-bottom: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 24px;
  background: black;
  color: #fff;
}

.help-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.4);
}

.help-panel {
  width: min(100%, 320px);
  padding: 14px;
  border: 2px solid gray;
  border-radius: 8px;
  background: gainsboro;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}

.help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.help-head h2 {
  font-size: 28px;
  font-weight: normal;
}

.close-help-button {
  width: 32px;
  height: 32px;
  font-size: 24px;
  border-radius: 8px;
}

.help-list {
  margin: 8px 0 0 18px;
  font-size: 22px;
}

.help-list li + li {
  margin-top: 6px;
}

@media (max-width: 420px) {
  .costcodle-app {
    width: 100%;
    padding: 8px 8px 16px;
  }

  .brand-title {
    font-size: 44px;
  }

  .product-image-shell,
  #productName {
    width: 100%;
  }

  .product-image-shell {
    height: min(64vw, 220px);
  }

  .status-row {
    font-size: 22px;
  }

  .guess-form,
  .action-row,
  .app-header {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }
}
