:root{
  --bg:#ffffff;
  --ac:#c90000;
  --text:var(--ac);
  --muted:rgba(0,0,0,.25);
  --shadow: 0 10px 30px rgba(0,0,0,.01);
  --radius: 18px;
  --fade-ms: 260ms;

  --main-w: 380px;
  --main-h: min(100px, 35vh);

  --grid-gap: 10px;
  --footer-safe: 96px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
  transition: background-color var(--fade-ms) ease-out, color var(--fade-ms) ease-out;
}

.app{
  min-height:100%;
  display:flex;
  flex-direction:column;
}

header{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  padding:16px 18px;
  position: relative;
  z-index: 2;
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
  user-select:none;
}

.resetBtn{
  width:38px;
  height:38px;
  border-radius:0px;
  border:0px solid var(--ac);
  display:grid;
  place-items:center;
  cursor:pointer;
  background:transparent;
  position:relative;
  transition: transform 120ms ease-out;
}
.resetBtn::before,
.resetBtn::after{
  content:"";
  position:absolute;
  width:20px;
  height:20px;
  background: var(--ac);
}
.resetBtn::before{ left:3px; top:3px; }
.resetBtn::after{ right:3px; bottom:3px; }
.resetBtn:hover{ transform: translateY(-1px); }
.resetBtn:active{ transform: translateY(0px) scale(.98); }

.title{
  font-weight:800;
  letter-spacing: .06em;
  font-size: 18px;
}

main{
  flex:1;
  display:grid;
  grid-template-columns: 1fr 360px;
  gap: 18px;
  padding: 0 18px calc(18px + var(--footer-safe));
  align-items:stretch;
}

@media (max-width: 920px){
  main{ grid-template-columns: 1fr; }
}

.panel{
  border:0px solid var(--ac);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--bg);
  transition: border-color var(--fade-ms) ease-out, background-color var(--fade-ms) ease-out;
}

.center{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap: 18px;
  padding: 18px;
  position:relative;
  overflow:hidden;
  min-height: 100%;
}

.stage{
  width:100%;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap: 14px;
  will-change: transform;
}

/* WHO'S NEXT? */
.stageTitle{
  font-family: "Alata", sans-serif;
  font-weight: 400;
  font-style: normal;

  letter-spacing:.06em;
  font-size: 50px;
  margin-bottom: 6px;
  text-align:center;
}

