:root{
  --bg:#fff6e6;
  --card:#ffffff;
  --accent:#ff8a00;
  --muted:#6b6b6b;
  --text:#222;
  --radius:14px;
}
*{box-sizing:border-box}
html,body,#app{height:100%}
body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,"Helvetica Neue",Arial;
  background:var(--bg);
  color:var(--text);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  touch-action:manipulation;
  height:100vh;
  display:flex;
  align-items:stretch;
  justify-content:center;
}
main#app{
  width:100%;
  max-width:480px;
  height:100vh;
  display:flex;
  flex-direction:column;
  padding:12px;
  gap:10px;
}

/* top bar */
.topbar{
  height:56px;
  display:flex;
  align-items:center;
  gap:10px;
  background:linear-gradient(90deg,#ffd9a8,#fff);
  border-radius:12px;
  padding:8px 12px;
  box-shadow:0 6px 14px rgba(0,0,0,0.06);
}
.logo{
  font-size:18px;
  width:40px;
  height:40px;
  border-radius:8px;
  background:var(--accent);
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:800;
  box-shadow:0 4px 8px rgba(0,0,0,0.08);
}
.title{font-weight:700; font-size:16px; flex:1}
.icon-btn{
  background:transparent;border:0;font-size:18px;padding:8px;border-radius:8px}

/* carousel container keeps portrait layout; inner grid scrolls horizontally with snap */
.carousel{
  width:100%;
  overflow:hidden;
  padding-bottom:6px;
}
.grid{
  display:flex;
  gap:10px;
  width:100%;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
  scroll-snap-type:x mandatory;
  padding:6px;
  /* ensure there's a little end padding so last card isn't clipped when snapping */
  padding-right:12px;
}
.grid::-webkit-scrollbar{display:none}
.card{
  scroll-snap-align:start;
  /* three equal cards per view with gaps accounted for */
  flex: 0 0 calc((100% - 20px) / 3);
  min-width: 0;
  max-width: 33.333%;
}
.card{
  background:var(--card);
  border-radius:12px;
  padding:16px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:8px;
  border:1px solid rgba(0,0,0,0.04);
  box-shadow:0 6px 14px rgba(0,0,0,0.04);
  min-height:110px;
  font-weight:700;
  font-size:14px;
  /* keep interactive scaling subtle */
  will-change:transform;
  touch-action:manipulation;
}
.card:active{transform:scale(.995)}
.emoji{font-size:32px}
.label{color:var(--muted); font-size:14px}

/* panel */
.panel{
  flex:1;
  background:var(--card);
  border-radius:12px;
  padding:10px;
  display:flex;
  flex-direction:column;
  gap:8px;
  overflow:hidden;
  border:1px solid rgba(0,0,0,0.04);
}
.panel-header{display:flex;align-items:center;gap:8px}
.text-btn{background:transparent;border:0;color:var(--accent);font-weight:600;padding:6px}
.panel-title{flex:1;font-weight:700;text-align:center}
.phrase-list{list-style:none;margin:0;padding:4px;display:flex;flex-direction:column;gap:8px;overflow:auto}
.phrase{
  display:flex;
  align-items:center;
  gap:12px;
  padding:10px;
  border-radius:12px;
  background:linear-gradient(90deg,#fff,#fff);
  border:1px solid rgba(0,0,0,0.04);
  flex-wrap:wrap;
}
.phrase .text{
  flex: 1 1 60%;
  min-width: 140px;
  white-space:normal;
  word-break:break-word;
  display:flex;
  flex-direction:column;
  gap:6px;
}
.phrase .en{font-weight:700}
.phrase .lang{color:var(--muted);font-size:13px}
.play-btn{
  width:44px;height:44px;border-radius:10px;border:0;background:var(--accent);color:#fff;font-weight:700;
  display:flex;align-items:center;justify-content:center;font-size:16px;
}

/* Activity-specific layout: text on top, controls below in a responsive grid */
.phrase.activity{
  align-items:flex-start;
  padding:12px;
}
.phrase.activity .text{
  flex-basis:100%;
  margin-bottom:8px;
}
.phrase.activity > div:last-child{
  flex-basis:100%;
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  align-items:center;
}
/* nicer input/select styles consistent with theme */
.phrase input[type="text"], .phrase select{
  padding:10px;
  border-radius:10px;
  border:1px solid rgba(0,0,0,0.08);
  font-size:15px;
  min-width:120px;
  flex:1;
  box-shadow:none;
}
.phrase .ok-btn{
  min-width:56px;
  height:44px;
  border-radius:10px;
  border:0;
  background:var(--accent);
  color:#fff;
  font-weight:700;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:0 12px;
}
/* controls removed (B&W switch removed by request) */

/* footer */
.footer{display:flex;gap:8px}
.primary-btn{flex:1;background:var(--accent);color:#fff;border:0;padding:12px;border-radius:12px;font-weight:700}
.secondary-btn{flex:1;background:transparent;border:1px solid rgba(0,0,0,0.06);padding:12px;border-radius:12px}

/* B&W mode */
.bw body, .bw #app, .bw .card, .bw .panel, .bw .topbar{filter:grayscale(1) contrast(.95)}

/* small adjustments for mobile */
@media (max-width:420px){
  .card{padding:12px}
  .panel{padding:8px}
  .phrase .text{font-size:15px}
}