*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  background: #162544;
}

body {
  /* position:fixed + inset:0 forces the gradient to cover the full physical 
     screen on iOS PWA, including the home-indicator safe area at the bottom */
  position: fixed;
  inset: 0;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(160deg, #1b2a4a 0%, #1e3256 50%, #162544 100%);
  color: #e8e8ec;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app {
  width: 100%;
  max-width: 420px;
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 0 24px;
  padding-top: env(safe-area-inset-top, 12px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Header ── */

header {
  padding: 16px 0 12px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  margin-bottom: 4px;
}

#title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.01em;
  opacity: 0.85;
  cursor: default;
}

/* ── Main ── */

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  min-height: 0;
}

/* ── Card display ── */

#card-display {
  width: 220px;
  height: 320px;
  cursor: pointer;
  transition: transform 0.15s ease;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.35))
          drop-shadow(0 2px 6px rgba(0, 0, 0, 0.2));
}

#card-display:active {
  transform: scale(0.96);
}

#card-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 12px;
  pointer-events: none;
}

#card-img.pop {
  animation: cardPop 0.2s ease;
}

@keyframes cardPop {
  0%   { transform: scale(0.92); opacity: 0.6; }
  100% { transform: scale(1);    opacity: 1; }
}

/* ── Info area ── */

.card-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.info-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.info-label {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.01em;
  opacity: 0.4;
}

.info-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.01em;
  min-height: 34px;
}

.info-value.flash {
  animation: textFlash 0.2s ease;
}

@keyframes textFlash {
  0%   { opacity: 0; transform: translateY(4px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ── Footer / buttons ── */

footer {
  flex-shrink: 0;
  display: flex;
  gap: 14px;
  padding: 20px 0 28px;
}

.btn {
  flex: 1;
  padding: 16px 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.1s ease;
  -webkit-appearance: none;
}

.btn:active {
  transform: scale(0.95);
  filter: brightness(0.85);
}

#btn-number {
  background: #5b5fc7;
  color: #fff;
}

#btn-card {
  background: #2ea043;
  color: #fff;
}

/* ── Version label ── */

.version {
  flex-shrink: 0;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  opacity: 0.4;
  padding-bottom: 10px;
}

/* ── Settings modal ── */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #1c1e2a;
  padding: 28px 24px;
  border-radius: 20px;
  width: calc(100% - 48px);
  max-width: 340px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
  text-align: center;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.5;
  margin-bottom: 8px;
}

.form-group input {
  width: 100%;
  padding: 12px 14px;
  font-size: 17px;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

.form-group input:focus {
  border-color: rgba(255, 255, 255, 0.3);
}

.form-hint {
  display: block;
  font-size: 12px;
  opacity: 0.35;
  margin-top: 6px;
}

.modal-buttons {
  display: flex;
  gap: 12px;
  margin-top: 28px;
}

.btn-ok {
  background: #2ea043;
  color: #fff;
}

.btn-cancel {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
}
