*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #fff;
  color: #111;
  font-family: "Noto Sans SC", "Noto Sans CJK SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
}

#app {
  min-height: 100dvh;
  min-height: 100svh;
}

.screen {
  min-height: 100dvh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding: calc(20px + env(safe-area-inset-top)) 22px calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto;
}

.screen.hidden,
.hidden {
  display: none !important;
}

.screen-inner {
  flex: 1;
  width: 100%;
  max-width: 390px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

h1 {
  margin: 0 0 10px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
  position: relative;
  z-index: 1;
}

.cover-inner {
  justify-content: center;
}

.cover-stage {
  position: relative;
  width: 100%;
  padding: 62px 10px 46px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cover-blob {
  position: absolute;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.blob-tl {
  top: 2px;
  left: 0;
  width: 74px;
  height: auto;
  transform: rotate(-8deg);
}

.blob-tr {
  top: 8px;
  right: -4px;
  width: 104px;
  height: auto;
  transform: rotate(7deg);
}

.blob-bl {
  bottom: 2px;
  left: 6px;
  width: 54px;
  height: auto;
  transform: rotate(-14deg);
}

.blob-br {
  bottom: 22px;
  left: 56px;
  width: 36px;
  height: auto;
  transform: rotate(12deg);
}

.tagline {
  margin: 0 0 16px;
  font-size: 16px;
  color: #111;
  letter-spacing: 0.04em;
  text-align: center;
  position: relative;
  z-index: 1;
}

.event-meta {
  margin: 0;
  text-align: center;
  color: #888;
  font-size: 13px;
  line-height: 1.6;
  letter-spacing: 0.02em;
  position: relative;
  z-index: 1;
}

.event-meta p {
  margin: 0;
}

.hero-face {
  width: min(220px, 56vw);
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  margin-top: 28px;
  user-select: none;
  -webkit-user-drag: none;
}

.claim-inner {
  justify-content: center;
}

.claim-inner .hero-face {
  width: min(260px, 68vw);
  margin-top: 36px;
}

.face-name {
  margin: 8px 0 0;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-align: center;
}

.face-name.big {
  margin-top: 6px;
  font-size: 28px;
  letter-spacing: 0.02em;
}

.btn {
  display: block;
  width: 100%;
  max-width: 260px;
  margin: 0 auto;
  padding: 14px 22px;
  border: 1px solid #111;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font: inherit;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-ghost {
  background: #fff;
  color: #111;
}

.btn-text {
  margin-top: 14px;
  padding: 8px 12px;
  border: 0;
  background: none;
  color: #666;
  font: inherit;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.site-foot {
  margin-top: auto;
  padding-top: 20px;
  font-size: 11px;
  line-height: 1.5;
  color: #999;
  text-align: center;
}

/* rules */
.rules-inner {
  align-items: stretch;
  padding-top: 8px;
}

.rules-lead {
  margin: 4px 0 16px;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0.03em;
  line-height: 1.5;
  text-align: center;
}

.rules {
  margin: 0;
  padding: 0 0 0 1.15em;
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: 0.02em;
}

.rules li {
  margin: 0 0 10px;
}

.rules-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 8px 0 22px;
}

.rules-preview img {
  width: 112px;
  height: 112px;
  object-fit: contain;
}


/* difficulty pills */
.diff-pills {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 260px;
  margin: 0 auto 16px;
}

.diff-pill {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #111;
  border-radius: 999px;
  background: #fff;
  color: #111;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.diff-pill.selected {
  background: #111;
  color: #fff;
}

.diff-pill:active {
  transform: scale(0.98);
}

#btn-claim-this {
  margin-top: 4px;
}

/* play */
#screen-play {
  padding-left: 12px;
  padding-right: 12px;
  max-width: 430px;
  margin: 0 auto;
}

.play-hud {
  width: 100%;
  max-width: 390px;
  margin: 0 auto 10px;
}

.event-chip {
  display: inline-block;
  margin: 0 0 8px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #f3f3f3;
  color: #666;
  font-size: 11px;
  letter-spacing: 0.06em;
}

.hud-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  align-items: center;
}