.mainCard{
  width: var(--main-w);
  height: var(--main-h);
  border-radius: 0px;
  border: 1.5px solid var(--ac);
  background: transparent;
  color: var(--ac);
  font-weight: 900;
  font-size: 44px;
  letter-spacing: .04em;
  cursor:pointer;
  transition: transform 120ms ease-out, background-color var(--fade-ms) ease-out, color var(--fade-ms) ease-out;
  display:grid;
  place-items:center;
  user-select:none;
  text-align:center;
  padding: 0 14px;
  overflow:hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* START */
.startBtn{
  font-family: "Alata", sans-serif;
  font-weight: 400;
  font-style: normal;
}
.startBtn:hover{
  background: var(--ac);
  color: var(--bg);
  transform: translateY(-2px);
}
.startBtn:active{ transform: translateY(0px) scale(.99); }
.startBtn:disabled{
  opacity: .45;
  cursor:not-allowed;
  transform:none;
}

.resultArea{
  width: 100%;
  padding: 0;
  border-radius: 0px;
  border: 0px dashed var(--ac);
  cursor:pointer;
  user-select:none;
  text-align:center;
  transition: transform 120ms ease-out, border-color var(--fade-ms) ease-out;
}
/* hoverズレ防止 */
.resultArea:hover{ transform: none; }

/* 横スクロール */
.resultScroller{
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 6px;
  -webkit-overflow-scrolling: touch;
}

.scrollerInner{
  display:flex;
  justify-content:center;
  width: max-content;
  min-width: 100%;
}

.cardsGrid{
  display:grid;
  gap: var(--grid-gap);
  grid-auto-flow: column; /* 上→下→右 */
  justify-content:center;
  align-items:center;
  width: max-content;
}

.cardsGrid.scale80{
  transform: scale(0.8);
  transform-origin: top center;
}

.nameCard{
  background: color-mix(in oklab, var(--ac) 90%, transparent);
  color: var(--bg);
  letter-spacing: .03em;

  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap: 8px;

  opacity: 0;
  transform: translateY(6px);
  animation: fadeIn var(--fade-ms) ease-out forwards;
}

.pickNo{
  font-size: 10px;
  font-weight: 300;
  letter-spacing: .08em;
  opacity: .9;
  line-height: 1;
  transform: translateY(-3px);
}

.pickName{
  font-size: 22px;
  font-weight: 900;
  letter-spacing: .03em;
  line-height: 1.15;
  padding: 0 10px;
  max-width: 100%;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes fadeIn{
  to{ opacity:1; transform: translateY(0px); }
}

/* HISTORY */
    .side{
    padding: 14px;
    display:flex;
    flex-direction:column;
    gap: 12px;
    overflow:hidden;
    font-size: 0.8em;

    transform: translateY(-50px);
  }

    .sideHeader{
      display:flex;
      align-items:baseline;
      justify-content:space-between;
      gap: 10px;
      padding-bottom: 8px;
      border-bottom: 1px solid color-mix(in oklab, var(--ac) 35%, transparent);
      flex: 0 0 auto;
    }

    .history{
      overflow:auto;
      padding-right:6px;
      flex: 1 1 auto;
      min-height: 0;
    }


.row{
  display:flex;
  gap: 10px;
  align-items:center;
  padding: 8px 8px;
  border-radius: 0px;
  border: 1px solid color-mix(in oklab, var(--ac) 25%, transparent);
  margin-bottom: 8px;
  background: color-mix(in oklab, var(--bg) 94%, transparent);
  transition: background-color var(--fade-ms) ease-out, border-color var(--fade-ms) ease-out;
}

.no{
  width: 44px;
  text-align:right;
  font-weight: 200;
  opacity: .75;
}

.name{
  flex:1;
  font-weight: 400;
  letter-spacing: .02em;
  color: color-mix(in oklab, var(--ac) 92%, #000);
}

.emptyDash{
  color: color-mix(in oklab, var(--ac) 75%, #000);
  font-weight: 300;
  opacity: .85;
}

/* Footer fixed */
footer{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 18px 18px;
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap: 12px;
  pointer-events:none;
  z-index: 3;
}

.pickWrap{
  display:flex;
  align-items:center;
  gap: 10px;
  border: 0px solid var(--ac);
  border-radius: 0px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  background: color-mix(in oklab, var(--bg) 92%, transparent);
  transition: border-color var(--fade-ms) ease-out, background-color var(--fade-ms) ease-out;
  pointer-events:auto;
}

.pickLabel{
  font-weight: 300;
  letter-spacing:.04em;
}

input[type="number"]{
  width: 55px;
  font-size: 16px;
  font-weight: 900;
  padding: 8px 10px;
  border-radius: 0px;
  border: 1px solid var(--ac);
  color: var(--ac);
  background: transparent;
  outline:none;
  transition: border-color var(--fade-ms) ease-out, color var(--fade-ms) ease-out;
}

.status{
  font-size: 12px;
  opacity: .85;
  text-align:right;
  pointer-events:none;
}

/* Toast */
.toast{
  position: fixed;
  left: 18px;
  bottom: 78px;
  max-width: min(520px, calc(100% - 36px));
  padding: 10px 12px;
  border-radius: 14px;
  border: 2px solid var(--ac);
  background: color-mix(in oklab, var(--bg) 92%, transparent);
  box-shadow: var(--shadow);
  font-size: 12px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events:none;
  transition: opacity 160ms ease-out, transform 160ms ease-out, border-color var(--fade-ms) ease-out, background-color var(--fade-ms) ease-out;
  z-index: 4;
}
.toast.show{ opacity:1; transform: translateY(0px); }

button:focus-visible, input:focus-visible{
  outline: 3px solid color-mix(in oklab, var(--ac) 55%, transparent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce){
  :root{ --fade-ms: 1ms; }
  .nameCard{ animation: none; opacity:1; transform:none; }
  *{ transition-duration: 1ms !important; }
}

@media (max-width: 920px){
      :root{
        /* カード幅を画面の70%に。ただしPCサイズは超えない */
        --main-w: min(70vw, 380px);

        --main-h: min(90px, 30vh);
      }

      .stageTitle{
        font-size: clamp(28px, 7vw, 50px);
      }

      .mainCard{
        font-size: clamp(28px, 9vw, 44px);
      }

      .pickName{
        font-size: clamp(18px, 5vw, 22px);
      }
  
      /* historyリストの高さ */  
      .side{
        transform: translateY(-5px);
      }
}
