/* 大富豪（party/daifugo）。共通の party.css を緑系（ラシャ盤）に上書きする。
 * 盤面は「デジタルのゲーム盤」哲学どおり素っ気なく、カードの読みやすさを最優先にする。 */

:root {
  --party-bg: #eaf4ec;
  --party-bg2: #ffffff;
  --party-card: #ffffff;
  --party-accent: #2f9e5f;
  --party-accent-dark: #1e7a46;
  --party-accent-soft: #d8efe0;
  --party-text: #21372a;
  --party-muted: #66826f;
  --party-line: #cde5d5;

  --df-felt: #1f7a4d;
  --df-felt-dark: #145c39;
  --df-red: #d32f3c;
  --df-black: #26332c;
}

/* ゲーム画面は縦いっぱいを使い、手札を親指の届く下端へ置く */
.df-game {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100dvh;
  padding-top: calc(env(safe-area-inset-top) + 8px);
}

/* ===== 上: 他のプレイヤー ===== */

.df-players {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.df-player {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--party-card);
  border: 3px solid transparent;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.07);
  max-width: 46%;
}

.df-player__icon {
  font-size: 20px;
}

.df-player__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* のこり枚数。数字だけだと読み落とすので「まい」を添える。
 * ここが折り返すと名前より背が高くなってチップが2行に割れるので改行させない */
.df-player__count {
  flex: 0 0 auto;
  white-space: nowrap;
  background: var(--party-accent-soft);
  color: var(--party-accent-dark);
  border-radius: 999px;
  padding: 1px 8px;
  font-variant-numeric: tabular-nums;
}

.df-player--turn {
  border-color: var(--party-accent);
  background: #fffdf0;
}

.df-player--me .df-player__name {
  text-decoration: underline;
}

.df-player--passed {
  opacity: 0.55;
}

.df-player--done {
  background: var(--party-accent-soft);
}

.df-player__title {
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: 13px;
}

/* ===== 中央: 場 ===== */

.df-table {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 10px 18px;
  border-radius: var(--party-radius);
  background: radial-gradient(ellipse at 50% 35%, #2a9160 0%, var(--df-felt) 55%, var(--df-felt-dark) 100%);
  box-shadow: inset 0 3px 12px rgba(0, 0, 0, 0.25);
  min-height: 190px;
}

.df-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 22px;
}

.df-badge {
  font-size: 12px;
  font-weight: 700;
  color: #eaf7ef;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 999px;
  padding: 2px 10px;
}

.df-badge--rev {
  background: #ffd54a;
  color: #4a3600;
}

.df-fieldlabel {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.2em;
}

.df-field {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  min-height: 84px;
  flex-wrap: wrap;
}

/* 場が流れた直後は「さっき出た札」を薄く残す（何が起きたか分かるように） */
.df-field--gone .df-card {
  opacity: 0.35;
  filter: grayscale(0.5);
}

.df-field__empty {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 700;
}

.df-turn {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.3);
  min-height: 26px;
  text-align: center;
}

/* ===== カード ===== */

/* 本物のトランプと同じく左上に「指標」を置く。手札は左端だけ見えるように重ねるので、
 * 指標さえ露出していればどの札かが読める（重なり幅はJSが指標幅を下回らないよう決める） */
.df-card {
  position: relative;
  flex: 0 0 auto;
  width: 56px;
  height: 80px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: #fff;
  color: var(--df-black);
  font-family: inherit;
  line-height: 1;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.28);
}

.df-card__idx {
  position: absolute;
  top: 4px;
  left: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 22px;
}

