:root {
  color-scheme: light;
  --bg: #ffffff;
  --text: #000000;
  --muted: #555555;
  --border: #000000;
  --crossed-bg: #eeeeee;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
}

.app-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: calc(env(safe-area-inset-top) + 0.75rem) 1rem 0.75rem;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  z-index: 10;
}

.app-header h1 {
  font-size: 1.25rem;
  margin: 0;
}

.back-link {
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.5rem 0.6rem;
  margin-left: -0.6rem;
  border-radius: 0.4rem;
}

.back-link:active {
  background: var(--crossed-bg);
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem;
}

label {
  display: block;
  font-weight: 600;
  margin: 1rem 0 0.4rem;
  font-size: 0.9rem;
}

input[type="text"],
textarea {
  width: 100%;
  font-size: 1rem;
  padding: 0.7rem 0.8rem;
  border-radius: 0.4rem;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

.link-fallback {
  font-size: 0.85rem;
  line-height: 1.4;
  word-break: break-all;
  resize: none;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.4rem 0 0;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.2rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1.1rem;
  min-height: 2.75rem;
  border-radius: 0.4rem;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  flex: 1 1 auto;
  text-align: center;
}

.button:active {
  transform: scale(0.98);
}

.button-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.button-danger {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
  text-decoration: underline;
}

.set-card {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.opponent-banner {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
  text-align: center;
  margin-bottom: 1rem;
}

.opponent-label {
  margin: 0 0 0.3rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.opponent-name {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  word-break: break-word;
}

.invite-section {
  text-align: center;
  margin-bottom: 1rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-top: 0.6rem;
}

.grid-item {
  border: 2px solid var(--border);
  color: var(--text);
  border-radius: 0.5rem;
  padding: 0.7rem 0.5rem;
  min-height: 2.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  word-break: break-word;
}

.grid-item.crossed {
  filter: grayscale(70%);
  opacity: 0.55;
  text-decoration: line-through;
}

@media (min-width: 420px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 640px) {
  .container {
    max-width: 640px;
  }

  .grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 900px) {
  .container {
    max-width: 760px;
  }

  .grid {
    grid-template-columns: repeat(5, 1fr);
  }
}
