:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --panel: #ffffff;
  --text: #12343b;
  --muted: #617378;
  --line: #dbe5e3;
  --primary: #1f8a70;
  --primary-dark: #156754;
  --warn: #b94a48;
  --soft: #eef6f3;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.app {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px 14px 28px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -16px -14px 12px;
  padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
  background: rgba(244, 247, 246, 0.95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand {
  min-width: 0;
}

.title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.25;
}

.subtitle,
.muted {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.panel,
.score-card {
  margin: 0 0 12px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.stack {
  display: grid;
  gap: 10px;
}

.input {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  border: 1px solid #cbd8d6;
  border-radius: 8px;
  outline: none;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 138, 112, 0.13);
}

.btn {
  min-height: 44px;
  padding: 0 14px;
  color: var(--text);
  background: #fff;
  border: 1px solid #cbd8d6;
  border-radius: 8px;
}

.btn.primary {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.btn.primary:active {
  background: var(--primary-dark);
}

.btn.warn {
  color: var(--warn);
}

.btn:disabled {
  opacity: 0.45;
}

.actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.actions .wide {
  grid-column: 1 / -1;
}

.tag {
  flex: 0 0 auto;
  padding: 5px 9px;
  color: var(--primary-dark);
  background: var(--soft);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.person {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.name {
  font-size: 17px;
  font-weight: 800;
}

.selected {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--primary);
  border-radius: 999px;
  font-weight: 800;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.score {
  height: 42px;
  padding: 0;
}

.score.active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.dimension-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.dimension-row:last-child {
  border-bottom: 0;
}

.big {
  margin-top: 6px;
  font-size: 28px;
  font-weight: 800;
}

.rank-row {
  margin-top: 16px;
}

.rank-text {
  margin-top: 6px;
  font-size: 18px;
  font-weight: 800;
}

.announcement-panel {
  border-color: #c9ddd7;
  background: #f8fcfa;
}

.announcement-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.announcement-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.announcement-row strong {
  text-align: right;
  color: var(--primary-dark);
  overflow-wrap: anywhere;
}

.history-detail-button {
  width: 100%;
  margin-top: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 10;
  max-width: min(86vw, 420px);
  transform: translateX(-50%);
  padding: 10px 14px;
  color: #fff;
  background: rgba(18, 52, 59, 0.94);
  border-radius: 999px;
  font-size: 14px;
}

.toast.success {
  background: rgba(22, 101, 52, 0.96);
}

.toast.error {
  background: rgba(180, 35, 24, 0.96);
}

@media (min-width: 680px) {
  .app {
    padding-top: 22px;
  }

  .topbar {
    margin-top: -22px;
  }
}

@media (max-width: 480px) {
  .rank-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .announcement-row {
    align-items: flex-start;
  }

  .announcement-row strong {
    max-width: 56%;
  }
}