.df-card__r {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.df-card__s {
  font-size: 15px;
}

/* 全部見えている時（場の札・扇の右端）だけ目に入る飾り。重なると隠れてよい */
.df-card__big {
  position: absolute;
  right: 4px;
  bottom: 3px;
  font-size: 27px;
  opacity: 0.3;
}

.df-card--red {
  color: var(--df-red);
}

.df-card--joker {
  background: linear-gradient(160deg, #fff 40%, #ffe9a8 100%);
}

.df-card--joker .df-card__r {
  font-size: 17px;
}

/* ジョーカーを代役で出した時、何のランクとして出したかを小さく添える */
.df-card__as {
  position: absolute;
  left: 4px;
  bottom: 3px;
  font-size: 11px;
  font-weight: 700;
  color: var(--party-muted);
}

/* ===== 下: 自分の手札 ===== */

.df-mine {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.df-handwrap {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.df-handwrap::-webkit-scrollbar {
  display: none;
}

/* 扇。回転はCSS変数でJSから1枚ずつ与える（transformだけなので軽い）。
 * 上下の余白は「選んだ札のせり上がり＋回転で膨らむぶん」を見込んであり、
 * ここが足りないと overflow-y: hidden で札の端が切れる */
.df-hand {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-width: 100%;
  width: max-content;
  margin: 0 auto;
  padding: 24px 12px 14px;
  min-height: 136px;
}

.df-hand .df-card {
  /* 回転の軸は札の下辺中央。上辺が横へ振れる量が読めるので、
   * JS側が「左どなりの指標を隠さない角度」を計算できる */
  transform: rotate(var(--rot, 0deg)) translateY(var(--lift, 0px));
  transform-origin: 50% 100%;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  cursor: pointer;
}

/* 選んだ札はせり上がる（タップの手応え） */
.df-hand .df-card.is-sel {
  transform: rotate(var(--rot, 0deg)) translateY(calc(var(--lift, 0px) - 18px));
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.3);
  outline: 3px solid var(--party-accent);
}

/* いまの場には関われない札は沈める（出せる札だけが目に入るように） */
.df-hand .df-card.is-dim {
  opacity: 0.42;
}

.df-actions {
  display: flex;
  gap: 10px;
  padding-bottom: calc(env(safe-area-inset-bottom) + 4px);
}

.df-act {
  flex: 1;
  margin: 0;
}

/* ===== ロビーに差し込むローカルルール ===== */

.df-rules {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.df-rule {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 14px;
  background: var(--party-accent-soft);
  cursor: pointer;
}

.df-rule input {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  accent-color: var(--party-accent);
}

.df-rule__text {
  flex: 1;
  min-width: 0;
}

.df-rule__name {
  font-weight: 800;
  display: block;
}

.df-rule__desc {
  font-size: 13px;
  color: var(--party-muted);
  display: block;
  line-height: 1.35;
}

/* ===== カットイン（8切り・革命・スぺ3返し） ===== */

.df-cutin {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: rgba(10, 40, 24, 0.55);
  animation: df-cutin-fade 1s ease forwards;
}

.df-cutin__text {
  font-size: 13vw;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.3);
  animation: df-cutin-pop 1s cubic-bezier(0.2, 1.4, 0.4, 1) forwards;
  white-space: nowrap;
}

.df-cutin--rev .df-cutin__text {
  color: #ffd54a;
}

.df-cutin--eight .df-cutin__text {
  color: #9ff2ff;
}

@keyframes df-cutin-fade {
  0% { opacity: 0; }
  15% { opacity: 1; }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes df-cutin-pop {
  0% { transform: scale(0.4) rotate(-8deg); }
  35% { transform: scale(1.12) rotate(2deg); }
  60% { transform: scale(1) rotate(0deg); }
  100% { transform: scale(1) rotate(0deg); }
}

@media (prefers-reduced-motion: reduce) {
  .df-cutin,
  .df-cutin__text {
    animation-duration: 0.01s;
  }
  .df-hand .df-card {
    transition: none;
  }
}

/* ===== 結果（称号） ===== */

.df-results {
  list-style: none;
  margin: 0 0 4px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.df-result {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--party-accent-soft);
  font-weight: 700;
}

.df-result--top {
  background: #fff3c4;
  outline: 3px solid #ffd54a;
}

.df-result__title {
  font-weight: 800;
}

.df-result__name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.df-result__wins {
  font-size: 13px;
  color: var(--party-muted);
}

.df-result__note {
  font-size: 12px;
  color: var(--party-danger);
}

/* ジョーカーの代役えらび */
.df-jokerpick {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 8px;
}

.df-jokerpick button {
  min-height: 56px;
  border: none;
  border-radius: 14px;
  background: var(--party-accent-soft);
  color: var(--party-accent-dark);
  font-size: 22px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
}
