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

:root {
  --green-deep: #0a5c36;
  --green: #0e7a46;
  --green-light: #e8f2ea;
  --green-line: #cfe0d3;
  --gold: #c9a227;
  --gold-deep: #a8841a;
  --ink: #1c2b22;
  --ink-soft: #5c6f63;
  --paper: #f2f5ef;
  --card: #ffffff;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(16, 40, 26, 0.10), 0 4px 14px rgba(16, 40, 26, 0.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  overscroll-behavior-y: none;
}

.noscript-msg { padding: 20px; text-align: center; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

button { font: inherit; border: 0; background: none; cursor: pointer; color: inherit; }
input { font: inherit; }

.content {
  max-width: 520px;
  margin: 0 auto;
  height: 100svh;
  padding: calc(env(safe-area-inset-top) + 10px) 12px calc(env(safe-area-inset-bottom) + 10px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.coin-card {
  flex: 1 1 0;
  min-height: 0;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.names-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.name-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--green-line);
  border-radius: 11px;
  background: var(--green-light);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  outline: none;
  text-align: center;
}
.name-field input:focus { border-color: var(--green); background: #fff; }
.name-field input::placeholder { color: #93a89a; font-weight: 500; }

.stage { perspective: 900px; padding: clamp(10px, 2svh, 18px) 0 0; }
.tosser { transform-style: preserve-3d; }
.tosser.tossing { animation: toss 2.1s cubic-bezier(0.25, 0.1, 0.25, 1); }
@keyframes toss {
  0% { transform: translateY(0) scale(1); }
  45% { transform: translateY(-8px) scale(1.13); }
  80% { transform: translateY(2px) scale(0.99); }
  100% { transform: translateY(0) scale(1); }
}
.turf {
  width: clamp(96px, 15svh, 130px);
  height: clamp(12px, 2svh, 20px);
  margin-top: -6px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(14, 122, 70, 0.35) 0%, rgba(14, 122, 70, 0.12) 55%, transparent 75%);
}

.coin {
  position: relative;
  width: clamp(100px, 19svh, 168px);
  height: clamp(100px, 19svh, 168px);
  transform-style: preserve-3d;
  transition: transform 2.1s cubic-bezier(0.22, 0.9, 0.32, 1);
  cursor: pointer;
}
.face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 14px;
  text-align: center;
  box-shadow: inset 0 -8px 16px rgba(20, 40, 28, 0.12), inset 0 0 0 1px rgba(20, 40, 28, 0.08), 0 6px 18px rgba(16, 40, 26, 0.28);
}
.face-a { background-size: cover; }
.face-b { background-size: cover; transform: rotateX(180deg); }
.face-name {
  font-size: clamp(16px, 3svh, 24px);
  font-weight: 800;
  color: #fff;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.face-brand, .face-model {
  font-weight: 700;
  line-height: 1.1;
  max-width: 78%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
}
.face-brand {
  font-size: clamp(8px, 1.45svh, 11px);
  letter-spacing: 0.7px;
  text-transform: uppercase;
  max-width: 88%;
  margin-bottom: clamp(6px, 1.5svh, 13px);
}
.face-model {
  font-size: clamp(7.5px, 1.25svh, 9.5px);
  letter-spacing: 0.9px;
  text-transform: uppercase;
  opacity: 0.85;
  margin-top: clamp(6px, 1.5svh, 13px);
}
.face-brand:empty, .face-model:empty { display: none; }
.face-model { opacity: 0.8; }

.result-line { min-height: clamp(16px, 2.6svh, 24px); font-size: clamp(13px, 2.2svh, 16px); font-weight: 700; color: var(--green-deep); text-align: center; }
.result-line.waiting { color: var(--ink-soft); font-weight: 500; font-size: clamp(12px, 2svh, 14px); }

.flip-btn {
  width: 100%;
  padding: clamp(11px, 1.8svh, 15px);
  border-radius: 12px;
  background: linear-gradient(160deg, var(--green) 0%, var(--green-deep) 100%);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
  box-shadow: 0 3px 10px rgba(10, 92, 54, 0.35);
}
.flip-btn:active { transform: scale(0.985); }
.flip-btn:disabled { opacity: 0.55; box-shadow: none; }