.hud-face {
  width: 52px;
  height: 52px;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.hud-meta {
  min-width: 0;
}

.hud-name {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-progress {
  margin: 0;
  font-size: 13px;
  color: #555;
  letter-spacing: 0.04em;
}

.hud-moves-wrap {
  text-align: right;
  min-width: 44px;
}

.hud-moves {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
}

.hud-moves.low {
  color: #c43b2e;
}

.hud-moves-label {
  margin-top: 2px;
  font-size: 11px;
  color: #888;
  letter-spacing: 0.08em;
}

.board-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.board {
  width: min(100%, 390px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 5px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.cell {
  position: relative;
  background: #f1efe9;
  border-radius: 10px;
  overflow: hidden;
}

.cell img {
  position: absolute;
  inset: 4%;
  width: 92%;
  height: 92%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform, opacity;
}

.cell.swap-anim img,
.cell.falling img {
  transition: transform 0.14s ease-out;
}

.cell.clearing {
  background: #e7e4dc;
}

.cell.clearing img {
  opacity: 0;
  transform: scale(0.82);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.cell.fresh img {
  animation: pop-in 0.16s ease-out;
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.play-bottom {
  width: 100%;
  max-width: 390px;
  margin: 12px auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.play-bottom .btn {
  max-width: 100%;
}

.qa-only {
  margin-top: 6px;
  font-size: 12px;
  color: #bbb;
}

.overlay {
  position: fixed;
  inset: 0;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 5;
}

.overlay-card {
  width: min(320px, 100%);
  text-align: center;
}

.lose-copy {
  margin: 0 0 28px;
  font-size: 22px;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 0.04em;
}

.claim-line {
  margin: 10px 0 36px;
  font-size: 16px;
  color: #333;
}

.claim-inner .btn + .btn {
  margin-top: 12px;
}

/* share */
.share-inner {
  align-items: stretch;
}

.share-frame {
  width: min(100%, 300px);
  margin: 0 auto 12px;
  background: #fff;
  border: 1px solid #eceae6;
}

.share-card {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  background: #fff;
  -webkit-touch-callout: default;
  user-select: auto;
}

.share-hint {
  margin: 0 0 14px;
  text-align: center;
  font-size: 13px;
  color: #777;
}

.share-inner .btn + .btn {
  margin-top: 12px;
}

@media (min-height: 760px) {
  .hero-face { margin-top: 48px; }
  .rules { font-size: 17px; }
  h1 { font-size: 30px; }
  .cover-stage { padding: 72px 12px 52px; }
  .blob-tl { width: 82px; }
  .blob-tr { width: 116px; }
}

@media (max-height: 700px) {
  .hero-face { width: min(180px, 46vw); margin-top: 12px; }
  .claim-inner .hero-face { width: min(200px, 52vw); margin-top: 16px; }
  h1 { font-size: 24px; }
  .tagline { margin-bottom: 12px; font-size: 15px; }
  .cover-stage { padding: 44px 8px 32px; }
  .blob-tl { width: 56px; }
  .blob-tr { width: 78px; }
  .blob-bl { width: 42px; }
  .blob-br { width: 28px; left: 46px; }
  .rules { font-size: 15px; }
  .rules li { margin-bottom: 8px; }
  .rules-lead { font-size: 16px; margin-bottom: 12px; }
  .rules-preview img { width: 88px; height: 88px; }
}


/* compose */
.photo-error {
  margin: 0 0 10px;
  text-align: center;
  font-size: 13px;
  color: #c43b2e;
  letter-spacing: 0.02em;
}

.claim-photo-wrap {
  position: relative;
  width: min(260px, 68vw);
  aspect-ratio: 1;
  margin-top: 36px;
  margin-bottom: 12px;
}

.claim-photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 28px;
  background: #f1efe9;
}

.claim-badge {
  position: absolute;
  width: 36%;
  height: auto;
  aspect-ratio: 1;
  right: -4%;
  bottom: -4%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.claim-inner #btn-claim-compose {
  margin-top: 0;
  margin-bottom: 10px;
}

.claim-inner #btn-make-card {
  margin-top: 6px;
}

.claim-inner .claim-line {
  margin-bottom: 12px;
}

/* auth */
.auth-gate {
  width: 100%;
  max-width: 260px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.auth-gate.hidden {
  display: none !important;
}

.auth-gate .btn {
  margin: 0;
}

.email-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.email-form input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #111;
  border-radius: 999px;
  background: #fff;
  color: #111;
  font: inherit;
  font-size: 16px;
  text-align: center;
  outline: none;
}

.email-form input:focus {
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
}

.auth-msg {
  margin: 0;
  text-align: center;
  font-size: 13px;
  line-height: 1.45;
  color: #c43b2e;
  letter-spacing: 0.02em;
}

.auth-msg.ok {
  color: #2a7a46;
}

#btn-logout {
  margin-top: 18px;
}

@media (max-height: 700px) {
  .claim-photo-wrap { width: min(200px, 52vw); margin-top: 16px; }
}

.claim-kicker {
  margin: 18px 0 0;
  font-size: 14px;
  color: #777;
  letter-spacing: 0.08em;
  text-align: center;
}
.claim-inner .face-name.big {
  margin-top: 4px;
}


/* language toggle */
.lang-toggle {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  right: 12px;
  z-index: 20;
  display: flex;
  gap: 0;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #e6e4df;
  border-radius: 999px;
  padding: 2px;
  user-select: none;
}

.lang-toggle.on-play {
  display: none;
}

.lang-toggle button {
  border: 0;
  background: transparent;
  padding: 4px 9px;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: #888;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1.2;
}

.lang-toggle button.active {
  background: #111;
  color: #fff;
}

/* user identity chip */
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px auto 0;
  width: 100%;
  max-width: 260px;
  min-height: 36px;
}

.user-chip.hidden {
  display: none !important;
}

#user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: #f1efe9;
  flex-shrink: 0;
}

.user-chip.no-photo #user-avatar {
  display: none;
}

.user-chip.no-photo::before {
  content: attr(data-letter);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #111;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  flex-shrink: 0;
  line-height: 36px;
  text-align: center;
  text-transform: uppercase;
}

#user-name {
  min-width: 0;
  flex: 1;
  font-size: 13px;
  color: #333;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#btn-logout-chip {
  margin-top: 0;
  padding: 4px 4px 4px 6px;
  font-size: 12px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
